From faefd05c03d20a892a47c27550fe6e23978993c7 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Wed, 17 Aug 2022 20:21:10 +0300 Subject: create new list UI --- src/components/lists_edit/lists_edit.js | 28 ++++++++++++++++++++++++---- src/components/lists_edit/lists_edit.vue | 24 +++++++++++++++++++----- 2 files changed, 43 insertions(+), 9 deletions(-) (limited to 'src/components/lists_edit') diff --git a/src/components/lists_edit/lists_edit.js b/src/components/lists_edit/lists_edit.js index 533bceb9..c22d1323 100644 --- a/src/components/lists_edit/lists_edit.js +++ b/src/components/lists_edit/lists_edit.js @@ -36,6 +36,7 @@ const ListsNew = { } }, created () { + if (!this.id) return this.$store.dispatch('fetchList', { listId: this.id }) .then(() => { this.title = this.findListTitle(this.id) @@ -71,19 +72,19 @@ const ListsNew = { }, toggleRemoveMember (user) { if (this.removedUserIds.has(user.id)) { - this.addUser(user) + this.id && this.addUser(user) this.removedUserIds.delete(user.id) } else { - this.removeUser(user.id) + this.id && this.removeUser(user.id) this.removedUserIds.add(user.id) } }, toggleAddFromSearch (user) { if (this.addedUserIds.has(user.id)) { - this.removeUser(user.id) + this.id && this.removeUser(user.id) this.addedUserIds.delete(user.id) } else { - this.addUser(user) + this.id && this.addUser(user) this.addedUserIds.add(user.id) } }, @@ -115,6 +116,25 @@ const ListsNew = { this.title = this.findListTitle(this.id) }) }, + createList () { + this.$store.dispatch('createList', { title: this.titleDraft }) + .then((list) => { + return this + .$store + .dispatch('setListAccounts', { listId: list.id, accountIds: [...this.addedUserIds] }) + .then(() => list.id) + }) + .then((listId) => { + this.$router.push({ name: 'lists-timeline', params: { id: listId } }) + }) + .catch((e) => { + this.$store.dispatch('pushGlobalNotice', { + messageKey: 'lists.error', + messageArgs: [e.message], + level: 'error' + }) + }) + }, deleteList () { this.$store.dispatch('deleteList', { listId: this.id }) this.$router.push({ name: 'lists' }) diff --git a/src/components/lists_edit/lists_edit.vue b/src/components/lists_edit/lists_edit.vue index e788c00a..6521aba6 100644 --- a/src/components/lists_edit/lists_edit.vue +++ b/src/components/lists_edit/lists_edit.vue @@ -15,12 +15,17 @@
+
@@ -33,6 +38,7 @@ v-model="titleDraft" > +