From 8fb6980ecc87f4fc911794b88b561c6c56fcd1d3 Mon Sep 17 00:00:00 2001 From: Marco Cano Date: Mon, 13 May 2024 16:03:00 -0700 Subject: [PATCH 1/3] fix: :hammer: add context, fix edit tool --- nuxt-app/components/guide/JSONItem.vue | 188 +++++++++++++++++++------ nuxt-app/pages/guide/Guide.vue | 4 +- nuxt-app/plugins/fontawesome.js | 4 +- nuxt-app/store/modules/guide.js | 20 +++ 4 files changed, 169 insertions(+), 47 deletions(-) diff --git a/nuxt-app/components/guide/JSONItem.vue b/nuxt-app/components/guide/JSONItem.vue index 4f1dcd0c..7e4df811 100644 --- a/nuxt-app/components/guide/JSONItem.vue +++ b/nuxt-app/components/guide/JSONItem.vue @@ -1,11 +1,21 @@ + + diff --git a/nuxt-app/pages/guide/Guide.vue b/nuxt-app/pages/guide/Guide.vue index 888406ef..a5ce5727 100644 --- a/nuxt-app/pages/guide/Guide.vue +++ b/nuxt-app/pages/guide/Guide.vue @@ -63,7 +63,7 @@
@@ -89,7 +89,7 @@ diff --git a/nuxt-app/plugins/fontawesome.js b/nuxt-app/plugins/fontawesome.js index 33ab8e97..7c0056e7 100644 --- a/nuxt-app/plugins/fontawesome.js +++ b/nuxt-app/plugins/fontawesome.js @@ -70,6 +70,7 @@ import { faChevronUp, faExpand, faIndent, + faMagnifyingGlass, } from "@fortawesome/free-solid-svg-icons"; import { faGithub, @@ -147,7 +148,8 @@ library.add( faChevronDown, faChevronUp, faExpand, - faIndent + faIndent, + faMagnifyingGlass ); // This is important, we are going to let Nuxt worry about the CSS diff --git a/nuxt-app/store/modules/guide.js b/nuxt-app/store/modules/guide.js index 51650b33..11d464d9 100644 --- a/nuxt-app/store/modules/guide.js +++ b/nuxt-app/store/modules/guide.js @@ -847,6 +847,26 @@ export const guide = { }); state.editingID = payload["id"]; }, + saveEditedItem(state, payload) { + state.bulkJSONItems[payload.index] = payload.value; + new Notify({ + status: "success", + title: "Guide", + text: "Updated", + effect: "fade", + speed: 300, + customClass: null, + customIcon: null, + showIcon: true, + showCloseButton: true, + autoclose: true, + autotimeout: 2000, + gap: 20, + distance: 20, + type: 1, + position: "right top", + }); + }, }, getters: { getBulkReport: (state) => { From db3a5b91c3f97fa9439838ad2e547d34befa52d6 Mon Sep 17 00:00:00 2001 From: Marco Cano Date: Tue, 14 May 2024 12:56:24 -0700 Subject: [PATCH 2/3] fix: add warnings for missing requirements --- nuxt-app/components/guide/JSONItem.vue | 83 ++++++++++++++------------ nuxt-app/pages/guide/Guide.vue | 1 - 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/nuxt-app/components/guide/JSONItem.vue b/nuxt-app/components/guide/JSONItem.vue index 7e4df811..114d438a 100644 --- a/nuxt-app/components/guide/JSONItem.vue +++ b/nuxt-app/components/guide/JSONItem.vue @@ -43,6 +43,9 @@ + Attention Required
Get help!`; }); }, - editItem() {}, - editItemOLD(item) { - let self = this; - this.$swal - .fire({ - title: "Edit Metadata", - confirmButtonColor: "#5C3069", - cancelButtonColor: "#006476", - customClass: "scale-in-center swal-wide", - html: '', - showCancelButton: true, - confirmButtonText: "Save Changes", - didOpen: function () { - // self.editor = CodeMirror.fromTextArea( - // document.getElementById("editContent"), - // { - // mode: "json", - // // lineNumbers: true, - // autorefresh: true, - // lineWrapping: true, - // spellcheck: true, - // autofocus: true, - // } - // ); - // self.editor.setValue(JSON.stringify(item, null, 2)); - // self.editor.on("change", (editor) => { - // self.beforeCloseVal = editor.getValue(); - // }); - }, - preConfirm: () => { - self.SaveDefinition(); - }, - }) - .then((dataChange) => { - if (dataChange.value) { - self.SaveDefinition(); - } - }); - }, + // editItemOLD(item) { + // let self = this; + // this.$swal + // .fire({ + // title: "Edit Metadata", + // confirmButtonColor: "#5C3069", + // cancelButtonColor: "#006476", + // customClass: "scale-in-center swal-wide", + // html: '', + // showCancelButton: true, + // confirmButtonText: "Save Changes", + // didOpen: function () { + // // self.editor = CodeMirror.fromTextArea( + // // document.getElementById("editContent"), + // // { + // // mode: "json", + // // // lineNumbers: true, + // // autorefresh: true, + // // lineWrapping: true, + // // spellcheck: true, + // // autofocus: true, + // // } + // // ); + // // self.editor.setValue(JSON.stringify(item, null, 2)); + // // self.editor.on("change", (editor) => { + // // self.beforeCloseVal = editor.getValue(); + // // }); + // }, + // preConfirm: () => { + // self.SaveDefinition(); + // }, + // }) + // .then((dataChange) => { + // if (dataChange.value) { + // self.SaveDefinition(); + // } + // }); + // }, closeAndSave() { try { let newVal = JSON.parse(this.editor.state.doc.toString()); @@ -521,6 +523,9 @@ export default { beginBulkRegistration: "beginBulkRegistration", }), }, + mounted: function(){ + this.checkRequirements(this.item); + }, watch: { beginBulkRegistration: function (v) { if (v) { diff --git a/nuxt-app/pages/guide/Guide.vue b/nuxt-app/pages/guide/Guide.vue index a5ce5727..3f29a676 100644 --- a/nuxt-app/pages/guide/Guide.vue +++ b/nuxt-app/pages/guide/Guide.vue @@ -52,7 +52,6 @@ Over
- + - Attention Required + Attention Required
- +
- +
{ if (res.data.total == 1) { @@ -358,20 +364,10 @@ export default { field: "Failed", value: self.item.identifier, }); - self.errMSG = `
    -
  • Reason: ${err.response.data.reason || "N/A"}
  • -
  • Required: ${ - err.response.data.validator ? "🟢 Yes" : "🔴 No" - }
  • -
  • Failing at field: ${err.response.data.path || "N/A"}
  • -
  • Additional Details: ${ - (err.response.data.parent && err.response.data.parent.reason) || - "N/A" - }
  • -
`; - self.help = ` Get help!`; + self.errMSG = + err.response?.data?.error == "Conflict" + ? "Registration already exists" + : err.response?.data?.error; }); }, updateJSONItem() { @@ -411,20 +407,10 @@ export default { field: "Failed", value: self.exists, }); - self.errMSG = `
    -
  • Reason: ${err.response.data.reason || "N/A"}
  • -
  • Required: ${ - err.response.data.validator ? "🟢 Yes" : "🔴 No" - }
  • -
  • Failing at field: ${err.response.data.path || "N/A"}
  • -
  • Additional Details: ${ - (err.response.data.parent && err.response.data.parent.reason) || - "N/A" - }
  • -
`; - self.help = `Get help!`; + self.errMSG = + err.response?.data?.error == "Conflict" + ? "Registration already exists" + : err.response?.data?.error; }); }, // editItemOLD(item) { @@ -466,15 +452,25 @@ export default { // }); // }, closeAndSave() { + let self = this; try { - let newVal = JSON.parse(this.editor.state.doc.toString()); - this.$store.commit("saveEditedItem", { - value: newVal, - index: this.number, - }); - this.editMode = false; + let editorData = this.editor.state.doc.toString(); + if (editorData) { + let newVal = JSON.parse(editorData); + this.$store.commit("saveEditedItem", { + value: newVal, + index: this.number, + }); + this.editor = null; + this.editMode = false; + setTimeout(() => { + self.checkRequirements(self.item); + }, 1000); + } else { + console.log("No editor data", editorData); + } } catch (error) { - alert(`Invalid JSON Structure: ${error.toString()}`); + console.log("INVALID JSON", error.toString()); } }, loadContent() { @@ -523,14 +519,12 @@ export default { beginBulkRegistration: "beginBulkRegistration", }), }, - mounted: function(){ + mounted: function () { this.checkRequirements(this.item); }, watch: { - beginBulkRegistration: function (v) { - if (v) { - this.register(); - } + beginBulkRegistration: function () { + this.register(); }, editMode: function (v) { if (v) { diff --git a/nuxt-app/pages/guide/Guide.vue b/nuxt-app/pages/guide/Guide.vue index 3f29a676..9a7f8ba2 100644 --- a/nuxt-app/pages/guide/Guide.vue +++ b/nuxt-app/pages/guide/Guide.vue @@ -23,10 +23,10 @@
- + v-text="jsonItems.length + ' items found'" + >
-
+
- - - - + + + + diff --git a/nuxt-app/store/modules/guide.js b/nuxt-app/store/modules/guide.js index 11d464d9..ae58129d 100644 --- a/nuxt-app/store/modules/guide.js +++ b/nuxt-app/store/modules/guide.js @@ -25,7 +25,7 @@ export const guide = { }, output_default: {}, editingID: false, - beginBulkRegistration: false, + beginBulkRegistration: 1, bulkReport: { Exists: [], Registered: [], @@ -58,7 +58,7 @@ export const guide = { }; }, toggleBeginBulkRegistration(state) { - state.beginBulkRegistration = !state.beginBulkRegistration; + state.beginBulkRegistration += 1; }, toggleDesc(state) { state.showDescriptions = !state.showDescriptions;
- Name - - Result/Details - - Options - - Status - NameResult/DetailsOptionsStatus