From 111cae7be3910a544856b840fa37280c276e1314 Mon Sep 17 00:00:00 2001 From: Tim Fischbach Date: Wed, 15 May 2024 17:06:26 +0200 Subject: [PATCH] Use tooltip titles as titles in hotspot area list REDMINE-20673 --- .../editor/models/AreasCollection-spec.js | 33 +++++++++++++++++++ .../hotspots/editor/models/Area.js | 5 +-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/entry_types/scrolled/package/spec/contentElements/hotspots/editor/models/AreasCollection-spec.js b/entry_types/scrolled/package/spec/contentElements/hotspots/editor/models/AreasCollection-spec.js index 0e0a091d4..d35b273ed 100644 --- a/entry_types/scrolled/package/spec/contentElements/hotspots/editor/models/AreasCollection-spec.js +++ b/entry_types/scrolled/package/spec/contentElements/hotspots/editor/models/AreasCollection-spec.js @@ -86,4 +86,37 @@ describe('hotspots AreasCollection', () => { expect(listener).toHaveBeenCalledWith(10, {type: 'RESET_AREA_HIGHLIGHT'}); }); + + it('return empty title by default', () => { + const contentElement = factories.contentElement({ + id: 10, + configuration: { + areas: [ + {id: 1}, + ] + } + }); + const areasCollection = AreasCollection.forContentElement(contentElement); + + expect(areasCollection.get(1).title()).toBeUndefined(); + }); + + it('extracts title from tooltip texts', () => { + const contentElement = factories.contentElement({ + id: 10, + configuration: { + tooltipTexts: { + 1: { + title: [{children: [{text: 'Some title'}]}] + } + }, + areas: [ + {id: 1}, + ] + } + }); + const areasCollection = AreasCollection.forContentElement(contentElement); + + expect(areasCollection.get(1).title()).toEqual('Some title'); + }); }); diff --git a/entry_types/scrolled/package/src/contentElements/hotspots/editor/models/Area.js b/entry_types/scrolled/package/src/contentElements/hotspots/editor/models/Area.js index 26106f6b9..9b91acf5e 100644 --- a/entry_types/scrolled/package/src/contentElements/hotspots/editor/models/Area.js +++ b/entry_types/scrolled/package/src/contentElements/hotspots/editor/models/Area.js @@ -9,11 +9,12 @@ export const Area = Backbone.Model.extend({ }, title() { - return this.get('title'); + const tooltipTexts = this.collection.contentElement.configuration.get('tooltipTexts'); + return tooltipTexts?.[this.id]?.title?.[0]?.children?.[0]?.text; }, imageFile() { - return this.collection.entry.imageFiles.getByPermaId(this.get('image')); + return this.collection.entry.imageFiles.getByPermaId(this.get('activeImage')); }, highlight() {