This commit is contained in:
@@ -820,42 +820,42 @@ export default {
|
|||||||
this.imageMenu = true;
|
this.imageMenu = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getAttachments() {
|
async getAttachments() {
|
||||||
let vm = this;
|
let vm = this;
|
||||||
vm.attachments = [];
|
try {
|
||||||
window.$gz.api
|
vm.attachments = [];
|
||||||
.get("attachment/list?ayatype=" + vm.ayaType + "&ayaid=" + vm.ayaId)
|
let res = await window.$gz.api.get(
|
||||||
.then(res => {
|
"attachment/list?ayatype=" + vm.ayaType + "&ayaid=" + vm.ayaId
|
||||||
if (res.error) {
|
);
|
||||||
window.$gz.errorHandler.handleFormError(res.error);
|
if (res.error) {
|
||||||
} else {
|
window.$gz.errorHandler.handleFormError(res.error);
|
||||||
let ret = [];
|
} else {
|
||||||
for (let i = 0; i < res.data.length; i++) {
|
let ret = [];
|
||||||
let o = res.data[i];
|
for (let i = 0; i < res.data.length; i++) {
|
||||||
|
let o = res.data[i];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
window.$gz.util.isImageAttachment(
|
window.$gz.util.isImageAttachment(
|
||||||
o.displayFileName,
|
o.displayFileName,
|
||||||
o.contentType
|
o.contentType
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
//attach url
|
//attach url
|
||||||
//
|
//
|
||||||
ret.push({
|
ret.push({
|
||||||
id: o.id,
|
id: o.id,
|
||||||
url: "[ATTACH:" + o.id + "]",
|
url: "[ATTACH:" + o.id + "]",
|
||||||
name: o.displayFileName
|
name: o.displayFileName
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
vm.attachments = ret;
|
|
||||||
}
|
}
|
||||||
})
|
vm.attachments = ret;
|
||||||
.catch(function handleGetListError(error) {
|
}
|
||||||
window.$gz.errorHandler.handleFormError(error);
|
} catch (error) {
|
||||||
});
|
window.$gz.errorHandler.handleFormError(error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
upload() {
|
async upload() {
|
||||||
//similar code in attachment-control upload
|
//similar code in attachment-control upload
|
||||||
let vm = this;
|
let vm = this;
|
||||||
let at = {
|
let at = {
|
||||||
@@ -864,53 +864,45 @@ export default {
|
|||||||
files: vm.uploadFiles,
|
files: vm.uploadFiles,
|
||||||
notes: ""
|
notes: ""
|
||||||
};
|
};
|
||||||
|
try {
|
||||||
|
let res = await window.$gz.api.uploadAttachment(at);
|
||||||
|
|
||||||
window.$gz.api
|
if (res.error) {
|
||||||
.uploadAttachment(at)
|
window.$gz.errorHandler.handleFormError(res.error);
|
||||||
.then(res => {
|
} else {
|
||||||
if (res.error) {
|
let ret = [];
|
||||||
window.$gz.errorHandler.handleFormError(res.error);
|
for (let i = 0; i < res.data.length; i++) {
|
||||||
} else {
|
let o = res.data[i];
|
||||||
let ret = [];
|
|
||||||
for (let i = 0; i < res.data.length; i++) {
|
|
||||||
let o = res.data[i];
|
|
||||||
|
|
||||||
// if (
|
//let them attach any file type to the wiki since it supports it anyway
|
||||||
// window.$gz.util.isImageAttachment(
|
ret.push({
|
||||||
// o.displayFileName,
|
id: o.id,
|
||||||
// o.contentType
|
url: window.$gz.api.attachmentDownloadUrl(o.id, o.contentType),
|
||||||
// )
|
name: o.displayFileName
|
||||||
// ) {
|
});
|
||||||
//let them attach any file type to the wiki since it supports it anyway
|
//}
|
||||||
ret.push({
|
}
|
||||||
id: o.id,
|
//put into attachments list
|
||||||
url: window.$gz.api.attachmentDownloadUrl(o.id, o.contentType),
|
vm.attachments = ret;
|
||||||
name: o.displayFileName
|
//NOW iterate upload files list and insert into wiki based on attachments
|
||||||
});
|
//insert into wiki
|
||||||
//}
|
for (let i = 0; i < vm.uploadFiles.length; i++) {
|
||||||
}
|
let upFile = vm.uploadFiles[i];
|
||||||
//put into attachments list
|
for (let j = 0; j < vm.attachments.length; j++) {
|
||||||
vm.attachments = ret;
|
let atFile = vm.attachments[j];
|
||||||
//NOW iterate upload files list and insert into wiki based on attachments
|
if (upFile.name == atFile.name) {
|
||||||
//insert into wiki
|
//found it
|
||||||
for (let i = 0; i < vm.uploadFiles.length; i++) {
|
this.insertUrl(atFile.url, atFile.name);
|
||||||
let upFile = vm.uploadFiles[i];
|
break;
|
||||||
for (let j = 0; j < vm.attachments.length; j++) {
|
|
||||||
let atFile = vm.attachments[j];
|
|
||||||
if (upFile.name == atFile.name) {
|
|
||||||
//found it
|
|
||||||
this.insertUrl(atFile.url, atFile.name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//finally, clear the upload files
|
|
||||||
vm.uploadFiles = [];
|
|
||||||
}
|
}
|
||||||
})
|
//finally, clear the upload files
|
||||||
.catch(function handleUploadError(error) {
|
vm.uploadFiles = [];
|
||||||
window.$gz.errorHandler.handleFormError(error);
|
}
|
||||||
});
|
} catch (error) {
|
||||||
|
window.$gz.errorHandler.handleFormError(error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onDrop(ev) {
|
onDrop(ev) {
|
||||||
//Drop image file
|
//Drop image file
|
||||||
|
|||||||
@@ -88,43 +88,38 @@
|
|||||||
const FORM_KEY = "adm-global-select-templates";
|
const FORM_KEY = "adm-global-select-templates";
|
||||||
const API_BASE_URL = "pick-list/template/";
|
const API_BASE_URL = "pick-list/template/";
|
||||||
export default {
|
export default {
|
||||||
beforeRouteLeave(to, from, next) {
|
async beforeRouteLeave(to, from, next) {
|
||||||
//let vm = this;
|
if (!this.formState.dirty) {
|
||||||
if (this.formState.dirty) {
|
|
||||||
window.$gz.dialog.confirmLeaveUnsaved().then(dialogResult => {
|
|
||||||
if (dialogResult == true) {
|
|
||||||
next();
|
|
||||||
} else {
|
|
||||||
next(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
next();
|
next();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
|
||||||
|
next();
|
||||||
|
} else {
|
||||||
|
next(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
window.$gz.eventBus.$off("menu-click", clickHandler);
|
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||||
},
|
},
|
||||||
created() {
|
async created() {
|
||||||
let vm = this;
|
let vm = this;
|
||||||
|
try {
|
||||||
initForm(vm)
|
await initForm(vm);
|
||||||
.then(() => {
|
vm.formState.ready = true;
|
||||||
vm.formState.ready = true;
|
vm.readOnly = !vm.rights.change;
|
||||||
vm.readOnly = !vm.rights.change;
|
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
//NOTE: this would normally be in getDataFromAPI but this form doesn't really need that function so doing it here
|
||||||
//NOTE: this would normally be in getDataFromAPI but this form doesn't really need that function so doing it here
|
//modify the menu as necessary
|
||||||
//modify the menu as necessary
|
generateMenu(vm, false); //default is never read only and passing in this vm
|
||||||
generateMenu(vm, false); //default is never read only and passing in this vm
|
//init disable save button so it can be enabled only on edit to show dirty form
|
||||||
//init disable save button so it can be enabled only on edit to show dirty form
|
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":delete");
|
||||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":delete");
|
vm.formState.loading = false;
|
||||||
vm.formState.loading = false;
|
} catch (err) {
|
||||||
})
|
vm.formState.ready = true;
|
||||||
.catch(err => {
|
window.$gz.errorHandler.handleFormError(err, vm);
|
||||||
vm.formState.ready = true;
|
}
|
||||||
window.$gz.errorHandler.handleFormError(err, vm);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -236,7 +231,7 @@ export default {
|
|||||||
vm.getDataFromApi();
|
vm.getDataFromApi();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getDataFromApi() {
|
async getDataFromApi() {
|
||||||
let vm = this;
|
let vm = this;
|
||||||
vm.formState.loading = true;
|
vm.formState.loading = true;
|
||||||
if (!vm.templateId || vm.templateId == 0) {
|
if (!vm.templateId || vm.templateId == 0) {
|
||||||
@@ -244,51 +239,50 @@ export default {
|
|||||||
}
|
}
|
||||||
vm.lastFetchedTemplateId = vm.templateId;
|
vm.lastFetchedTemplateId = vm.templateId;
|
||||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||||
|
try {
|
||||||
|
//get available fields
|
||||||
|
let res = await window.$gz.api.get(
|
||||||
|
API_BASE_URL + "listfields/" + vm.templateId
|
||||||
|
);
|
||||||
|
|
||||||
//get available fields
|
if (res.error) {
|
||||||
window.$gz.api
|
vm.formState.serverError = res.error;
|
||||||
.get(API_BASE_URL + "listfields/" + vm.templateId)
|
window.$gz.form.setErrorBoxErrors(vm);
|
||||||
.then(res => {
|
} else {
|
||||||
if (res.error) {
|
vm.availableFields = res.data;
|
||||||
vm.formState.serverError = res.error;
|
vm.fieldKeys = [];
|
||||||
window.$gz.form.setErrorBoxErrors(vm);
|
for (let i = 0; i < res.data.length; i++) {
|
||||||
} else {
|
vm.fieldKeys.push(res.data[i].tKey);
|
||||||
vm.availableFields = res.data;
|
|
||||||
vm.fieldKeys = [];
|
|
||||||
for (let i = 0; i < res.data.length; i++) {
|
|
||||||
vm.fieldKeys.push(res.data[i].tKey);
|
|
||||||
}
|
|
||||||
return window.$gz.translation.cacheTranslations(vm.fieldKeys);
|
|
||||||
}
|
}
|
||||||
})
|
await window.$gz.translation.cacheTranslations(vm.fieldKeys);
|
||||||
.then(function() {
|
}
|
||||||
//weirdly, this wasn't working properly until I put it in a function, it was just executing immediately before translations were resolved from fetch above
|
|
||||||
//get current edited template
|
//weirdly, this wasn't working properly until I put it in a function, it was just executing immediately before translations were resolved from fetch above
|
||||||
window.$gz.api.get(API_BASE_URL + vm.templateId).then(res => {
|
//get current edited template
|
||||||
if (res.error) {
|
res = await window.$gz.api.get(API_BASE_URL + vm.templateId);
|
||||||
vm.formState.serverError = res.error;
|
|
||||||
window.$gz.form.setErrorBoxErrors(vm);
|
if (res.error) {
|
||||||
} else {
|
vm.formState.serverError = res.error;
|
||||||
vm.obj = res.data;
|
window.$gz.form.setErrorBoxErrors(vm);
|
||||||
synthesizeWorkingArray(vm);
|
} else {
|
||||||
//Update the form status
|
vm.obj = res.data;
|
||||||
window.$gz.form.setFormState({
|
synthesizeWorkingArray(vm);
|
||||||
vm: vm,
|
|
||||||
dirty: false,
|
|
||||||
valid: true,
|
|
||||||
loading: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(function handleGetDataFromAPIError(error) {
|
|
||||||
//Update the form status
|
//Update the form status
|
||||||
window.$gz.form.setFormState({
|
window.$gz.form.setFormState({
|
||||||
vm: vm,
|
vm: vm,
|
||||||
|
dirty: false,
|
||||||
|
valid: true,
|
||||||
loading: false
|
loading: false
|
||||||
});
|
});
|
||||||
window.$gz.errorHandler.handleFormError(error, vm);
|
}
|
||||||
|
} catch (error) {
|
||||||
|
//Update the form status
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
loading: false
|
||||||
});
|
});
|
||||||
|
window.$gz.errorHandler.handleFormError(error, vm);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
submit() {
|
submit() {
|
||||||
let vm = this;
|
let vm = this;
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ export default {
|
|||||||
next();
|
next();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((await window.$gz.dialog.confirmLeaveUnsaved()) == true) {
|
if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
next(false);
|
next(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user