From 565d806792050afcd6d3e67c9edc5df65c146881 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 23 Apr 2020 18:28:58 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 2 + ayanova/src/components/attachment-control.vue | 92 ++++++++++++------- 2 files changed, 59 insertions(+), 35 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index dd8cb1ab..7a8d1f10 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -114,6 +114,8 @@ todo: after attachments - integration tests update todo: THIS! At this point, upload to dev server and thoroughly test with devices, it seems a bit slow at times - Might need to hide attachments until user clicks on something to reveal as it seems odd to fetch every open +todo: careful and thorough PERF tests remotely and local + todo: after attachments - DATADUMP - v7 wiki to RAVEN markdown - https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3468 - Need to export images and attached docs as attachments diff --git a/ayanova/src/components/attachment-control.vue b/ayanova/src/components/attachment-control.vue index 3c1084a7..d502a884 100644 --- a/ayanova/src/components/attachment-control.vue +++ b/ayanova/src/components/attachment-control.vue @@ -12,14 +12,18 @@
- - + - + - + fa-edit - - fa-trash - @@ -84,6 +85,9 @@ >
+ + fa-trash + {{ $ay.t("Cancel") }} {{ @@ -102,7 +106,6 @@ export default { data() { return { height: 300, - attachedFiles: [], displayList: [], notes: null, tab: null, @@ -144,24 +147,27 @@ export default { window.$gz.errorHandler.handleFormError(res.error); } else { vm.uploadFiles = []; - vm.attachedFiles = res.data; - vm.updateDisplayList(); + vm.updateDisplayList(res.data); } }) .catch(function handleUploadError(error) { window.$gz.errorHandler.handleFormError(error); }); }, - remove(item) { + remove() { let vm = this; window.$gz.dialog.confirmDelete().then(dialogResult => { if (dialogResult == true) { window.$gz.api - .remove("Attachment/" + item.id) + .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(); } }) @@ -179,35 +185,30 @@ export default { if (res.error) { window.$gz.errorHandler.handleFormError(res.error); } else { - vm.attachedFiles = res.data; - vm.updateDisplayList(); + vm.updateDisplayList(res.data); } }) .catch(function handleGetListError(error) { window.$gz.errorHandler.handleFormError(error); }); }, - updateDisplayList() { + updateDisplayList(data) { //{"data":[{"id":1,"concurrencyToken":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,"concurrencyToken":7733354,"contentType":"text/plain","displayFileName":"TNT log file ayanova.txt","lastModified":"0001-01-01T00:00:00Z","notes":"Here are notes"},{"id":2,"concurrencyToken":7733342,"contentType":"text/plain","displayFileName":"stack.txt","lastModified":"0001-01-01T00:00:00Z","notes":"Here are notes"},{"id":3,"concurrencyToken":7733348,"contentType":"image/jpeg","displayFileName":"t2cx6sloffk41.jpg","lastModified":"0001-01-01T00:00:00Z","notes":"Here are notes"}]} - if (!this.attachedFiles) { - this.attachedFiles = []; + if (!data) { + data = []; } let timeZoneName = window.$gz.locale.getBrowserTimeZoneName(); let languageName = window.$gz.locale.getBrowserLanguages(); let hour12 = window.$gz.store.state.locale.hour12; let ret = []; - for (let i = 0; i < this.attachedFiles.length; i++) { - let o = this.attachedFiles[i]; + for (let i = 0; i < data.length; i++) { + let o = data[i]; //http://localhost:7575/api/v8/Attachment/download/100?t=sssss ret.push({ id: o.id, - title: - "" + - o.displayFileName + - "", + concurrencyToken: o.concurrencyToken, + url: window.$gz.api.downloadUrl(o.id), name: o.displayFileName, date: window.$gz.locale.utcDateToShortDateAndTimeLocalized( o.lastModified, @@ -242,7 +243,8 @@ export default { } //check if they differ first let o = null; - for (let i = 0; i < vm.displayList.length; i++) { + let i = 0; + for (i = 0; i < vm.displayList.length; i++) { if (vm.displayList[i].id == vm.editId) { o = vm.displayList[i]; break; @@ -254,16 +256,36 @@ export default { } //post to server - //get concurrency token for PUT from master list? - //or do away with master list and just have updateDisplayList become createDisplayList (and it adds concurrency token) and - //get called from all routes that return a list? **BETTER IDEA!** - //todo: MAKE A PUT ROUTE then POST THIS + /* + public uint ConcurrencyToken { get; set; } + [Required] + public string DisplayFileName { get; set; } + public string Notes { get; set; } + */ - //Update item in list - //(attempting to cheat here, rather than refresh the whole list from server) - //but I do like a clean refresh so if this doesn't work then just call get list - o.name = vm.editName; - o.notes = vm.editNotes; + let p = { + concurrencyToken: o.concurrencyToken, + displayFileName: vm.editName, + notes: vm.editNotes + }; + + window.$gz.api + .upsert("Attachment/" + vm.editId, p) + .then(res => { + if (res.error) { + window.$gz.errorHandler.handleFormError(res.error); + } else { + vm.editMenu = false; + vm.editName = null; + vm.editNotes = null; + vm.editId = null; + //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); + } + }) + .catch(function handleUploadError(error) { + window.$gz.errorHandler.handleFormError(error); + }); } //----- }