This commit is contained in:
2021-01-30 19:38:22 +00:00
parent f0abfcbf6f
commit d895b40122

View File

@@ -4,34 +4,7 @@
<v-form ref="form">
<v-row>
<gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error>
<v-col cols="12">
<v-row>
<v-col cols="12" sm="6" lg="4" xl="3">
<v-text-field
v-model="obj.name"
:readonly="formState.readOnly"
:clearable="!formState.readOnly"
@click:clear="fieldValueChanged('name')"
:label="$ay.t('Name')"
:rules="[form().required(this, 'name')]"
:error-messages="form().serverErrors(this, 'name')"
ref="name"
@input="fieldValueChanged('name')"
data-cy="name"
></v-text-field>
</v-col>
<v-col cols="12" sm="6" lg="4" xl="3">
<v-checkbox
v-model="obj.public"
:readonly="formState.readOnly"
:label="$ay.t('AnyUser')"
ref="public"
@change="fieldValueChanged('public')"
></v-checkbox>
</v-col>
</v-row>
</v-col>
<template v-for="(item, index) in obj.editView">
<v-col :key="item.key" cols="12" sm="6" lg="4" xl="3" px-2>
<v-card :data-cy="'columncard:' + item.key">
@@ -72,332 +45,6 @@
><v-icon large>$ayiStepForward</v-icon></v-btn
>
</div>
<!-- SORT CONTROL -->
<template v-if="item.isSortable">
<div @click="toggleSort(item)" class="pt-6">
<v-btn x-large v-if="item.sort == null" icon>
<v-icon x-large>$ayiSort</v-icon></v-btn
>
<v-btn
v-if="item.sort != null && item.sort == '-'"
icon
x-large
><v-icon color="primary" x-large
>$ayiSortAmountDown</v-icon
></v-btn
>
<v-btn
v-if="item.sort != null && item.sort == '+'"
icon
x-large
><v-icon color="primary" x-large
>$ayiSortAmountUp</v-icon
></v-btn
>
<label class="v-label theme--light"
>&nbsp;{{ $ay.t("Sort") }}</label
>
</div>
</template>
<!-- FILTER CONTROL -->
<template v-if="item.isFilterable">
<div class="pt-6">
<!-- ******** BUILDER FOR EACH TYPE Tag, decimal,currency, bool, integer, string, datetime ******** -->
<!-- NOTE: currently not implemented: TimeSpan=15, seems unsupportable for a filter -->
<!-- DATETIME BUILDER -->
<!-- Note: date time is a bit unusual in that it presents the date tokens first as it would be the most common choice whereas the other types would do something
like that later -->
<div v-if="item.uiFieldDataType === 1">
<v-select
v-model="item.tempFilterToken"
:items="selectLists.dateFilterTokens"
item-text="name"
item-value="id"
:label="$ay.t('Filter')"
prepend-icon="$ayiFilter"
></v-select>
<div v-if="item.tempFilterToken == '*select*'">
<v-select
v-model="item.tempFilterOperator"
:items="selectLists.dateFilterOperators"
item-text="name"
item-value="id"
></v-select>
<gz-date-time-picker
v-if="
item.tempFilterOperator != '*NOVALUE*' &&
item.tempFilterOperator != '*HASVALUE*'
"
v-model="item.tempFilterValue"
></gz-date-time-picker>
</div>
<v-btn
large
block
v-if="item.tempFilterToken != null"
@click="addFilterCondition(item)"
><v-icon large>$ayiPlus</v-icon></v-btn
>
</div>
<!-- STRING(text-4, emailaddress-11, http-12, phone-16) BUILDER -->
<div
v-if="
item.uiFieldDataType === 4 ||
item.uiFieldDataType === 11 ||
item.uiFieldDataType === 12 ||
item.uiFieldDataType === 16
"
>
<v-select
v-model="item.tempFilterOperator"
:items="selectLists.stringFilterOperators"
item-text="name"
item-value="id"
:label="$ay.t('Filter')"
prepend-icon="$ayiFilter"
></v-select>
<v-text-field
v-if="
item.tempFilterOperator != null &&
item.tempFilterOperator != '*NOVALUE*' &&
item.tempFilterOperator != '*HASVALUE*'
"
v-model="item.tempFilterValue"
:clearable="!formState.readOnly"
></v-text-field>
<v-btn
large
block
v-if="item.tempFilterOperator != null"
@click="addFilterCondition(item)"
><v-icon large>$ayiPlus</v-icon></v-btn
>
</div>
<!-- INTEGER BUILDER -->
<!-- Also MemorySize type 14 are integers -->
<div
v-if="
item.uiFieldDataType === 5 ||
item.uiFieldDataType === 14
"
>
<v-select
v-model="item.tempFilterOperator"
:items="selectLists.integerFilterOperators"
item-text="name"
item-value="id"
:label="$ay.t('Filter')"
prepend-icon="$ayiFilter"
></v-select>
<v-text-field
v-if="
item.tempFilterOperator != null &&
item.tempFilterOperator != '*NOVALUE*' &&
item.tempFilterOperator != '*HASVALUE*'
"
v-model="item.tempFilterValue"
:clearable="!formState.readOnly"
type="number"
></v-text-field>
<v-btn
large
block
v-if="item.tempFilterOperator != null"
@click="addFilterCondition(item)"
><v-icon large>$ayiPlus</v-icon></v-btn
>
</div>
<!-- BOOL BUILDER -->
<div v-if="item.uiFieldDataType === 6">
<v-select
v-model="item.tempFilterOperator"
:items="selectLists.boolFilterOperators"
item-text="name"
item-value="id"
:label="$ay.t('Filter')"
prepend-icon="$ayiFilter"
></v-select>
<v-radio-group
v-model="item.tempFilterValue"
v-if="
item.tempFilterOperator != null &&
item.tempFilterOperator != '*NOVALUE*' &&
item.tempFilterOperator != '*HASVALUE*'
"
row
>
<v-radio
:label="$ay.t('False')"
:value="false"
></v-radio>
<v-radio
:label="$ay.t('True')"
:value="true"
></v-radio>
</v-radio-group>
<v-btn
large
block
v-if="item.tempFilterOperator != null"
@click="addFilterCondition(item)"
><v-icon large>$ayiPlus</v-icon></v-btn
>
</div>
<!-- DECIMAL BUILDER -->
<div v-if="item.uiFieldDataType === 7">
<v-select
v-model="item.tempFilterOperator"
:items="selectLists.decimalFilterOperators"
item-text="name"
item-value="id"
:label="$ay.t('Filter')"
prepend-icon="$ayiFilter"
></v-select>
<gz-decimal
v-if="
item.tempFilterOperator != null &&
item.tempFilterOperator != '*NOVALUE*' &&
item.tempFilterOperator != '*HASVALUE*'
"
v-model="item.tempFilterValue"
:clearable="!formState.readOnly"
></gz-decimal>
<v-btn
large
block
v-if="item.tempFilterOperator != null"
@click="addFilterCondition(item)"
><v-icon large>$ayiPlus</v-icon></v-btn
>
</div>
<!-- CURRENCY BUILDER -->
<div v-if="item.uiFieldDataType === 8">
<v-select
v-model="item.tempFilterOperator"
:items="selectLists.decimalFilterOperators"
item-text="name"
item-value="id"
:label="$ay.t('Filter')"
prepend-icon="$ayiFilter"
></v-select>
<gz-currency
v-if="
item.tempFilterOperator != null &&
item.tempFilterOperator != '*NOVALUE*' &&
item.tempFilterOperator != '*HASVALUE*'
"
v-model="item.tempFilterValue"
:clearable="!formState.readOnly"
></gz-currency>
<v-btn
large
block
v-if="item.tempFilterOperator != null"
@click="addFilterCondition(item)"
><v-icon large>$ayiPlus</v-icon></v-btn
>
</div>
<!-- TAG BUILDER -->
<div v-if="item.uiFieldDataType === 9">
<v-select
v-model="item.tempFilterOperator"
:items="selectLists.tagFilterOperators"
item-text="name"
item-value="id"
:label="$ay.t('Filter')"
prepend-icon="$ayiFilter"
></v-select>
<gz-tag-picker
v-if="item.tempFilterOperator != null"
v-model="item.tempFilterValue"
></gz-tag-picker>
<v-btn
large
block
v-if="item.tempFilterOperator != null"
@click="addFilterCondition(item)"
><v-icon large>$ayiPlus</v-icon></v-btn
>
</div>
<!-- ENUM BUILDER -->
<div v-if="item.uiFieldDataType === 10">
<v-select
v-model="item.tempFilterOperator"
:items="selectLists.enumFilterOperators"
item-text="name"
item-value="id"
:label="$ay.t('Filter')"
prepend-icon="$ayiFilter"
></v-select>
<v-select
v-if="
item.tempFilterOperator != null &&
item.tempFilterOperator != '*NOVALUE*' &&
item.tempFilterOperator != '*HASVALUE*'
"
v-model="item.tempFilterValue"
:items="enumSelectionList(item.enumType)"
item-text="name"
item-value="id"
></v-select>
<v-btn
large
block
v-if="item.tempFilterOperator != null"
@click="addFilterCondition(item)"
><v-icon large>$ayiPlus</v-icon></v-btn
>
</div>
</div>
<div class="pt-6">
<!-- FILTER LIST -->
<template v-if="item.filter.items.length > 0">
<v-list elevation="2">
<v-subheader v-if="item.filter.items.length > 1">
<!-- AND / OR FILTER CONDITIONS -->
<v-radio-group v-model="item.filter.any" row>
<v-radio
:label="$ay.t('GridFilterDialogAndRadioText')"
:value="false"
></v-radio>
<v-radio
:label="$ay.t('GridFilterDialogOrRadioText')"
:value="true"
></v-radio> </v-radio-group
></v-subheader>
<v-list-item
v-for="(filterItem, index) in item.filter.items"
:key="index"
>
<v-list-item-content>
<v-list-item-title v-text="filterItem.display">
</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-btn
icon
@click="removeFilterCondition(item, index)"
>
<v-icon>$ayiTrashAlt</v-icon>
</v-btn>
</v-list-item-action>
</v-list-item>
</v-list>
</template>
<!-- <v-divider></v-divider>
{{ item }} -->
</div>
</template>
</v-card-text>
</v-card>
</v-col>
@@ -414,21 +61,23 @@
const FORM_KEY = "ay-data-list-column-view";
const API_BASE_URL = "data-list-column-view/";
let JUST_DELETED = false;
export default {
//unsaved changes are actually valid for this form so no need to warn
beforeRouteLeave(to, from, next) {
let vm = this;
if (this.formState.dirty && !JUST_DELETED) {
//Put in unsaved listview
let formSettings = window.$gz.form.getFormSettings(vm.formKey);
formSettings.saved.dataTable.unsavedListView = JSON.stringify(
generateListViewFromEdited(vm)
);
formSettings.saved.dataTable.listViewId = -1;
formSettings.temp.cachedListView = null;
formSettings.temp.page = 1;
window.$gz.form.setFormSettings(vm.formKey, formSettings);
if (this.formState.dirty) {
//LVNEW: SAVE AUTOMATICALLY?
// //Put in unsaved listview
// let formSettings = window.$gz.form.getFormSettings(vm.formKey);
// formSettings.saved.dataTable.unsavedListView = JSON.stringify(
// generateListViewFromEdited(vm)
// );
// formSettings.temp.cachedListView = null;
// formSettings.temp.page = 1;
// window.$gz.form.setFormSettings(vm.formKey, formSettings);
next();
} else {
next();
@@ -442,7 +91,6 @@ export default {
try {
//set route values in data object so init form can handle
vm.dataListKey = this.$route.params.dataListKey;
vm.listViewId = this.$route.params.listViewId;
vm.formKey = this.$route.params.formKey;
await initForm(vm);
vm.formState.ready = true;
@@ -467,7 +115,6 @@ export default {
concurrency: 0,
userId: 0
},
listViewId: undefined,
dataListKey: undefined,
formKey: undefined,
fieldDefinitions: [],
@@ -735,13 +382,6 @@ export default {
listView: JSON.stringify(generateListViewFromEdited(vm))
};
//are we working off a pre-existing listview (save over)?
if (vm.listViewId > 0) {
lvSave.id = vm.listViewId;
lvSave.concurrency = vm.obj.concurrency;
url = url + vm.listViewId;
}
//clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(this);
try {
@@ -758,8 +398,7 @@ export default {
formSettings.temp.cachedListView = lvSave.listView;
formSettings.temp.page = 1;
formSettings.saved.dataTable.unsavedListView = null;
formSettings.saved.dataTable.listViewId =
res.data.id || vm.listViewId; //if res.data.id then a post, if null then a put and vm.listviewId has the id
window.$gz.form.setFormSettings(vm.formKey, formSettings);
//Logic for detecting if a post or put: if id then it was a post, if no id then it was a put
@@ -803,35 +442,25 @@ export default {
//do the delete
vm.formState.loading = true;
//No need to delete a non saved record, just abandon it...
if (vm.listViewId < 1) {
//this should not get offered for delete but to be safe and clear just in case:
JUST_DELETED = true;
let url = API_BASE_URL + vm.listViewId;
window.$gz.form.deleteAllErrorBoxErrors(vm);
let res = await window.$gz.api.remove(url);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//set it to the default list view so the caller doesn't try to load the non-existant deleted view it was just working with
let formSettings = window.$gz.form.getFormSettings(vm.formKey);
formSettings.temp.cachedListView = null;
formSettings.temp.page = 1;
formSettings.saved.dataTable.unsavedListView = null;
window.$gz.form.setFormSettings(vm.formKey, formSettings);
// navigate backwards
vm.$router.go(-1);
} else {
let url = API_BASE_URL + vm.listViewId;
window.$gz.form.deleteAllErrorBoxErrors(vm);
let res = await window.$gz.api.remove(url);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//workaround to prevent warning about leaving dirty record
//For some reason I couldn't just reset isdirty in formstate
JUST_DELETED = true;
//set it to the default list view so the caller doesn't try to load the non-existant deleted view it was just working with
let formSettings = window.$gz.form.getFormSettings(vm.formKey);
formSettings.temp.cachedListView = null;
formSettings.temp.page = 1;
formSettings.saved.dataTable.unsavedListView = null;
formSettings.saved.dataTable.listViewId = 0;
window.$gz.form.setFormSettings(vm.formKey, formSettings);
// navigate backwards
vm.$router.go(-1);
}
}
} catch (error) {
//Update the form status
@@ -841,51 +470,6 @@ export default {
});
window.$gz.errorHandler.handleFormError(error, vm);
}
},
async duplicate() {
let vm = this;
if (this.canDuplicate && vm.listViewId > 0) {
this.formState.loading = true;
let url = API_BASE_URL + "duplicate/" + vm.listViewId;
//clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(this);
try {
let res = await window.$gz.api.upsert(url);
vm.formState.loading = false;
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//switch to the new record in the formsettings
let formSettings = window.$gz.form.getFormSettings(vm.formKey);
formSettings.temp.cachedListView = null;
formSettings.temp.page = 1;
formSettings.saved.dataTable.unsavedListView = null;
formSettings.saved.dataTable.listViewId = res.data.id;
window.$gz.form.setFormSettings(vm.formKey, formSettings);
//Set some values that otherwise don't get updated because we're not really navigating fresh
vm.obj.name = res.data.name;
vm.obj.concurrency = res.data.concurrency;
vm.listViewId = res.data.id;
//Navigate to new record
//NOTE: this doesn't really update the form at all so need to set some th9ings
vm.$router.push(
vm.$route.fullPath.slice(0, -1) + res.data.id
// window.$gz.api.replaceAfterLastSlash(
// vm.$route.fullPath,
// res.data.id
// )
);
}
} catch (error) {
vm.formState.loading = false;
window.$gz.errorHandler.handleFormError(error, vm);
}
}
}
}
};
@@ -903,8 +487,8 @@ function clickHandler(menuItem) {
case "save":
m.vm.submit();
break;
case "delete":
m.vm.remove();
case "reset":
m.vm.reset();
break;
case "duplicate":
m.vm.duplicate();
@@ -936,32 +520,22 @@ function generateMenu(vm) {
menuItems: []
};
if (vm.rights.change) {
menuOptions.menuItems.push({
title: "Save",
icon: "$ayiSave",
surface: true,
key: FORM_KEY + ":save",
vm: vm
});
}
if (vm.rights.delete) {
menuOptions.menuItems.push({
title: "Delete",
icon: "$ayiTrashAlt",
surface: false,
key: FORM_KEY + ":delete",
vm: vm
});
}
if (vm.rights.change) {
menuOptions.menuItems.push({
title: "Duplicate",
icon: "$ayiClone",
key: FORM_KEY + ":duplicate",
vm: vm
});
}
menuOptions.menuItems.push({
title: "Save",
icon: "$ayiSave",
surface: true,
key: FORM_KEY + ":save",
vm: vm
});
menuOptions.menuItems.push({
title: "ResetToDefault",
icon: "$ayiTrashAlt",
surface: false,
key: FORM_KEY + ":reset",
vm: vm
});
window.$gz.eventBus.$emit("menu-change", menuOptions);
}
@@ -984,6 +558,7 @@ async function initForm(vm) {
//
async function fetchTranslatedText(vm) {
await window.$gz.translation.cacheTranslations([
"ResetToDefault",
"DataListView",
"GridFilterName",
"Include",