This commit is contained in:
@@ -754,11 +754,11 @@ function initNavPanel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getUserOptions() {
|
async function getUserOptions() {
|
||||||
let res = await window.$gz.api.get(
|
|
||||||
"user-option/" + window.$gz.store.state.userId
|
|
||||||
);
|
|
||||||
// eslint-disable-next-line
|
|
||||||
try {
|
try {
|
||||||
|
let res = await window.$gz.api.get(
|
||||||
|
"user-option/" + window.$gz.store.state.userId
|
||||||
|
);
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
@@ -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,58 +217,53 @@ 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)
|
if (res.error) {
|
||||||
.then(res => {
|
window.$gz.errorHandler.handleFormError(res.error);
|
||||||
if (res.error) {
|
} else {
|
||||||
window.$gz.errorHandler.handleFormError(res.error);
|
vm.uploadFiles = [];
|
||||||
} else {
|
vm.updateDisplayList(res.data);
|
||||||
vm.uploadFiles = [];
|
|
||||||
vm.updateDisplayList(res.data);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(function handleUploadError(error) {
|
|
||||||
window.$gz.errorHandler.handleFormError(error);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
remove() {
|
|
||||||
let vm = this;
|
|
||||||
window.$gz.dialog.confirmDelete().then(dialogResult => {
|
|
||||||
if (dialogResult == true) {
|
|
||||||
window.$gz.api
|
|
||||||
.remove("attachment/" + vm.editId)
|
|
||||||
.then(res => {
|
|
||||||
if (res.error) {
|
|
||||||
window.$gz.errorHandler.handleFormError(res.error);
|
|
||||||
} else {
|
|
||||||
vm.editMenu = false;
|
|
||||||
vm.editName = null;
|
|
||||||
vm.editNotes = null;
|
|
||||||
vm.editId = null;
|
|
||||||
vm.getList();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(function handleUploadError(error) {
|
|
||||||
window.$gz.errorHandler.handleFormError(error);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
} catch (error) {
|
||||||
|
window.$gz.errorHandler.handleFormError(error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
getList() {
|
async remove() {
|
||||||
let vm = this;
|
let vm = this;
|
||||||
window.$gz.api
|
try {
|
||||||
.get("attachment/list?ayatype=" + vm.ayaType + "&ayaid=" + vm.ayaId)
|
if ((await window.$gz.dialog.confirmDelete()) !== true) {
|
||||||
.then(res => {
|
return;
|
||||||
if (res.error) {
|
}
|
||||||
window.$gz.errorHandler.handleFormError(res.error);
|
|
||||||
} else {
|
let res = await window.$gz.api.remove("attachment/" + vm.editId);
|
||||||
vm.updateDisplayList(res.data);
|
if (res.error) {
|
||||||
}
|
window.$gz.errorHandler.handleFormError(res.error);
|
||||||
})
|
} else {
|
||||||
.catch(function handleGetListError(error) {
|
vm.editMenu = false;
|
||||||
window.$gz.errorHandler.handleFormError(error);
|
vm.editName = null;
|
||||||
});
|
vm.editNotes = null;
|
||||||
|
vm.editId = null;
|
||||||
|
vm.getList();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
window.$gz.errorHandler.handleFormError(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getList() {
|
||||||
|
let vm = this;
|
||||||
|
try {
|
||||||
|
let res = await window.$gz.api.get(
|
||||||
|
"attachment/list?ayatype=" + vm.ayaType + "&ayaid=" + vm.ayaId
|
||||||
|
);
|
||||||
|
if (res.error) {
|
||||||
|
window.$gz.errorHandler.handleFormError(res.error);
|
||||||
|
} else {
|
||||||
|
vm.updateDisplayList(res.data);
|
||||||
|
}
|
||||||
|
} catch (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,24 +341,22 @@ 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
|
if (res.error) {
|
||||||
.upsert("attachment/" + vm.editId, p)
|
window.$gz.errorHandler.handleFormError(res.error);
|
||||||
.then(res => {
|
} else {
|
||||||
if (res.error) {
|
vm.editMenu = false;
|
||||||
window.$gz.errorHandler.handleFormError(res.error);
|
vm.editName = null;
|
||||||
} else {
|
vm.editNotes = null;
|
||||||
vm.editMenu = false;
|
vm.editId = null;
|
||||||
vm.editName = null;
|
//due to fucking reactivity issues which never seem to resolve no matter what I'm returning a fresh list on update
|
||||||
vm.editNotes = null;
|
vm.updateDisplayList(res.data);
|
||||||
vm.editId = null;
|
}
|
||||||
//due to fucking reactivity issues which never seem to resolve no matter what I'm returning a fresh list on update
|
} catch (error) {
|
||||||
vm.updateDisplayList(res.data);
|
window.$gz.errorHandler.handleFormError(error);
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch(function handleUploadError(error) {
|
|
||||||
window.$gz.errorHandler.handleFormError(error);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
onDrop(ev) {
|
onDrop(ev) {
|
||||||
dropDiv.style.border = "none";
|
dropDiv.style.border = "none";
|
||||||
|
|||||||
Reference in New Issue
Block a user