diff --git a/src/composables/task-properties.js b/src/composables/task-properties.js index 5bb19d1c82..c9f7a6d5e2 100644 --- a/src/composables/task-properties.js +++ b/src/composables/task-properties.js @@ -1,6 +1,6 @@ import { useViewSettings } from '@/composables/view-settings' -export function useTaskProperties() { +export function useTaskProperties(propertyList) { const { SORT_TYPE_KEY } = useViewSettings() const propertyItem = ({ @@ -18,39 +18,54 @@ export function useTaskProperties() { sortable, required }) - const propertyId = propertyItem({ + const id = propertyItem({ key: 'id', icon: 'image', sortable: true }) - const propertyName = propertyItem({ + const name = propertyItem({ icon: 'image', key: 'name', sortable: true, required: true }) - const propertyCreatedAt = propertyItem({ + const createdAt = propertyItem({ icon: 'image', key: 'createdAt', sortingKey: 'creationDate', sortingType: SORT_TYPE_KEY.DATE, sortable: true }) - const propertyProgress = propertyItem({ + + const progress = propertyItem({ icon: 'image', key: 'progress', sortingType: SORT_TYPE_KEY.NUMBER, sortable: true }) - const propertyState = propertyItem({ + const state = propertyItem({ icon: 'image', key: 'state', type: SORT_TYPE_KEY.NUMBER, sortable: false, required: true }) - - const propertyItems = [propertyState, propertyName, propertyId, propertyCreatedAt, propertyProgress] - - return { propertyItems } + const propertyItems = { + id, + name, + createdAt, + progress, + state + } + const items = propertyList.reduce((acc, p) => { + if (propertyItems[p] === undefined) { + acc.push(propertyItem({ key: p })) + console.warn(`${p} does not exist`) + return acc + } + acc.push(propertyItems[p]) + return acc + }, []) + console.log('propertyList', propertyList) + return { items } } diff --git a/src/store/modules/app.js b/src/store/modules/app.js index b7f37a3238..0f87ed2fac 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -25,27 +25,27 @@ export const state = () => ({ task: { orderBy: ['name', 'desc'], perPage: 10, - properties: ['id', 'name', 'createdAt', 'progress', 'result', 'state'] + properties: ['id', 'name', 'createdAt', 'progress', 'state'] }, entities: { orderBy: ['name', 'desc'], perPage: 10, - properties: ['id', 'name', 'createdAt', 'progress', 'result', 'state'] + properties: ['state', 'id', 'name', 'createdAt', 'progress'] }, documents: { orderBy: ['name', 'desc'], perPage: 10, - properties: ['id', 'name', 'createdAt', 'progress', 'result', 'state'] + properties: ['id', 'name', 'createdAt', 'progress', 'state'] }, 'batch-download': { orderBy: ['name', 'desc'], perPage: 10, - properties: ['id', 'name', 'createdAt', 'progress', 'result', 'state'] + properties: ['id', 'name', 'createdAt', 'progress', 'state'] }, 'batch-search': { orderBy: ['name', 'desc'], perPage: 10, - properties: ['id', 'name', 'createdAt', 'progress', 'result', 'state'] + properties: ['id', 'name', 'createdAt', 'progress', 'state'] }, documentView: { tab: 'text' @@ -64,25 +64,6 @@ export const state = () => ({ }) export const mutations = { - taskSettingsCreated( - state, - { - name = 'task', - settings: { - orderBy = ['name', 'desc'], - perPage = 10, - properties = ['id', 'name', 'createdAt', 'progress', 'result', 'state'] - } - } - ) { - if (!state.settings[name]) { - state.settings[name] = { - orderBy, - perPage, - properties - } - } - }, sidebarCompact(state, compact) { state.sidebar.compact = compact }, @@ -121,11 +102,6 @@ export const getters = { return get(state.settings.views, [view, name].join('.')) } }, - getTaskSettings(state) { - return (view, name) => { - return get(state.settings.views.task, [view, 'task', name].join('.')) - } - }, isProjectPinned(state) { return (name) => state.pins.projects.includes(name) } diff --git a/src/views/Task/task-settings.js b/src/views/Task/task-settings.js index bd24dd840b..c3fdb98f18 100644 --- a/src/views/Task/task-settings.js +++ b/src/views/Task/task-settings.js @@ -36,7 +36,9 @@ export function useTaskSettings(pageName) { } ] }) - const { propertyItems } = useTaskProperties() + const vals = store.getters['app/getSettings'](pageName, 'properties') + console.log('vals', vals) + const { items } = useTaskProperties(vals) const sortBy = ref({ label: sortByLabel, @@ -46,7 +48,7 @@ export function useTaskSettings(pageName) { get: () => store.getters['app/getSettings'](pageName, 'orderBy'), set: (sort, order) => store.commit('app/setSettings', { view: pageName, orderBy: [sort, order] }) }), - options: propertyItems.reduce((acc, p) => { + options: items.reduce((acc, p) => { if (p.sortable) { const labelKey = p.sortingKey ?? p.key acc.push( @@ -66,7 +68,7 @@ export function useTaskSettings(pageName) { get: () => store.getters['app/getSettings'](pageName, 'properties'), set: (properties) => store.commit('app/setSettings', { view: pageName, properties }) }), - options: propertyItems.map((p) => ({ + options: items.map((p) => ({ value: p.key, icon: p.icon, disabled: p.required,