This commit is contained in:
@@ -1,63 +1,59 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-row>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-select
|
||||
ref="ayaType"
|
||||
v-model="ayaType"
|
||||
:items="selectLists.importableAyaTypes"
|
||||
item-text="name"
|
||||
item-value="id"
|
||||
:label="$ay.t('AyaType')"
|
||||
data-cy="ayaType"
|
||||
></v-select>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-checkbox
|
||||
v-model="doImport"
|
||||
:label="$ay.t('ImportNewRecords')"
|
||||
></v-checkbox>
|
||||
<v-checkbox
|
||||
v-model="doUpdate"
|
||||
:label="$ay.t('UpdateExistingRecords')"
|
||||
color="warning"
|
||||
></v-checkbox>
|
||||
</v-col>
|
||||
<!-- <v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-checkbox
|
||||
v-model="doUpdate"
|
||||
:label="$ay.t('UpdateExisting')"
|
||||
></v-checkbox>
|
||||
</v-col> -->
|
||||
<div v-if="formState.ready">
|
||||
<gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
|
||||
<div>
|
||||
<v-row>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-select
|
||||
ref="ayaType"
|
||||
v-model="ayaType"
|
||||
:items="selectLists.importableAyaTypes"
|
||||
item-text="name"
|
||||
item-value="id"
|
||||
:label="$ay.t('AyaType')"
|
||||
data-cy="ayaType"
|
||||
></v-select>
|
||||
</v-col>
|
||||
<v-col v-if="ayaType != 0" cols="12" sm="6" lg="4" xl="3">
|
||||
<v-file-input
|
||||
v-model="uploadFile"
|
||||
:label="$ay.t('Import')"
|
||||
accept=".json, .csv, application/json, text/csv"
|
||||
prepend-icon="$ayiFileUpload"
|
||||
show-size
|
||||
></v-file-input
|
||||
><v-btn
|
||||
v-if="importable"
|
||||
:loading="uploading"
|
||||
color="primary"
|
||||
text
|
||||
@click="process"
|
||||
>{{ $ay.t("Import") }}</v-btn
|
||||
>
|
||||
</v-col>
|
||||
<v-col v-if="ayaType != 0" cols="12" sm="6" lg="4" xl="3">
|
||||
<v-checkbox
|
||||
v-model="doImport"
|
||||
:label="$ay.t('ImportNewRecords')"
|
||||
></v-checkbox>
|
||||
<v-checkbox
|
||||
v-model="doUpdate"
|
||||
:label="$ay.t('UpdateExistingRecords')"
|
||||
color="warning"
|
||||
></v-checkbox>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-file-input
|
||||
v-model="uploadFile"
|
||||
:label="$ay.t('Import')"
|
||||
accept=".json, .csv, application/json, text/csv"
|
||||
prepend-icon="$ayiFileUpload"
|
||||
show-size
|
||||
></v-file-input
|
||||
><v-btn
|
||||
v-if="importable"
|
||||
:loading="uploading"
|
||||
color="primary"
|
||||
text
|
||||
@click="process"
|
||||
>{{ $ay.t("Import") }}</v-btn
|
||||
>
|
||||
</v-col>
|
||||
|
||||
<v-col v-if="outputText != null" cols="12">
|
||||
<v-textarea
|
||||
v-model="outputText"
|
||||
full-width
|
||||
readonly
|
||||
auto-grow
|
||||
data-cy="outputText"
|
||||
></v-textarea>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-col v-if="outputText != null" cols="12">
|
||||
<v-textarea
|
||||
v-model="outputText"
|
||||
full-width
|
||||
readonly
|
||||
auto-grow
|
||||
data-cy="outputText"
|
||||
></v-textarea>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
@@ -75,7 +71,17 @@ export default {
|
||||
doUpdate: false,
|
||||
outputText: null,
|
||||
rights: window.$gz.role.defaultRightsObject(),
|
||||
uploading: false
|
||||
uploading: false,
|
||||
formState: {
|
||||
ready: false,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
readOnly: false,
|
||||
loading: true,
|
||||
errorBoxMessage: null,
|
||||
appError: null,
|
||||
serverError: {}
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -95,15 +101,20 @@ export default {
|
||||
await fetchTranslatedText(this);
|
||||
await populateSelectionLists(this);
|
||||
generateMenu(this);
|
||||
this.formState.ready = true;
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||
},
|
||||
methods: {
|
||||
async process() {
|
||||
if (this.uploading) {
|
||||
return;
|
||||
}
|
||||
if (!this.uploadFile) {
|
||||
return;
|
||||
}
|
||||
this.uploading = true;
|
||||
this.outputText = null;
|
||||
try {
|
||||
let fileType = this.uploadFile.type.toLowerCase();
|
||||
@@ -150,12 +161,12 @@ export default {
|
||||
await this.upload(dat);
|
||||
} catch (error) {
|
||||
window.$gz.errorHandler.handleFormError(error);
|
||||
} finally {
|
||||
this.uploading = false;
|
||||
}
|
||||
},
|
||||
async upload(dat) {
|
||||
try {
|
||||
this.uploading = true;
|
||||
|
||||
if (this.doUpdate == true) {
|
||||
let dialogResult = await window.$gz.dialog.confirmGeneric(
|
||||
"AdminImportUpdateWarning",
|
||||
@@ -186,8 +197,6 @@ export default {
|
||||
}
|
||||
} catch (error) {
|
||||
window.$gz.errorHandler.handleFormError(error);
|
||||
} finally {
|
||||
this.uploading = false;
|
||||
}
|
||||
},
|
||||
handleSelected() {}
|
||||
|
||||
Reference in New Issue
Block a user