update js inject file to bust caching
This commit is contained in:
parent
4b55d8790e
commit
07c1181d6e
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@ -403,27 +403,32 @@ const primaryContactEmail = computed(() => {
|
||||
const isFormValid = computed(() => {
|
||||
const hasCustomerName = formData.value.customerName?.trim();
|
||||
const hasCustomerType = formData.value.customerType?.trim();
|
||||
const hasAddressTitle = formData.value.addressTitle?.trim();
|
||||
const hasAddressLine1 = formData.value.addressLine1?.trim();
|
||||
const hasPincode = formData.value.pincode?.trim();
|
||||
const hasCity = formData.value.city?.trim();
|
||||
const hasState = formData.value.state?.trim();
|
||||
const hasContacts = formData.value.contacts && formData.value.contacts.length > 0;
|
||||
const primaryContact = formData.value.contacts?.find((c) => c.isPrimary);
|
||||
const hasFirstName = primaryContact?.firstName?.trim();
|
||||
const hasLastName = primaryContact?.lastName?.trim();
|
||||
|
||||
// Check that all contacts have required fields
|
||||
const allContactsValid = formData.value.contacts?.every((contact) => {
|
||||
return (
|
||||
contact.firstName?.trim() &&
|
||||
contact.lastName?.trim() &&
|
||||
contact.email?.trim() &&
|
||||
contact.phoneNumber?.trim() &&
|
||||
contact.contactRole?.trim()
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
hasCustomerName &&
|
||||
hasCustomerType &&
|
||||
hasAddressTitle &&
|
||||
hasAddressLine1 &&
|
||||
hasPincode &&
|
||||
hasCity &&
|
||||
hasState &&
|
||||
hasContacts &&
|
||||
hasFirstName &&
|
||||
hasLastName
|
||||
allContactsValid
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@
|
||||
:disabled="selectedItems.length === 0"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="!isNew && estimate">
|
||||
<div v-if="estimate">
|
||||
<Button label="Send Estimate" @click="showConfirmationModal = true"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user