This commit is contained in:
2020-03-29 00:47:19 +00:00
parent 4e5435e0f4
commit 408ae6d07d
10 changed files with 140 additions and 35 deletions

View File

@@ -105,10 +105,10 @@ export default {
///////////////////////////////////// /////////////////////////////////////
// Display LT message with wait for ok // Display LT message with wait for ok
// //
displayLTErrorMessage(ltKeyText, ltKeyTitle = undefined) { displayLTErrorMessage(tKeyText, tKeyTitle = undefined) {
return VM_LOCAL.$root.$gzconfirm({ return VM_LOCAL.$root.$gzconfirm({
message: ltKeyText ? window.$gz.translation.get(ltKeyText) : "", message: tKeyText ? window.$gz.translation.get(tKeyText) : "",
title: ltKeyTitle ? window.$gz.translation.get(ltKeyTitle) : "", title: tKeyTitle ? window.$gz.translation.get(tKeyTitle) : "",
yesButtonText: window.$gz.translation.get("OK") yesButtonText: window.$gz.translation.get("OK")
}); });
} }

View File

@@ -42,7 +42,7 @@ export default {
window.$gz.store.commit("addTranslationText", item); window.$gz.store.commit("addTranslationText", item);
} }
); );
console.log("3");
resolve(); resolve();
}); });
}); });

View File

