From fc4becdab162c891d647bb47f7e0e6498ccff7f3 Mon Sep 17 00:00:00 2001 From: luckyrat Date: Tue, 30 Jun 2020 21:42:09 +0100 Subject: [PATCH] Highlight preferred group if it's found in the "Where" list --- popup/App.vue | 10 ++++++++-- popup/components/Save1stParty.vue | 14 +++++++------- popup/components/SaveWhere.vue | 19 +++++++++++++------ 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/popup/App.vue b/popup/App.vue index bb34f1dd..14fc8322 100644 --- a/popup/App.vue +++ b/popup/App.vue @@ -42,7 +42,11 @@ @save-where-clicked="saveWhere" @cancel-clicked="saveDiscard" /> - + @@ -191,6 +195,7 @@ export default { saveLastActiveAt: null, showSaveWhere: false, displayWhereReason: null, + preferredGroupUuid: "", // imported constants are only available in Vue if we assign them to data tooltipDelay, @@ -307,8 +312,9 @@ export default { this.$store.dispatch("updateSaveState", updatedSaveState); //this.saveLastActiveAt = updatedSaveState.lastActiveAt; }, - saveWhere: function (this: any, displayWhereReason: string) { + saveWhere: function (this: any, displayWhereReason: string, preferredGroupUuid: string) { this.displayWhereReason = displayWhereReason; + this.preferredGroupUuid = preferredGroupUuid; this.showSaveWhere = true; }, showHelp: () => { diff --git a/popup/components/Save1stParty.vue b/popup/components/Save1stParty.vue index 8649153a..55d56be0 100644 --- a/popup/components/Save1stParty.vue +++ b/popup/components/Save1stParty.vue @@ -180,13 +180,13 @@ export default { }, async mounted(this: any) { this.preferToSkipWhere = configManager.current.rememberMRUGroup; + const dbs = this.$store.state.KeePassDatabases as Database[]; + const { preferredGroupUuid, preferredDb, primaryFound } = this.getPreferredGroup( + configManager.current.mruGroup, + dbs + ); + this.preferredGroupUuid = preferredGroupUuid; if (this.preferToSkipWhere) { - const dbs = this.$store.state.KeePassDatabases as Database[]; - const { preferredGroupUuid, preferredDb, primaryFound } = this.getPreferredGroup( - configManager.current.mruGroup, - dbs - ); - this.preferredGroupUuid = preferredGroupUuid; this.preferredDb = preferredDb; this.primaryFound = primaryFound; @@ -203,7 +203,7 @@ export default { this.$emit("cancel-clicked"); }, nextClicked: function (this: any) { - this.$emit("save-where-clicked", this.displayWhereReason); + this.$emit("save-where-clicked", this.displayWhereReason, this.preferredGroupUuid); }, saveEntry: function (this: any) { const updatedSaveState = Object.assign({}, this.$store.state.saveState) as SaveState; diff --git a/popup/components/SaveWhere.vue b/popup/components/SaveWhere.vue index 48d40d6c..c501bbc4 100644 --- a/popup/components/SaveWhere.vue +++ b/popup/components/SaveWhere.vue @@ -24,6 +24,7 @@ ({ search: null, - saveEnabled: true, - skipInFuture: configManager.current.rememberMRUGroup + saveEnabled: false, + skipInFuture: configManager.current.rememberMRUGroup, + groupUuidArray: [] }), computed: { ...mapGetters(["saveState", "KeePassDatabases", "ActiveKeePassDatabaseIndex"]), @@ -123,23 +125,28 @@ export default { } } }, + mounted(this: any) { + this.groupUuidArray = [{ uuid: this.preferredGroupUuid }]; + }, methods: { saveEntry: function (this: any) { Port.postMessage({ action: Action.CreateEntry } as AddonMessage); window.close(); }, - setGroup: function (this: any, value) { - const database = findDatabaseByGroup(this.KeePassDatabases, value[0]); + setGroup: function (this: any, values) { + if (!(values?.length > 0)) return; + const database = findDatabaseByGroup(this.KeePassDatabases, values[0]); const updatedSaveState = Object.assign({}, this.$store.state.saveState) as SaveState; updatedSaveState.newEntry = new Entry({ ...updatedSaveState.newEntry, - parentGroup: value[0], + parentGroup: values[0], database: new DatabaseSummary({ fileName: database.fileName, root: new GroupSummary({ uuid: TemporaryIDString }) }) }); this.$store.dispatch("updateSaveState", updatedSaveState); + this.saveEnabled = true; } } };