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,
|
"custom_customer": customer_doc.name,
|
||||||
"role": contact_data.get("contact_role", "Other"),
|
"role": contact_data.get("contact_role", "Other"),
|
||||||
"custom_email": contact_data.get("email"),
|
"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_ids": [{
|
||||||
"email_id": contact_data.get("email"),
|
"email_id": contact_data.get("email"),
|
||||||
"is_primary": 1
|
"is_primary": 1
|
||||||
@ -338,7 +338,7 @@ def upsert_client(data):
|
|||||||
|
|
||||||
address_doc.save(ignore_permissions=True)
|
address_doc.save(ignore_permissions=True)
|
||||||
customer_doc.save(ignore_permissions=True)
|
customer_doc.save(ignore_permissions=True)
|
||||||
|
frappe.local.message_log = []
|
||||||
return build_success_response({
|
return build_success_response({
|
||||||
"customer": customer_doc.as_dict(),
|
"customer": customer_doc.as_dict(),
|
||||||
"address": address_doc.as_dict(),
|
"address": address_doc.as_dict(),
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<div id="custom-ui-app"></div>
|
<div id="custom-ui-app"></div>
|
||||||
|
<span id="test-footer">THIS IS A TEST</span>
|
||||||
{% if bundle_path %}
|
{% if bundle_path %}
|
||||||
<script type="module" src="{{ bundle_path }}"></script>
|
<script type="module" src="{{ bundle_path }}"></script>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
@ -1,20 +1,47 @@
|
|||||||
frappe.pages["custom_ui"].on_page_load = async (wrapper) => {
|
frappe.pages["custom_ui"].on_page_load = async (wrapper) => {
|
||||||
$(wrapper).html('<div id="custom-ui-app"></div>');
|
// Create root div for spa if it doesn't exist
|
||||||
console.log("App root div created");
|
const appRootId = "custom-ui-app";
|
||||||
manifest = await fetch("/assets/custom_ui/dist/.vite/manifest.json").then((res) => res.json());
|
if (!document.getElementById(appRootId)) {
|
||||||
console.log("Fetched manifest:", manifest);
|
$(wrapper).html('<div id="custom-ui-app"></div>');
|
||||||
|
console.log("App root div created");
|
||||||
|
}
|
||||||
|
|
||||||
const script = document.createElement("script");
|
// Attempt to load the manifest file
|
||||||
script.src = "/assets/custom_ui/dist/" + manifest["src/main.js"]["file"];
|
try {
|
||||||
script.type = "module";
|
// Cache busting by appending a timestamp
|
||||||
document.body.appendChild(script);
|
const manifestUrl = `/assets/custom_ui/dist/.vite/manifest.json?v=${Date.now()}`;
|
||||||
console.log("Appended script:", script.src);
|
manifest = await fetch(manifestUrl).then((res) => res.json());
|
||||||
|
console.log("Fetched manifest:", manifest);
|
||||||
|
|
||||||
const link = document.createElement("link");
|
// Check existence of old script and link elements and remove them
|
||||||
link.rel = "stylesheet";
|
const existingScript = document.getElementById("custom-ui-main-js");
|
||||||
link.href = "/assets/custom_ui/dist/" + manifest["src/main.js"]["css"][0];
|
if (existingScript) existingScript.remove();
|
||||||
document.head.appendChild(link);
|
|
||||||
|
|
||||||
console.log("Custom UI stylesheet loaded:", link.href);
|
const existingLink = document.getElementById("custom-ui-main-css");
|
||||||
console.log("Custom UI script loaded:", script.src);
|
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 isFormValid = computed(() => {
|
||||||
const hasCustomerName = formData.value.customerName?.trim();
|
const hasCustomerName = formData.value.customerName?.trim();
|
||||||
const hasCustomerType = formData.value.customerType?.trim();
|
const hasCustomerType = formData.value.customerType?.trim();
|
||||||
const hasAddressTitle = formData.value.addressTitle?.trim();
|
|
||||||
const hasAddressLine1 = formData.value.addressLine1?.trim();
|
const hasAddressLine1 = formData.value.addressLine1?.trim();
|
||||||
const hasPincode = formData.value.pincode?.trim();
|
const hasPincode = formData.value.pincode?.trim();
|
||||||
const hasCity = formData.value.city?.trim();
|
const hasCity = formData.value.city?.trim();
|
||||||
const hasState = formData.value.state?.trim();
|
const hasState = formData.value.state?.trim();
|
||||||
const hasContacts = formData.value.contacts && formData.value.contacts.length > 0;
|
const hasContacts = formData.value.contacts && formData.value.contacts.length > 0;
|
||||||
const primaryContact = formData.value.contacts?.find((c) => c.isPrimary);
|
|
||||||
const hasFirstName = primaryContact?.firstName?.trim();
|
// Check that all contacts have required fields
|
||||||
const hasLastName = primaryContact?.lastName?.trim();
|
const allContactsValid = formData.value.contacts?.every((contact) => {
|
||||||
|
return (
|
||||||
|
contact.firstName?.trim() &&
|
||||||
|
contact.lastName?.trim() &&
|
||||||
|
contact.email?.trim() &&
|
||||||
|
contact.phoneNumber?.trim() &&
|
||||||
|
contact.contactRole?.trim()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
hasCustomerName &&
|
hasCustomerName &&
|
||||||
hasCustomerType &&
|
hasCustomerType &&
|
||||||
hasAddressTitle &&
|
|
||||||
hasAddressLine1 &&
|
hasAddressLine1 &&
|
||||||
hasPincode &&
|
hasPincode &&
|
||||||
hasCity &&
|
hasCity &&
|
||||||
hasState &&
|
hasState &&
|
||||||
hasContacts &&
|
hasContacts &&
|
||||||
hasFirstName &&
|
allContactsValid
|
||||||
hasLastName
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -92,7 +92,7 @@
|
|||||||
:disabled="selectedItems.length === 0"
|
:disabled="selectedItems.length === 0"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!isNew && estimate">
|
<div v-if="estimate">
|
||||||
<Button label="Send Estimate" @click="showConfirmationModal = true"/>
|
<Button label="Send Estimate" @click="showConfirmationModal = true"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user