diff --git a/cataloging/src/components/care/bulk-changes-header.vue b/cataloging/src/components/care/bulk-changes-header.vue index bb676d09f..856d71eb8 100644 --- a/cataloging/src/components/care/bulk-changes-header.vue +++ b/cataloging/src/components/care/bulk-changes-header.vue @@ -4,6 +4,9 @@ import FormBuilder from "@/components/care/form-builder.vue"; import IdPill from "@/components/shared/id-pill.vue"; import * as StringUtil from 'lxljs/string.js'; import {mapGetters} from "vuex"; +import { + STATUS_KEY, +} from "@/utils/bulk.js"; export default { name: 'bulk-changes-header.vue', @@ -31,7 +34,7 @@ export default { return this.currentBulkChange['@id']; }, status() { - return StringUtil.getLabelByLang(this.currentBulkChange.bulkChangeStatus, this.user.settings.language, this.resources); + return StringUtil.getLabelByLang(this.currentBulkChange[STATUS_KEY], this.user.settings.language, this.resources); }, }, methods: { diff --git a/cataloging/src/components/care/bulk-changes.vue b/cataloging/src/components/care/bulk-changes.vue index 9262707dc..853dfea72 100644 --- a/cataloging/src/components/care/bulk-changes.vue +++ b/cataloging/src/components/care/bulk-changes.vue @@ -4,10 +4,10 @@ import TargetFormBuilder from '@/components/care/target-form-builder.vue'; import Preview from '@/components/care/preview.vue'; import BulkChangesHeader from "@/components/care/bulk-changes-header.vue"; import { mapGetters } from 'vuex'; -import {cloneDeep, get, isEmpty, isEqual} from 'lodash-es'; +import { cloneDeep, get, isEmpty, isEqual } from 'lodash-es'; import emptyTemplate from './templates/empty.json'; import toolbar from "@/components/inspector/bulkchange-toolbar.vue"; -import {labelByLang, translatePhrase} from "@/utils/filters.js"; +import { labelByLang, translatePhrase } from "@/utils/filters.js"; import * as LayoutUtil from '@/utils/layout'; import Inspector from "@/views/Inspector.vue"; import ModalComponent from '@/components/shared/modal-component.vue'; @@ -18,7 +18,15 @@ import * as RecordUtil from "@/utils/record.js"; import * as LxlDataUtil from "lxljs/data.js"; import * as HistoryUtil from "@/utils/history.js"; import ReverseRelations from "../inspector/reverse-relations.vue"; -import {appendIds} from "../../utils/data.js"; +import { appendIds } from "../../utils/data.js"; +import { + CHANGE_SPEC_KEY, + MATCH_FORM_KEY, + SHOULD_UPDATE_TIMESTAMP_KEY, + STATUS_KEY, + TARGET_FORM_KEY, + Status, +} from "@/utils/bulk.js"; export default { name: 'bulk-changes.vue', @@ -89,10 +97,10 @@ export default { return this.inspector.data.mainEntity; }, formObj() { - return this.isActive('form') ? this.inspector.data.mainEntity : this.currentSpec.matchForm; + return this.isActive('form') ? this.inspector.data.mainEntity : this.currentSpec[MATCH_FORM_KEY]; }, targetFormObj() { - return this.isActive('targetForm') ? this.inspector.data.mainEntity : this.currentSpec.targetForm; + return this.isActive('targetForm') ? this.inspector.data.mainEntity : this.currentSpec[TARGET_FORM_KEY]; }, formTitle() { return `${this.steps.indexOf('form') + 1}. ${translatePhrase('Selection')}` @@ -116,35 +124,35 @@ export default { return this.activeStep === this.steps[0]; }, isDraft() { - return this.currentBulkChange.bulkChangeStatus === 'DraftBulkChange'; + return this.currentBulkChange[STATUS_KEY] === Status.Draft; }, isReady() { - return this.currentBulkChange.bulkChangeStatus === 'ReadyBulkChange'; + return this.currentBulkChange[STATUS_KEY] === Status.Ready; }, isFinished() { - return this.currentBulkChange.bulkChangeStatus === 'CompletedBulkChange' - || this.currentBulkChange.bulkChangeStatus === 'FailedBulkChange'; + return this.currentBulkChange[STATUS_KEY] === Status.Completed + || this.currentBulkChange[STATUS_KEY] === Status.Failed; }, isRunningOrFinished() { return this.isFinished - || this.currentBulkChange.bulkChangeStatus === 'RunningBulkChange'; + || this.currentBulkChange[STATUS_KEY] === Status.Running; }, statusLabel() { - return StringUtil.getLabelByLang(this.currentBulkChange.bulkChangeStatus, this.user.settings.language, this.resources); + return StringUtil.getLabelByLang(this.currentBulkChange[STATUS_KEY], this.user.settings.language, this.resources); }, loudOrSilentLabel() { return translatePhrase('Export changed records (update change date)'); }, isLoud() { - return this.currentBulkChange.bulkChangeMetaChanges === "LoudBulkChange"; + return this.currentBulkChange[SHOULD_UPDATE_TIMESTAMP_KEY] === true; }, shouldExportAffected() { return this.isLoud; }, hasUnsavedChanges() { if (this.lastFetchedSpec && this.isDraft) { - const matchFormEqual = isEqual(this.formObj, this.lastFetchedSpec.matchForm); - const targetFormEqual = isEqual(this.targetFormObj, this.lastFetchedSpec.targetForm); + const matchFormEqual = isEqual(this.formObj, this.lastFetchedSpec[MATCH_FORM_KEY]); + const targetFormEqual = isEqual(this.targetFormObj, this.lastFetchedSpec[MATCH_FORM_KEY]); return !matchFormEqual || !targetFormEqual; } return false; @@ -164,7 +172,7 @@ export default { this.currentBulkChange = mainEntity; this.currentBulkChange.label = '-' + this.getDateString(); - this.currentSpec = this.currentBulkChange.bulkChangeSpecification; + this.currentSpec = this.currentBulkChange[CHANGE_SPEC_KEY]; //TODO: Allow differing initial match and target forms. + Make it work with appended _ids. this.record = record; @@ -172,9 +180,9 @@ export default { DataUtil.fetchMissingLinkedToQuoted(this.currentBulkChange, this.$store); this.setActive(this.steps[0]); - const initialForm = appendIds(mainEntity.bulkChangeSpecification.matchForm); - this.currentSpec.matchForm = initialForm; - this.currentSpec.targetForm = initialForm; + const initialForm = appendIds(mainEntity[CHANGE_SPEC_KEY][MATCH_FORM_KEY]); + this.currentSpec[MATCH_FORM_KEY] = initialForm; + this.currentSpec[TARGET_FORM_KEY] = initialForm; this.setInspectorData(initialForm); this.$store.dispatch('pushInspectorEvent', { name: 'record-control', @@ -184,10 +192,10 @@ export default { initFromRecord() { this.setActive(this.steps[0]); // FIXME: remove emptyTemplate - const initial = emptyTemplate.mainEntity.bulkChangeSpecification.matchForm; + const initial = emptyTemplate.mainEntity[CHANGE_SPEC_KEY][MATCH_FORM_KEY]; this.setInspectorData(initial); - this.currentSpec.matchForm = initial; - this.currentSpec.targetForm = initial; //FIXME: to avoid undefined on init + this.currentSpec[MATCH_FORM_KEY] = initial; + this.currentSpec[TARGET_FORM_KEY] = initial; //FIXME: to avoid undefined on init this.fetchRecord(this.documentId); }, fetchRecord(fnurgel) { @@ -217,16 +225,16 @@ export default { if (typeof result !== 'undefined') { const bulkChange = LxlDataUtil.splitJson(result); this.currentBulkChange = bulkChange.mainEntity; - this.currentSpec = this.currentBulkChange.bulkChangeSpecification; + this.currentSpec = this.currentBulkChange[CHANGE_SPEC_KEY]; this.record = bulkChange.record; this.lastFetchedSpec = cloneDeep(this.currentSpec); if (this.isActive('form')) { - this.setInspectorData(this.currentSpec.matchForm); + this.setInspectorData(this.currentSpec[MATCH_FORM_KEY]); } else if (this.isActive('targetForm')){ - this.setInspectorData(this.currentSpec.targetForm) + this.setInspectorData(this.currentSpec[TARGET_FORM_KEY]) } else { - this.setInspectorData(this.currentSpec.matchForm) + this.setInspectorData(this.currentSpec[MATCH_FORM_KEY]) } if (this.isDraft) { this.$store.dispatch('pushInspectorEvent', { @@ -256,18 +264,18 @@ export default { }, onInactiveForm() { let form = DataUtil.appendIds(cloneDeep(this.inspector.data.mainEntity)); - if (isEqual(form, this.currentSpec.matchForm)) { - this.setInspectorData(this.currentSpec.targetForm); + if (isEqual(form, this.currentSpec[MATCH_FORM_KEY])) { + this.setInspectorData(this.currentSpec[TARGET_FORM_KEY]); } else { this.setInspectorData(form); - this.currentSpec.matchForm = form; + this.currentSpec[MATCH_FORM_KEY] = form; } }, onInactiveTargetForm() { if (this.activeStep === 'form') { - this.setInspectorData(this.currentSpec.matchForm); + this.setInspectorData(this.currentSpec[MATCH_FORM_KEY]); } - this.currentSpec.targetForm = cloneDeep(this.inspector.data.mainEntity); + this.currentSpec[TARGET_FORM_KEY] = cloneDeep(this.inspector.data.mainEntity); }, reset() { this.$store.dispatch('setInspectorStatusValue', { @@ -331,11 +339,7 @@ export default { this.showConfirmRunModal = true; }, toggleExportAffected() { - if (this.shouldExportAffected) { - this.currentBulkChange.bulkChangeMetaChanges = "SilentBulkChange"; - } else { - this.currentBulkChange.bulkChangeMetaChanges = "LoudBulkChange"; - } + this.currentBulkChange[SHOULD_UPDATE_TIMESTAMP_KEY] = !!this.shouldExportAffected; }, save() { this.resetLastAdded(); @@ -367,8 +371,8 @@ export default { const formChangeset = result.changeSets[1]; const [formDisplayData, formDisplayPaths] = HistoryUtil.buildDisplayData( - this.currentSpec.matchForm, - this.currentSpec.targetForm, + this.currentSpec[MATCH_FORM_KEY], + this.currentSpec[TARGET_FORM_KEY], formChangeset.addedPaths, formChangeset.removedPaths, (s) => StringUtil.getLabelByLang(s, this.user.settings.language, this.resources), @@ -422,12 +426,12 @@ export default { }, doRun() { this.closeConfirmRunModal(); - this.setRunStatus('ReadyBulkChange'); + this.setRunStatus(Status.Ready); this.save(); this.setActive('preview'); }, setAsDraft() { - this.setRunStatus('DraftBulkChange'); + this.setRunStatus(Status.Draft); }, openIdListModal() { this.idListUri = ''; @@ -463,7 +467,7 @@ export default { this.getPreviewFromUrl(`${this.settings.apiPath}${this.previousPreviewLink['@id']}`); }, setRunStatus(status) { - this.currentBulkChange.bulkChangeStatus = status; + this.currentBulkChange[STATUS_KEY] = status; }, resetPreviewData() { this.fullPreview = {}; diff --git a/cataloging/src/components/care/preview.vue b/cataloging/src/components/care/preview.vue index 07a4a3b06..b35636049 100644 --- a/cataloging/src/components/care/preview.vue +++ b/cataloging/src/components/care/preview.vue @@ -7,6 +7,7 @@ import EntitySummary from "@/components/shared/entity-summary.vue"; import {asFnurgelLink, translatePhrase} from "@/utils/filters.js"; import {offset} from "@floating-ui/dom"; import * as StringUtil from "../../../../lxljs/string.js"; +import { Status } from "@/utils/bulk.js"; export default { name: 'preview', @@ -79,7 +80,7 @@ export default { } }, completedLabel() { - return StringUtil.getLabelByLang('CompletedBulkChange', this.user.settings.language, this.resources) + return StringUtil.getLabelByLang(Status.Completed, this.user.settings.language, this.resources) } }, emits: ['onInactive', 'onActive'], diff --git a/cataloging/src/components/care/templates/empty.json b/cataloging/src/components/care/templates/empty.json index 2fcb62ab1..c0e302796 100644 --- a/cataloging/src/components/care/templates/empty.json +++ b/cataloging/src/components/care/templates/empty.json @@ -1,17 +1,17 @@ { "mainEntity": { - "@type": "BulkChange", + "@type": "bulk:Job", "@id": "https://id.kb.se/TEMPID#it", "label": "", "comment": "", - "bulkChangeStatus": "DraftBulkChange", - "bulkChangeMetaChanges": "SilentBulkChange", - "bulkChangeSpecification": { - "@type": "FormSpecification", - "matchForm": { + "bulk:status": "bulk:Draft", + "bulk:shouldUpdateModifiedTimestamp": false, + "bulk:changeSpec": { + "@type": "bulk:Update", + "bulk:matchForm": { "@type": "Instance" }, - "targetForm": { + "bulk:targetForm": { "@type": "Instance" } } diff --git a/cataloging/src/components/mixins/item-mixin.vue b/cataloging/src/components/mixins/item-mixin.vue index 53f97dea3..ec023bbaf 100644 --- a/cataloging/src/components/mixins/item-mixin.vue +++ b/cataloging/src/components/mixins/item-mixin.vue @@ -5,7 +5,7 @@ import * as VocabUtil from 'lxljs/vocab'; import * as StringUtil from 'lxljs/string'; import * as DataUtil from '@/utils/data'; import * as RecordUtil from '@/utils/record'; -import { DELETE_ON_SAVE } from "@/store"; +import { JOB_TYPE } from "@/utils/bulk.js"; export default { props: { @@ -184,7 +184,7 @@ export default { const uriParts = this.recordId.split('/'); const fnurgel = uriParts[uriParts.length - 1]; - if (this.recordType === 'BulkChange') { + if (this.recordType === JOB_TYPE) { return `/directory-care/bulkchanges/${fnurgel}`; } diff --git a/cataloging/src/components/search/search-form.vue b/cataloging/src/components/search/search-form.vue index 6e086c3c4..97f943923 100644 --- a/cataloging/src/components/search/search-form.vue +++ b/cataloging/src/components/search/search-form.vue @@ -8,6 +8,7 @@ import PropertyMappings from '@/resources/json/propertymappings.json'; import { buildQueryString } from '@/utils/http'; import { translatePhrase } from '@/utils/filters'; import RemoteDatabases from '@/components/search/remote-databases.vue'; +import { JOB_TYPE } from "@/utils/bulk.js"; export default { name: 'search-form', @@ -199,7 +200,7 @@ export default { ]), dataSetFilters() { if (this.user.settings.activeSigel === 'SEK') { - const extraFilter = { value: 'BulkChange', label: 'Bulk change' }; + const extraFilter = { value: JOB_TYPE, label: 'Bulk change' }; return [...this.settings.dataSetFilters.libris, extraFilter]; } else { return this.settings.dataSetFilters.libris; diff --git a/cataloging/src/components/shared/entity-summary.vue b/cataloging/src/components/shared/entity-summary.vue index 6190c99d8..2e94647d3 100644 --- a/cataloging/src/components/shared/entity-summary.vue +++ b/cataloging/src/components/shared/entity-summary.vue @@ -11,6 +11,7 @@ import TypeIcon from '@/components/shared/type-icon.vue'; import SummaryNode from '@/components/shared/summary-node.vue'; import IdPill from '@/components/shared/id-pill.vue'; import LensMixin from '../mixins/lens-mixin.vue'; +import { JOB_TYPE } from "@/utils/bulk.js"; export default { mixins: [LensMixin, OverflowMixin], @@ -186,7 +187,7 @@ export default { const uriParts = this.recordId.split('/'); const fnurgel = uriParts[uriParts.length - 1]; - if (this.recordType === 'BulkChange') { + if (this.recordType === JOB_TYPE) { return `/directory-care/bulkchanges/${fnurgel}`; } diff --git a/cataloging/src/resources/json/combinedTemplates.json b/cataloging/src/resources/json/combinedTemplates.json index eb0ed18f6..8fccc490f 100644 --- a/cataloging/src/resources/json/combinedTemplates.json +++ b/cataloging/src/resources/json/combinedTemplates.json @@ -4203,19 +4203,19 @@ "@id": "instance", "value": { "mainEntity": { - "@type": "BulkChange", + "@type": "bulk:Job", "@id": "https://id.kb.se/TEMPID#it", "label": "", "comment": "", - "bulkChangeStatus": "DraftBulkChange", - "bulkChangeMetaChanges": "SilentBulkChange", - "bulkChangeSpecification": { - "@type": "FormSpecification", - "matchForm": { + "bulk:status": "bulk:Draft", + "bulk:shouldUpdateModifiedTimestamp": false, + "bulk:changeSpec": { + "@type": "bulk:Update", + "bulk:matchForm": { "@type": "Instance", "_match": ["Subtypes"] }, - "targetForm": { + "bulk:targetForm": { "@type": "Instance" } } @@ -4236,19 +4236,19 @@ "@id": "work", "value": { "mainEntity": { - "@type": "BulkChange", + "@type": "bulk:Job", "@id": "https://id.kb.se/TEMPID#it", "label": "", "comment": "", - "bulkChangeStatus": "DraftBulkChange", - "bulkChangeMetaChanges": "SilentBulkChange", - "bulkChangeSpecification": { - "@type": "FormSpecification", - "matchForm": { + "bulk:status": "bulk:Draft", + "bulk:shouldUpdateModifiedTimestamp": false, + "bulk:changeSpec": { + "@type": "bulk:Update", + "bulk:matchForm": { "@type": "Work", "_match": ["Subtypes"] }, - "targetForm": { + "bulk:targetForm": { "@type": "Work" } } @@ -4269,19 +4269,19 @@ "@id": "agent", "value": { "mainEntity": { - "@type": "BulkChange", + "@type": "bulk:Job", "@id": "https://id.kb.se/TEMPID#it", "label": "", "comment": "", - "bulkChangeStatus": "DraftBulkChange", - "bulkChangeMetaChanges": "SilentBulkChange", - "bulkChangeSpecification": { - "@type": "FormSpecification", - "matchForm": { + "bulk:status": "bulk:Draft", + "bulk:shouldUpdateModifiedTimestamp": false, + "bulk:changeSpec": { + "@type": "bulk:Update", + "bulk:matchForm": { "@type": "Agent", "_match": ["Subtypes"] }, - "targetForm": { + "bulk:targetForm": { "@type": "Agent" } } @@ -4302,19 +4302,19 @@ "@id": "concept", "value": { "mainEntity": { - "@type": "BulkChange", + "@type": "bulk:Job", "@id": "https://id.kb.se/TEMPID#it", "label": "", "comment": "", - "bulkChangeStatus": "DraftBulkChange", - "bulkChangeMetaChanges": "SilentBulkChange", - "bulkChangeSpecification": { - "@type": "FormSpecification", - "matchForm": { + "bulk:status": "bulk:Draft", + "bulk:shouldUpdateModifiedTimestamp": false, + "bulk:changeSpec": { + "@type": "bulk:Update", + "bulk:matchForm": { "@type": "Concept", "_match": ["Subtypes"] }, - "targetForm": { + "bulk:targetForm": { "@type": "Concept" } } @@ -4335,19 +4335,19 @@ "@id": "item", "value": { "mainEntity": { - "@type": "BulkChange", + "@type": "bulk:Job", "@id": "https://id.kb.se/TEMPID#it", "label": "", "comment": "", - "bulkChangeStatus": "DraftBulkChange", - "bulkChangeMetaChanges": "SilentBulkChange", - "bulkChangeSpecification": { - "@type": "FormSpecification", - "matchForm": { + "bulk:status": "bulk:Draft", + "bulk:shouldUpdateModifiedTimestamp": false, + "bulk:changeSpec": { + "@type": "bulk:Update", + "bulk:matchForm": { "@type": "Item", "_match": ["Subtypes"] }, - "targetForm": { + "bulk:targetForm": { "@type": "Item" } } @@ -4368,19 +4368,19 @@ "@id": "resource", "value": { "mainEntity": { - "@type": "BulkChange", + "@type": "bulk:Job", "@id": "https://id.kb.se/TEMPID#it", "label": "", "comment": "", - "bulkChangeStatus": "DraftBulkChange", - "bulkChangeMetaChanges": "SilentBulkChange", - "bulkChangeSpecification": { - "@type": "FormSpecification", - "matchForm": { + "bulk:status": "bulk:Draft", + "bulk:shouldUpdateModifiedTimestamp": false, + "bulk:changeSpec": { + "@type": "bulk:Update", + "bulk:matchForm": { "@type": "Resource", "_match": ["Subtypes"] }, - "targetForm": { + "bulk:targetForm": { "@type": "Resource" } }