From 09cb350dca8e7741be0432b47eef80afdd009c02 Mon Sep 17 00:00:00 2001 From: Daniele Guido Date: Thu, 26 Sep 2024 11:00:00 +0200 Subject: [PATCH] Fix/issue text reuse (#1274) * fix #1270 (timeline not working) * add back exclude filter in the text reuse passage ccomparison * fix #1257 wording + eslint * fix #1226 general error display * add right padding to text reuse lines in AnnotatedText component * increase height of modal SelectionMonitor * show SelectionMonitor when clicking on the passage * refactor pagination in TextReuseClusterMonitor --- src/components/SelectionMonitor.vue | 13 +- src/components/TextReuseClusterMonitor.vue | 155 +++++++++++------- src/components/TextReusePassageMonitor.vue | 5 +- src/components/TheHeader.vue | 5 +- src/components/modules/AnnotatedText.vue | 4 +- src/components/modules/EmbeddingsSearch.vue | 32 ++-- src/components/modules/FilterDynamicRange.vue | 9 + src/components/modules/IssueViewerText.vue | 86 +++++----- src/i18n/messages.js | 2 +- 9 files changed, 171 insertions(+), 140 deletions(-) diff --git a/src/components/SelectionMonitor.vue b/src/components/SelectionMonitor.vue index b333a2bc..ea851d1f 100644 --- a/src/components/SelectionMonitor.vue +++ b/src/components/SelectionMonitor.vue @@ -181,7 +181,7 @@ import Helpers from '@/plugins/Helpers' import ItemLabel from './modules/lists/ItemLabel.vue' import SearchQuerySummary from './modules/SearchQuerySummary.vue' import { SupportedFiltersByIndex } from '@/logic/filters' -import { searchFacets } from '@/services' +import { getSearchFacetsService } from '@/services' import Timeline from '@/components/modules/Timeline.vue' import FilterFactory from '@/models/FilterFactory' import TextReuseClusterMonitor from './TextReuseClusterMonitor.vue' @@ -286,14 +286,14 @@ export default defineComponent({ console.debug( '[SelectionMonitor] timelineApiQueryParams', this.displayCurrentSearchFilters, - this.applyCurrentSearchFilters + this.applyCurrentSearchFilters, + query ) if (this.monitor.displayCurrentSearchFilters && this.applyCurrentSearchFilters) { query.filters = [...this.monitorFilters] } else if (!this.applyCurrentSearchFilters && this.monitor.item) { query.filters = [{ ...this.monitorFilter }] } - return { query, hash: JSON.stringify(query).split('').sort().join('') @@ -384,7 +384,8 @@ export default defineComponent({ }, loadTimeline() { // eslint-disable-next-line - console.debug('[ItemSelector] loadTimeline') + console.debug('[ItemSelector] loadTimeline index:', this.timelineApiQueryParams.query.index) + const searchFacets = getSearchFacetsService(this.timelineApiQueryParams.query.index) searchFacets .get( 'year', @@ -441,7 +442,7 @@ export default defineComponent({ .SelectionMonitor.textReusePassage { width: 800px; top: 100px; - height: 600px; + height: calc(100% - 200px); margin-top: auto; margin-left: -400px; } @@ -523,7 +524,7 @@ export default defineComponent({ "types_textReuseClusterLexicalOverlap": "lexical overlap", "tabs_collection_overview": "collection", "tabs_textReuseCluster_overview": "cluster of text reuse", - "tabs_textReuseCluster_comparePassages": "compare text reuse passages", + "tabs_textReuseCluster_comparePassages": "compare text reuse passages in this cluster", "tabs_textReusePassage_comparePassages": "compare text reuse passages", "tabs_textReuseClusterSize_closeUp": "text reuse cluster size - close-up view", "tabs_textReuseClusterLexicalOverlap_closeUp": "lexical overlap - close-up view", diff --git a/src/components/TextReuseClusterMonitor.vue b/src/components/TextReuseClusterMonitor.vue index c77958a3..e14d39ca 100644 --- a/src/components/TextReuseClusterMonitor.vue +++ b/src/components/TextReuseClusterMonitor.vue @@ -4,33 +4,67 @@
- - + +
- - + +
- - + +
-
+

- + {{ part.value }} {{ part.value }} {{ part.value }} @@ -42,7 +76,7 @@

- + {{ part.value }} {{ part.value }} {{ part.value }} @@ -67,18 +101,18 @@ export default { name: 'TextReuseClusterMonitor', components: { TextReusePassageItemLabel, - Pagination, + Pagination }, props: { // item is a textReuseCluster item item: { type: Object, - required: true, + required: true }, filters: { type: Array, - default: () => [], - }, + default: () => [] + } }, data: () => ({ totalPassages: -1, @@ -90,53 +124,50 @@ export default { endPassageOrderBy: '-date', startPassageOffset: 0, - endPassageOffset: 1, + endPassageOffset: 0, startPassageIsLoading: false, endPassageIsLoading: false, isLoading: false, - orderByOptions: OrderByOptions, + orderByOptions: OrderByOptions }), methods: { handleStartPassageOffsetChange(offset) { - this.startPassageOffset = offset + this.startPassageOffset = offset - 1 }, handleEndPassageOffsetChange(offset) { - this.endPassageOffset = offset + this.endPassageOffset = offset - 1 }, async loadStartPassage({ query }) { this.startPassageIsLoading = true - await textReusePassages + this.startPassage = await textReusePassages .find({ query }) .then(res => { - this.startPassage = new TextReusePassage(res.data[0]) this.totalPassages = res.total - this.startPassageIsLoading = false - return res + return res.data.length ? new TextReusePassage(res.data[0]) : null }) .catch(err => { console.error('[TextReuseClusterMonitor] loadPassages', err) - this.startPassageIsLoading = false + return null }) + this.startPassageIsLoading = false }, async loadEndPassage({ query }) { this.endPassageIsLoading = true - await textReusePassages + this.endPassage = await textReusePassages .find({ query }) .then(res => { - this.endPassage = new TextReusePassage(res.data[0]) this.totalPassages = res.total - this.endPassageIsLoading = false - return res + return res.data.length ? new TextReusePassage(res.data[0]) : null }) .catch(err => { console.error('[TextReuseClusterMonitor] loadPassages', err) - this.endPassageIsLoading = false - return { data: [] } + return null }) - }, + this.endPassageIsLoading = false + } }, computed: { diff() { @@ -147,40 +178,40 @@ export default { }, searchApiStartPassageQueryParameters() { const query = { - page: this.startPassageOffset, + offset: this.startPassageOffset, limit: 1, order_by: this.startPassageOrderBy, filters: this.filters.length ? optimizeFilters(this.filters) : [{ type: 'textReuseCluster', q: this.item.id }], - addons: { newspaper: 'text' }, + addons: { newspaper: 'text' } } return { query, - hash: JSON.stringify(query) - .split('') - .sort() - .join(''), + hash: JSON.stringify(query).split('').sort().join('') } }, searchApiEndPassageQueryParameters() { + const filters = this.filters.length + ? optimizeFilters(this.filters) + : [{ type: 'textReuseCluster', q: this.item.id }] + + if (this.startPassage) { + filters.push({ type: 'textReusePassage', context: 'exclude', q: this.startPassage.id }) + } + const query = { - page: this.endPassageOffset, + offset: this.endPassageOffset, limit: 1, order_by: this.endPassageOrderBy, - filters: this.filters.length - ? optimizeFilters(this.filters) - : [{ type: 'textReuseCluster', q: this.item.id }], - addons: { newspaper: 'text' }, + filters, + addons: { newspaper: 'text' } } return { query, - hash: JSON.stringify(query) - .split('') - .sort() - .join(''), + hash: JSON.stringify(query).split('').sort().join('') } - }, + } }, watch: { searchApiStartPassageQueryParameters: { @@ -191,11 +222,11 @@ export default { // eslint-disable-next-line console.debug( '[TextReuseClusterMonitor] @searchApiStartPassageQueryParameters \n query:', - query, + query ) await this.loadStartPassage({ query }) }, - immediate: true, + immediate: true }, searchApiEndPassageQueryParameters: { async handler({ query, hash }, previousValue) { @@ -205,18 +236,18 @@ export default { // eslint-disable-next-line console.debug( '[TextReuseClusterMonitor] @searchApiEndPassageQueryParameters \n query:', - query, + query ) await this.loadEndPassage({ query }) }, - immediate: true, - }, - }, + immediate: true + } + } }