contentful-migration 4.8.1 → 4.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -6
- package/README.md +237 -140
- package/built/lib/action/content-type-annotate.js +27 -0
- package/built/lib/action/content-type-annotate.js.map +1 -0
- package/built/lib/action/editor-layout/editor-layout-change-field-group-control.js +23 -0
- package/built/lib/action/editor-layout/editor-layout-change-field-group-control.js.map +1 -0
- package/built/lib/action/editor-layout/editor-layout-create-field-group.js +26 -0
- package/built/lib/action/editor-layout/editor-layout-create-field-group.js.map +1 -0
- package/built/lib/action/editor-layout/editor-layout-create.js +18 -0
- package/built/lib/action/editor-layout/editor-layout-create.js.map +1 -0
- package/built/lib/action/editor-layout/editor-layout-delete-field-group.js +23 -0
- package/built/lib/action/editor-layout/editor-layout-delete-field-group.js.map +1 -0
- package/built/lib/action/editor-layout/editor-layout-delete.js +21 -0
- package/built/lib/action/editor-layout/editor-layout-delete.js.map +1 -0
- package/built/lib/action/editor-layout/editor-layout-move-field.js +24 -0
- package/built/lib/action/editor-layout/editor-layout-move-field.js.map +1 -0
- package/built/lib/action/editor-layout/editor-layout-update-field-group.js +41 -0
- package/built/lib/action/editor-layout/editor-layout-update-field-group.js.map +1 -0
- package/built/lib/action/field-annotate.js +28 -0
- package/built/lib/action/field-annotate.js.map +1 -0
- package/built/lib/action/field-rename.js +4 -0
- package/built/lib/action/field-rename.js.map +1 -1
- package/built/lib/entities/content-type.js +239 -11
- package/built/lib/entities/content-type.js.map +1 -1
- package/built/lib/fetcher.js +2 -1
- package/built/lib/fetcher.js.map +1 -1
- package/built/lib/intent/base-intent.js +47 -0
- package/built/lib/intent/base-intent.js.map +1 -1
- package/built/lib/intent/composed-intent.js +51 -1
- package/built/lib/intent/composed-intent.js.map +1 -1
- package/built/lib/intent/content-type-annotate.js +57 -0
- package/built/lib/intent/content-type-annotate.js.map +1 -0
- package/built/lib/intent/editor-layout/editor-layout-change-field-group-control.js +57 -0
- package/built/lib/intent/editor-layout/editor-layout-change-field-group-control.js.map +1 -0
- package/built/lib/intent/editor-layout/editor-layout-change-field-group-id.js +59 -0
- package/built/lib/intent/editor-layout/editor-layout-change-field-group-id.js.map +1 -0
- package/built/lib/intent/editor-layout/editor-layout-create-field-group.js +54 -0
- package/built/lib/intent/editor-layout/editor-layout-create-field-group.js.map +1 -0
- package/built/lib/intent/editor-layout/editor-layout-create.js +49 -0
- package/built/lib/intent/editor-layout/editor-layout-create.js.map +1 -0
- package/built/lib/intent/editor-layout/editor-layout-delete-field-group.js +53 -0
- package/built/lib/intent/editor-layout/editor-layout-delete-field-group.js.map +1 -0
- package/built/lib/intent/editor-layout/editor-layout-delete.js +45 -0
- package/built/lib/intent/editor-layout/editor-layout-delete.js.map +1 -0
- package/built/lib/intent/editor-layout/editor-layout-invalid-method.js +38 -0
- package/built/lib/intent/editor-layout/editor-layout-invalid-method.js.map +1 -0
- package/built/lib/intent/editor-layout/editor-layout-move-field.js +81 -0
- package/built/lib/intent/editor-layout/editor-layout-move-field.js.map +1 -0
- package/built/lib/intent/editor-layout/editor-layout-update-field-group.js +57 -0
- package/built/lib/intent/editor-layout/editor-layout-update-field-group.js.map +1 -0
- package/built/lib/intent/field-annotate.js +57 -0
- package/built/lib/intent/field-annotate.js.map +1 -0
- package/built/lib/intent/index.js +23 -1
- package/built/lib/intent/index.js.map +1 -1
- package/built/lib/intent-list/index.js +4 -0
- package/built/lib/intent-list/index.js.map +1 -1
- package/built/lib/interfaces/annotation.js +86 -0
- package/built/lib/interfaces/annotation.js.map +1 -0
- package/built/lib/migration-chunks/validation/editor-layout.js +305 -0
- package/built/lib/migration-chunks/validation/editor-layout.js.map +1 -0
- package/built/lib/migration-chunks/validation/errors.js +91 -0
- package/built/lib/migration-chunks/validation/errors.js.map +1 -1
- package/built/lib/migration-chunks/validation/field.js +24 -23
- package/built/lib/migration-chunks/validation/field.js.map +1 -1
- package/built/lib/migration-chunks/validation/index.js +16 -3
- package/built/lib/migration-chunks/validation/index.js.map +1 -1
- package/built/lib/migration-parser.js +1 -1
- package/built/lib/migration-parser.js.map +1 -1
- package/built/lib/migration-steps/action-creators.js +164 -0
- package/built/lib/migration-steps/action-creators.js.map +1 -1
- package/built/lib/migration-steps/index.js +111 -3
- package/built/lib/migration-steps/index.js.map +1 -1
- package/built/lib/offline-api/index.js +13 -4
- package/built/lib/offline-api/index.js.map +1 -1
- package/built/lib/offline-api/validator/annotations.js +76 -0
- package/built/lib/offline-api/validator/annotations.js.map +1 -0
- package/built/lib/offline-api/validator/editor-interface.js +16 -0
- package/built/lib/offline-api/validator/editor-interface.js.map +1 -0
- package/built/lib/offline-api/validator/errors.js +21 -0
- package/built/lib/offline-api/validator/errors.js.map +1 -1
- package/built/lib/offline-api/validator/field-groups-count.js +34 -0
- package/built/lib/offline-api/validator/field-groups-count.js.map +1 -0
- package/built/lib/offline-api/validator/schema/editor-layout-schema.js +46 -0
- package/built/lib/offline-api/validator/schema/editor-layout-schema.js.map +1 -0
- package/built/lib/offline-api/validator/schema/schema-validation.js +42 -1
- package/built/lib/offline-api/validator/schema/schema-validation.js.map +1 -1
- package/built/lib/utils/editor-layout.js +60 -0
- package/built/lib/utils/editor-layout.js.map +1 -0
- package/docs/validation.md +104 -0
- package/index.d.ts +87 -0
- package/package.json +3 -3
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContentTypeAnnotateAction = void 0;
|
|
4
|
+
const action_1 = require("./action");
|
|
5
|
+
class ContentTypeAnnotateAction extends action_1.EntityAction {
|
|
6
|
+
constructor(contentTypeId, annotations) {
|
|
7
|
+
super();
|
|
8
|
+
this.contentTypeId = contentTypeId;
|
|
9
|
+
this.annotations = annotations;
|
|
10
|
+
}
|
|
11
|
+
getEntityId() {
|
|
12
|
+
return this.contentTypeId;
|
|
13
|
+
}
|
|
14
|
+
getEntityType() {
|
|
15
|
+
return action_1.EntityType.ContentType;
|
|
16
|
+
}
|
|
17
|
+
async applyTo(ct) {
|
|
18
|
+
if (!this.annotations) {
|
|
19
|
+
ct.clearAnnotations();
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
ct.setAnnotations(this.annotations);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.ContentTypeAnnotateAction = ContentTypeAnnotateAction;
|
|
27
|
+
//# sourceMappingURL=content-type-annotate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-type-annotate.js","sourceRoot":"","sources":["../../../src/lib/action/content-type-annotate.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AAGnD,MAAM,yBAA0B,SAAQ,qBAAY;IAIlD,YAAY,aAAqB,EAAE,WAA8B;QAC/D,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,aAAa;QACX,OAAO,mBAAU,CAAC,WAAW,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAe;QAC3B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,EAAE,CAAC,gBAAgB,EAAE,CAAA;SACtB;aAAM;YACL,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;SACpC;IACH,CAAC;CACF;AAEQ,8DAAyB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EditorLayoutChangeFieldGroupControlAction = void 0;
|
|
4
|
+
const action_1 = require("../action");
|
|
5
|
+
class EditorLayoutChangeFieldGroupControlAction extends action_1.EntityAction {
|
|
6
|
+
constructor(contentTypeId, fieldGroupId, groupControl) {
|
|
7
|
+
super();
|
|
8
|
+
this.contentTypeId = contentTypeId;
|
|
9
|
+
this.fieldGroupId = fieldGroupId;
|
|
10
|
+
this.groupControl = groupControl;
|
|
11
|
+
}
|
|
12
|
+
getEntityType() {
|
|
13
|
+
return action_1.EntityType.EditorInterface;
|
|
14
|
+
}
|
|
15
|
+
getEntityId() {
|
|
16
|
+
return this.contentTypeId;
|
|
17
|
+
}
|
|
18
|
+
async applyTo(editorInterfaces) {
|
|
19
|
+
await editorInterfaces.updateGroupControl(this.fieldGroupId, this.groupControl);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.EditorLayoutChangeFieldGroupControlAction = EditorLayoutChangeFieldGroupControlAction;
|
|
23
|
+
//# sourceMappingURL=editor-layout-change-field-group-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-layout-change-field-group-control.js","sourceRoot":"","sources":["../../../../src/lib/action/editor-layout/editor-layout-change-field-group-control.ts"],"names":[],"mappings":";;;AACA,sCAAoD;AAGpD,MAAM,yCAA0C,SAAQ,qBAAY;IAKlE,YAAa,aAAqB,EAAE,YAAoB,EAAE,YAA6D;QACrH,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED,aAAa;QACX,OAAO,mBAAU,CAAC,eAAe,CAAA;IACnC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO,CAAE,gBAAkC;QAC/C,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;IACjF,CAAC;CACF;AAEQ,8FAAyC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EditorLayoutCreateFieldGroupAction = void 0;
|
|
4
|
+
const action_1 = require("../action");
|
|
5
|
+
class EditorLayoutCreateFieldGroupAction extends action_1.EntityAction {
|
|
6
|
+
constructor(contentTypeId, fieldGroupId, parentFieldGroupId) {
|
|
7
|
+
super();
|
|
8
|
+
this.contentTypeId = contentTypeId;
|
|
9
|
+
this.fieldGroupId = fieldGroupId;
|
|
10
|
+
this.parentFieldGroupId = parentFieldGroupId;
|
|
11
|
+
}
|
|
12
|
+
getEntityType() {
|
|
13
|
+
return action_1.EntityType.EditorInterface;
|
|
14
|
+
}
|
|
15
|
+
getEntityId() {
|
|
16
|
+
return this.contentTypeId;
|
|
17
|
+
}
|
|
18
|
+
async applyTo(editorInterfaces) {
|
|
19
|
+
await editorInterfaces.createEditorLayoutFieldGroup(this.fieldGroupId, this.parentFieldGroupId);
|
|
20
|
+
if (!this.parentFieldGroupId) {
|
|
21
|
+
await editorInterfaces.createTabGroupControl(this.fieldGroupId);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.EditorLayoutCreateFieldGroupAction = EditorLayoutCreateFieldGroupAction;
|
|
26
|
+
//# sourceMappingURL=editor-layout-create-field-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-layout-create-field-group.js","sourceRoot":"","sources":["../../../../src/lib/action/editor-layout/editor-layout-create-field-group.ts"],"names":[],"mappings":";;;AACA,sCAAoD;AAEpD,MAAM,kCAAmC,SAAQ,qBAAY;IAK3D,YAAa,aAAqB,EAAE,YAAoB,EAAE,kBAA2B;QACnF,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;IAC9C,CAAC;IAED,aAAa;QACX,OAAO,mBAAU,CAAC,eAAe,CAAA;IACnC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO,CAAE,gBAAkC;QAC/C,MAAM,gBAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAA;QAC/F,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC5B,MAAM,gBAAgB,CAAC,qBAAqB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;SAChE;IACH,CAAC;CACF;AAEQ,gFAAkC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EditorLayoutCreateAction = void 0;
|
|
4
|
+
const action_1 = require("../action");
|
|
5
|
+
class EditorLayoutCreateAction extends action_1.APIAction {
|
|
6
|
+
constructor(contentTypeId) {
|
|
7
|
+
super();
|
|
8
|
+
this.contentTypeId = contentTypeId;
|
|
9
|
+
}
|
|
10
|
+
async applyTo(api) {
|
|
11
|
+
const editorInterfaces = await api.getEditorInterfaces(this.contentTypeId);
|
|
12
|
+
const contentType = await api.getContentType(this.contentTypeId);
|
|
13
|
+
await editorInterfaces.createEditorLayout(contentType.fields.fields);
|
|
14
|
+
await editorInterfaces.createGroupControls();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.EditorLayoutCreateAction = EditorLayoutCreateAction;
|
|
18
|
+
//# sourceMappingURL=editor-layout-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-layout-create.js","sourceRoot":"","sources":["../../../../src/lib/action/editor-layout/editor-layout-create.ts"],"names":[],"mappings":";;;AACA,sCAAqC;AAErC,MAAM,wBAAyB,SAAQ,kBAAS;IAG9C,YAAa,aAAqB;QAChC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,OAAO,CAAE,GAAe;QAC5B,MAAM,gBAAgB,GAAG,MAAM,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QAC1E,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QAEhE,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACpE,MAAM,gBAAgB,CAAC,mBAAmB,EAAE,CAAA;IAC9C,CAAC;CACF;AAEQ,4DAAwB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EditorLayoutDeleteFieldGroupAction = void 0;
|
|
4
|
+
const action_1 = require("../action");
|
|
5
|
+
class EditorLayoutDeleteFieldGroupAction extends action_1.EntityAction {
|
|
6
|
+
constructor(contentTypeId, fieldGroupId) {
|
|
7
|
+
super();
|
|
8
|
+
this.contentTypeId = contentTypeId;
|
|
9
|
+
this.fieldGroupId = fieldGroupId;
|
|
10
|
+
}
|
|
11
|
+
getEntityType() {
|
|
12
|
+
return action_1.EntityType.EditorInterface;
|
|
13
|
+
}
|
|
14
|
+
getEntityId() {
|
|
15
|
+
return this.contentTypeId;
|
|
16
|
+
}
|
|
17
|
+
async applyTo(editorInterfaces) {
|
|
18
|
+
await editorInterfaces.deleteEditorLayoutFieldGroup(this.fieldGroupId);
|
|
19
|
+
await editorInterfaces.deleteGroupControl(this.fieldGroupId);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.EditorLayoutDeleteFieldGroupAction = EditorLayoutDeleteFieldGroupAction;
|
|
23
|
+
//# sourceMappingURL=editor-layout-delete-field-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-layout-delete-field-group.js","sourceRoot":"","sources":["../../../../src/lib/action/editor-layout/editor-layout-delete-field-group.ts"],"names":[],"mappings":";;;AACA,sCAAoD;AAgBpD,MAAM,kCAAmC,SAAQ,qBAAY;IAI3D,YAAa,aAAqB,EAAE,YAAoB;QACtD,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED,aAAa;QACX,OAAO,mBAAU,CAAC,eAAe,CAAA;IACnC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO,CAAE,gBAAkC;QAC/C,MAAM,gBAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACtE,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;IAC9D,CAAC;CACF;AAEQ,gFAAkC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EditorLayoutDeleteAction = void 0;
|
|
4
|
+
const action_1 = require("../action");
|
|
5
|
+
class EditorLayoutDeleteAction extends action_1.EntityAction {
|
|
6
|
+
constructor(contentTypeId) {
|
|
7
|
+
super();
|
|
8
|
+
this.contentTypeId = contentTypeId;
|
|
9
|
+
}
|
|
10
|
+
getEntityType() {
|
|
11
|
+
return action_1.EntityType.EditorInterface;
|
|
12
|
+
}
|
|
13
|
+
getEntityId() {
|
|
14
|
+
return this.contentTypeId;
|
|
15
|
+
}
|
|
16
|
+
async applyTo(editorInterfaces) {
|
|
17
|
+
await editorInterfaces.deleteEditorLayout();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.EditorLayoutDeleteAction = EditorLayoutDeleteAction;
|
|
21
|
+
//# sourceMappingURL=editor-layout-delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-layout-delete.js","sourceRoot":"","sources":["../../../../src/lib/action/editor-layout/editor-layout-delete.ts"],"names":[],"mappings":";;;AACA,sCAAoD;AAEpD,MAAM,wBAAyB,SAAQ,qBAAY;IAGjD,YAAa,aAAqB;QAChC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;IACpC,CAAC;IAED,aAAa;QACX,OAAO,mBAAU,CAAC,eAAe,CAAA;IACnC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO,CAAE,gBAAkC;QAC/C,MAAM,gBAAgB,CAAC,kBAAkB,EAAE,CAAA;IAC7C,CAAC;CACF;AAEQ,4DAAwB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EditorLayoutMoveFieldGroupAction = void 0;
|
|
4
|
+
const action_1 = require("../action");
|
|
5
|
+
class EditorLayoutMoveFieldGroupAction extends action_1.EntityAction {
|
|
6
|
+
constructor(contentTypeId, fieldId, direction, pivot) {
|
|
7
|
+
super();
|
|
8
|
+
this.contentTypeId = contentTypeId;
|
|
9
|
+
this.fieldId = fieldId,
|
|
10
|
+
this.direction = direction,
|
|
11
|
+
this.pivot = pivot;
|
|
12
|
+
}
|
|
13
|
+
getEntityType() {
|
|
14
|
+
return action_1.EntityType.EditorInterface;
|
|
15
|
+
}
|
|
16
|
+
getEntityId() {
|
|
17
|
+
return this.contentTypeId;
|
|
18
|
+
}
|
|
19
|
+
async applyTo(editorInterfaces) {
|
|
20
|
+
await editorInterfaces.moveFieldInEditorLayout(this.fieldId, this.direction, this.pivot);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.EditorLayoutMoveFieldGroupAction = EditorLayoutMoveFieldGroupAction;
|
|
24
|
+
//# sourceMappingURL=editor-layout-move-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-layout-move-field.js","sourceRoot":"","sources":["../../../../src/lib/action/editor-layout/editor-layout-move-field.ts"],"names":[],"mappings":";;;AACA,sCAAoD;AAEpD,MAAM,gCAAiC,SAAQ,qBAAY;IAMzD,YAAa,aAAqB,EAAE,OAAe,EAAE,SAA6C,EAAE,KAAc;QAChH,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO;YACtB,IAAI,CAAC,SAAS,GAAG,SAAS;YAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,aAAa;QACX,OAAO,mBAAU,CAAC,eAAe,CAAA;IACnC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO,CAAE,gBAAkC;QAC/C,MAAM,gBAAgB,CAAC,uBAAuB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IAC1F,CAAC;CACF;AAEQ,4EAAgC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EditorLayoutChangeFieldGroupIdAction = exports.EditorLayoutUpdateFieldGroupAction = void 0;
|
|
4
|
+
const action_1 = require("../action");
|
|
5
|
+
class EditorLayoutUpdateFieldGroupAction extends action_1.EntityAction {
|
|
6
|
+
constructor(contentTypeId, fieldGroupId, props) {
|
|
7
|
+
super();
|
|
8
|
+
this.contentTypeId = contentTypeId;
|
|
9
|
+
this.fieldGroupId = fieldGroupId;
|
|
10
|
+
this.props = props;
|
|
11
|
+
}
|
|
12
|
+
getEntityType() {
|
|
13
|
+
return action_1.EntityType.EditorInterface;
|
|
14
|
+
}
|
|
15
|
+
getEntityId() {
|
|
16
|
+
return this.contentTypeId;
|
|
17
|
+
}
|
|
18
|
+
async applyTo(editorInterfaces) {
|
|
19
|
+
await editorInterfaces.updateEditorLayoutFieldGroup(this.fieldGroupId, this.props);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.EditorLayoutUpdateFieldGroupAction = EditorLayoutUpdateFieldGroupAction;
|
|
23
|
+
class EditorLayoutChangeFieldGroupIdAction extends action_1.EntityAction {
|
|
24
|
+
constructor(contentTypeId, fieldGroupId, newFieldGroupId) {
|
|
25
|
+
super();
|
|
26
|
+
this.contentTypeId = contentTypeId;
|
|
27
|
+
this.fieldGroupId = fieldGroupId;
|
|
28
|
+
this.newFieldGroupId = newFieldGroupId;
|
|
29
|
+
}
|
|
30
|
+
getEntityType() {
|
|
31
|
+
return action_1.EntityType.EditorInterface;
|
|
32
|
+
}
|
|
33
|
+
getEntityId() {
|
|
34
|
+
return this.contentTypeId;
|
|
35
|
+
}
|
|
36
|
+
async applyTo(editorInterfaces) {
|
|
37
|
+
await editorInterfaces.changeFieldGroupId(this.fieldGroupId, this.newFieldGroupId);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.EditorLayoutChangeFieldGroupIdAction = EditorLayoutChangeFieldGroupIdAction;
|
|
41
|
+
//# sourceMappingURL=editor-layout-update-field-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-layout-update-field-group.js","sourceRoot":"","sources":["../../../../src/lib/action/editor-layout/editor-layout-update-field-group.ts"],"names":[],"mappings":";;;AACA,sCAAoD;AAGpD,MAAM,kCAAmC,SAAQ,qBAAY;IAK3D,YAAa,aAAqB,EAAE,YAAoB,EAAE,KAAkD;QAC1G,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,aAAa;QACX,OAAO,mBAAU,CAAC,eAAe,CAAA;IACnC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO,CAAE,gBAAkC;QAC/C,MAAM,gBAAgB,CAAC,4BAA4B,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IACpF,CAAC;CACF;AA2BQ,gFAAkC;AAzB3C,MAAM,oCAAqC,SAAQ,qBAAY;IAK7D,YAAa,aAAqB,EAAE,YAAoB,EAAE,eAAuB;QAC/E,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;IACxC,CAAC;IAED,aAAa;QACX,OAAO,mBAAU,CAAC,eAAe,CAAA;IACnC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO,CAAE,gBAAkC;QAC/C,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,CAAA;IACpF,CAAC;CACF;AAE4C,oFAAoC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FieldAnnotateAction = void 0;
|
|
4
|
+
const action_1 = require("./action");
|
|
5
|
+
class FieldAnnotateAction extends action_1.EntityAction {
|
|
6
|
+
constructor(contentTypeId, fieldId, annotations) {
|
|
7
|
+
super();
|
|
8
|
+
this.contentTypeId = contentTypeId;
|
|
9
|
+
this.fieldId = fieldId;
|
|
10
|
+
this.annotations = annotations;
|
|
11
|
+
}
|
|
12
|
+
getEntityId() {
|
|
13
|
+
return this.contentTypeId;
|
|
14
|
+
}
|
|
15
|
+
getEntityType() {
|
|
16
|
+
return action_1.EntityType.ContentType;
|
|
17
|
+
}
|
|
18
|
+
async applyTo(ct) {
|
|
19
|
+
if (!this.annotations || !this.annotations.length) {
|
|
20
|
+
ct.clearFieldAnnotations(this.fieldId);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
ct.setFieldAnnotations(this.fieldId, this.annotations);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.FieldAnnotateAction = FieldAnnotateAction;
|
|
28
|
+
//# sourceMappingURL=field-annotate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-annotate.js","sourceRoot":"","sources":["../../../src/lib/action/field-annotate.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AAGnD,MAAM,mBAAoB,SAAQ,qBAAY;IAK5C,YAAY,aAAqB,EAAE,OAAe,EAAE,WAA8B;QAChF,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,aAAa;QACX,OAAO,mBAAU,CAAC,WAAW,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAe;QAC3B,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;YACjD,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SACvC;aAAM;YACL,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;SACvD;IACH,CAAC;CACF;AAEQ,kDAAmB"}
|
|
@@ -18,10 +18,14 @@ class FieldRenameAction extends action_1.EntityAction {
|
|
|
18
18
|
async applyTo(ct) {
|
|
19
19
|
const fields = ct.fields;
|
|
20
20
|
const field = fields.getField(this.fieldId);
|
|
21
|
+
const fieldAnnotations = ct.getFieldAnnotations(this.fieldId);
|
|
21
22
|
fields.deleteField(this.fieldId);
|
|
22
23
|
field.id = this.props.newId;
|
|
23
24
|
delete field.newId;
|
|
24
25
|
fields.setField(this.props.newId, field);
|
|
26
|
+
if (fieldAnnotations) {
|
|
27
|
+
ct.setFieldAnnotations(this.props.newId, fieldAnnotations);
|
|
28
|
+
}
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
exports.FieldRenameAction = FieldRenameAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-rename.js","sourceRoot":"","sources":["../../../src/lib/action/field-rename.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AAOnD,MAAM,iBAAkB,SAAQ,qBAAY;IAK1C,YAAY,aAAqB,EAAE,OAAe,EAAE,KAAuB;QACzE,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,aAAa;QACX,OAAO,mBAAU,CAAC,WAAW,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAe;QAC3B,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,CAAA;QACxB,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAE3C,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAChC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAA;QAC3B,OAAO,KAAK,CAAC,KAAK,CAAA;QAElB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"field-rename.js","sourceRoot":"","sources":["../../../src/lib/action/field-rename.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AAOnD,MAAM,iBAAkB,SAAQ,qBAAY;IAK1C,YAAY,aAAqB,EAAE,OAAe,EAAE,KAAuB;QACzE,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,aAAa;QACX,OAAO,mBAAU,CAAC,WAAW,CAAA;IAC/B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAe;QAC3B,MAAM,MAAM,GAAG,EAAE,CAAC,MAAM,CAAA;QACxB,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAE3C,MAAM,gBAAgB,GAAG,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC7D,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAChC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAA;QAC3B,OAAO,KAAK,CAAC,KAAK,CAAA;QAElB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QACxC,IAAI,gBAAgB,EAAE;YACpB,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAA;SAC3D;IACH,CAAC;CACF;AAEQ,8CAAiB"}
|
|
@@ -3,8 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EditorInterfaces = exports.Fields = exports.ContentType = exports.default = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const sidebarwidget_1 = require("../action/sidebarwidget");
|
|
6
|
+
const editor_layout_1 = require("../utils/editor-layout");
|
|
7
|
+
function prune(obj) {
|
|
8
|
+
if (obj === undefined) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(obj)) {
|
|
12
|
+
return obj.length === 0 ? undefined : obj;
|
|
13
|
+
}
|
|
14
|
+
let isEmpty = true;
|
|
15
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
16
|
+
if (!prune(value)) {
|
|
17
|
+
delete obj[key];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
isEmpty = false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return isEmpty ? undefined : obj;
|
|
24
|
+
}
|
|
6
25
|
class Fields {
|
|
7
|
-
constructor(fields = []) {
|
|
26
|
+
constructor(contentType, fields = []) {
|
|
27
|
+
this._contentType = contentType;
|
|
8
28
|
this._fields = fields;
|
|
9
29
|
}
|
|
10
30
|
getField(id) {
|
|
@@ -19,11 +39,15 @@ class Fields {
|
|
|
19
39
|
else {
|
|
20
40
|
allFields[currentFieldIndex] = field;
|
|
21
41
|
}
|
|
42
|
+
if (field.deleted) {
|
|
43
|
+
this._contentType.clearFieldAnnotations(id);
|
|
44
|
+
}
|
|
22
45
|
this._fields = allFields;
|
|
23
46
|
}
|
|
24
47
|
deleteField(id) {
|
|
25
48
|
const fieldToDelete = (0, lodash_1.find)(this._fields, { id });
|
|
26
49
|
(0, lodash_1.pull)(this._fields, fieldToDelete);
|
|
50
|
+
this._contentType.clearFieldAnnotations(id);
|
|
27
51
|
}
|
|
28
52
|
moveField(id, direction, pivot) {
|
|
29
53
|
const fields = this._fields;
|
|
@@ -56,7 +80,7 @@ class Fields {
|
|
|
56
80
|
this._fields = fields;
|
|
57
81
|
}
|
|
58
82
|
clone() {
|
|
59
|
-
return new Fields(this.toRaw());
|
|
83
|
+
return new Fields(this._contentType.clone(), this.toRaw());
|
|
60
84
|
}
|
|
61
85
|
toRaw() {
|
|
62
86
|
return (0, lodash_1.cloneDeep)(this.fields);
|
|
@@ -70,6 +94,8 @@ class EditorInterfaces {
|
|
|
70
94
|
this._sidebar = apiEditorInterfaces.sidebar || undefined;
|
|
71
95
|
this._editor = apiEditorInterfaces.editor || undefined;
|
|
72
96
|
this._editors = apiEditorInterfaces.editors || undefined;
|
|
97
|
+
this._editorLayout = apiEditorInterfaces.editorLayout || undefined;
|
|
98
|
+
this._groupControls = apiEditorInterfaces.groupControls || undefined;
|
|
73
99
|
}
|
|
74
100
|
get version() {
|
|
75
101
|
return this._version;
|
|
@@ -89,6 +115,12 @@ class EditorInterfaces {
|
|
|
89
115
|
getControls() {
|
|
90
116
|
return this._controls;
|
|
91
117
|
}
|
|
118
|
+
getEditorLayout() {
|
|
119
|
+
return this._editorLayout;
|
|
120
|
+
}
|
|
121
|
+
getGroupControls() {
|
|
122
|
+
return this._groupControls;
|
|
123
|
+
}
|
|
92
124
|
reset(fieldId) {
|
|
93
125
|
let controlIndex = (0, lodash_1.findIndex)(this._controls, (c) => {
|
|
94
126
|
return c.fieldId === fieldId;
|
|
@@ -180,6 +212,177 @@ class EditorInterfaces {
|
|
|
180
212
|
setEditors(editors) {
|
|
181
213
|
this._editors = editors;
|
|
182
214
|
}
|
|
215
|
+
createEditorLayout(fields) {
|
|
216
|
+
// A newly created editor layout doesn’t have the correct shape. This is corrected when adding the first group.
|
|
217
|
+
this._editorLayout = fields.map((field) => ({
|
|
218
|
+
fieldId: field.id
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
deleteEditorLayout() {
|
|
222
|
+
delete this._groupControls;
|
|
223
|
+
delete this._editorLayout;
|
|
224
|
+
}
|
|
225
|
+
createEditorLayoutFieldGroup(fieldGroupId, parentFieldGroupId) {
|
|
226
|
+
if (parentFieldGroupId) {
|
|
227
|
+
// create field set
|
|
228
|
+
const parent = (0, editor_layout_1.findFieldGroup)(this._editorLayout, parentFieldGroupId);
|
|
229
|
+
parent.item.items.push({
|
|
230
|
+
groupId: fieldGroupId,
|
|
231
|
+
items: []
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
// create tab
|
|
236
|
+
const hasFieldGroup = this._editorLayout.some((item) => (0, editor_layout_1.isFieldGroupItem)(item));
|
|
237
|
+
if (hasFieldGroup) {
|
|
238
|
+
this._editorLayout.push({
|
|
239
|
+
groupId: fieldGroupId,
|
|
240
|
+
items: []
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
this._editorLayout = [
|
|
245
|
+
{
|
|
246
|
+
groupId: fieldGroupId,
|
|
247
|
+
items: [...this._editorLayout]
|
|
248
|
+
}
|
|
249
|
+
];
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
deleteEditorLayoutFieldGroup(fieldGroupId) {
|
|
254
|
+
const fieldGroup = (0, editor_layout_1.findFieldGroup)(this._editorLayout, fieldGroupId);
|
|
255
|
+
if (!fieldGroup) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const parentPath = fieldGroup.path.slice(0, -1);
|
|
259
|
+
const groupIndex = fieldGroup.path[fieldGroup.path.length - 1];
|
|
260
|
+
if (parentPath.length === 0) {
|
|
261
|
+
this._editorLayout = this._editorLayout.filter((item) => item.groupId !== fieldGroupId);
|
|
262
|
+
this._editorLayout[0].items = [...this._editorLayout[0].items, ...fieldGroup.item.items];
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
(0, lodash_1.update)(this._editorLayout, parentPath, (prev) => {
|
|
266
|
+
const group = prev[groupIndex];
|
|
267
|
+
return [...prev.slice(0, groupIndex), ...group.items, ...prev.slice(groupIndex + 1)];
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
changeFieldGroupId(fieldGroupId, newFieldGroupId) {
|
|
271
|
+
const fieldGroup = (0, editor_layout_1.findFieldGroup)(this._editorLayout, fieldGroupId);
|
|
272
|
+
if (fieldGroup === null || fieldGroup === void 0 ? void 0 : fieldGroup.item) {
|
|
273
|
+
fieldGroup.item.groupId = newFieldGroupId;
|
|
274
|
+
}
|
|
275
|
+
const existingGroupControl = this._groupControls.find((control) => control.groupId === fieldGroupId);
|
|
276
|
+
if (existingGroupControl) {
|
|
277
|
+
existingGroupControl.groupId = newFieldGroupId;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
updateEditorLayoutFieldGroup(fieldGroupId, props) {
|
|
281
|
+
const fieldGroup = (0, editor_layout_1.findFieldGroup)(this._editorLayout, fieldGroupId);
|
|
282
|
+
Object.assign(fieldGroup.item, (0, lodash_1.pick)(props, ['name']));
|
|
283
|
+
}
|
|
284
|
+
createGroupControls() {
|
|
285
|
+
this._groupControls = [];
|
|
286
|
+
}
|
|
287
|
+
createTabGroupControl(fieldGroupId) {
|
|
288
|
+
this._groupControls.push({
|
|
289
|
+
groupId: fieldGroupId,
|
|
290
|
+
widgetId: 'topLevelTab',
|
|
291
|
+
widgetNamespace: 'builtin'
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
updateGroupControl(fieldGroupId, groupControl) {
|
|
295
|
+
var _a;
|
|
296
|
+
const existingGroupControl = this._groupControls.find((control) => control.groupId === fieldGroupId);
|
|
297
|
+
if (existingGroupControl) {
|
|
298
|
+
existingGroupControl.widgetId = groupControl.widgetId;
|
|
299
|
+
existingGroupControl.widgetNamespace = groupControl.widgetNamespace;
|
|
300
|
+
if (groupControl.settings !== undefined) {
|
|
301
|
+
existingGroupControl.settings = groupControl.settings;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
this._groupControls.push({
|
|
306
|
+
groupId: fieldGroupId,
|
|
307
|
+
widgetId: groupControl.widgetId,
|
|
308
|
+
widgetNamespace: groupControl.widgetNamespace,
|
|
309
|
+
settings: (_a = groupControl.settings) !== null && _a !== void 0 ? _a : {}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
deleteGroupControl(fieldGroupId) {
|
|
314
|
+
this._groupControls = this._groupControls.filter((control) => control.groupId !== fieldGroupId);
|
|
315
|
+
}
|
|
316
|
+
moveFieldInEditorLayout(fieldId, direction, pivot) {
|
|
317
|
+
// find the field and its parent (sourceGroup) within editorLayout
|
|
318
|
+
let fieldItem;
|
|
319
|
+
const { item: sourceGroupItem } = (0, editor_layout_1.find)(this._editorLayout, (item) => (0, editor_layout_1.isFieldGroupItem)(item) &&
|
|
320
|
+
Boolean(item.items.find((item) => {
|
|
321
|
+
if (isTargetFieldItem(item, fieldId)) {
|
|
322
|
+
fieldItem = item;
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
return false;
|
|
326
|
+
})));
|
|
327
|
+
// remove field item from original group
|
|
328
|
+
if (sourceGroupItem) {
|
|
329
|
+
(0, lodash_1.pull)(sourceGroupItem.items, fieldItem);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
fieldItem = { fieldId };
|
|
333
|
+
}
|
|
334
|
+
// here it's assumed the field is moved within its group. If not the case, later below destination is updated
|
|
335
|
+
let destinationGroupItem = sourceGroupItem;
|
|
336
|
+
const findGroupItem = (groupId) => {
|
|
337
|
+
const { item } = (0, editor_layout_1.find)(this._editorLayout, (item) => isTargetGroupItem(item, groupId));
|
|
338
|
+
return item;
|
|
339
|
+
};
|
|
340
|
+
let pivotIndex;
|
|
341
|
+
if (direction === 'toTheTopOfFieldGroup') {
|
|
342
|
+
if (pivot) {
|
|
343
|
+
destinationGroupItem = findGroupItem(pivot);
|
|
344
|
+
}
|
|
345
|
+
pivotIndex = 0;
|
|
346
|
+
}
|
|
347
|
+
else if (direction === 'toTheBottomOfFieldGroup') {
|
|
348
|
+
if (pivot) {
|
|
349
|
+
destinationGroupItem = findGroupItem(pivot);
|
|
350
|
+
}
|
|
351
|
+
pivotIndex = destinationGroupItem.items.length;
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
const movementConfigMap = {
|
|
355
|
+
afterField: {
|
|
356
|
+
isTargetPivot: (item) => isTargetFieldItem(item, pivot),
|
|
357
|
+
pivotIndexOffset: 1
|
|
358
|
+
},
|
|
359
|
+
beforeField: {
|
|
360
|
+
isTargetPivot: (item) => isTargetFieldItem(item, pivot),
|
|
361
|
+
pivotIndexOffset: 0
|
|
362
|
+
},
|
|
363
|
+
afterFieldGroup: {
|
|
364
|
+
isTargetPivot: (item) => isTargetGroupItem(item, pivot),
|
|
365
|
+
pivotIndexOffset: 1
|
|
366
|
+
},
|
|
367
|
+
beforeFieldGroup: {
|
|
368
|
+
isTargetPivot: (item) => isTargetGroupItem(item, pivot),
|
|
369
|
+
pivotIndexOffset: 0
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
const movementConfig = movementConfigMap[direction];
|
|
373
|
+
// find the parent group of target pivot
|
|
374
|
+
const { item: pivotParent } = (0, editor_layout_1.find)(this._editorLayout, (item) => (0, editor_layout_1.isFieldGroupItem)(item) &&
|
|
375
|
+
Boolean(item.items.find((childItem, childItemIndex) => {
|
|
376
|
+
if (movementConfig.isTargetPivot(childItem)) {
|
|
377
|
+
pivotIndex = childItemIndex + movementConfig.pivotIndexOffset;
|
|
378
|
+
return true;
|
|
379
|
+
}
|
|
380
|
+
return false;
|
|
381
|
+
})));
|
|
382
|
+
destinationGroupItem = pivotParent;
|
|
383
|
+
}
|
|
384
|
+
destinationGroupItem.items.splice(pivotIndex, 0, fieldItem);
|
|
385
|
+
}
|
|
183
386
|
toAPI() {
|
|
184
387
|
let controls = [];
|
|
185
388
|
(0, lodash_1.forEach)(this._controls, (c) => {
|
|
@@ -203,6 +406,12 @@ class EditorInterfaces {
|
|
|
203
406
|
else if (this._editor) {
|
|
204
407
|
result.editor = this._editor;
|
|
205
408
|
}
|
|
409
|
+
if (this._editorLayout) {
|
|
410
|
+
result.editorLayout = this._editorLayout;
|
|
411
|
+
}
|
|
412
|
+
if (this._groupControls) {
|
|
413
|
+
result.groupControls = this._groupControls;
|
|
414
|
+
}
|
|
206
415
|
return result;
|
|
207
416
|
}
|
|
208
417
|
}
|
|
@@ -210,11 +419,12 @@ exports.EditorInterfaces = EditorInterfaces;
|
|
|
210
419
|
class ContentType {
|
|
211
420
|
constructor(ct) {
|
|
212
421
|
this._id = ct.sys.id;
|
|
213
|
-
this._fields = new Fields(ct.fields);
|
|
422
|
+
this._fields = new Fields(this, ct.fields);
|
|
214
423
|
this._name = ct.name;
|
|
215
424
|
this._description = ct.description;
|
|
216
425
|
this._version = ct.sys.version;
|
|
217
426
|
this._displayField = ct.displayField;
|
|
427
|
+
this._metadata = ct.metadata;
|
|
218
428
|
}
|
|
219
429
|
get id() {
|
|
220
430
|
return this._id;
|
|
@@ -243,6 +453,28 @@ class ContentType {
|
|
|
243
453
|
set displayField(displayField) {
|
|
244
454
|
this._displayField = displayField;
|
|
245
455
|
}
|
|
456
|
+
setAnnotations(annotations) {
|
|
457
|
+
(0, lodash_1.set)(this, '_metadata.annotations.ContentType', annotations);
|
|
458
|
+
}
|
|
459
|
+
getAnnotations() {
|
|
460
|
+
var _a, _b;
|
|
461
|
+
return (_b = (_a = this._metadata) === null || _a === void 0 ? void 0 : _a.annotations) === null || _b === void 0 ? void 0 : _b.ContentType;
|
|
462
|
+
}
|
|
463
|
+
clearAnnotations() {
|
|
464
|
+
var _a, _b;
|
|
465
|
+
(_b = (_a = this._metadata) === null || _a === void 0 ? void 0 : _a.annotations) === null || _b === void 0 ? true : delete _b.ContentType;
|
|
466
|
+
}
|
|
467
|
+
setFieldAnnotations(fieldId, annotations) {
|
|
468
|
+
(0, lodash_1.set)(this, `_metadata.annotations.ContentTypeField.${fieldId}`, annotations);
|
|
469
|
+
}
|
|
470
|
+
getFieldAnnotations(fieldId) {
|
|
471
|
+
var _a, _b, _c;
|
|
472
|
+
return (_c = (_b = (_a = this._metadata) === null || _a === void 0 ? void 0 : _a.annotations) === null || _b === void 0 ? void 0 : _b.ContentTypeField) === null || _c === void 0 ? void 0 : _c[fieldId];
|
|
473
|
+
}
|
|
474
|
+
clearFieldAnnotations(fieldId) {
|
|
475
|
+
var _a, _b, _c;
|
|
476
|
+
(_c = (_b = (_a = this._metadata) === null || _a === void 0 ? void 0 : _a.annotations) === null || _b === void 0 ? void 0 : _b.ContentTypeField) === null || _c === void 0 ? true : delete _c[fieldId];
|
|
477
|
+
}
|
|
246
478
|
get version() {
|
|
247
479
|
return this._version;
|
|
248
480
|
}
|
|
@@ -250,16 +482,10 @@ class ContentType {
|
|
|
250
482
|
this._version = version;
|
|
251
483
|
}
|
|
252
484
|
toAPI() {
|
|
253
|
-
return {
|
|
254
|
-
sys: {
|
|
485
|
+
return (0, lodash_1.cloneDeep)(Object.assign({ sys: {
|
|
255
486
|
id: this.id,
|
|
256
487
|
version: this.version
|
|
257
|
-
},
|
|
258
|
-
name: this.name,
|
|
259
|
-
displayField: this.displayField,
|
|
260
|
-
fields: this.fields.toRaw(),
|
|
261
|
-
description: this.description
|
|
262
|
-
};
|
|
488
|
+
}, name: this.name, displayField: this.displayField, fields: this.fields.toRaw(), description: this.description }, (this._metadata ? prune({ metadata: this._metadata }) : undefined)));
|
|
263
489
|
}
|
|
264
490
|
clone() {
|
|
265
491
|
return new ContentType(this.toAPI());
|
|
@@ -267,4 +493,6 @@ class ContentType {
|
|
|
267
493
|
}
|
|
268
494
|
exports.default = ContentType;
|
|
269
495
|
exports.ContentType = ContentType;
|
|
496
|
+
const isTargetFieldItem = (item, fieldId) => (0, editor_layout_1.isFieldItem)(item) && item.fieldId === fieldId;
|
|
497
|
+
const isTargetGroupItem = (item, groupId) => (0, editor_layout_1.isFieldGroupItem)(item) && item.groupId === groupId;
|
|
270
498
|
//# sourceMappingURL=content-type.js.map
|