HUGE REFACTOR / CLEANUP

if there is a issue it's probably something in here that was changed
This commit is contained in:
2021-09-28 20:19:44 +00:00
parent 51eddfede9
commit d0afdd9855
238 changed files with 3127 additions and 8614 deletions

View File

@@ -29,7 +29,6 @@
<v-icon data-cy="btnsearch">$ayiSearch</v-icon>
</v-btn>
</v-col>
<v-col cols="12">
<p v-if="!items.length">{{ $ay.t("NoResults") }}</p>
<v-card v-if="items.length" max-width="900">
@@ -75,12 +74,7 @@
</v-col>
</v-row>
</template>
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Xeslint-disable */
////////////////////////////////////////////////////////////////////////////////////////////////////////////
const FORM_KEY = "search";
const API_BASE_URL = "search/";
const FORM_CUSTOM_TEMPLATE_KEY = "home-search";
@@ -88,7 +82,7 @@ const MAX_RESULTS = 200;
export default {
beforeRouteLeave(to, from, next) {
let vm = this;
const vm = this;
//save last search in session cache
window.$gz.form.setFormSettings(FORM_KEY, {
temp: {
@@ -98,11 +92,10 @@ export default {
maxResultsReturned: vm.maxResultsReturned
}
});
next();
},
async created() {
let vm = this;
const vm = this;
try {
await initForm(vm);
@@ -168,7 +161,7 @@ export default {
});
},
async getExcerpt(item) {
let vm = this;
const vm = this;
//Search/Info/2/1?phrase=we
if (item.info || item.id == 0) {
return;
@@ -212,10 +205,10 @@ export default {
window.$gz.form.setErrorBoxErrors(vm);
} else {
let showInfo = res.data;
let searchTerms = vm.searchPhrase.replace(/[*]/gi, "").split(" ");
const searchTerms = vm.searchPhrase.replace(/[*]/gi, "").split(" ");
for (let i = 0; i < searchTerms.length; i++) {
let regEx = new RegExp(searchTerms[i], "ig");
let replaceMask =
const regEx = new RegExp(searchTerms[i], "ig");
const replaceMask =
"<span class='v-list-item__mask'>" + searchTerms[i] + "</span>";
showInfo = showInfo.replace(regEx, replaceMask);
}
@@ -227,23 +220,14 @@ export default {
}
},
async getDataFromApi() {
let vm = this;
const vm = this;
if (!vm.searchPhrase || vm.formState.loading) {
return;
}
vm.formState.loading = true;
window.$gz.form.deleteAllErrorBoxErrors(vm);
/**
* {
"phrase": "e*",
"nameOnly": false,
"typeOnly": 0,
"maxResults": 100
}
*
*/
try {
let res = await window.$gz.api.upsert(API_BASE_URL, {
const res = await window.$gz.api.upsert(API_BASE_URL, {
phrase: vm.searchPhrase,
nameOnly: false,
typeOnly: !!vm.searchAType ? vm.searchAType : 0,
@@ -254,19 +238,17 @@ export default {
window.$gz.form.setErrorBoxErrors(vm);
} else {
vm.maxResultsReturned = res.data.searchResults.length == MAX_RESULTS;
let newResults = [];
const newResults = [];
let nDex = 0;
let lastType = -1;
for (let i = 0; i < res.data.searchResults.length; i++) {
let item = res.data.searchResults[i];
const item = res.data.searchResults[i];
item.name = await window.$gz.translation.translateStringWithMultipleKeysAsync(
item.name
);
if (item.type != lastType) {
//change of type, set subheader props
//Note: was going to show the type name translated but coded it to get the name from the list which doesn't have the translated names due to a change
//so opted to just show the icon instead due to TTM concerns
let tsub = vm.selectLists.objectTypes.find(
const tsub = vm.selectLists.objectTypes.find(
z => z.id == item.type
);
@@ -275,7 +257,6 @@ export default {
} else {
item.subheader = "TYPE " + item.type;
}
// item.subheader = item.type;
item.icon = window.$gz.util.iconForType(item.type);
lastType = item.type;
}
@@ -288,7 +269,6 @@ export default {
} catch (error) {
window.$gz.errorHandler.handleFormError(error, vm);
} finally {
//Update the form status
window.$gz.form.setFormState({
vm: vm,
loading: false
@@ -305,7 +285,7 @@ function clickHandler(menuItem) {
if (!menuItem) {
return;
}
let m = window.$gz.menu.parseMenuItem(menuItem);
const m = window.$gz.menu.parseMenuItem(menuItem);
if (m.owner == FORM_KEY && !m.disabled) {
switch (m.key) {
default:
@@ -321,7 +301,7 @@ function clickHandler(menuItem) {
//
//
function generateMenu(vm) {
let menuOptions = {
const menuOptions = {
isMain: true,
icon: "$ayiSearch",
title: "Search",
@@ -361,7 +341,7 @@ async function fetchTranslatedText(vm) {
//
//
async function populateSelectionLists(vm) {
let res = await window.$gz.api.get("enum-list/list/alltranslated");
const res = await window.$gz.api.get("enum-list/list/alltranslated");
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);