diff --git a/print_designer/public/js/print_designer/frappeControl.js b/print_designer/public/js/print_designer/frappeControl.js index b887e34..7629b10 100644 --- a/print_designer/public/js/print_designer/frappeControl.js +++ b/print_designer/public/js/print_designer/frappeControl.js @@ -57,8 +57,9 @@ export const makeFeild = ({ obj_value = formatValue(object, propertyName, isStyle); if ( - (value || fieldtype == "Color") && - formatValue(object, propertyName, isStyle) != value + (!(typeof value == "undefined" || value === null) || + fieldtype == "Color") && + obj_value != value ) { object[propertyName] = value; onChangeCallback && onChangeCallback(value); @@ -93,10 +94,15 @@ export const makeFeild = ({ MainStore.frappeControls[name].$input[0].onfocus = () => { MainStore.frappeControls[name].$input.select(); MainStore.frappeControls[name].$input.one("blur", () => { - MainStore.frappeControls[name].$input.val( - MainStore.frappeControls[name].value || - MainStore.frappeControls[name].last_value - ); + let value = MainStore.frappeControls[name].value; + if ( + typeof value == "undefined" || + value === null || + (fieldtype == "Int" && !Number.isInteger(value)) + ) { + value = MainStore.frappeControls[name].last_value; + } + MainStore.frappeControls[name].$input.val(value); }); }; } else if (fieldtype === "Select") { diff --git a/print_designer/public/js/print_designer/store/MainStore.js b/print_designer/public/js/print_designer/store/MainStore.js index b5be495..ac36cab 100644 --- a/print_designer/public/js/print_designer/store/MainStore.js +++ b/print_designer/public/js/print_designer/store/MainStore.js @@ -415,6 +415,14 @@ export const useMainStore = defineStore("MainStore", { object.selectedColumn?.["style"] || object[styleEditMode]; }, + isValidValue: (state) => (value) => { + if (typeof value == "string") { + return value.length != 0; + } else if (typeof value == "number") { + return true; + } + return false; + }, getCurrentStyle: (state) => (propertyName) => { let object = state.getCurrentElementsValues[0]; if (!object) return state.getGlobalStyleObject?.[propertyName]; @@ -426,12 +434,20 @@ export const useMainStore = defineStore("MainStore", { }); let styleEditMode = mapper[object.styleEditMode]; if (propertyName != "backgroundColor") { - return ( - object.selectedDynamicText?.[styleEditMode][propertyName] || - object.selectedColumn?.["style"][propertyName] || - object[styleEditMode][propertyName] || - state.getGlobalStyleObject[propertyName] - ); + if ( + state.isValidValue(object.selectedDynamicText?.[styleEditMode][propertyName]) + ) { + return object.selectedDynamicText?.[styleEditMode][propertyName]; + } + if (state.isValidValue(object.selectedColumn?.["style"][propertyName])) { + return object.selectedColumn?.["style"][propertyName]; + } + if (state.isValidValue(object[styleEditMode][propertyName])) { + return object[styleEditMode][propertyName]; + } + if (state.isValidValue(state.getGlobalStyleObject[propertyName])) { + return state.getGlobalStyleObject[propertyName]; + } } else { // we need to check if empty string incase it is background color and set as transparent if (typeof object.selectedDynamicText?.[styleEditMode][propertyName] == "string") {