fix: archiving a list

This commit is contained in:
kolaente 2022-06-30 18:04:41 +02:00
parent 8eed0be072
commit 2b8a786825
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 34 additions and 19 deletions

View File

@ -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.')
})
})

View File

@ -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 ''

View File

@ -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)) {

View File

@ -17,13 +17,11 @@ export default defineComponent({name: 'list-setting-archive'})
</script>
<script setup lang="ts">
import {computed, shallowReactive} from 'vue'
import {computed} from 'vue'
import {useStore} from 'vuex'
import {useRouter, useRoute} from 'vue-router'
import {useI18n} from 'vue-i18n'
import ListService from '@/services/list'
import { success } from '@/message'
import { useTitle } from '@/composables/useTitle'
@ -35,16 +33,13 @@ const route = useRoute()
const list = computed(() => store.getters['lists/getListById'](route.params.listId))
useTitle(() => t('list.archive.title', {list: list.value.title}))
const listService = shallowReactive(new ListService())
async function archiveList() {
try {
const newList = await listService.update({
...list,
const newList = await store.dispatch('lists/updateList', {
...list.value,
isArchived: !list.value.isArchived,
})
store.commit('currentList', newList)
store.commit('namespaces/setListInNamespaceById', newList)
success({message: t('list.archive.success')})
} finally {
router.back()