Skip to content

Commit

Permalink
Merge branch 'develop' into feat/LWS-273-find-using-cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
johanbissemattsson authored Dec 12, 2024
2 parents 4609ded + f2e112a commit afd2ceb
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cataloging/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cataloging",
"version": "1.37.2",
"version": "1.37.3",
"type": "module",
"private": true,
"scripts": {
Expand Down
42 changes: 35 additions & 7 deletions cataloging/src/components/care/bulk-changes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default {
fullPreview: {},
fullPreviewData: {'@type': 'Instance'},
fullPreviewDiff: {},
previewError: null,
showOverwriteWarning: false,
showConfirmRunModal: false,
completePreview: true,
Expand Down Expand Up @@ -469,7 +470,8 @@ export default {
},
getPreviewFromUrl(fetchUrl) {
this.currentPreviewUrl = fetchUrl;
fetch(fetchUrl).then((response) => response.json()).then((result) => {
HttpUtil.fetchJson(fetchUrl).then((result) => {
this.previewError = null;
// Form preview
if (typeof result.changeSets !== 'undefined') {
Expand All @@ -489,11 +491,23 @@ export default {
}
this.totalItems = result.totalItems;
if (result['_complete'] === false) {
this.getMinimalPreviewFromUrl(fetchUrl);
const isEmptyResult = this.totalItems === 0 || typeof this.totalItems === 'undefined';
this.completePreview = !(result['_complete'] === false);
if (!this.completePreview) {
if (isEmptyResult) {
this.previewError = translatePhrase('This might take a while...')
setTimeout(() => {
if (this.currentPreviewUrl === fetchUrl && !this.completePreview) {
this.getPreviewFromUrl(fetchUrl);
}
}, 1000);
return
} else {
this.getMinimalPreviewFromUrl(fetchUrl);
}
}
if (this.totalItems === 0 || typeof this.totalItems === 'undefined') {
if (isEmptyResult) {
this.resetPreviewData();
return;
} else {
Expand Down Expand Up @@ -532,12 +546,18 @@ export default {
this.loadingPreview.previous = false;
this.initializingPreview = false;
}, (error) => {
this.initializingPreview = false;
console.error('Failed to fetch preview', error);
this.previewError = error;
setTimeout(() => {
if (this.currentPreviewUrl === fetchUrl) {
this.getPreviewFromUrl(fetchUrl);
}
}, 1000);
});
},
getMinimalPreviewFromUrl(fetchUrl) {
fetch(fetchUrl).then((response) => response.json()).then((result) => {
HttpUtil.fetchJson(fetchUrl).then((result) => {
this.previewError = null;
this.totalItems = result.totalItems;
if (result['_complete'] === false) {
this.completePreview = false;
Expand All @@ -550,8 +570,13 @@ export default {
this.completePreview = true;
}
}, (error) => {
this.initializingPreview = false;
console.error('Failed to fetch preview', error);
this.previewError = error;
setTimeout(() => {
if (this.currentPreviewUrl === fetchUrl) {
this.getMinimalPreviewFromUrl(fetchUrl);
}
}, 1000);
});
},
async triggerRunBulkChange() {
Expand Down Expand Up @@ -875,6 +900,9 @@ export default {
:initializing-preview="initializingPreview"
@onActive="focusPreview"
/>
<span v-if="this.previewError">
<i class="fa fa-warning" /> {{ this.previewError }}
</span>
</div>
<div class="BulkChanges-result" v-if="isRunningOrFinished">
<div>
Expand Down
3 changes: 2 additions & 1 deletion cataloging/src/resources/json/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@
"Show as bulk change" : "Visa som körning",
"Show as record" : "Visa som post",
"To see bulk changes you need to switch to a sigel with access.": "För att se körningar behöver du växla till ett sigel med rättigheter.",
"Back to create bulk change": "Tillbaka till skapa massändring"
"Back to create bulk change": "Tillbaka till skapa massändring",
"This might take a while...": "Det här verkar ta lite tid..."
}
}
8 changes: 8 additions & 0 deletions cataloging/src/utils/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,11 @@ export function fetchPlainEtags(ids) {
.all(ids.map((id) => getDocument(id, undefined, false)))
.then((responses) => Object.fromEntries(responses.map((r) => [r.uri, r.ETag])));
}

export async function fetchJson (url) {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return await response.json();
}
4 changes: 2 additions & 2 deletions packages/codemirror-lang-lxlquery/src/syntax.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ term {
Group { "(" term* ")" }

BooleanQuery {
(freetext | Qualifier) BooleanOperator (freetext | Qualifier)
(BooleanOperator (freetext | Qualifier))+?
(freetext | Qualifier | Group ) BooleanOperator (freetext | Qualifier | Group )
(BooleanOperator (freetext | Qualifier | Group ))+?
}

Qualifier {
Expand Down
11 changes: 11 additions & 0 deletions packages/codemirror-lang-lxlquery/test/cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ Query(
)


# BooleanQuery with groups

(rummet röda) OR (rummet vita)

==>

Query(
BooleanQuery(Group(...),Group(...))
)


# BooleanQuery - erroneous

OR AND sommar
Expand Down

0 comments on commit afd2ceb

Please sign in to comment.