Skip to content

Commit 6067831

Browse files
authored
fix conditional fields in image editor (#5022)
1 parent 82b1854 commit 6067831

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
### Fixes
1414

1515
* The `?render-areas=1` API feature now correctly disregards areas in separate documents loaded via relationship fields. Formerly their presence resulted in an error, not a rendering.
16+
* Make conditional fields work in Image Editor.
1617

1718
## 4.20.0 (2025-08-06)
1819

modules/@apostrophecms/image/ui/apos/components/AposMediaManagerEditor.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
:trigger-validation="triggerValidation"
8888
:doc-id="docFields.data._id"
8989
:following-values="followingValues()"
90+
:conditional-fields="conditionalFields"
9091
:server-errors="serverErrors"
9192
@validate="triggerValidate"
9293
@reset="$emit('modified', false)"
@@ -231,6 +232,7 @@ export default {
231232
'docFields.data': {
232233
deep: true,
233234
handler(newData, oldData) {
235+
this.evaluateConditions();
234236
this.$nextTick(() => {
235237
// If either old or new state are an empty object, it's not
236238
// "modified."
@@ -252,8 +254,8 @@ export default {
252254
}
253255
}
254256
},
255-
media(newVal) {
256-
this.updateActiveDoc(newVal);
257+
async media(newVal) {
258+
await this.updateActiveDoc(newVal);
257259
}
258260
},
259261
mounted() {
@@ -271,6 +273,8 @@ export default {
271273
this.restoreOnly = !!this.activeMedia.archived;
272274
this.original = klona(newMedia);
273275
this.docFields.data = klona(newMedia);
276+
this.evaluateConditions();
277+
await this.evaluateExternalConditions();
274278
this.generateLipKey();
275279
await this.unlock();
276280
// Distinguish between an actual doc and an empty placeholder
@@ -402,7 +406,7 @@ export default {
402406
}
403407
404408
await this.cancel();
405-
this.updateActiveDoc(this.activeMedia);
409+
await this.updateActiveDoc(this.activeMedia);
406410
}
407411
apos.bus.$emit('admin-menu-click', {
408412
itemName: '@apostrophecms/i18n:localize',

modules/@apostrophecms/modal/ui/apos/mixins/AposEditorMixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default {
7878
async evaluateExternalConditions() {
7979
this.externalConditionsResults = await evaluateExternalConditions(
8080
this.schema,
81-
this.docId || this.docFields?.data?._docId,
81+
this.docId || this.docFields?.data?._docId || this.docFields?.data?._id,
8282
this.$t
8383
);
8484
},

0 commit comments

Comments
 (0)