This commit is contained in:
2020-06-19 22:57:58 +00:00
parent 01490c574a
commit f79fed7154
2 changed files with 65 additions and 72 deletions

View File

@@ -754,11 +754,11 @@ function initNavPanel() {
} }
async function getUserOptions() { async function getUserOptions() {
try {
let res = await window.$gz.api.get( let res = await window.$gz.api.get(
"user-option/" + window.$gz.store.state.userId "user-option/" + window.$gz.store.state.userId
); );
// eslint-disable-next-line
try {
if (res.error) { if (res.error) {
//In a form this would trigger a bunch of validation or error display code but for here and now: //In a form this would trigger a bunch of validation or error display code but for here and now:
//convert error to human readable string for display and popup a notification to user //convert error to human readable string for display and popup a notification to user

View File

@@ -202,7 +202,7 @@ export default {
} }
return true; return true;
}, },
upload() { async upload() {
//similar code in wiki-control //similar code in wiki-control
let vm = this; let vm = this;
let fileData = []; let fileData = [];
@@ -217,28 +217,26 @@ export default {
fileData: JSON.stringify(fileData), //note this is required for an array or it will come to the server as a string [object,object] fileData: JSON.stringify(fileData), //note this is required for an array or it will come to the server as a string [object,object]
notes: vm.notes ? vm.notes : "" notes: vm.notes ? vm.notes : ""
}; };
try {
window.$gz.api let res = await window.$gz.api.uploadAttachment(at);
.uploadAttachment(at)
.then(res => {
if (res.error) { if (res.error) {
window.$gz.errorHandler.handleFormError(res.error); window.$gz.errorHandler.handleFormError(res.error);
} else { } else {
vm.uploadFiles = []; vm.uploadFiles = [];
vm.updateDisplayList(res.data); vm.updateDisplayList(res.data);
} }
}) } catch (error) {
.catch(function handleUploadError(error) {
window.$gz.errorHandler.handleFormError(error); window.$gz.errorHandler.handleFormError(error);
}); }
}, },
remove() { async remove() {
let vm = this; let vm = this;
window.$gz.dialog.confirmDelete().then(dialogResult => { try {
if (dialogResult == true) { if ((await window.$gz.dialog.confirmDelete()) !== true) {
window.$gz.api return;
.remove("attachment/" + vm.editId) }
.then(res => {
let res = await window.$gz.api.remove("attachment/" + vm.editId);
if (res.error) { if (res.error) {
window.$gz.errorHandler.handleFormError(res.error); window.$gz.errorHandler.handleFormError(res.error);
} else { } else {
@@ -248,27 +246,24 @@ export default {
vm.editId = null; vm.editId = null;
vm.getList(); vm.getList();
} }
}) } catch (error) {
.catch(function handleUploadError(error) {
window.$gz.errorHandler.handleFormError(error); window.$gz.errorHandler.handleFormError(error);
});
} }
});
}, },
getList() { async getList() {
let vm = this; let vm = this;
window.$gz.api try {
.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) { if (res.error) {
window.$gz.errorHandler.handleFormError(res.error); window.$gz.errorHandler.handleFormError(res.error);
} else { } else {
vm.updateDisplayList(res.data); vm.updateDisplayList(res.data);
} }
}) } catch (error) {
.catch(function handleGetListError(error) {
window.$gz.errorHandler.handleFormError(error); window.$gz.errorHandler.handleFormError(error);
}); }
}, },
updateDisplayList(data) { updateDisplayList(data) {
//{"data":[{"id":1,"concurrency":7733332,"contentType":"image/png","displayFileName":"Screen Shot 2020-01-09 at 10.50.24.png","lastModified":"0001-01-01T00:00:00Z","notes":"Here are notes"},{"id":4,"concurrency":7733354,"contentType":"text/plain","displayFileName":"TNT log file ayanova.txt","lastModified":"0001-01-01T00:00:00Z","notes":"Here are notes"},{"id":2,"concurrency":7733342,"contentType":"text/plain","displayFileName":"stack.txt","lastModified":"0001-01-01T00:00:00Z","notes":"Here are notes"},{"id":3,"concurrency":7733348,"contentType":"image/jpeg","displayFileName":"t2cx6sloffk41.jpg","lastModified":"0001-01-01T00:00:00Z","notes":"Here are notes"}]} //{"data":[{"id":1,"concurrency":7733332,"contentType":"image/png","displayFileName":"Screen Shot 2020-01-09 at 10.50.24.png","lastModified":"0001-01-01T00:00:00Z","notes":"Here are notes"},{"id":4,"concurrency":7733354,"contentType":"text/plain","displayFileName":"TNT log file ayanova.txt","lastModified":"0001-01-01T00:00:00Z","notes":"Here are notes"},{"id":2,"concurrency":7733342,"contentType":"text/plain","displayFileName":"stack.txt","lastModified":"0001-01-01T00:00:00Z","notes":"Here are notes"},{"id":3,"concurrency":7733348,"contentType":"image/jpeg","displayFileName":"t2cx6sloffk41.jpg","lastModified":"0001-01-01T00:00:00Z","notes":"Here are notes"}]}
@@ -313,7 +308,7 @@ export default {
this.editMenu = true; this.editMenu = true;
}); });
}, },
saveEdit() { async saveEdit() {
let vm = this; let vm = this;
if (!vm.editName) { if (!vm.editName) {
//todo: some error here, name is required.. //todo: some error here, name is required..
@@ -346,10 +341,9 @@ export default {
displayFileName: vm.editName, displayFileName: vm.editName,
notes: vm.editNotes notes: vm.editNotes
}; };
try {
let res = await window.$gz.api.upsert("attachment/" + vm.editId, p);
window.$gz.api
.upsert("attachment/" + vm.editId, p)
.then(res => {
if (res.error) { if (res.error) {
window.$gz.errorHandler.handleFormError(res.error); window.$gz.errorHandler.handleFormError(res.error);
} else { } else {
@@ -360,10 +354,9 @@ export default {
//due to fucking reactivity issues which never seem to resolve no matter what I'm returning a fresh list on update //due to fucking reactivity issues which never seem to resolve no matter what I'm returning a fresh list on update
vm.updateDisplayList(res.data); vm.updateDisplayList(res.data);
} }
}) } catch (error) {
.catch(function handleUploadError(error) {
window.$gz.errorHandler.handleFormError(error); window.$gz.errorHandler.handleFormError(error);
}); }
}, },
onDrop(ev) { onDrop(ev) {
dropDiv.style.border = "none"; dropDiv.style.border = "none";