From 60cf87d3eaf823689c6df72e6b0b489caffff823 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 25 Jan 2021 15:16:57 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 34 ------------------- ayanova/src/api/errorhandler.js | 2 +- ayanova/src/api/gzform.js | 18 +++++----- ayanova/src/api/translation.js | 22 +++++++++++- ayanova/src/components/extensions-control.vue | 2 +- ayanova/src/views/adm-import.vue | 2 +- ayanova/src/views/ay-history.vue | 2 +- ayanova/src/views/ops-jobs.vue | 2 +- 8 files changed, 34 insertions(+), 50 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 33969f97..9f74f11d 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -168,43 +168,9 @@ CURRENTLY DOING: Cleanup with untranslated error string when attempting to dele Remove translation await code from gzform as it's not going to work that way and assume all errors come with pre-translated or do not require a fetch all stock error number validation codes errors should nto need to fetch as be prefetched so no need for async for that particualr purpose - At server add standard *biz function to Translate(key) to replace the long winded one in ValidateCanDelete that is available to *all* biz objects - Then go into every validate save and validate delete and look for lt keys and replace with this pre-translate call to Translate(key) - Finally the error display for a referential integrity error on delete is ugly, confusing and has too much shit going on - clean it up to a one liner that clearly mixes in the object name with the error however that has to happen. - just want to see a clean list of all the types of objects it's linked to - -How it would look with ErrorDBForeignKeyViolation method: ---- -Validation error -ErrorAPI2200 -Invalid operation [2030] - "This object can not be deleted because it is linked to one or more related objects: Inventory transaction" -Invalid operation [2030] - "This object can not be deleted because it is linked to one or more related objects: Part" -Invalid operation [2030] - "This object can not be deleted because it is linked to one or more related objects: Unit" -Invalid operation [2030] - "This object can not be deleted because it is linked to one or more related objects: User" ---- - -Validation error -ErrorAPI2200 -This object is linked to others and can not be changed this way [2208] - "Part" -This object is linked to others and can not be changed this way [2208] - "Unit" -This object is linked to others and can not be changed this way [2208] - "Inventory transaction" -This object is linked to others and can not be changed this way [2208] - "User" - -PartByWarehouseInventory part stock taking view and list -todo: make the adjustments list item the partinventorytransactions list -todo: make the partinventory just be the partinventory reconcilliation stock taking thing - -EDIT form for partinventory item openobjecthyandler should open up to event log history of entry, not entry form since it is not editable anyway - - - - - - todo: LT:NoType modify datagrid to handle LT: in text fields (needs to cache values it finds) diff --git a/ayanova/src/api/errorhandler.js b/ayanova/src/api/errorhandler.js index c17e3326..855965ce 100644 --- a/ayanova/src/api/errorhandler.js +++ b/ayanova/src/api/errorhandler.js @@ -19,7 +19,7 @@ async function dealWithError(msg, vm) { lastMessageTimeStamp = new Date(); //translate as necessary - msg = await window.$gz.translation.translateStringWithMultipleKeys(msg); + msg = await window.$gz.translation.translateStringWithMultipleKeysAsync(msg); //In some cases the error may not be translatable, if this is not a debug run then it should show without the ?? that translating puts in keys not found //so it's not as weird looking to the user diff --git a/ayanova/src/api/gzform.js b/ayanova/src/api/gzform.js index d4365f83..c84bee41 100644 --- a/ayanova/src/api/gzform.js +++ b/ayanova/src/api/gzform.js @@ -654,16 +654,14 @@ export default { ve.error + "]"; if (ve.message) { - //NOTE: This is (**still not**) how to handle calling an async function from a sync function - //for reference sync async function async method from sync method - //it just can't be done and this needs to go away and not be expected to do this - let transMessage = ve.message; - window.$gz.translation - .translateStringWithMultipleKeys(ve.message) - .then(result => { - transMessage = result; - }); - fldErr += ' - "' + transMessage + '"'; + //NOTE: call sync version here as can't call async code from here + //so translations must already be pre-fetched to work here + fldErr += + ' - "' + + window.$gz.translation.translateStringWithMultipleKeys( + ve.message + ) + + '"'; ret.push(fldErr); } else { ret.push(fldErr); diff --git a/ayanova/src/api/translation.js b/ayanova/src/api/translation.js index e21e0df5..480f9f34 100644 --- a/ayanova/src/api/translation.js +++ b/ayanova/src/api/translation.js @@ -301,7 +301,7 @@ export default { //translation keys that start with LT: //translate each and replace and return the string translated // (fetch and cache any missing strings) - async translateStringWithMultipleKeys(s) { + async translateStringWithMultipleKeysAsync(s) { let ret = s; let found = s.match(/LT:[\w]*/gm); if (found == null) { @@ -324,6 +324,26 @@ export default { return ret; }, + //////////////////////////////////////////////////////// + // Take in a string that contains one or more + //translation keys that start with LT: + //translate each and replace and return the string translated + // (DOES NOT fetch and cache any missing strings, they must exist) + //this is the sync version to be used in non async capable code + translateStringWithMultipleKeys(s) { + let ret = s; + let found = s.match(/LT:[\w]*/gm); + if (found == null) { + return ret; + } + //replace + found.forEach(z => { + let translated = this.get(z.replace("LT:", "")); + //replace all + ret = ret.split(z).join(translated); + }); + return ret; + }, //////////////////////////////////////////////////////// // dynamically set the vuetify language elements from diff --git a/ayanova/src/components/extensions-control.vue b/ayanova/src/components/extensions-control.vue index 336fd7b7..06c3b97e 100644 --- a/ayanova/src/components/extensions-control.vue +++ b/ayanova/src/components/extensions-control.vue @@ -102,7 +102,7 @@ export default { this.languageName, this.hour12 ), - status: await window.$gz.translation.translateStringWithMultipleKeys( + status: await window.$gz.translation.translateStringWithMultipleKeysAsync( o.statusText ), jobId: diff --git a/ayanova/src/views/adm-import.vue b/ayanova/src/views/adm-import.vue index 01b2b868..076460a6 100644 --- a/ayanova/src/views/adm-import.vue +++ b/ayanova/src/views/adm-import.vue @@ -97,7 +97,7 @@ export default { res.data.forEach(function appendImportResultItem(value) { outText += value + "\n"; }); - vm.importResult = await window.$gz.translation.translateStringWithMultipleKeys( + vm.importResult = await window.$gz.translation.translateStringWithMultipleKeysAsync( outText ); } diff --git a/ayanova/src/views/ay-history.vue b/ayanova/src/views/ay-history.vue index 159076b6..284daf6d 100644 --- a/ayanova/src/views/ay-history.vue +++ b/ayanova/src/views/ay-history.vue @@ -304,7 +304,7 @@ export default { ); temp[ i - ].name = await window.$gz.translation.translateStringWithMultipleKeys( + ].name = await window.$gz.translation.translateStringWithMultipleKeysAsync( temp[i].name ); diff --git a/ayanova/src/views/ops-jobs.vue b/ayanova/src/views/ops-jobs.vue index ed330fff..5baf729b 100644 --- a/ayanova/src/views/ops-jobs.vue +++ b/ayanova/src/views/ops-jobs.vue @@ -115,7 +115,7 @@ export default { this.languageName, this.hour12 ), - status: await window.$gz.translation.translateStringWithMultipleKeys( + status: await window.$gz.translation.translateStringWithMultipleKeysAsync( o.statusText ), jobId: