Skip to content

Commit

Permalink
chore: merge develop into main (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
maharshivpatel authored Jun 20, 2024
2 parents a6995b3 + e80ad3d commit 7ddce0c
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions print_designer/public/js/print_designer/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ export const parseJinja = async (field, row) => {

export const getFormattedValue = async (field, row = null) => {
const MainStore = useMainStore();
const formattedValue = ref(field.value);

if (isRef(row)) {
row = row.value;
}
Expand All @@ -398,11 +398,13 @@ export const getFormattedValue = async (field, row = null) => {
}

const isDataAvailable = !!row || Object.keys(MainStore.docData).length > 0;

const formattedValue = ref(field.value);

if (field.is_static) {
if (field.parseJinja) {
formattedValue.value = await parseJinja(field, row);
}
return formattedValue.value;
} else if (row) {
if (field.fieldtype == "Image") {
formattedValue.value = frappe.format(
Expand All @@ -425,7 +427,6 @@ export const getFormattedValue = async (field, row = null) => {
? null
: `{{ ${field.fieldname} }}`;
}
return formattedValue.value;
} else {
let rawValue = MainStore.docData[field.fieldname];
if (field.parentField) {
Expand All @@ -435,38 +436,38 @@ export const getFormattedValue = async (field, row = null) => {
field.fieldname
);
}
field.value = frappe.format(
formattedValue.value = frappe.format(
rawValue,
{ fieldtype: field.fieldtype, options: field.options },
{ inline: true },
MainStore.docData
);
if (!field.value) {
if (!formattedValue.value) {
if (["Image, Attach Image"].indexOf(field.fieldtype) != -1) {
field.value = null;
formattedValue.value = null;
} else {
switch (field.fieldname) {
case "page":
field.value = "0";
formattedValue.value = "0";
break;
case "topage":
field.value = "999";
formattedValue.value = "999";
break;
case "date":
field.value = frappe.datetime.now_date();
formattedValue.value = frappe.datetime.now_date();
break;
case "time":
field.value = frappe.datetime.now_time();
formattedValue.value = frappe.datetime.now_time();
break;
default:
field.value = `{{ ${field.parentField ? field.parentField + "." : ""}${
field.fieldname
} }}`;
formattedValue.value = `{{ ${
field.parentField ? field.parentField + "." : ""
}${field.fieldname} }}`;
}
}
}
return field.value;
}
return formattedValue.value;
};

export const updateDynamicData = async () => {
Expand Down

0 comments on commit 7ddce0c

Please sign in to comment.