fix: archiving a list
This commit is contained in:
parent
8eed0be072
commit
2b8a786825
4 changed files with 34 additions and 19 deletions
|
@ -98,4 +98,23 @@ describe('Lists', () => {
|
||||||
cy.location('pathname')
|
cy.location('pathname')
|
||||||
.should('equal', '/')
|
.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.')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -26,11 +26,17 @@ export default class ListService extends AbstractService {
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeUpdate(model) {
|
beforeUpdate(model) {
|
||||||
const taskService = new TaskService()
|
if(typeof model.tasks !== 'undefined') {
|
||||||
model.tasks = model.tasks.map(task => {
|
const taskService = new TaskService()
|
||||||
return taskService.beforeUpdate(task)
|
model.tasks = model.tasks.map(task => {
|
||||||
})
|
return taskService.beforeUpdate(task)
|
||||||
model.hexColor = colorFromHex(model.hexColor)
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeof model.hexColor !== 'undefined') {
|
||||||
|
model.hexColor = colorFromHex(model.hexColor)
|
||||||
|
}
|
||||||
|
|
||||||
return model
|
return model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +45,6 @@ export default class ListService extends AbstractService {
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
update(model) {
|
|
||||||
const newModel = { ... model }
|
|
||||||
return super.update(newModel)
|
|
||||||
}
|
|
||||||
|
|
||||||
async background(list) {
|
async background(list) {
|
||||||
if (list.background === null) {
|
if (list.background === null) {
|
||||||
return ''
|
return ''
|
||||||
|
|
|
@ -60,7 +60,7 @@ export const store = createStore({
|
||||||
state.loadingModule = module
|
state.loadingModule = module
|
||||||
},
|
},
|
||||||
[CURRENT_LIST](state, currentList) {
|
[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
|
// 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.
|
// when updating the list in global state.
|
||||||
if (typeof state.currentList.maxRight !== 'undefined' && (typeof currentList.maxRight === 'undefined' || currentList.maxRight === null)) {
|
if (typeof state.currentList.maxRight !== 'undefined' && (typeof currentList.maxRight === 'undefined' || currentList.maxRight === null)) {
|
||||||
|
|
|
@ -17,13 +17,11 @@ export default defineComponent({name: 'list-setting-archive'})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {computed, shallowReactive} from 'vue'
|
import {computed} from 'vue'
|
||||||
import {useStore} from 'vuex'
|
import {useStore} from 'vuex'
|
||||||
import {useRouter, useRoute} from 'vue-router'
|
import {useRouter, useRoute} from 'vue-router'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
import ListService from '@/services/list'
|
|
||||||
|
|
||||||
import { success } from '@/message'
|
import { success } from '@/message'
|
||||||
import { useTitle } from '@/composables/useTitle'
|
import { useTitle } from '@/composables/useTitle'
|
||||||
|
|
||||||
|
@ -35,16 +33,13 @@ const route = useRoute()
|
||||||
const list = computed(() => store.getters['lists/getListById'](route.params.listId))
|
const list = computed(() => store.getters['lists/getListById'](route.params.listId))
|
||||||
useTitle(() => t('list.archive.title', {list: list.value.title}))
|
useTitle(() => t('list.archive.title', {list: list.value.title}))
|
||||||
|
|
||||||
const listService = shallowReactive(new ListService())
|
|
||||||
|
|
||||||
async function archiveList() {
|
async function archiveList() {
|
||||||
try {
|
try {
|
||||||
const newList = await listService.update({
|
const newList = await store.dispatch('lists/updateList', {
|
||||||
...list,
|
...list.value,
|
||||||
isArchived: !list.value.isArchived,
|
isArchived: !list.value.isArchived,
|
||||||
})
|
})
|
||||||
store.commit('currentList', newList)
|
store.commit('currentList', newList)
|
||||||
store.commit('namespaces/setListInNamespaceById', newList)
|
|
||||||
success({message: t('list.archive.success')})
|
success({message: t('list.archive.success')})
|
||||||
} finally {
|
} finally {
|
||||||
router.back()
|
router.back()
|
||||||
|
|
Loading…
Reference in a new issue