update js inject file to bust caching
This commit is contained in:
parent
4b55d8790e
commit
07c1181d6e
5 changed files with 58 additions and 25 deletions
|
|
@ -262,7 +262,7 @@ def upsert_client(data):
|
|||
"custom_customer": customer_doc.name,
|
||||
"role": contact_data.get("contact_role", "Other"),
|
||||
"custom_email": contact_data.get("email"),
|
||||
"is_primary_contact": data.get("is_primary", False),
|
||||
"is_primary_contact":1 if data.get("is_primary", False) else 0,
|
||||
"email_ids": [{
|
||||
"email_id": contact_data.get("email"),
|
||||
"is_primary": 1
|
||||
|
|
@ -338,7 +338,7 @@ def upsert_client(data):
|
|||
|
||||
address_doc.save(ignore_permissions=True)
|
||||
customer_doc.save(ignore_permissions=True)
|
||||
|
||||
frappe.local.message_log = []
|
||||
return build_success_response({
|
||||
"customer": customer_doc.as_dict(),
|
||||
"address": address_doc.as_dict(),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<div id="custom-ui-app"></div>
|
||||
<span id="test-footer">THIS IS A TEST</span>
|
||||
{% if bundle_path %}
|
||||
<script type="module" src="{{ bundle_path }}"></script>
|
||||
{% else %}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,47 @@
|
|||
frappe.pages["custom_ui"].on_page_load = async (wrapper) => {
|
||||
$(wrapper).html('<div id="custom-ui-app"></div>');
|
||||
console.log("App root div created");
|
||||
manifest = await fetch("/assets/custom_ui/dist/.vite/manifest.json").then((res) => res.json());
|
||||
console.log("Fetched manifest:", manifest);
|
||||
// Create root div for spa if it doesn't exist
|
||||
const appRootId = "custom-ui-app";
|
||||
if (!document.getElementById(appRootId)) {
|
||||
$(wrapper).html('<div id="custom-ui-app"></div>');
|
||||
console.log("App root div created");
|
||||
}
|
||||
|
||||
const script = document.createElement("script");
|
||||
script.src = "/assets/custom_ui/dist/" + manifest["src/main.js"]["file"];
|
||||
script.type = "module";
|
||||
document.body.appendChild(script);
|
||||
console.log("Appended script:", script.src);
|
||||
// Attempt to load the manifest file
|
||||
try {
|
||||
// Cache busting by appending a timestamp
|
||||
const manifestUrl = `/assets/custom_ui/dist/.vite/manifest.json?v=${Date.now()}`;
|
||||
manifest = await fetch(manifestUrl).then((res) => res.json());
|
||||
console.log("Fetched manifest:", manifest);
|
||||
|
||||
const link = document.createElement("link");
|
||||
link.rel = "stylesheet";
|
||||
link.href = "/assets/custom_ui/dist/" + manifest["src/main.js"]["css"][0];
|
||||
document.head.appendChild(link);
|
||||
// Check existence of old script and link elements and remove them
|
||||
const existingScript = document.getElementById("custom-ui-main-js");
|
||||
if (existingScript) existingScript.remove();
|
||||
|
||||
console.log("Custom UI stylesheet loaded:", link.href);
|
||||
console.log("Custom UI script loaded:", script.src);
|
||||
const existingLink = document.getElementById("custom-ui-main-css");
|
||||
if (existingLink) existingLink.remove();
|
||||
|
||||
// Append new script and link elements
|
||||
const cssHref = manifest["src/main.js"]["css"]?.[0];
|
||||
if (cssHref) {
|
||||
const link = document.createElement("link");
|
||||
link.id = "custom-ui-main-css";
|
||||
link.rel = "stylesheet";
|
||||
link.href = `/assets/custom_ui/dist/${cssHref}`;
|
||||
document.head.appendChild(link);
|
||||
console.log("Appended stylesheet:", link.href);
|
||||
}
|
||||
|
||||
const jsFile = manifest["src/main.js"]["file"];
|
||||
if (jsFile) {
|
||||
const script = document.createElement("script");
|
||||
script.id = "custom-ui-main-js";
|
||||
script.type = "module";
|
||||
script.src = `/assets/custom_ui/dist/${jsFile}`;
|
||||
document.body.appendChild(script);
|
||||
console.log("Appended script:", script.src);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error loading manifest or app resources:", error);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue