From 2b8a7868254db5fd739d6f0ec62e67ee802d8429 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 30 Jun 2022 18:04:41 +0200 Subject: [PATCH] fix: archiving a list --- cypress/e2e/list/list.spec.js | 19 +++++++++++++++++++ src/services/list.ts | 21 +++++++++++---------- src/store/index.ts | 2 +- src/views/list/settings/archive.vue | 11 +++-------- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/cypress/e2e/list/list.spec.js b/cypress/e2e/list/list.spec.js index 00f5b4f5ef..3a108a7d28 100644 --- a/cypress/e2e/list/list.spec.js +++ b/cypress/e2e/list/list.spec.js @@ -98,4 +98,23 @@ describe('Lists', () => { cy.location('pathname') .should('equal', '/') }) + + it('Should archive a list', () => { + cy.visit(`/lists/${lists[0].id}`) + + cy.get('.list-title .dropdown') + .click() + cy.get('.list-title .dropdown .dropdown-menu .dropdown-item') + .contains('Archive') + .click() + cy.get('.modal-content') + .should('contain.text', 'Archive this list') + cy.get('.modal-content [data-cy=modalPrimary]') + .click() + + cy.get('.namespace-container .menu.namespaces-lists .more-container .menu-list') + .should('not.contain', lists[0].title) + cy.get('main.app-content') + .should('contain.text', 'This list is archived. It is not possible to create new or edit tasks for it.') + }) }) diff --git a/src/services/list.ts b/src/services/list.ts index 0238700341..dba90f95b7 100644 --- a/src/services/list.ts +++ b/src/services/list.ts @@ -26,11 +26,17 @@ export default class ListService extends AbstractService { } beforeUpdate(model) { - const taskService = new TaskService() - model.tasks = model.tasks.map(task => { - return taskService.beforeUpdate(task) - }) - model.hexColor = colorFromHex(model.hexColor) + if(typeof model.tasks !== 'undefined') { + const taskService = new TaskService() + model.tasks = model.tasks.map(task => { + return taskService.beforeUpdate(task) + }) + } + + if(typeof model.hexColor !== 'undefined') { + model.hexColor = colorFromHex(model.hexColor) + } + return model } @@ -39,11 +45,6 @@ export default class ListService extends AbstractService { return list } - update(model) { - const newModel = { ... model } - return super.update(newModel) - } - async background(list) { if (list.background === null) { return '' diff --git a/src/store/index.ts b/src/store/index.ts index aff24495ea..c421cb0339 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -60,7 +60,7 @@ export const store = createStore({ state.loadingModule = module }, [CURRENT_LIST](state, currentList) { - // Server updates don't return the right. Therefore the right is reset after updating the list which is + // Server updates don't return the right. Therefore, the right is reset after updating the list which is // confusing because all the buttons will disappear in that case. To prevent this, we're keeping the right // when updating the list in global state. if (typeof state.currentList.maxRight !== 'undefined' && (typeof currentList.maxRight === 'undefined' || currentList.maxRight === null)) { diff --git a/src/views/list/settings/archive.vue b/src/views/list/settings/archive.vue index 92e24d0fa1..b752448f3b 100644 --- a/src/views/list/settings/archive.vue +++ b/src/views/list/settings/archive.vue @@ -17,13 +17,11 @@ export default defineComponent({name: 'list-setting-archive'})