diff options
| author | Henry Jameson <me@hjkos.com> | 2022-08-17 20:21:10 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2022-08-17 20:21:10 +0300 |
| commit | faefd05c03d20a892a47c27550fe6e23978993c7 (patch) | |
| tree | e14dd9f61571975eb56601810907c184404ca609 /src/components/lists_edit/lists_edit.js | |
| parent | b4f4b370d406faf69be5c414ce394b608d8792f5 (diff) | |
create new list UI
Diffstat (limited to 'src/components/lists_edit/lists_edit.js')
| -rw-r--r-- | src/components/lists_edit/lists_edit.js | 28 |
1 files changed, 24 insertions, 4 deletions
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' }) |
