This commit is contained in:
2020-12-15 19:17:28 +00:00
parent de48dce53c
commit e49889d134
3 changed files with 44 additions and 31 deletions

View File

@@ -31,8 +31,6 @@ todo: biz rule like validatecansave and validatecandelete but validatecanFetch f
currently doing: MEMO - currently doing: MEMO -
READ menu items
Reply, Forward
compose - must filter OUT outside users, currently they show, new picklist I guess with extra criteria? compose - must filter OUT outside users, currently they show, new picklist I guess with extra criteria?
search results should not pull up other's memo's search results should not pull up other's memo's
exclude from searching? Not searchable?? exclude from searching? Not searchable??

View File

@@ -37,10 +37,9 @@
</template> </template>
<script> <script>
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* eslint-disable */ /* Xeslint-disable */
//////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
export default { export default {
created() { created() {
this.fetchValueIfNotPresent(); this.fetchValueIfNotPresent();
@@ -76,13 +75,17 @@ export default {
showEditIcon: { showEditIcon: {
type: Boolean, type: Boolean,
default: false default: false
}, },
allowNoSelection: { allowNoSelection: {
type: Boolean, type: Boolean,
default: true default: true
}, },
canClear:{type: Boolean, default: true}, canClear: { type: Boolean, default: true },
label: { type: String, default: "" } label: { type: String, default: "" },
variant: {
type: String,
default: null
}
}, },
watch: { watch: {
ayaType(val, oldVal) { ayaType(val, oldVal) {
@@ -161,20 +164,19 @@ export default {
type: this.ayaType, type: this.ayaType,
id: idToOpen id: idToOpen
}); });
}, },
selectionMade(e) { selectionMade(e) {
this.clearErrors(); this.clearErrors();
if (e == undefined) { if (e == undefined) {
//this will happen when clear clicked //this will happen when clear clicked
//simulate empty selection: //simulate empty selection:
e = window.$gz.form.getNoSelectionItem(true); e = window.$gz.form.getNoSelectionItem(true);
} }
this.lastSelection = e; this.lastSelection = e;
//this is required for the control to update and parent form to detect it //this is required for the control to update and parent form to detect it
this.$emit("input", e.id); this.$emit("input", e.id);
}, },
fetchValueIfNotPresent() { fetchValueIfNotPresent() {
//is there a value that might require fetching? //is there a value that might require fetching?
@@ -195,7 +197,12 @@ export default {
window.$gz.form.addNoSelectionItem(vm.searchResults, true); window.$gz.form.addNoSelectionItem(vm.searchResults, true);
} else { } else {
//Not here, better get it //Not here, better get it
let urlParams = "?ayaType=" + vm.ayaType + "&preId=" + vm.value; let variantSegment = "";
if (vm.variant != null) {
variantSegment = `&variant=${vm.variant}`;
}
let urlParams =
"?ayaType=" + vm.ayaType + "&preId=" + vm.value + variantSegment;
vm.getList(urlParams); vm.getList(urlParams);
} }
}, },
@@ -270,18 +277,21 @@ export default {
if (vm.includeInactive) { if (vm.includeInactive) {
urlParams += "&inactive=true"; urlParams += "&inactive=true";
} }
if (vm.variant != null) {
urlParams += `&variant=${vm.variant}`;
}
} }
try { try {
let res = await window.$gz.api.get("pick-list/list" + urlParams); let res = await window.$gz.api.get("pick-list/list" + urlParams);
vm.fetching = false; vm.fetching = false;
//We never expect there to be no data here //We never expect there to be no data here
if (!res.hasOwnProperty("data")) { if (!res.hasOwnProperty("data")) {
return Promise.reject(res); return Promise.reject(res);
} }
vm.searchResults = res.data; vm.searchResults = res.data;
if(vm.allowNoSelection){ if (vm.allowNoSelection) {
window.$gz.form.addNoSelectionItem(vm.searchResults, true); window.$gz.form.addNoSelectionItem(vm.searchResults, true);
} }
vm.replaceLastSelection(); vm.replaceLastSelection();
} catch (err) { } catch (err) {
@@ -293,7 +303,7 @@ export default {
//NOTE debounce with a watcher is a bit different, currently it has to be done exactly this way, nothing else will work properly //NOTE debounce with a watcher is a bit different, currently it has to be done exactly this way, nothing else will work properly
//https://vuejs.org/v2/guide/migration.html#debounce-Param-Attribute-for-v-model-removed //https://vuejs.org/v2/guide/migration.html#debounce-Param-Attribute-for-v-model-removed
//----------------- //-----------------
let vm = this; let vm = this;
let isATwoTermQuery = false; let isATwoTermQuery = false;
let queryTerms = []; let queryTerms = [];
@@ -342,8 +352,8 @@ export default {
//check that both terms aren't tags //check that both terms aren't tags
if ( if (
//note: de-lodashed here not sure if I need to add a null check or not //note: de-lodashed here not sure if I need to add a null check or not
queryTerms[0].startsWith("..") && queryTerms[0].startsWith("..") &&
queryTerms[1].startsWith("..") queryTerms[1].startsWith("..")
) { ) {
vm.errors.push(vm.$ay.t("ErrorPickListQueryInvalid")); vm.errors.push(vm.$ay.t("ErrorPickListQueryInvalid"));
return; return;
@@ -373,6 +383,9 @@ export default {
if (vm.includeInactive) { if (vm.includeInactive) {
urlParams += "&inactive=true"; urlParams += "&inactive=true";
} }
if (vm.variant != null) {
urlParams += `&variant=${vm.variant}`;
}
this.getList(urlParams); this.getList(urlParams);
//------------ //------------
}, 300) //did some checking, 200-300ms seems to be the most common debounce time for ajax search queries }, 300) //did some checking, 200-300ms seems to be the most common debounce time for ajax search queries
@@ -383,13 +396,14 @@ export default {
function debounce(func, wait, immediate) { function debounce(func, wait, immediate) {
var timeout; var timeout;
return function() { return function() {
var context = this, args = arguments; var context = this,
clearTimeout(timeout); args = arguments;
timeout = setTimeout(function() { clearTimeout(timeout);
timeout = null; timeout = setTimeout(function() {
if (!immediate) func.apply(context, args); timeout = null;
}, wait); if (!immediate) func.apply(context, args);
if (immediate && !timeout) func.apply(context, args); }, wait);
if (immediate && !timeout) func.apply(context, args);
}; };
} }
</script> </script>

View File

@@ -72,6 +72,7 @@
:allowNoSelection="false" :allowNoSelection="false"
:canClear="false" :canClear="false"
:ayaType="ayaTypes().User" :ayaType="ayaTypes().User"
:variant="'outside'"
:showEditIcon="false" :showEditIcon="false"
v-model="pickListSelectedUserId" v-model="pickListSelectedUserId"
:label="$ay.t('MemoToID')" :label="$ay.t('MemoToID')"