This commit is contained in:
2021-01-04 23:15:13 +00:00
parent 9d6355470e
commit 09bcb7021d

View File

@@ -385,21 +385,22 @@ async function initDataObject(vm) {
//Iterate ObjectFields //Iterate ObjectFields
//create a new object based on the f.a.f. item and any existing template values for that item //create a new object based on the f.a.f. item and any existing template values for that item
//Iterate first to ensure the cached translations of field keys //Iterate first to ensure the cached translations of field keys
//(due to this form being opened directly from things like record history so might not be cached yet) //(due to this form being opened directly from things like record history so might not be cached yet)
let requiredTranslations=[]; //if they *are* cached then this is a pretty fast operation and no trip is made to the server
//for (var i=0, l=arr.length; i<l; i++) let requiredTranslations = [];
//if (a.indexOf(arr[i]) === -1 && arr[i] !== '')
// a.push(arr[i]);
for (let i = 0; i < res.data.length; i++) { for (let i = 0; i < res.data.length; i++) {
if (requiredTranslations.indexOf(res.data[i].tKey) === -1) {
requiredTranslations.push(res.data[i].tKey);
}
} }
await window.$gz.translation.cacheTranslations(requiredTranslations);
//Iterate a second time to build the working collection //Iterate a second time to build the working collection
for (let i = 0; i < res.data.length; i++) { for (let i = 0; i < res.data.length; i++) {
//get the formAvailableField record into an object to save typing //get the formAvailableField record into an object to save typing
let faf = res.data[i]; let faf = res.data[i];
//get the customTemplate record for this field if it exists //get the customTemplate record for this field if it exists
let templateItem = window.$gz.formCustomTemplate.getFieldTemplateValue( let templateItem = window.$gz.formCustomTemplate.getFieldTemplateValue(
@@ -418,7 +419,7 @@ async function initDataObject(vm) {
let objItem = { let objItem = {
key: faf.fieldKey, key: faf.fieldKey,
title: vm.$ay.t(faf.tKey), title: vm.$ay.t(faf.tKey), //sb already cached either above or from the main form it's customizing
stockRequired: !faf.hideable, stockRequired: !faf.hideable,
custom: faf.isCustomField, custom: faf.isCustomField,
required: faf.hideable === false || templateItem.required === true, required: faf.hideable === false || templateItem.required === true,
@@ -431,7 +432,5 @@ async function initDataObject(vm) {
vm.formCustomTemplateKey vm.formCustomTemplateKey
); );
} }
} }
</script> </script>