diff --git a/src/composables/task-properties.js b/src/composables/task-properties.js new file mode 100644 index 000000000..767ce0021 --- /dev/null +++ b/src/composables/task-properties.js @@ -0,0 +1,55 @@ +import { useViewSettings } from '@/composables/view-settings' + +export function useTaskProperties() { + const { SORT_TYPE_KEY } = useViewSettings() + + const propertyItem = ({ + key, + icon = null, + sortable = false, + sortingKey = null, + sortingType = SORT_TYPE_KEY.ALPHA, + required = false + }) => ({ + key, + icon, + sortingKey, + sortingType, + sortable, + required + }) + const propertyId = propertyItem({ + key: 'id', + icon: 'image', + sortable: true + }) + const propertyName = propertyItem({ + icon: 'image', + key: 'name', + sortable: true, + required: true + }) + const propertyCreatedAt = propertyItem({ + icon: 'image', + key: 'createdAt', + sortingKey: 'creationDate', + sortingType: SORT_TYPE_KEY.DATE, + sortable: true + }) + const propertyProgress = propertyItem({ + icon: 'image', + key: 'progress', + sortingType: SORT_TYPE_KEY.NUMBER, + sortable: true + }) + const propertyState = propertyItem({ + icon: 'image', + key: 'state', + type: SORT_TYPE_KEY.NUMBER, + sortable: false + }) + + const propertyItems = [propertyId, propertyName, propertyCreatedAt, propertyProgress, propertyState] + + return { propertyItems } +} diff --git a/src/composables/task-settings.js b/src/composables/task-settings.js deleted file mode 100644 index ad4baf6c8..000000000 --- a/src/composables/task-settings.js +++ /dev/null @@ -1,30 +0,0 @@ -import { computed } from 'vue' -import { useI18n } from 'vue-i18n' - -export function useTaskSettings() { - const { t } = useI18n() - - const propertiesOrder = ['state', 'name', 'id', 'progress', 'createdAt'] - - const propertiesLabel = computed(() => { - return { - id: 'id', - name: 'name', - createdAt: 'createdAt', - progress: 'progress', - result: 'result', - state: 'state' - } - }) - - const propertiesIcon = { - id: 'image', - name: 'file-text', - createdAt: 'quotes', - progress: 'user-circle', - result: 'tree-structure', - state: 'hash' - } - - return { propertiesOrder, propertiesLabel, propertiesIcon } -} diff --git a/src/composables/view-settings.js b/src/composables/view-settings.js index 3666d8b5b..934674c77 100644 --- a/src/composables/view-settings.js +++ b/src/composables/view-settings.js @@ -4,6 +4,7 @@ const SORT_ORDER_KEY = Object.freeze({ ASC: 'asc', DESC: 'desc' }) + const SORT_TYPE_KEY = Object.freeze({ DEFAULT: 'default', ALPHA: 'alpha', diff --git a/src/lang/en.json b/src/lang/en.json index 17ac9d792..30d25d530 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -908,7 +908,15 @@ "info":"Entity recognitions are tasks that you run in order to recognize and to list the entities in your documents.", "searchPlaceholder": "Search task", "empty": "You have not yet started any tasks. Read more.", - "noResults": "No search results. Try adjusting the query or filters." + "noResults": "No search results. Try adjusting the query or filters.", + "properties": { + "id": "Id", + "name":"Name", + "createdAt": "Creation date", + "progress":"Progress", + "result": "Result", + "state":"State" + } }, "new": { "title":"Find entities" diff --git a/src/store/modules/app.js b/src/store/modules/app.js index ffd3e4374..b7f37a323 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -27,6 +27,26 @@ export const state = () => ({ perPage: 10, properties: ['id', 'name', 'createdAt', 'progress', 'result', 'state'] }, + entities: { + orderBy: ['name', 'desc'], + perPage: 10, + properties: ['id', 'name', 'createdAt', 'progress', 'result', 'state'] + }, + documents: { + orderBy: ['name', 'desc'], + perPage: 10, + properties: ['id', 'name', 'createdAt', 'progress', 'result', 'state'] + }, + 'batch-download': { + orderBy: ['name', 'desc'], + perPage: 10, + properties: ['id', 'name', 'createdAt', 'progress', 'result', 'state'] + }, + 'batch-search': { + orderBy: ['name', 'desc'], + perPage: 10, + properties: ['id', 'name', 'createdAt', 'progress', 'result', 'state'] + }, documentView: { tab: 'text' }, @@ -44,6 +64,25 @@ 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 }, @@ -82,6 +121,11 @@ 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/BatchDownload/TaskBatchDownloadList.vue b/src/views/Task/BatchDownload/TaskBatchDownloadList.vue index a614521d2..a07616ac8 100644 --- a/src/views/Task/BatchDownload/TaskBatchDownloadList.vue +++ b/src/views/Task/BatchDownload/TaskBatchDownloadList.vue @@ -4,9 +4,9 @@ import TaskList from '@/components/Task/TaskList' import DisplayStatus from '@/components/Display/DisplayStatus' import DisplayDatetimeFromNow from '@/components/Display/DisplayDatetimeFromNow' import DisplayProgress from '@/components/Display/DisplayProgress' -import { useTaskProperties } from '@/views/Task/task-properties' -const settingName = 'task' -const { propertiesModelValueOptions } = useTaskProperties(settingName) +import { useTaskSettings } from '@/views/Task/task-settings' +const settingName = 'batch-download' +const { propertiesModelValueOptions } = useTaskSettings(settingName)