Skip to content

Commit 7db5236

Browse files
committed
removes AposEditor composable, moves postprocess logic in piece-type ui lib folder (no vue related)
1 parent 56fc71f commit 7db5236

4 files changed

Lines changed: 13 additions & 17 deletions

File tree

modules/@apostrophecms/image-widget/ui/apos/components/AposImageWidget.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
} from 'vue';
2727
import { useAposWidget } from 'Modules/@apostrophecms/widget-type/composables/AposWidget.js';
2828
import aposWidgetProps from 'Modules/@apostrophecms/widget-type/composables/AposWidgetProps.js';
29-
import { _postprocess } from 'Modules/@apostrophecms/modal/composables/AposEditor.js';
29+
import { postprocessRelationships } from 'Modules/@apostrophecms/piece-type/lib/postprocessRelationships.js';
3030
3131
const props = defineProps(aposWidgetProps);
3232
const imgModuleOptions = apos.modules['@apostrophecms/image'];
@@ -83,7 +83,7 @@ async function selectFromManager() {
8383
...props.modelValue,
8484
_image: [ selectedImg ]
8585
};
86-
await _postprocess(widgetModuleOptions.schema, widgetData, props.options);
86+
await postprocessRelationships(widgetModuleOptions.schema, widgetData, props.options);
8787
8888
emit('update', widgetData);
8989
}
@@ -195,7 +195,7 @@ async function upload(files = []) {
195195
...props.modelValue,
196196
_image: [ imgPiece ]
197197
};
198-
await _postprocess(widgetModuleOptions.schema, widgetData, props.options);
198+
await postprocessRelationships(widgetModuleOptions.schema, widgetData, props.options);
199199
200200
emit('update', widgetData);
201201
} catch (e) {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { klona } from 'klona';
1818
import {
1919
evaluateExternalConditions, getConditionalFields, getConditionTypesObject
2020
} from 'Modules/@apostrophecms/schema/lib/conditionalFields.js';
21-
import { _postprocess } from '../composables/AposEditor.js';
2221

2322
export default {
2423
props: {

modules/@apostrophecms/modal/ui/apos/composables/AposEditor.js renamed to modules/@apostrophecms/piece-type/ui/apos/lib/postprocessRelationships.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
// For now just moving postprocess logic here,
2-
// if needed we might move more from AposEditorMixin.js
3-
41
// Perform any postprocessing required by direct or nested schema fields
52
// before the object can be saved
6-
export async function _postprocess(schema, data, widgetOptions) {
3+
export async function postprocessRelationships(schema, data, widgetOptions) {
74
// Relationship fields may have postprocessors (e.g. autocropping)
8-
const relationships = _findRelationships(schema, data);
5+
const relationships = findRelationships(schema, data);
96

107
for (const {
118
value, field, context
129
} of relationships) {
13-
context[field.name] = await _getPostprocessedRelationship(
10+
context[field.name] = await getPostprocessedRelationship(
1411
value,
1512
field,
1613
widgetOptions
1714
);
1815
}
1916
}
2017

21-
export async function _getPostprocessedRelationship(
18+
export async function getPostprocessedRelationship(
2219
value,
2320
field,
2421
widgetOptions
@@ -44,7 +41,7 @@ export async function _getPostprocessedRelationship(
4441
return response.relationship;
4542
}
4643

47-
function _findRelationships(schema, object) {
44+
function findRelationships(schema, object) {
4845
let relationships = [];
4946
for (const field of schema) {
5047
if (field.type === 'relationship') {
@@ -57,13 +54,13 @@ function _findRelationships(schema, object) {
5754
for (const value of (object[field.name] || [])) {
5855
relationships = [
5956
...relationships,
60-
_findRelationships(field.schema, value)
57+
findRelationships(field.schema, value)
6158
];
6259
}
6360
} else if (field.type === 'object') {
6461
relationships = [
6562
...relationships,
66-
_findRelationships(field.schema, object[field.name] || {})
63+
findRelationships(field.schema, object[field.name] || {})
6764
];
6865
}
6966
}

modules/@apostrophecms/schema/ui/apos/logic/AposInputRelationship.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { klona } from 'klona';
22
import AposInputMixin from 'Modules/@apostrophecms/schema/mixins/AposInputMixin';
33
import newInstance from 'apostrophe/modules/@apostrophecms/schema/lib/newInstance.js';
4-
import { _getPostprocessedRelationship } from 'Modules/@apostrophecms/modal/composables/AposEditor.js';
4+
import { getPostprocessedRelationship } from 'Modules/@apostrophecms/piece-type/lib/postprocessRelationships.js';
55

66
export default {
77
name: 'AposInputRelationship',
@@ -157,7 +157,7 @@ export default {
157157
this.disabled = !!this.limitReached;
158158
},
159159
async updateSelected(items) {
160-
this.next = await _getPostprocessedRelationship(
160+
this.next = await getPostprocessedRelationship(
161161
items,
162162
this.field,
163163
this.widgetOptions
@@ -303,7 +303,7 @@ export default {
303303
: rel;
304304
});
305305

306-
this.next = await _getPostprocessedRelationship(
306+
this.next = await getPostprocessedRelationship(
307307
updatedItems,
308308
this.field,
309309
this.widgetOptions

0 commit comments

Comments
 (0)