@@ -158,8 +158,8 @@ export default {
}, },
methods: { methods: {
t: function(ltkey) { t: function(tKey) {
return window.$gz.translation.get(ltkey); return window.$gz.translation.get(tKey);
}, },
form() { form() {
//nothing //nothing

View File

@@ -107,8 +107,8 @@ export default {
} }
}, },
methods: { methods: {
t: function(ltkey) { t: function(tKey) {
return window.$gz.translation.get(ltkey); return window.$gz.translation.get(tKey);
}, },
hasError: function() { hasError: function() {
return this.errors.length > 0; return this.errors.length > 0;

View File

@@ -95,8 +95,8 @@ export default {
}, },
methods: { methods: {
t: function(ltkey) { t: function(tKey) {
return window.$gz.translation.get(ltkey); return window.$gz.translation.get(tKey);
}, },
addTag() { addTag() {
var theTag = this.tagSearchEntry; var theTag = this.tagSearchEntry;

View File

@@ -27,11 +27,17 @@
> >
</v-select> </v-select>
</v-col> </v-col>
template: <div>WORKING ARRAY: {{ workingArray }}</div>
{{ obj }}
available fields: <!-- <div>
{{ availableFields }} TEMPLATE:
{{ obj }}
</div>
<div>
available fields:
{{ availableFields }}
</div> -->
<!-- <template v-for="item in obj"> <!-- <template v-for="item in obj">
<v-col :key="item.key" cols="12" sm="6" lg="4" xl="3" px-2> <v-col :key="item.key" cols="12" sm="6" lg="4" xl="3" px-2>
<v-card> <v-card>
@@ -136,6 +142,7 @@ export default {
}, },
availableFields: [], availableFields: [],
workingArray: [], workingArray: [],
fieldKeys: [],
templateId: 0, templateId: 0,
formState: { formState: {
ready: false, ready: false,
@@ -151,8 +158,8 @@ export default {
}; };
}, },
methods: { methods: {
t: function(ltkey) { t: function(tKey) {
return window.$gz.translation.get(ltkey); return window.$gz.translation.get(tKey);
}, },
templateSelected: function() { templateSelected: function() {
if (this.formState.dirty) { if (this.formState.dirty) {
@@ -173,7 +180,7 @@ export default {
} }
window.$gz.form.deleteAllErrorBoxErrors(vm); window.$gz.form.deleteAllErrorBoxErrors(vm);
console.log("1");
//get available fields //get available fields
window.$gz.api window.$gz.api
.get(API_BASE_URL + "ListFields/" + vm.templateId) .get(API_BASE_URL + "ListFields/" + vm.templateId)
@@ -183,8 +190,37 @@ export default {
window.$gz.form.setErrorBoxErrors(vm); window.$gz.form.setErrorBoxErrors(vm);
} else { } else {
vm.availableFields = res.data; vm.availableFields = res.data;
vm.fieldKeys = [];
for (var i = 0; i < res.data.length; i++) {
vm.fieldKeys.push(res.data[i].tKey);
}
} }
}) })
.then(
window.$gz.translation.fetch(vm.fieldKeys)
//TODO: this is fucked and I don't know why, maybe because it's calling a new thing, not processing the existing thing?
//way easier to just return the template with the ltkeys already processed at the server instead of this fuckery,
//but it would be good to know what the fuck is happening,maybe it needs await and stuff like in ay-data-list-view initform example since they are all new calls
//rather than in then which is I think there to chain the first call basically
//THIS MIGHT BE RELEVANT, LOOK INTO IT: https://stackoverflow.com/questions/40981040/using-a-fetch-inside-another-fetch-in-javascript
//get translations for field names
// console.log("fetchTranslatedFieldNames");
// if (!fields) {
// return;
// }
// var fieldKeys = [];
// for (var i = 0; i < fields.length; i++) {
// fieldKeys.push(fields[i].tKey);
// }
// //Now fetch all the keys and await the response before returning
// await window.$gz.translation.fetch(fieldKeys).then(() => {
// console.log("fetchTranslatedFieldNames:done");
// return;
// });
)
.then( .then(
//get current edited template //get current edited template
window.$gz.api.get(API_BASE_URL + vm.templateId).then(res => { window.$gz.api.get(API_BASE_URL + vm.templateId).then(res => {
@@ -192,11 +228,9 @@ export default {
vm.formState.serverError = res.error; vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm); window.$gz.form.setErrorBoxErrors(vm);
} else { } else {
console.log("4");
vm.obj = res.data; vm.obj = res.data;
synthesizeWorkingArray(vm);
//TODO: Here need to set workingArray to a synthesis of the active template, and available fields so it reflects the current state and provides the extra fields
//then modify form so it uses workingArray to display like custom etc. note if has rowId is required and must be included=true
//Update the form status //Update the form status
window.$gz.form.setFormState({ window.$gz.form.setFormState({
vm: vm, vm: vm,
@@ -373,9 +407,9 @@ function initForm(vm) {
// Ensures UI translated text is available // Ensures UI translated text is available
// //
function fetchTranslatedText(vm) { function fetchTranslatedText(vm) {
var ltKeysRequired = ["Include"]; var tKeysRequired = ["Include"];
return window.$gz.translation.fetch(ltKeysRequired); return window.$gz.translation.fetch(tKeysRequired);
} }
////////////////////// //////////////////////
@@ -391,4 +425,75 @@ function populateSelectionLists(vm) {
} }
}); });
} }
////////////////////
//
function synthesizeWorkingArray(vm) {
vm.workingArray = [];
if (vm.obj.template == null) {
return;
}
var template = JSON.parse(vm.obj.template);
//first, insert the templated fields into the working array so they are in current selected order
for (var i = 0; i < template.length; i++) {
var templateItem = template[i];
var afItem = window.$gz._.find(vm.availableFields, [
"fieldKey",
templateItem.fld
]);
if (afItem != null) {
//Push into working array
vm.workingArray.push({
key: afItem.fieldKey,
required: afItem.isRowId == true,
include: true,
title: vm.t(afItem.tKey)
});
}
}
//Now iterate all the available fields and insert the ones that were not in the current template
for (var i = 0; i < vm.availableFields.length; i++) {
var afItem = vm.availableFields[i];
//skip the active column
if (afItem.isActive == true) {
continue;
}
//is this field already in the template and was added above?
if (window.$gz._.find(template, ["fld", afItem.fieldKey]) != null) {
continue;
}
//Push into working array
vm.workingArray.push({
key: afItem.fieldKey,
required: afItem.isRowId == true,
include: false,
title: vm.t(afItem.tKey)
});
}
}
// //////////////////////////////////////////////////////////
// //
// // Ensures field names are present in translation table
// //
// async function fetchTranslatedFieldNames(fields) {
// console.log("fetchTranslatedFieldNames:top");
// if (!fields) {
// return;
// }
// var fieldKeys = [];
// for (var i = 0; i < fields.length; i++) {
// fieldKeys.push(fields[i].tKey);
// }
// //Now fetch all the keys and await the response before returning
// await window.$gz.translation.fetch(fieldKeys).then(() => {
// console.log("fetchTranslatedFieldNames:done");
// return;
// });
// }
</script> </script>

View File

@@ -263,7 +263,7 @@ function initForm(vm) {
// Ensures UI translated text is available // Ensures UI translated text is available
// //
function fetchTranslatedText(vm) { function fetchTranslatedText(vm) {
var ltKeysRequired = [ var tKeysRequired = [
"HelpAboutAyaNova", "HelpAboutAyaNova",
"ClientApp", "ClientApp",
"Server", "Server",
@@ -287,7 +287,7 @@ function fetchTranslatedText(vm) {
"CurrencyCode" "CurrencyCode"
]; ];
return window.$gz.translation.fetch(ltKeysRequired); return window.$gz.translation.fetch(tKeysRequired);
} }
//////////////////// ////////////////////

View File

@@ -133,8 +133,8 @@ export default {
}, },
methods: { methods: {
t: function(ltkey) { t: function(tKey) {
return window.$gz.translation.get(ltkey); return window.$gz.translation.get(tKey);
}, },
visibleChanged: function(item) { visibleChanged: function(item) {
//Note: stock items can't be changed so no need to take that into account //Note: stock items can't be changed so no need to take that into account
@@ -330,7 +330,7 @@ function initForm(vm) {
// Ensures UI translated text is available // Ensures UI translated text is available
// //
function fetchTranslatedText(vm) { function fetchTranslatedText(vm) {
var ltKeysRequired = [ var tKeysRequired = [
"FormFieldEntryRequired", "FormFieldEntryRequired",
"FormFieldVisible", "FormFieldVisible",
"UiFieldDataType", "UiFieldDataType",
@@ -344,7 +344,7 @@ function fetchTranslatedText(vm) {
"UiFieldDataTypesTrueFalse" "UiFieldDataTypesTrueFalse"
]; ];
return window.$gz.translation.fetch(ltKeysRequired); return window.$gz.translation.fetch(tKeysRequired);
} }
///////////////////////////////// /////////////////////////////////

View File

@@ -555,8 +555,8 @@ export default {
} }
}, },
methods: { methods: {
t: function(ltkey) { t: function(tKey) {
return window.$gz.translation.get(ltkey); return window.$gz.translation.get(tKey);
}, },
enumSelectionList: function(enumKey) { enumSelectionList: function(enumKey) {
return window.$gz.enums.getSelectionList(enumKey); return window.$gz.enums.getSelectionList(enumKey);
@@ -993,7 +993,7 @@ function initForm(vm) {
// Ensures UI translated text is available // Ensures UI translated text is available
// //
function fetchTranslatedText(vm) { function fetchTranslatedText(vm) {
var ltKeysRequired = [ var tKeysRequired = [
"DataListView", "DataListView",
"GridFilterName", "GridFilterName",
"Include", "Include",
@@ -1040,7 +1040,7 @@ function fetchTranslatedText(vm) {
"Name" "Name"
]; ];
return window.$gz.translation.fetch(ltKeysRequired); return window.$gz.translation.fetch(tKeysRequired);
} }
///////////////////////////////// /////////////////////////////////

View File

@@ -52,8 +52,8 @@ export default {
}; };
}, },
methods: { methods: {
t: function(ltkey) { t: function(tKey) {
return window.$gz.translation.get(ltkey); return window.$gz.translation.get(tKey);
}, },
ayaType: function() { ayaType: function() {
return window.$gz.type; return window.$gz.type;