From f17c5164f23d8bfe83de462edb131aa3138ff09b Mon Sep 17 00:00:00 2001 From: Etienne Laurent Date: Thu, 9 May 2024 13:39:03 +0200 Subject: [PATCH 1/6] fix cypress tests --- .../widget-type/ui/apos/components/AposWidgetEditor.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue b/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue index 61474184a5..324e303ea5 100644 --- a/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue +++ b/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue @@ -200,9 +200,9 @@ export default { this.evaluateConditions(); }, async save() { - const widget = klona(this.docFields.data); this.triggerValidation = true; this.$nextTick(async () => { + const widget = klona(this.docFields.data); if (this.docFields.hasErrors) { this.triggerValidation = false; return; From a61a4edce8dbd27d17c265eb8a61be2d31d4da5e Mon Sep 17 00:00:00 2001 From: Etienne Laurent Date: Thu, 9 May 2024 16:52:01 +0200 Subject: [PATCH 2/6] pass a limit prop to AposModalTabs --- .../modal/ui/apos/components/AposModalTabs.vue | 10 ++++++++++ .../ui/apos/components/AposWidgetEditor.vue | 1 + 2 files changed, 11 insertions(+) diff --git a/modules/@apostrophecms/modal/ui/apos/components/AposModalTabs.vue b/modules/@apostrophecms/modal/ui/apos/components/AposModalTabs.vue index d9264572e7..6f6e606041 100644 --- a/modules/@apostrophecms/modal/ui/apos/components/AposModalTabs.vue +++ b/modules/@apostrophecms/modal/ui/apos/components/AposModalTabs.vue @@ -59,6 +59,10 @@ export default { orientation: { type: String, default: 'vertical' + }, + limit: { + type: Number, + default: 0 } }, emits: [ 'select-tab' ], @@ -71,6 +75,12 @@ export default { // a top-level property safe const tab = { ...this.tabs[i] }; tab.action = tab.name; + + if (!this.limit) { + visibleTabs.push(this.tabs[i]); + continue; + } + if (i < 5) { visibleTabs.push(tab); } else { diff --git a/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue b/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue index 324e303ea5..d7975a45ae 100644 --- a/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue +++ b/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue @@ -17,6 +17,7 @@ :tabs="tabs" orientation="horizontal" :errors="fieldErrors" + limit="5" @select-tab="switchPane" /> From d8d7f00ebfa50f107a75d8ed607fe3c764978ea7 Mon Sep 17 00:00:00 2001 From: Etienne Laurent Date: Thu, 9 May 2024 17:10:36 +0200 Subject: [PATCH 3/6] make a sparate AposWidgetModalTabs used only by AposWidgetEditor --- .../ui/apos/components/AposModalTabs.vue | 129 +------- .../apos/components/AposWidgetModalTabs.vue | 282 ++++++++++++++++++ .../ui/apos/components/AposWidgetEditor.vue | 3 +- 3 files changed, 286 insertions(+), 128 deletions(-) create mode 100644 modules/@apostrophecms/modal/ui/apos/components/AposWidgetModalTabs.vue diff --git a/modules/@apostrophecms/modal/ui/apos/components/AposModalTabs.vue b/modules/@apostrophecms/modal/ui/apos/components/AposModalTabs.vue index 6f6e606041..af41603560 100644 --- a/modules/@apostrophecms/modal/ui/apos/components/AposModalTabs.vue +++ b/modules/@apostrophecms/modal/ui/apos/components/AposModalTabs.vue @@ -1,8 +1,8 @@ @@ -55,49 +40,9 @@ export default { default() { return {}; } - }, - orientation: { - type: String, - default: 'vertical' - }, - limit: { - type: Number, - default: 0 } }, emits: [ 'select-tab' ], - data() { - const visibleTabs = []; - const hiddenTabs = []; - - for (let i = 0; i < this.tabs.length; i++) { - // Shallow clone is sufficient to make mutating - // a top-level property safe - const tab = { ...this.tabs[i] }; - tab.action = tab.name; - - if (!this.limit) { - visibleTabs.push(this.tabs[i]); - continue; - } - - if (i < 5) { - visibleTabs.push(tab); - } else { - hiddenTabs.push(tab); - } - } - - return { - visibleTabs, - hiddenTabs, - moreMenuButton: { - icon: 'dots-vertical-icon', - iconOnly: true, - type: 'subtle' - } - }; - }, computed: { tabErrors() { const errors = {}; @@ -124,15 +69,6 @@ export default { const tab = e.target; const id = tab.id; this.$emit('select-tab', id); - }, - moreMenuHandler(item) { - const lastVisibleTab = this.visibleTabs[this.visibleTabs.length - 1]; - const selectedItem = this.hiddenTabs.find((tab) => tab.name === item); - - this.hiddenTabs.splice(this.hiddenTabs.indexOf(selectedItem), 1, lastVisibleTab); - this.visibleTabs.splice(this.visibleTabs.length - 1, 1, selectedItem); - - this.$emit('select-tab', item); } } }; @@ -144,65 +80,6 @@ export default { height: 100%; } -:deep(.apos-context-menu) { - position: absolute; - top: 10px; - right: 0; - - svg { - width: 20px; - height: 20px; - color: var(--a-base-1); - } - - .apos-button--subtle:hover { - background-color: initial; - } -} - -.apos-modal-tabs--horizontal { - position: relative; - - .apos-modal-tabs__tabs { - flex-direction: row; - border-top: 1px solid var(--a-base-7); - border-bottom: 1px solid var(--a-base-7); - } - - .apos-modal-tabs__tab { - display: flex; - width: 100%; - } - - .apos-modal-tabs__tab--small { - width: 50%; - color: var(--a-base-1); - background-color: var(--a-base-10); - border-bottom: 1px solid var(--a-base-7); - } - - .apos-modal-tabs__btn { - justify-content: center; - color: var(--a-base-1); - background-color: var(--a-base-10); - - &:hover, &:focus { - color: var(--a-primary-light-40); - background-color: var(--a-base-10); - } - - &[aria-selected='true'], &[aria-selected='true']:hover, &[aria-selected='true']:focus { - color: var(--a-primary); - background-color: var(--a-base-10); - border-bottom: 3px solid var(--a-primary); - } - } - - .apos-modal-tabs__btn::before { - content: none; - } -} - .apos-modal-tabs__tabs { display: flex; flex-direction: column; diff --git a/modules/@apostrophecms/modal/ui/apos/components/AposWidgetModalTabs.vue b/modules/@apostrophecms/modal/ui/apos/components/AposWidgetModalTabs.vue new file mode 100644 index 0000000000..6d223fe3eb --- /dev/null +++ b/modules/@apostrophecms/modal/ui/apos/components/AposWidgetModalTabs.vue @@ -0,0 +1,282 @@ + + + + + diff --git a/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue b/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue index d7975a45ae..6e179986b2 100644 --- a/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue +++ b/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue @@ -10,14 +10,13 @@ > From 3034c701230f01c502d908a23beb49ec40fcb48a Mon Sep 17 00:00:00 2001 From: "E.T" Date: Thu, 9 May 2024 19:55:49 +0200 Subject: [PATCH 4/6] fix image cropper stencil getting smaller when changing aspect ratio (#4529) --- CHANGELOG.md | 1 + .../@apostrophecms/image/ui/apos/components/AposImageCropper.vue | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58b08f7c39..75db27f23e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Thanks to Michelin for contributing this feature. * Autocrop image attachments for referenced documents when replacing an image in the Media Manager. * Fixes modals in transition, as well as slider transition on overlay opacity. +* Changing the aspect ratio multiple times in the image cropper modal no longer makes the stencil smaller and smaller. ## 4.2.1 (2024-04-29) diff --git a/modules/@apostrophecms/image/ui/apos/components/AposImageCropper.vue b/modules/@apostrophecms/image/ui/apos/components/AposImageCropper.vue index d0524a723e..78a536f929 100644 --- a/modules/@apostrophecms/image/ui/apos/components/AposImageCropper.vue +++ b/modules/@apostrophecms/image/ui/apos/components/AposImageCropper.vue @@ -105,6 +105,7 @@ export default { }, aspectRatio: { handler(newVal) { + this.$refs.cropper.reset(); this.stencilProps.aspectRatio = newVal; this.$refs.cropper.refresh(); } From 082e6d82f41ed58216c4564d543ed1c537882389 Mon Sep 17 00:00:00 2001 From: Miro Yovchev <2827783+myovchev@users.noreply.github.com> Date: Fri, 10 May 2024 11:31:39 +0300 Subject: [PATCH 5/6] Hide single tab --- CHANGELOG.md | 3 +++ .../widget-type/ui/apos/components/AposWidgetEditor.vue | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75db27f23e..510b2b9a8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ except as part of the admin UI bundle which depends on it. For use with external front ends such as [apostrophe-astro](https://github.com/apostrophecms/apostrophe-astro). Thanks to Michelin for contributing this feature. +### Fixes +* Do not show widget editor tabs when there is only one tab. + ### Changes * Improves `debounce` function to handle async properly (waiting for previous async call to finish before to trigger new one). diff --git a/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue b/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue index 6e179986b2..ed650e2cf5 100644 --- a/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue +++ b/modules/@apostrophecms/widget-type/ui/apos/components/AposWidgetEditor.vue @@ -11,7 +11,7 @@