From d63983188207e055c632d36c74e969185f5ad031 Mon Sep 17 00:00:00 2001 From: kwahlin Date: Tue, 12 Nov 2024 14:55:58 +0100 Subject: [PATCH 01/19] Update merge template --- cataloging/src/resources/json/combinedTemplates.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cataloging/src/resources/json/combinedTemplates.json b/cataloging/src/resources/json/combinedTemplates.json index f97300606..1fb05aa25 100644 --- a/cataloging/src/resources/json/combinedTemplates.json +++ b/cataloging/src/resources/json/combinedTemplates.json @@ -4416,8 +4416,14 @@ "bulk:shouldUpdateModifiedTimestamp": false, "bulk:changeSpec": { "@type": "bulk:Merge", - "bulk:deprecate": [], - "bulk:keep": null + "bulk:deprecate": { + "@type": "URI", + "value": "" + }, + "bulk:keep": { + "@type": "URI", + "value": "" + } } }, "quoted": {}, From fb04237a16f558cc5e7ea869fdb7acf483784c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Rosenstr=C3=B6m?= Date: Tue, 12 Nov 2024 17:00:03 +0100 Subject: [PATCH 02/19] fix(cataloging-bulkchanges): keyboard shortcuts for next and previous preview --- .../components/inspector/bulkchange-toolbar.vue | 14 ++++++++++---- cataloging/src/resources/json/keybindings.json | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cataloging/src/components/inspector/bulkchange-toolbar.vue b/cataloging/src/components/inspector/bulkchange-toolbar.vue index c47f5c00a..0877033e3 100644 --- a/cataloging/src/components/inspector/bulkchange-toolbar.vue +++ b/cataloging/src/components/inspector/bulkchange-toolbar.vue @@ -86,6 +86,12 @@ export default { case 'previous': this.previous(); break; + case 'next-preview': + this.nextPreview(); + break; + case 'previous-preview': + this.previousPreview(); + break; case 'undo': this.undo(); break; @@ -296,8 +302,8 @@ export default { v-if="lastItemActive && !finished" class="Toolbar-btn btn btn-default toolbar-button" :disabled="!hasNext" - v-tooltip.left="`${translatePhrase('Next')} (${getKeybindText('next')})`" - @click="nextPreview" + v-tooltip.left="`${translatePhrase('Next')} (${getKeybindText('next-preview')})`" + @click="formControl('next-preview')" :aria-label="translatePhrase('Next')"> @@ -306,8 +312,8 @@ export default { v-if="lastItemActive && !finished" class="Toolbar-btn btn btn-default toolbar-button" :disabled="!hasPrevious" - v-tooltip.left="`${translatePhrase('Previous')} (${getKeybindText('previous')})`" - @click="previousPreview" + v-tooltip.left="`${translatePhrase('Previous')} (${getKeybindText('previous-preview')})`" + @click="formControl('previous-preview')" :aria-label="translatePhrase('Previous')"> diff --git a/cataloging/src/resources/json/keybindings.json b/cataloging/src/resources/json/keybindings.json index 0a453ddb6..0822a8b70 100644 --- a/cataloging/src/resources/json/keybindings.json +++ b/cataloging/src/resources/json/keybindings.json @@ -19,6 +19,8 @@ "alt+b": "add-holding", "alt+s": "focus-main-search", "alt+down": "next", - "alt+up": "previous" + "alt+up": "previous", + "alt+right": "next-preview", + "alt+left": "previous-preview" } } From e51dd518046a0c88e2244c1870d9dfa7505f0d6b Mon Sep 17 00:00:00 2001 From: kwahlin Date: Tue, 12 Nov 2024 17:33:41 +0100 Subject: [PATCH 03/19] Update removeTopicSubdivision template --- cataloging/src/resources/json/combinedTemplates.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cataloging/src/resources/json/combinedTemplates.json b/cataloging/src/resources/json/combinedTemplates.json index 1fb05aa25..abef739be 100644 --- a/cataloging/src/resources/json/combinedTemplates.json +++ b/cataloging/src/resources/json/combinedTemplates.json @@ -4662,8 +4662,14 @@ "bulk:changeSpec": { "@type": "bulk:Other", "bulk:script": "removeTopicSubdivision", - "bulk:deprecate": [], - "bulk:keep": null + "bulk:deprecate": { + "@type": "URI", + "value": "" + }, + "bulk:keep": { + "@type": "URI", + "value": "" + } } }, "quoted": {}, From 36eff737a9aab6d5baa9939f3bd85f90e2c394c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Rosenstr=C3=B6m?= Date: Wed, 13 Nov 2024 09:03:12 +0100 Subject: [PATCH 04/19] fix(cataloging-bulkchanges): Allow unspecified type on top level --- .../components/inspector/bulkchange-toolbar.vue | 8 -------- .../src/resources/json/combinedTemplates.json | 14 +++++++------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/cataloging/src/components/inspector/bulkchange-toolbar.vue b/cataloging/src/components/inspector/bulkchange-toolbar.vue index 0877033e3..1ffb7138a 100644 --- a/cataloging/src/components/inspector/bulkchange-toolbar.vue +++ b/cataloging/src/components/inspector/bulkchange-toolbar.vue @@ -191,14 +191,6 @@ export default { 'settings', 'status', ]), - allowed() { - return VocabUtil.getPropertiesFromArray( - this.formObj['@type'], - this.resources.vocabClasses, - this.resources.vocabProperties, - this.resources.context, - ); - }, showRecord() { return this.status.showRecord; }, diff --git a/cataloging/src/resources/json/combinedTemplates.json b/cataloging/src/resources/json/combinedTemplates.json index abef739be..fd3066c5b 100644 --- a/cataloging/src/resources/json/combinedTemplates.json +++ b/cataloging/src/resources/json/combinedTemplates.json @@ -4370,8 +4370,8 @@ } }, "resource": { - "label": "✎ Resurs", - "description": "Ändra resurs", + "label": "✎ Ospecificerad typ", + "description": "Ändra ospecificerad typ", "@id": "resource", "value": { "mainEntity": { @@ -4384,11 +4384,11 @@ "bulk:changeSpec": { "@type": "bulk:Update", "bulk:matchForm": { - "@type": "Resource", + "@type": "bulk:Any", "bulk:matchingMode": ["bulk:Subtypes"] }, "bulk:targetForm": { - "@type": "Resource" + "@type": "bulk:Any" } } }, @@ -4437,8 +4437,8 @@ } }, "removeResource": { - "label": "\uD83D\uDDD1 Resurs", - "description": "Radera resurs", + "label": "\uD83D\uDDD1 Ospecificerad typ", + "description": "Radera ospecificerad typ", "@id": "removeResource", "value": { "mainEntity": { @@ -4451,7 +4451,7 @@ "bulk:changeSpec": { "@type": "bulk:Delete", "bulk:matchForm": { - "@type": "Resource", + "@type": "bulk:Any", "bulk:matchingMode": [ "bulk:Subtypes" ] From c05bdbc44d1215d12219393def8132c72180116b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Rosenstr=C3=B6m?= Date: Wed, 13 Nov 2024 09:39:00 +0100 Subject: [PATCH 05/19] fix(cataloging-bulkchanges): wait until ES is ready for run poll --- cataloging/src/components/care/bulk-changes.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cataloging/src/components/care/bulk-changes.vue b/cataloging/src/components/care/bulk-changes.vue index 1274a6bbf..9c6e256bd 100644 --- a/cataloging/src/components/care/bulk-changes.vue +++ b/cataloging/src/components/care/bulk-changes.vue @@ -642,10 +642,9 @@ export default { } if (this.isReady) { this.setActive('preview'); - this.triggerRunBulkChange(); setTimeout(() => { this.triggerRunBulkChange(); - }, 5000); + }, 1000); } this.$nextTick(() => { this.$store.dispatch('setInspectorStatusValue', { property: 'saving', value: false }); From e4c5f3f5919f0f573df1f66a47a7ddd02b8442f8 Mon Sep 17 00:00:00 2001 From: Johan Bisse Mattsson Date: Wed, 13 Nov 2024 11:24:57 +0100 Subject: [PATCH 06/19] chore(supersearch): Add GitHub workflow file --- .github/workflows/supersearch.yml | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/supersearch.yml diff --git a/.github/workflows/supersearch.yml b/.github/workflows/supersearch.yml new file mode 100644 index 000000000..07cf66b6e --- /dev/null +++ b/.github/workflows/supersearch.yml @@ -0,0 +1,34 @@ +name: supersearch +on: + push: + branches: [develop] + paths: + - 'packages/supersearch/**' + pull_request: + branches: [develop] + paths: + - 'packages/supersearch/**' +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./packages/supersearch + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + run: npm run test + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 From 6f97a19d1319543814dd0e2d2d0038bf5950825b Mon Sep 17 00:00:00 2001 From: Johan Bisse Mattsson Date: Wed, 13 Nov 2024 11:25:36 +0100 Subject: [PATCH 07/19] chore(lxl-querylang): Add GitHub workflow file --- .../workflows/codemirror-lang-lxlquery.yml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/codemirror-lang-lxlquery.yml diff --git a/.github/workflows/codemirror-lang-lxlquery.yml b/.github/workflows/codemirror-lang-lxlquery.yml new file mode 100644 index 000000000..b351b06ba --- /dev/null +++ b/.github/workflows/codemirror-lang-lxlquery.yml @@ -0,0 +1,26 @@ +name: codemirror-lang-lxlquery +on: + push: + branches: [develop] + paths: + - 'packages/codemirror-lang-lxlquery/**' + pull_request: + branches: [develop] + paths: + - 'packages/codemirror-lang-lxlquery/**' +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./packages/codemirror-lang-lxlquery + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - name: Install dependencies + run: npm ci + - name: Run tests + run: npm run test From 5ee609374e1b561e7ef044801874342f66a2f15e Mon Sep 17 00:00:00 2001 From: Johan Bisse Mattsson Date: Wed, 13 Nov 2024 11:26:02 +0100 Subject: [PATCH 08/19] chore(lxl-web): Specify paths to run GitHub workflow on --- .github/workflows/lxl-web.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/lxl-web.yml b/.github/workflows/lxl-web.yml index 11fa6f048..8fa5f9b1a 100644 --- a/.github/workflows/lxl-web.yml +++ b/.github/workflows/lxl-web.yml @@ -2,8 +2,16 @@ name: lxl-web on: push: branches: [develop] + paths: + - 'lxl-web/**' + - 'lxljs/**' + - 'packages/**' pull_request: branches: [develop] + paths: + - 'lxl-web/**' + - 'lxljs/**' + - 'packages/**' jobs: test: timeout-minutes: 60 From d2a72214e9b0a72ab42ee9ba40cd019c8076a6a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Rosenstr=C3=B6m?= Date: Wed, 13 Nov 2024 14:16:17 +0100 Subject: [PATCH 09/19] fix(cataloging-bulkchanges): spinner when preview is initializing --- .../src/components/care/bulk-changes.vue | 11 +++-- cataloging/src/components/care/preview.vue | 45 +++++++++++-------- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/cataloging/src/components/care/bulk-changes.vue b/cataloging/src/components/care/bulk-changes.vue index 9c6e256bd..47c2b6211 100644 --- a/cataloging/src/components/care/bulk-changes.vue +++ b/cataloging/src/components/care/bulk-changes.vue @@ -79,6 +79,7 @@ export default { idListUri: '', idListTempPath: '', currentPreviewUrl: null, + initializingPreview: false, }; }, computed: { @@ -442,6 +443,7 @@ export default { this.saveBulkChange(); }, getPreview(fnurgel) { + this.initializingPreview = true; const baseUri = this.settings.dataPath; const offset = 0; const limit = 1; @@ -451,8 +453,6 @@ export default { getPreviewFromUrl(fetchUrl) { this.currentPreviewUrl = fetchUrl; fetch(fetchUrl).then((response) => response.json()).then((result) => { - // const agents = (this.changeSets || []).map((c) => c.agent).filter((a) => a); - // DataUtil.fetchMissingLinkedToQuoted(agents, this.$store); // Form preview if (typeof result.changeSets !== 'undefined') { @@ -482,7 +482,6 @@ export default { } else { this.completePreview = true; } - if (this.totalItems === 0 || typeof this.totalItems === 'undefined') { this.resetPreviewData(); return; @@ -515,6 +514,10 @@ export default { DataUtil.fetchMissingLinkedToQuoted(this.fullPreviewData, this.$store); this.loadingPreview.next = false; this.loadingPreview.previous = false; + this.initializingPreview = false; + }, (error) => { + this.initializingPreview = false; + console.error('Failed to fetch preview', error); }); }, async triggerRunBulkChange() { @@ -575,6 +578,7 @@ export default { this.fullPreview = {}; this.fullPreviewData = {}; this.fullPreviewDiff = {}; + this.initializingPreview = false; }, async saveBulkChange() { try { @@ -824,6 +828,7 @@ export default { :total-items="totalItems" :finished="isFinished" :has-unsaved="hasUnsavedChanges" + :initializing-preview="initializingPreview" @onActive="focusPreview" /> diff --git a/cataloging/src/components/care/preview.vue b/cataloging/src/components/care/preview.vue index ace5ba9e2..a13616efa 100644 --- a/cataloging/src/components/care/preview.vue +++ b/cataloging/src/components/care/preview.vue @@ -5,12 +5,11 @@ import {isEmpty} from 'lodash-es'; import ItemEntity from "@/components/inspector/item-entity.vue"; import EntitySummary from "@/components/shared/entity-summary.vue"; import {translatePhrase} from "@/utils/filters.js"; -import * as StringUtil from "../../../../lxljs/string.js"; -import { Status, Type } from "@/utils/bulk.js"; +import Spinner from "../shared/spinner.vue"; export default { name: 'preview', - components: {EntitySummary, ItemEntity, EntityForm }, + components: {Spinner, EntitySummary, ItemEntity, EntityForm }, data() { return { selected: true, @@ -54,6 +53,10 @@ export default { type: Boolean, default: true, }, + initializingPreview: { + type: Boolean, + default: false + } }, computed: { ...mapGetters([ @@ -118,22 +121,28 @@ export default { {{ this.title }}
- {{ this.noHitsLabel }} -
-
- +
+ +
+
+ {{ this.noHitsLabel }} +
+
+ +
+
-
From cea3b53bf2cc45d2ad54ffc6305f9917dc5e8671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Rosenstr=C3=B6m?= Date: Wed, 13 Nov 2024 14:27:43 +0100 Subject: [PATCH 10/19] fix(cataloging-bulkchanges): Poll on status ready when fetching record instead --- cataloging/src/components/care/bulk-changes.vue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cataloging/src/components/care/bulk-changes.vue b/cataloging/src/components/care/bulk-changes.vue index 47c2b6211..2e9e36d90 100644 --- a/cataloging/src/components/care/bulk-changes.vue +++ b/cataloging/src/components/care/bulk-changes.vue @@ -319,6 +319,12 @@ export default { value: 'start-edit', }); } + if (this.isReady) { + this.setActive('preview'); + setTimeout(() => { + this.triggerRunBulkChange(); + }, 1000); + } DataUtil.fetchMissingLinkedToQuoted(this.currentBulkChange, this.$store); this.getPreview(fnurgel); this.isSaving = false; @@ -644,12 +650,6 @@ export default { this.fetchRecord(this.documentId); this.warnOnSave(); } - if (this.isReady) { - this.setActive('preview'); - setTimeout(() => { - this.triggerRunBulkChange(); - }, 1000); - } this.$nextTick(() => { this.$store.dispatch('setInspectorStatusValue', { property: 'saving', value: false }); this.$store.dispatch('setInspectorStatusValue', { property: 'isNew', value: false }); From d849523c178a887fc5a0b9fdf114fb90263fc638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Rosenstr=C3=B6m?= Date: Thu, 14 Nov 2024 09:49:25 +0100 Subject: [PATCH 11/19] fix(cataloging-bulkchanges): translate loading preview spinner text --- cataloging/src/resources/json/i18n.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cataloging/src/resources/json/i18n.json b/cataloging/src/resources/json/i18n.json index bf0aafba8..9d79edc90 100644 --- a/cataloging/src/resources/json/i18n.json +++ b/cataloging/src/resources/json/i18n.json @@ -458,6 +458,7 @@ "Remove records" : "Ta bort poster", "Create records" : "Skapa poster", "Merge" : "Slå ihop", - "Change" : "Ändring" + "Change" : "Ändring", + "Fetching preview" : "Hämtar förhandsgranskning" } } From aec1bac35827a7acae7e77f4b6247b8fb2366bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olov=20Ylinenp=C3=A4=C3=A4?= <51744858+olovy@users.noreply.github.com> Date: Thu, 14 Nov 2024 09:52:55 +0100 Subject: [PATCH 12/19] Display bulk executions / reports (#1161) --- .../src/components/care/bulk-changes.vue | 23 +++++++++++++++++-- .../src/components/inspector/entity-form.vue | 5 ++++ cataloging/src/utils/bulk.js | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/cataloging/src/components/care/bulk-changes.vue b/cataloging/src/components/care/bulk-changes.vue index 2e9e36d90..136fac8c2 100644 --- a/cataloging/src/components/care/bulk-changes.vue +++ b/cataloging/src/components/care/bulk-changes.vue @@ -5,7 +5,7 @@ import MergeSpec from '@/components/care/merge-spec.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, pickBy } from 'lodash-es'; import toolbar from "@/components/inspector/bulkchange-toolbar.vue"; import { labelByLang, translatePhrase } from "@/utils/filters.js"; import * as LayoutUtil from '@/utils/layout'; @@ -29,12 +29,14 @@ import { Status, TARGET_FORM_KEY, VALUE_FROM_KEY, - Type + Type, EXECUTION_KEY } from "@/utils/bulk.js"; +import EntityForm from "@/components/inspector/entity-form.vue"; export default { name: 'bulk-changes.vue', components: { + EntityForm, ReverseRelations, Inspector, toolbar, @@ -225,6 +227,13 @@ export default { specType() { return this.currentSpec['@type']; }, + executionData() { + return pickBy( + this.currentBulkChange || {}, function (_, key) { + return ['@type', EXECUTION_KEY].includes(key); + } + ); + }, isInitialized() { return !isEmpty(this.currentSpec) && typeof this.currentSpec !== 'undefined'; } @@ -859,6 +868,16 @@ export default {
+ +
+
diff --git a/cataloging/src/components/inspector/entity-form.vue b/cataloging/src/components/inspector/entity-form.vue index 42e49c6e4..b497b2ad4 100644 --- a/cataloging/src/components/inspector/entity-form.vue +++ b/cataloging/src/components/inspector/entity-form.vue @@ -45,6 +45,10 @@ export default { type: Boolean, default: false, }, + hideTopLevelFieldNames: { + type: Boolean, + default: false, + }, }, data() { return { @@ -159,6 +163,7 @@ export default { :field-value="v" :parent-path="editingObject" :showBulkchangeActions="showBulkchangeActions" + :show-key="!hideTopLevelFieldNames" />
diff --git a/cataloging/src/utils/bulk.js b/cataloging/src/utils/bulk.js
index 3ffa224d9..f263ddab8 100644
--- a/cataloging/src/utils/bulk.js
+++ b/cataloging/src/utils/bulk.js
@@ -5,6 +5,7 @@ export const MATCH_FORM_KEY = 'bulk:matchForm';
 export const SHOULD_UPDATE_TIMESTAMP_KEY = 'bulk:shouldUpdateModifiedTimestamp';
 export const CHANGE_SPEC_KEY = 'bulk:changeSpec';
 export const TARGET_FORM_KEY = 'bulk:targetForm';
+export const EXECUTION_KEY = 'bulk:execution';
 
 export class Status {
   static Draft = 'bulk:Draft';

From 2abce7de4566e64d9c664b6a7d2f1b0dca628d0e Mon Sep 17 00:00:00 2001
From: kwahlin 
Date: Thu, 14 Nov 2024 10:41:08 +0100
Subject: [PATCH 13/19] Wrap bulk:deprecate value in array

---
 cataloging/src/resources/json/combinedTemplates.json | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/cataloging/src/resources/json/combinedTemplates.json b/cataloging/src/resources/json/combinedTemplates.json
index fd3066c5b..2799bc30c 100644
--- a/cataloging/src/resources/json/combinedTemplates.json
+++ b/cataloging/src/resources/json/combinedTemplates.json
@@ -4662,10 +4662,12 @@
           "bulk:changeSpec": {
             "@type": "bulk:Other",
             "bulk:script": "removeTopicSubdivision",
-            "bulk:deprecate": {
-              "@type": "URI",
-              "value": ""
-            },
+            "bulk:deprecate": [
+              {
+                "@type": "URI",
+                "value": ""
+              }
+            ],
             "bulk:keep": {
               "@type": "URI",
               "value": ""

From 4f818e83bef5b1800be6aab52e618725b2241d25 Mon Sep 17 00:00:00 2001
From: kwahlin 
Date: Thu, 14 Nov 2024 10:46:56 +0100
Subject: [PATCH 14/19] Wrap bulk:deprecate value in array 2

---
 cataloging/src/resources/json/combinedTemplates.json | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/cataloging/src/resources/json/combinedTemplates.json b/cataloging/src/resources/json/combinedTemplates.json
index 2799bc30c..8c1ad9685 100644
--- a/cataloging/src/resources/json/combinedTemplates.json
+++ b/cataloging/src/resources/json/combinedTemplates.json
@@ -4416,10 +4416,12 @@
           "bulk:shouldUpdateModifiedTimestamp": false,
           "bulk:changeSpec": {
             "@type": "bulk:Merge",
-            "bulk:deprecate": {
-              "@type": "URI",
-              "value": ""
-            },
+            "bulk:deprecate": [
+              {
+                "@type": "URI",
+                "value": ""
+              }
+            ],
             "bulk:keep": {
               "@type": "URI",
               "value": ""

From 1be637907594064b5d2629fb03ab15d5ddf52417 Mon Sep 17 00:00:00 2001
From: Johan Bisse Mattsson 
Date: Thu, 14 Nov 2024 11:01:23 +0100
Subject: [PATCH 15/19] LWS-260: Codemirror extension for submitting forms on
 enter key (#1155)

* Add CodeMirror extension for submitting form on enter keypress

* Add test

* Add optional form attribute

* Add hidden textarea inside component for name and value attributes
---
 lxl-web/src/lib/components/Search.svelte      | 13 +++++--
 packages/supersearch/e2e/supersearch.spec.ts  | 17 +++++++++
 .../src/lib/components/SuperSearch.svelte     |  9 ++++-
 .../lib/extensions/submitFormOnEnterKey.ts    | 37 +++++++++++++++++++
 packages/supersearch/src/routes/+page.svelte  | 17 ++++++++-
 .../supersearch/src/routes/test1/+page.svelte |  1 +
 .../supersearch/src/routes/test2/+page.svelte |  1 +
 7 files changed, 88 insertions(+), 7 deletions(-)
 create mode 100644 packages/supersearch/e2e/supersearch.spec.ts
 create mode 100644 packages/supersearch/src/lib/extensions/submitFormOnEnterKey.ts
 create mode 100644 packages/supersearch/src/routes/test1/+page.svelte
 create mode 100644 packages/supersearch/src/routes/test2/+page.svelte

diff --git a/lxl-web/src/lib/components/Search.svelte b/lxl-web/src/lib/components/Search.svelte
index 050b78ed8..fdcd82546 100644
--- a/lxl-web/src/lib/components/Search.svelte
+++ b/lxl-web/src/lib/components/Search.svelte
@@ -15,8 +15,8 @@
 	let q = $page.params.fnurgel
 		? '' //don't reflect related search on resource pages
 		: showAdvanced
-			? $page.url.searchParams.get('_q')?.trim()
-			: $page.url.searchParams.get('_i')?.trim();
+			? $page.url.searchParams.get('_q')?.trim() || ''
+			: $page.url.searchParams.get('_i')?.trim() || '';
 
 	let params = getSortedSearchParams(addDefaultSearchParams($page.url.searchParams));
 	// Always reset these params on new search
@@ -30,7 +30,7 @@
 		/** Update input value after navigation on /find route */
 		if (to?.url) {
 			let param = showAdvanced ? '_q' : '_i';
-			q = $page.params.fnurgel ? '' : new URL(to.url).searchParams.get(param)?.trim();
+			q = $page.params.fnurgel ? '' : new URL(to.url).searchParams.get(param)?.trim() || '';
 		}
 	});
 
@@ -45,7 +45,12 @@
 
 
{#if env?.PUBLIC_USE_SUPERSEARCH === 'true'} - + {:else} { + await page.goto('/'); +}); + +test('submits closest form on enter key press', async ({ page }) => { + await page.locator('[data-test-id="test1"]').getByRole('textbox').locator('div').fill('hello world') + await page.keyboard.press('Enter'); + await expect(page).toHaveURL('/test1?q=hello+world') +}); + +test('submits form identified by form attribute on enter key press', async ({ page }) => { + await page.locator('[data-test-id="test2"]').getByRole('textbox').locator('div').fill('hello world') + await page.keyboard.press('Enter'); + await expect(page).toHaveURL('/test2?q=hello+world') +}); \ No newline at end of file diff --git a/packages/supersearch/src/lib/components/SuperSearch.svelte b/packages/supersearch/src/lib/components/SuperSearch.svelte index 0a8acc9ef..99e2c24cf 100644 --- a/packages/supersearch/src/lib/components/SuperSearch.svelte +++ b/packages/supersearch/src/lib/components/SuperSearch.svelte @@ -3,21 +3,25 @@ import { EditorView, placeholder as placeholderExtension } from '@codemirror/view'; import { Compartment } from '@codemirror/state'; import { type LRLanguage } from '@codemirror/language'; + import submitFormOnEnterKey from '$lib/extensions/submitFormOnEnterKey.js'; interface Props { + name: string; + value?: string; + form?: string; language?: LRLanguage; placeholder?: string; } - let { language, placeholder = '' }: Props = $props(); + let { name, value = $bindable(''), form, language, placeholder = '' }: Props = $props(); - let value = $state(''); let editorView: EditorView | undefined = $state(); let placeholderCompartment = new Compartment(); let prevPlaceholder = placeholder; const extensions = [ + submitFormOnEnterKey(form), ...(language ? [language] : []), placeholderCompartment.of(placeholderExtension(placeholder)) ]; @@ -37,3 +41,4 @@ + diff --git a/packages/supersearch/src/lib/extensions/submitFormOnEnterKey.ts b/packages/supersearch/src/lib/extensions/submitFormOnEnterKey.ts new file mode 100644 index 000000000..d09f25558 --- /dev/null +++ b/packages/supersearch/src/lib/extensions/submitFormOnEnterKey.ts @@ -0,0 +1,37 @@ +import { Prec } from '@codemirror/state'; +import { EditorView, keymap } from '@codemirror/view'; + +/** + * CodeMirror extension that submits form elements (either the closest or by specified id using the `form` attribute) on enter keypresses. + * + * @param {string} form Optional id of the `` element with which the form control should be associated with (equivalent with + * the [form attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#form) on HTML Input elements). + */ + +const submitFormOnEnterKey = (form?: string) => { + const submitForm = (editorView: EditorView) => { + const formElement = form ? document.getElementById(form) : editorView.dom?.closest('form'); + + if (formElement && formElement instanceof HTMLFormElement) { + formElement.requestSubmit(); + return true; // return true to prevent further commands to be tried + } + + return false; + }; + + return Prec.highest( + keymap.of([ + { + key: 'Enter', + run: submitForm + }, + { + key: 'Shift-Enter', + run: submitForm + } + ]) + ); +}; + +export default submitFormOnEnterKey; diff --git a/packages/supersearch/src/routes/+page.svelte b/packages/supersearch/src/routes/+page.svelte index 979b1757f..27799f04f 100644 --- a/packages/supersearch/src/routes/+page.svelte +++ b/packages/supersearch/src/routes/+page.svelte @@ -1,9 +1,24 @@ - + +
+ Supersearch inside <form> element + +
+ + +
+
+ Supersearch using form attribute + +
+
+ +
diff --git a/packages/supersearch/src/routes/test1/+page.svelte b/packages/supersearch/src/routes/test1/+page.svelte new file mode 100644 index 000000000..ac07b7c64 --- /dev/null +++ b/packages/supersearch/src/routes/test1/+page.svelte @@ -0,0 +1 @@ +

A test route

\ No newline at end of file diff --git a/packages/supersearch/src/routes/test2/+page.svelte b/packages/supersearch/src/routes/test2/+page.svelte new file mode 100644 index 000000000..1d6fd03ad --- /dev/null +++ b/packages/supersearch/src/routes/test2/+page.svelte @@ -0,0 +1 @@ +

Another test route

\ No newline at end of file From 75e5cbaae1309c1a5b7839791afea642f1cc596c Mon Sep 17 00:00:00 2001 From: kwahlin Date: Thu, 14 Nov 2024 13:32:26 +0100 Subject: [PATCH 16/19] Update templates --- .../src/resources/json/combinedTemplates.json | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/cataloging/src/resources/json/combinedTemplates.json b/cataloging/src/resources/json/combinedTemplates.json index 8c1ad9685..0b5112dca 100644 --- a/cataloging/src/resources/json/combinedTemplates.json +++ b/cataloging/src/resources/json/combinedTemplates.json @@ -4416,16 +4416,8 @@ "bulk:shouldUpdateModifiedTimestamp": false, "bulk:changeSpec": { "@type": "bulk:Merge", - "bulk:deprecate": [ - { - "@type": "URI", - "value": "" - } - ], - "bulk:keep": { - "@type": "URI", - "value": "" - } + "bulk:deprecate": null, + "bulk:keep": null } }, "quoted": {}, @@ -4664,16 +4656,8 @@ "bulk:changeSpec": { "@type": "bulk:Other", "bulk:script": "removeTopicSubdivision", - "bulk:deprecate": [ - { - "@type": "URI", - "value": "" - } - ], - "bulk:keep": { - "@type": "URI", - "value": "" - } + "bulk:deprecate": null, + "bulk:add": null } }, "quoted": {}, From 5b231145f1ee90428df79bf08ae64a297f20606a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20Engstr=C3=B6m?= Date: Thu, 14 Nov 2024 13:44:37 +0100 Subject: [PATCH 17/19] fix(lxlweb): prevent error when missing matomo-id (#1160) * fix(lxlweb): prevent error when missing matomo-id --- lxl-web/src/lib/components/CookieConsent.svelte | 6 +++--- lxl-web/src/lib/contexts/matomo.ts | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lxl-web/src/lib/components/CookieConsent.svelte b/lxl-web/src/lib/components/CookieConsent.svelte index 869e6ae32..e78a595ba 100644 --- a/lxl-web/src/lib/components/CookieConsent.svelte +++ b/lxl-web/src/lib/components/CookieConsent.svelte @@ -36,14 +36,14 @@ }, onConsent: ({ cookie }) => { if (cookie.categories.includes('analytics')) { - $matomoTracker.rememberConsentGiven(); + $matomoTracker?.rememberConsentGiven(); } }, onChange: ({ cookie }) => { if (cookie.categories.includes('analytics')) { - $matomoTracker.rememberConsentGiven(); + $matomoTracker?.rememberConsentGiven(); } else { - $matomoTracker.forgetConsentGiven(); + $matomoTracker?.forgetConsentGiven(); } }, language: { diff --git a/lxl-web/src/lib/contexts/matomo.ts b/lxl-web/src/lib/contexts/matomo.ts index 6da70a4f3..be7503b70 100644 --- a/lxl-web/src/lib/contexts/matomo.ts +++ b/lxl-web/src/lib/contexts/matomo.ts @@ -5,7 +5,7 @@ import { type Writable } from 'svelte/store'; import { type MatomoTracker } from '$lib/types/matomo'; import { setContext, getContext } from 'svelte'; -const MATOMO_ID: number = +env.PUBLIC_MATOMO_ID; +const MATOMO_ID = env.PUBLIC_MATOMO_ID && +env.PUBLIC_MATOMO_ID; const tracker = writable(); @@ -29,7 +29,6 @@ export function setMatomoTracker() { const initializedMatomoTracker = initMatomo(); if (initializedMatomoTracker) { tracker.set(initializedMatomoTracker); - console.info('Matomo tracker set'); } } From 1c8697fe54f75f4f090f68ac762c0ce50cde8918 Mon Sep 17 00:00:00 2001 From: Johan Bisse Mattsson Date: Thu, 14 Nov 2024 14:01:08 +0100 Subject: [PATCH 18/19] chore(supersearch, lxl-querylang): Format and lint code https://github.com/libris/lxlviewer/pull/1151 contained a bug which caused automatic formatting and linting not to be done on commit hooks (should be resolved in https://github.com/libris/lxlviewer/commit/b8f485409ec7d56d9f86abeda81c0054fc82a88f and https://github.com/libris/lxlviewer/commit/44fa67cb572c32aa196207b755a5840af46b6a66). Some files remained therefore unformatted and unlinted, this PR should fix that. --- .../codemirror-lang-lxlquery/package.json | 2 +- .../test/grammar.test.ts | 5 ++++- .../codemirror-lang-lxlquery/vitest.config.ts | 6 ++--- packages/supersearch/e2e/supersearch.spec.ts | 22 +++++++++++++------ .../src/lib/components/CodeMirror.svelte | 2 +- .../lib/extensions/submitFormOnEnterKey.ts | 2 +- packages/supersearch/src/lib/index.ts | 2 +- .../supersearch/src/routes/test1/+page.svelte | 2 +- .../supersearch/src/routes/test2/+page.svelte | 2 +- 9 files changed, 28 insertions(+), 17 deletions(-) diff --git a/packages/codemirror-lang-lxlquery/package.json b/packages/codemirror-lang-lxlquery/package.json index 3c3ca8c0e..cb7e66038 100644 --- a/packages/codemirror-lang-lxlquery/package.json +++ b/packages/codemirror-lang-lxlquery/package.json @@ -5,7 +5,7 @@ "scripts": { "test": "vitest", "prepare": "cd ../../ && husky && cd ./packages/codemirror-lang-lxlquery && rollup -c", - "lint": "eslint . && prettier --check .", + "lint": "eslint . && prettier --check .", "format": "prettier --write ." }, "lint-staged": { diff --git a/packages/codemirror-lang-lxlquery/test/grammar.test.ts b/packages/codemirror-lang-lxlquery/test/grammar.test.ts index 21e10cdb4..080747e72 100644 --- a/packages/codemirror-lang-lxlquery/test/grammar.test.ts +++ b/packages/codemirror-lang-lxlquery/test/grammar.test.ts @@ -13,7 +13,10 @@ for (const file of fs.readdirSync(caseDir)) { const name = /^[^.]*/.exec(file)?.[0]; if (name) { describe(name, () => { - for (const { name, run } of fileTests(fs.readFileSync(path.join(caseDir, file), 'utf8'), file)) + for (const { name, run } of fileTests( + fs.readFileSync(path.join(caseDir, file), 'utf8'), + file + )) it(name, () => run(lxlQueryLanguage.parser)); }); } diff --git a/packages/codemirror-lang-lxlquery/vitest.config.ts b/packages/codemirror-lang-lxlquery/vitest.config.ts index 53bc194a4..ea11a23b4 100644 --- a/packages/codemirror-lang-lxlquery/vitest.config.ts +++ b/packages/codemirror-lang-lxlquery/vitest.config.ts @@ -1,7 +1,7 @@ import { defineConfig } from 'vitest/config'; export default defineConfig({ - test: { - include: ['**/*.{test,spec}.{js,ts}'] - } + test: { + include: ['**/*.{test,spec}.{js,ts}'] + } }); diff --git a/packages/supersearch/e2e/supersearch.spec.ts b/packages/supersearch/e2e/supersearch.spec.ts index c2f25455b..820287a54 100644 --- a/packages/supersearch/e2e/supersearch.spec.ts +++ b/packages/supersearch/e2e/supersearch.spec.ts @@ -5,13 +5,21 @@ test.beforeEach(async ({ page }) => { }); test('submits closest form on enter key press', async ({ page }) => { - await page.locator('[data-test-id="test1"]').getByRole('textbox').locator('div').fill('hello world') - await page.keyboard.press('Enter'); - await expect(page).toHaveURL('/test1?q=hello+world') + await page + .locator('[data-test-id="test1"]') + .getByRole('textbox') + .locator('div') + .fill('hello world'); + await page.keyboard.press('Enter'); + await expect(page).toHaveURL('/test1?q=hello+world'); }); test('submits form identified by form attribute on enter key press', async ({ page }) => { - await page.locator('[data-test-id="test2"]').getByRole('textbox').locator('div').fill('hello world') - await page.keyboard.press('Enter'); - await expect(page).toHaveURL('/test2?q=hello+world') -}); \ No newline at end of file + await page + .locator('[data-test-id="test2"]') + .getByRole('textbox') + .locator('div') + .fill('hello world'); + await page.keyboard.press('Enter'); + await expect(page).toHaveURL('/test2?q=hello+world'); +}); diff --git a/packages/supersearch/src/lib/components/CodeMirror.svelte b/packages/supersearch/src/lib/components/CodeMirror.svelte index 06517448b..ed4a76935 100644 --- a/packages/supersearch/src/lib/components/CodeMirror.svelte +++ b/packages/supersearch/src/lib/components/CodeMirror.svelte @@ -19,7 +19,7 @@ }; let { - value = '', // value isn't bindable as it can easily cause undo/redo history issues when changing the value from outside – it's preferable to dispatch changes instead + value = '', // value isn't bindable as it can easily cause undo/redo history issues when changing the value from outside – it's preferable to dispatch changes instead extensions = [], onchange = () => {}, editorView = $bindable() diff --git a/packages/supersearch/src/lib/extensions/submitFormOnEnterKey.ts b/packages/supersearch/src/lib/extensions/submitFormOnEnterKey.ts index d09f25558..776faaf74 100644 --- a/packages/supersearch/src/lib/extensions/submitFormOnEnterKey.ts +++ b/packages/supersearch/src/lib/extensions/submitFormOnEnterKey.ts @@ -3,7 +3,7 @@ import { EditorView, keymap } from '@codemirror/view'; /** * CodeMirror extension that submits form elements (either the closest or by specified id using the `form` attribute) on enter keypresses. - * + * * @param {string} form Optional id of the `
` element with which the form control should be associated with (equivalent with * the [form attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#form) on HTML Input elements). */ diff --git a/packages/supersearch/src/lib/index.ts b/packages/supersearch/src/lib/index.ts index 6f0fb03af..15a9ade1e 100644 --- a/packages/supersearch/src/lib/index.ts +++ b/packages/supersearch/src/lib/index.ts @@ -1,3 +1,3 @@ import SuperSearch from '$lib/components/SuperSearch.svelte'; -export { SuperSearch } +export { SuperSearch }; diff --git a/packages/supersearch/src/routes/test1/+page.svelte b/packages/supersearch/src/routes/test1/+page.svelte index ac07b7c64..97056abde 100644 --- a/packages/supersearch/src/routes/test1/+page.svelte +++ b/packages/supersearch/src/routes/test1/+page.svelte @@ -1 +1 @@ -

A test route

\ No newline at end of file +

A test route

diff --git a/packages/supersearch/src/routes/test2/+page.svelte b/packages/supersearch/src/routes/test2/+page.svelte index 1d6fd03ad..96b26cd31 100644 --- a/packages/supersearch/src/routes/test2/+page.svelte +++ b/packages/supersearch/src/routes/test2/+page.svelte @@ -1 +1 @@ -

Another test route

\ No newline at end of file +

Another test route

From 34048b060c4faa135f6581e3fb9e45308b1f1fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olov=20Ylinenp=C3=A4=C3=A4?= Date: Thu, 14 Nov 2024 14:13:32 +0100 Subject: [PATCH 19/19] fix(cataloging-bulk-changes): Search freetext parameter for bulk:Job --- cataloging/src/resources/json/propertymappings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cataloging/src/resources/json/propertymappings.json b/cataloging/src/resources/json/propertymappings.json index 9a6122ddb..d6817b42e 100644 --- a/cataloging/src/resources/json/propertymappings.json +++ b/cataloging/src/resources/json/propertymappings.json @@ -11,7 +11,7 @@ "Concept", "Work", "Resource", - "BulkChange" + "bulk:Job" ] }, {