This commit is contained in:
@@ -1,30 +1,92 @@
|
||||
export default {
|
||||
NoType: 0,
|
||||
Global: 1,
|
||||
//corebizobject
|
||||
Widget: 2,
|
||||
//corebizobject
|
||||
User: 3,
|
||||
ServerState: 4,
|
||||
License: 5,
|
||||
LogFile: 6,
|
||||
PickListTemplate: 7,
|
||||
DEPRECATED_REUSELATER_8: 8,
|
||||
//corebizobject
|
||||
Customer: 8,
|
||||
ServerJob: 9,
|
||||
AyaNova7Import: 10,
|
||||
//corebizobject
|
||||
Contract: 10,
|
||||
TrialSeeder: 11,
|
||||
Metrics: 12,
|
||||
Translation: 13,
|
||||
UserOptions: 14,
|
||||
DEPRECATED_REUSELATER_15: 15,
|
||||
DEPRECATED_REUSELATER_16: 16,
|
||||
//corebizobject
|
||||
HeadOffice: 15,
|
||||
//corebizobject
|
||||
LoanUnit: 16,
|
||||
FileAttachment: 17,
|
||||
DataListView: 18,
|
||||
FormCustom: 19,
|
||||
DataListTemplate: 20
|
||||
//corebizobject
|
||||
Part: 20,
|
||||
//corebizobject
|
||||
PM: 21,
|
||||
//corebizobject
|
||||
PMItem: 22,
|
||||
//corebizobject
|
||||
PMTemplate: 23,
|
||||
//corebizobject
|
||||
PMTemplateItem: 24,
|
||||
//corebizobject
|
||||
Project: 25,
|
||||
//corebizobject
|
||||
PurchaseOrder: 26,
|
||||
//corebizobject
|
||||
Quote: 27,
|
||||
//corebizobject
|
||||
QuoteItem: 28,
|
||||
//corebizobject
|
||||
QuoteTemplate: 29,
|
||||
//corebizobject
|
||||
QuoteTemplateItem: 30,
|
||||
//corebizobject
|
||||
Unit: 31,
|
||||
//corebizobject
|
||||
UnitModel: 32,
|
||||
//corebizobject
|
||||
Vendor: 33,
|
||||
//--- WorkOrder
|
||||
//corebizobject
|
||||
WorkOrder: 34,
|
||||
//corebizobject
|
||||
WorkOrderItem: 35,
|
||||
//corebizobject
|
||||
WorkOrderItemExpense: 36,
|
||||
//corebizobject
|
||||
WorkOrderItemLabor: 37,
|
||||
//corebizobject
|
||||
WorkOrderItemLoan: 38,
|
||||
//corebizobject
|
||||
WorkOrderItemPart: 39,
|
||||
//corebizobject
|
||||
WorkOrderItemPartRequest: 40,
|
||||
//corebizobject
|
||||
WorkOrderItemScheduledUser: 41,
|
||||
//corebizobject
|
||||
WorkOrderItemTask: 42,
|
||||
//corebizobject
|
||||
WorkOrderItemTravel: 43,
|
||||
//corebizobject
|
||||
WorkOrderItemUnit: 44,
|
||||
//---
|
||||
//corebizobject
|
||||
WorkOrderTemplate: 45,
|
||||
//corebizobject
|
||||
WorkOrderTemplateItem: 46,
|
||||
GlobalOps: 47
|
||||
};
|
||||
/**
|
||||
*
|
||||
* This is a mirror of AyaType.cs in server project
|
||||
* To update just copy the contents of AyaType.cs and replace " =" with ":" (without quotes obvsly)
|
||||
* To update just copy the contents of AyaType.cs and replace " :" with ":" (without quotes obvsly)
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -1,21 +1,423 @@
|
||||
|
||||
<template>
|
||||
<UnderConstruction />
|
||||
<v-row v-if="formState.ready">
|
||||
<v-col>
|
||||
<v-form ref="form">
|
||||
<v-row>
|
||||
<gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-select
|
||||
v-model="obj.translationId"
|
||||
:items="selectLists.translations"
|
||||
item-text="name"
|
||||
item-value="id"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('Translation')"
|
||||
ref="translationId"
|
||||
:error-messages="form().serverErrors(this, 'translationId')"
|
||||
@input="fieldValueChanged('translationId')"
|
||||
></v-select>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
v-model="obj.emailAddress"
|
||||
:readonly="formState.readOnly"
|
||||
:clearable="!formState.readOnly"
|
||||
@click:clear="fieldValueChanged('emailAddress')"
|
||||
:label="$ay.t('UserEmailAddress')"
|
||||
:error-messages="form().serverErrors(this, 'emailAddress')"
|
||||
ref="emailAddress"
|
||||
@input="fieldValueChanged('emailAddress')"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
v-model="obj.currencyName"
|
||||
hint="e.g. USD, EUR, GBP, AUD, CAD etc"
|
||||
:readonly="formState.readOnly"
|
||||
:clearable="!formState.readOnly"
|
||||
@click:clear="fieldValueChanged('currencyName')"
|
||||
:label="$ay.t('CurrencyCode')"
|
||||
:rules="[form().required(this, 'currencyName')]"
|
||||
:error-messages="form().serverErrors(this, 'currencyName')"
|
||||
ref="currencyName"
|
||||
@input="fieldValueChanged('currencyName')"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-checkbox
|
||||
v-model="obj.hour12"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('Hour12')"
|
||||
ref="hour12"
|
||||
:error-messages="form().serverErrors(this, 'hour12')"
|
||||
@change="fieldValueChanged('hour12')"
|
||||
></v-checkbox>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<!-- https://vuetifyjs.com/en/components/color-pickers -->
|
||||
<span class="v-label v-label--active theme--light">
|
||||
{{ $ay.t("UserColor") }}
|
||||
</span>
|
||||
<v-color-picker
|
||||
v-model="obj.uiColor"
|
||||
:readonly="formState.readOnly"
|
||||
hide-mode-switch
|
||||
mode="hexa"
|
||||
:error-messages="form().serverErrors(this, 'uiColor')"
|
||||
ref="uiColor"
|
||||
@input="fieldValueChanged('uiColor')"
|
||||
></v-color-picker>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
v-model="obj.languageOverride"
|
||||
:placeholder="locale().getBrowserFirstLanguage()"
|
||||
:readonly="formState.readOnly"
|
||||
:clearable="!formState.readOnly"
|
||||
@click:clear="fieldValueChanged('languageOverride')"
|
||||
:label="$ay.t('LanguageCode')"
|
||||
:error-messages="form().serverErrors(this, 'languageOverride')"
|
||||
ref="languageOverride"
|
||||
@input="fieldValueChanged('languageOverride')"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
v-model="obj.timeZoneOverride"
|
||||
:placeholder="locale().getBrowserTimeZoneName()"
|
||||
:readonly="formState.readOnly"
|
||||
:clearable="!formState.readOnly"
|
||||
@click:clear="fieldValueChanged('timeZoneOverride')"
|
||||
:label="$ay.t('TimeZone')"
|
||||
:error-messages="form().serverErrors(this, 'timeZoneOverride')"
|
||||
ref="timeZoneOverride"
|
||||
@input="fieldValueChanged('timeZoneOverride')"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-form>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UnderConstruction from "../components/underconstruction.vue";
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/* Xeslint-disable */
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const FORM_KEY = "ops-backup";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
UnderConstruction
|
||||
created() {
|
||||
let vm = this;
|
||||
initForm(vm)
|
||||
.then(() => {
|
||||
vm.rights = window.$gz.role.fullRightsObject();
|
||||
vm.formState.ready = true;
|
||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||
//This form record is PUT only and there is only ever one record and it's id is 1
|
||||
|
||||
vm.getDataFromApi();
|
||||
})
|
||||
.catch(err => {
|
||||
vm.formState.ready = true;
|
||||
window.$gz.errorHandler.handleFormError(err, vm);
|
||||
});
|
||||
},
|
||||
beforeCreate() {
|
||||
window.$gz.eventBus.$emit("menu-change", {
|
||||
isMain: true,
|
||||
icon: "fa-file-archive",
|
||||
title: this.$ay.t("Backup"),
|
||||
helpUrl: "form-ops-backup"
|
||||
});
|
||||
beforeRouteLeave(to, from, next) {
|
||||
if (this.formState.dirty) {
|
||||
window.$gz.dialog.confirmLeaveUnsaved().then(dialogResult => {
|
||||
if (dialogResult == true) {
|
||||
next();
|
||||
} else {
|
||||
next(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||
},
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||
selectLists: {
|
||||
translations: []
|
||||
},
|
||||
obj: {
|
||||
/*{
|
||||
"id": 0,
|
||||
"concurrency": 0,
|
||||
"backupTime": "2020-05-21T23:10:19.906Z",
|
||||
"lastBackup": "2020-05-21T23:10:19.906Z",
|
||||
"backupSetsToKeep": 0,
|
||||
"backupAttachments": true
|
||||
}*/
|
||||
id: 1,
|
||||
concurrency: 0,
|
||||
backupTime: null,
|
||||
lastBackup: null,
|
||||
backupSetsToKeep: null,
|
||||
backupAttachments: null
|
||||
},
|
||||
formState: {
|
||||
ready: false,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
readOnly: false,
|
||||
loading: true,
|
||||
errorBoxMessage: null,
|
||||
appError: null,
|
||||
serverError: {}
|
||||
},
|
||||
rights: window.$gz.role.fullRightsObject()
|
||||
};
|
||||
},
|
||||
//WATCHERS
|
||||
watch: {
|
||||
formState: {
|
||||
handler: function(val) {
|
||||
//,oldval is available here too if necessary
|
||||
if (this.formState.loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
//enable / disable save button
|
||||
let canSave = val.dirty && val.valid && !val.readOnly;
|
||||
if (canSave) {
|
||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
|
||||
} else {
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
canSave: function() {
|
||||
return this.formState.valid && this.formState.dirty;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
translation() {
|
||||
return window.$gz.translation;
|
||||
},
|
||||
locale() {
|
||||
return window.$gz.locale;
|
||||
},
|
||||
form() {
|
||||
return window.$gz.form;
|
||||
},
|
||||
fieldValueChanged(ref) {
|
||||
if (!this.formState.loading && !this.formState.readOnly) {
|
||||
window.$gz.form.fieldValueChanged(this, ref);
|
||||
}
|
||||
},
|
||||
getDataFromApi() {
|
||||
let vm = this;
|
||||
vm.formState.loading = true;
|
||||
let url = "global-ops-backup-setting";
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
window.$gz.api
|
||||
.get(url)
|
||||
.then(res => {
|
||||
if (res.error) {
|
||||
//Not found?
|
||||
if (res.error.code == "2010") {
|
||||
//notify not found error then navigate backwards
|
||||
window.$gz.eventBus.$emit(
|
||||
"notify-error",
|
||||
vm.$ay.t("ErrorAPI2010")
|
||||
);
|
||||
// navigate backwards
|
||||
window.$gz._.delay(function() {
|
||||
vm.$router.go(-1);
|
||||
}, 2000);
|
||||
}
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
vm.obj = res.data;
|
||||
|
||||
//Update the form status
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
loading: false
|
||||
});
|
||||
//modify the menu as necessary
|
||||
generateMenu(vm);
|
||||
}
|
||||
})
|
||||
.catch(function handleGetDataFromAPIError(error) {
|
||||
//Update the form status
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
loading: false
|
||||
});
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
});
|
||||
},
|
||||
submit() {
|
||||
let vm = this;
|
||||
if (vm.canSave) {
|
||||
vm.formState.loading = true;
|
||||
|
||||
//always submit from this form for the current logged in user id
|
||||
let url = API_BASE_URL + vm.$store.state.userId;
|
||||
|
||||
//clear any errors vm might be around from previous submit
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
window.$gz.api
|
||||
.upsert(url, vm.obj)
|
||||
.then(res => {
|
||||
vm.formState.loading = false;
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
//UserOptions is never a POST as it always exists and can't be deleted so always a PUT
|
||||
|
||||
//Handle "put" of an existing record (UPDATE)
|
||||
vm.obj.concurrency = res.data.concurrency;
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false
|
||||
});
|
||||
|
||||
//Set values in store so they are updated immediately for user
|
||||
let l = vm.$store.state.locale;
|
||||
|
||||
if (vm.obj.languageOverride) {
|
||||
l.languageOverride = vm.obj.languageOverride;
|
||||
}
|
||||
|
||||
if (vm.obj.timeZoneOverride) {
|
||||
l.timeZoneOverride = vm.obj.timeZoneOverride;
|
||||
}
|
||||
|
||||
if (vm.obj.currencyName) {
|
||||
l.currencyName = vm.obj.currencyName;
|
||||
}
|
||||
|
||||
if (vm.obj.hour12) {
|
||||
l.hour12 = vm.obj.hour12;
|
||||
}
|
||||
|
||||
window.$gz.store.commit("setLocale", l);
|
||||
}
|
||||
})
|
||||
.catch(function handleSubmitError(error) {
|
||||
vm.formState.loading = false;
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/////////////////////////////
|
||||
//
|
||||
//
|
||||
function clickHandler(menuItem) {
|
||||
if (!menuItem) {
|
||||
return;
|
||||
}
|
||||
let m = window.$gz.menu.parseMenuItem(menuItem);
|
||||
if (m.owner == FORM_KEY && !m.disabled) {
|
||||
switch (m.key) {
|
||||
case "save":
|
||||
m.vm.submit();
|
||||
break;
|
||||
|
||||
default:
|
||||
window.$gz.eventBus.$emit(
|
||||
"notify-warning",
|
||||
FORM_KEY + "::context click: [" + m.key + "]"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
//
|
||||
//
|
||||
function generateMenu(vm) {
|
||||
let menuOptions = {
|
||||
isMain: true,
|
||||
icon: "fa-file-archive",
|
||||
title: vm.$ay.t("Backup"),
|
||||
helpUrl: "form-ops-backup",
|
||||
formData: {},
|
||||
menuItems: []
|
||||
};
|
||||
|
||||
if (vm.rights.change) {
|
||||
menuOptions.menuItems.push({
|
||||
title: vm.$ay.t("Save"),
|
||||
icon: "fa-save",
|
||||
surface: true,
|
||||
key: FORM_KEY + ":save",
|
||||
vm: vm
|
||||
});
|
||||
}
|
||||
|
||||
window.$gz.eventBus.$emit("menu-change", menuOptions);
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
//
|
||||
//
|
||||
function initForm(vm) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
(async function() {
|
||||
try {
|
||||
await fetchTranslatedText(vm);
|
||||
await populateSelectionLists(vm);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
resolve();
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// Ensures UI translated text is available
|
||||
//
|
||||
function fetchTranslatedText(vm) {
|
||||
return window.$gz.translation.fetch([
|
||||
"CurrencyCode",
|
||||
"LanguageCode",
|
||||
"TimeZone",
|
||||
"UserEmailAddress",
|
||||
"Hour12",
|
||||
"UserColor",
|
||||
"Translation"
|
||||
]);
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
//
|
||||
//
|
||||
function populateSelectionLists(vm) {
|
||||
//http://localhost:7575/api/v8/translation/list
|
||||
return window.$gz.api.get("translation/list").then(res => {
|
||||
if (res.error) {
|
||||
window.$gz.errorHandler.handleFormError(res.error, vm);
|
||||
} else {
|
||||
vm.selectLists.translations = res.data;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user