@nascentdigital/funnel-editor 4.6.1 → 5.0.1
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/dist/EditorApp.js +1 -1
- package/dist/EditorRoutes.js +7 -5
- package/dist/changesets/screens/ChangeSetViewer.js +1 -1
- package/dist/changesets/screens/ChangeSetsExplorer.js +1 -2
- package/dist/collection/hooks/CollectionController.d.ts +5 -16
- package/dist/collection/hooks/CollectionController.js +18 -37
- package/dist/collection/hooks/ICollectionController.d.ts +24 -0
- package/dist/collection/hooks/ICollectionController.js +20 -0
- package/dist/collection/hooks/index.d.ts +1 -0
- package/dist/collection/hooks/index.js +1 -0
- package/dist/collection/hooks/useCollectionController.d.ts +3 -3
- package/dist/collection/screens/CollectionEditor.js +2 -2
- package/dist/components.d.ts +20 -0
- package/dist/components.js +41 -0
- package/dist/core/components/feedback/dialog/MinimalDialogLayout.js +1 -1
- package/dist/core/components/fields/BooleanField.d.ts +2 -1
- package/dist/core/components/fields/BooleanField.js +2 -2
- package/dist/core/components/fields/DateField.d.ts +2 -1
- package/dist/core/components/fields/DateField.js +2 -2
- package/dist/core/components/fields/DynamicPagesEditor.d.ts +2 -1
- package/dist/core/components/fields/DynamicPagesEditor.js +1 -1
- package/dist/core/components/fields/EnumField.d.ts +2 -1
- package/dist/core/components/fields/EnumField.js +2 -2
- package/dist/core/components/fields/FieldCard.d.ts +1 -0
- package/dist/core/components/fields/FieldCard.js +8 -1
- package/dist/core/components/fields/FieldEditor.d.ts +2 -1
- package/dist/core/components/fields/FieldEditor.js +11 -11
- package/dist/core/components/fields/FieldLayout.d.ts +2 -1
- package/dist/core/components/fields/FieldLayout.js +3 -3
- package/dist/core/components/fields/ListEditor.d.ts +2 -1
- package/dist/core/components/fields/ListEditor.js +5 -6
- package/dist/core/components/fields/OptInField.d.ts +2 -1
- package/dist/core/components/fields/OptInField.js +2 -2
- package/dist/core/components/fields/RichTextEditor.js +1 -1
- package/dist/core/components/fields/RichTextField.d.ts +2 -1
- package/dist/core/components/fields/RichTextField.js +3 -5
- package/dist/core/components/fields/TextField.d.ts +2 -0
- package/dist/core/components/fields/TextField.js +2 -2
- package/dist/core/components/fields/TimestampField.d.ts +2 -1
- package/dist/core/components/fields/TimestampField.js +3 -3
- package/dist/core/components/fields/asset/AssetEditor.js +12 -44
- package/dist/core/components/fields/asset/AssetPicker.js +6 -6
- package/dist/core/components/fields/asset/AssetUploader.js +23 -31
- package/dist/core/components/fields/asset/preview/VideoPreview.js +16 -11
- package/dist/core/components/fields/asset/useAssetFields.d.ts +2 -17
- package/dist/core/components/fields/asset/useAssetFields.js +0 -21
- package/dist/core/components/fields/collection/CollectionEditor.js +1 -1
- package/dist/core/components/fields/collection/CollectionPicker.d.ts +2 -2
- package/dist/core/components/fields/collection/CollectionPicker.js +3 -4
- package/dist/core/components/fields/dynamicPages/PagePriorityDialog.js +1 -1
- package/dist/core/components/fields/embed/EmbeddedVideoEditor.js +34 -27
- package/dist/core/components/fields/factories/FieldValueFactory.js +11 -4
- package/dist/core/components/fields/factories/MediaFactory.d.ts +13 -0
- package/dist/core/components/fields/factories/MediaFactory.js +256 -0
- package/dist/core/components/fields/list/CreateFieldButton.js +1 -1
- package/dist/core/components/fields/media/MediaCard.d.ts +7 -0
- package/dist/core/components/fields/media/MediaCard.js +92 -0
- package/dist/core/components/fields/media/MediaEditor.d.ts +37 -0
- package/dist/core/components/fields/media/MediaEditor.js +235 -0
- package/dist/core/components/fields/media/MediaPicker.d.ts +15 -0
- package/dist/core/components/fields/media/MediaPicker.js +251 -0
- package/dist/core/components/fields/media/index.d.ts +3 -0
- package/dist/core/components/fields/media/index.js +19 -0
- package/dist/core/components/fields/object/ObjectEditor.js +1 -1
- package/dist/core/components/fields/page/PagePicker.d.ts +2 -2
- package/dist/core/components/fields/page/PagePicker.js +1 -1
- package/dist/core/components/interaction/Combobox.js +1 -1
- package/dist/core/components/interaction/DateTimePicker.d.ts +0 -1
- package/dist/core/components/interaction/DateTimePicker.js +0 -2
- package/dist/core/components/interaction/MultiSelectControls.js +2 -5
- package/dist/core/components/interaction/Popup.js +1 -0
- package/dist/core/components/interaction/QuickEditor.js +1 -1
- package/dist/core/components/interaction/QuickPicker.js +1 -1
- package/dist/core/components/interaction/SideSheet.js +1 -1
- package/dist/core/components/interaction/centersheet/CenterSheet.js +7 -1
- package/dist/core/components/interaction/centersheet/CenterSheetContainer.js +3 -1
- package/dist/core/components/transitions/FadeIn.js +2 -14
- package/dist/core/components/visuals/Icon.d.ts +1 -1
- package/dist/core/components/visuals/Icon.js +3 -0
- package/dist/core/containers/AssetRepositoryContainer.d.ts +2 -0
- package/dist/core/containers/AssetRepositoryContainer.js +18 -0
- package/dist/core/containers/CollectionRepositoryContainer.d.ts +2 -0
- package/dist/core/containers/CollectionRepositoryContainer.js +18 -0
- package/dist/core/containers/PageRepositoryContainer.d.ts +2 -0
- package/dist/core/containers/PageRepositoryContainer.js +18 -0
- package/dist/core/containers/index.d.ts +3 -0
- package/dist/core/containers/index.js +19 -0
- package/dist/core/domain/Block.d.ts +1 -0
- package/dist/core/domain/Block.js +8 -5
- package/dist/core/domain/BlockConfiguration.d.ts +4 -1
- package/dist/core/domain/BlockConfiguration.js +64 -3
- package/dist/core/domain/Collection.d.ts +10 -28
- package/dist/core/domain/Collection.js +2 -16
- package/dist/core/domain/CollectionBrowser.d.ts +3 -2
- package/dist/core/domain/CollectionBrowser.js +3 -3
- package/dist/core/domain/CollectionFieldProxy.d.ts +12 -8
- package/dist/core/domain/CollectionFieldProxy.js +14 -8
- package/dist/core/domain/CollectionGroup.d.ts +0 -5
- package/dist/core/domain/CollectionGroup.js +0 -7
- package/dist/core/domain/CollectionSummary.d.ts +2 -2
- package/dist/core/domain/Collections.d.ts +3 -3
- package/dist/core/domain/Collections.js +4 -4
- package/dist/core/domain/ICollection.d.ts +71 -0
- package/dist/core/domain/ICollection.js +20 -0
- package/dist/core/domain/IPage.d.ts +72 -0
- package/dist/core/domain/IPage.js +20 -0
- package/dist/core/domain/IPageRefStore.d.ts +3 -3
- package/dist/core/domain/ItemBase.d.ts +6 -6
- package/dist/core/domain/ItemBase.js +5 -5
- package/dist/core/domain/Page.d.ts +9 -22
- package/dist/core/domain/Page.js +3 -18
- package/dist/core/domain/PageOverview.d.ts +2 -2
- package/dist/core/domain/PageRefStoreProxy.d.ts +4 -4
- package/dist/core/domain/PageSettings.d.ts +3 -3
- package/dist/core/domain/PageSummary.d.ts +2 -2
- package/dist/core/domain/Pages.js +4 -6
- package/dist/core/domain/SectionBlock.js +2 -1
- package/dist/core/domain/Site.d.ts +4 -4
- package/dist/core/domain/Site.js +3 -3
- package/dist/core/domain/index.d.ts +2 -1
- package/dist/core/domain/index.js +2 -1
- package/dist/core/hooks/index.d.ts +4 -3
- package/dist/core/hooks/index.js +4 -3
- package/dist/core/hooks/useAssetRepository.d.ts +3 -0
- package/dist/core/hooks/useAssetRepository.js +11 -0
- package/dist/core/hooks/useCollection.d.ts +4 -4
- package/dist/core/hooks/useCollectionRepository.d.ts +3 -2
- package/dist/core/hooks/useCollectionRepository.js +4 -4
- package/dist/core/hooks/usePage.d.ts +4 -4
- package/dist/core/hooks/usePageRef.d.ts +1 -1
- package/dist/core/hooks/usePageRepository.d.ts +3 -2
- package/dist/core/hooks/usePageRepository.js +4 -4
- package/dist/core/hooks/useTempFields.d.ts +2 -3
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/repository/AssetRepository.d.ts +10 -0
- package/dist/core/repository/AssetRepository.js +22 -0
- package/dist/core/repository/CollectionRepository.d.ts +21 -20
- package/dist/core/repository/CollectionRepository.js +23 -161
- package/dist/core/repository/CollectionSerializer.d.ts +4 -1
- package/dist/core/repository/CollectionSerializer.js +3 -3
- package/dist/core/repository/IAssetRepository.d.ts +25 -0
- package/dist/core/repository/ICollectionRepository.d.ts +62 -0
- package/dist/core/repository/ICollectionRepository.js +2 -0
- package/dist/core/repository/IPageRepository.d.ts +40 -0
- package/dist/core/repository/IPageRepository.js +2 -0
- package/dist/core/repository/PageRepository.d.ts +6 -9
- package/dist/core/repository/PageRepository.js +7 -280
- package/dist/core/repository/PageSerializer.d.ts +34 -1
- package/dist/core/repository/PageSerializer.js +4 -0
- package/dist/core/repository/SerializeCollectionUpdate.d.ts +8 -0
- package/dist/core/repository/SerializeCollectionUpdate.js +168 -0
- package/dist/core/repository/SerializePageUpdate.d.ts +11 -0
- package/dist/core/repository/SerializePageUpdate.js +292 -0
- package/dist/core/repository/index.d.ts +4 -0
- package/dist/core/repository/index.js +4 -0
- package/dist/dashboard/screens/Dashboard.js +1 -1
- package/dist/devtools/screens/Devtools.js +1 -1
- package/dist/explore/components/CreatePageDialog.d.ts +2 -2
- package/dist/explore/screens/CollectionExplorer.js +1 -1
- package/dist/explore/screens/CollectionsExplorer.js +1 -1
- package/dist/explore/screens/PageExplorer.js +1 -1
- package/dist/explore/screens/SiteExplorer.js +1 -1
- package/dist/page/components/BlockEditor.js +1 -1
- package/dist/page/components/PageHeader.d.ts +2 -2
- package/dist/page/components/PageNotCreated.d.ts +2 -2
- package/dist/page/components/PageNotFound.d.ts +2 -2
- package/dist/page/components/SettingsEditor.js +0 -7
- package/dist/page/components/config/BlockConfigButton.d.ts +2 -1
- package/dist/page/components/config/BlockConfigButton.js +84 -24
- package/dist/page/components/config/BlockPreview.d.ts +8 -0
- package/dist/page/components/config/BlockPreview.js +53 -0
- package/dist/page/components/config/index.d.ts +1 -1
- package/dist/page/components/config/index.js +1 -1
- package/dist/page/components/config/preview/ColumnLayout.d.ts +10 -0
- package/dist/page/components/config/preview/ColumnLayout.js +15 -0
- package/dist/page/components/config/preview/ItemLayout.d.ts +12 -0
- package/dist/page/components/config/preview/ItemLayout.js +45 -0
- package/dist/page/components/config/preview/ListPanel.d.ts +12 -0
- package/dist/page/components/config/preview/ListPanel.js +14 -0
- package/dist/page/components/config/preview/MessagePanel.d.ts +12 -0
- package/dist/page/components/config/preview/MessagePanel.js +21 -0
- package/dist/page/components/config/preview/Panel.d.ts +15 -0
- package/dist/page/components/config/preview/Panel.js +74 -0
- package/dist/page/components/config/preview/RowLayout.d.ts +10 -0
- package/dist/page/components/config/preview/RowLayout.js +26 -0
- package/dist/page/components/config/preview/StackLayout.d.ts +10 -0
- package/dist/page/components/config/preview/StackLayout.js +15 -0
- package/dist/page/components/config/preview/VisualPanel.d.ts +12 -0
- package/dist/page/components/config/preview/VisualPanel.js +27 -0
- package/dist/page/components/config/preview/index.d.ts +3 -0
- package/dist/page/components/config/preview/index.js +19 -0
- package/dist/page/components/panels/BlockConfigPanel.js +4 -4
- package/dist/page/hooks/IPageController.d.ts +42 -0
- package/dist/page/hooks/IPageController.js +32 -0
- package/dist/page/hooks/PageController.d.ts +11 -36
- package/dist/page/hooks/PageController.js +7 -33
- package/dist/page/hooks/index.d.ts +1 -0
- package/dist/page/hooks/index.js +1 -0
- package/dist/page/hooks/usePageController.d.ts +3 -3
- package/dist/page/screens/PageEditor.js +1 -1
- package/dist/styles/index.css +809 -60
- package/dist/styles/tailwind.js +1 -0
- package/dist/users/screens/UserExplorer.js +1 -1
- package/package.json +3 -2
- package/dist/core/domain/TranslateSchema.d.ts +0 -7
- package/dist/page/components/config/LegacyBlockPreview.d.ts +0 -8
- package/dist/page/components/config/LegacyBlockPreview.js +0 -452
- /package/dist/core/{domain/TranslateSchema.js → repository/IAssetRepository.js} +0 -0
|
@@ -18,6 +18,7 @@ export declare class Block<TBlock extends Schema.Block = Schema.Block> extends I
|
|
|
18
18
|
get identifier(): string;
|
|
19
19
|
get name(): string;
|
|
20
20
|
get state(): "undefined" | "invalid" | "valid";
|
|
21
|
+
get fieldChanged$(): import("rxjs").Observable<Field.Event>;
|
|
21
22
|
get value(): Schema.Block.Data;
|
|
22
23
|
get modified(): boolean;
|
|
23
24
|
get changes(): Block.Changes;
|
|
@@ -39,10 +39,7 @@ class Block extends ItemBase_1.ItemBase {
|
|
|
39
39
|
this.listsFields = this.fields.filter(field => field.id === 'list');
|
|
40
40
|
this.extendedFields = this.fields.filter(field => !messageKeys.includes(field.id) && field.id !== 'visual' && field.id !== 'list');
|
|
41
41
|
// listen to field changes
|
|
42
|
-
this.
|
|
43
|
-
.pipe((0, rxjs_1.filter)(funnel_core_1.Field.Event.filter), (0, rxjs_1.filter)(event => (event.type === 'changed' || event.type === 'reset')
|
|
44
|
-
&& this.fields.includes(event.field)))
|
|
45
|
-
.subscribe(event => this.onFieldChange(event));
|
|
42
|
+
this.fieldChanged$.subscribe(event => this.onFieldChange(event));
|
|
46
43
|
}
|
|
47
44
|
get identifier() {
|
|
48
45
|
return this.key;
|
|
@@ -57,6 +54,11 @@ class Block extends ItemBase_1.ItemBase {
|
|
|
57
54
|
: 'invalid'
|
|
58
55
|
: 'undefined';
|
|
59
56
|
}
|
|
57
|
+
get fieldChanged$() {
|
|
58
|
+
return this.eventBus.events$
|
|
59
|
+
.pipe((0, rxjs_1.filter)(funnel_core_1.Field.Event.filter), (0, rxjs_1.filter)(event => (event.type === 'changed' || event.type === 'reset')
|
|
60
|
+
&& this.fields.includes(event.field)));
|
|
61
|
+
}
|
|
60
62
|
get value() {
|
|
61
63
|
const { schema, config, fields } = this;
|
|
62
64
|
return {
|
|
@@ -117,7 +119,8 @@ class Block extends ItemBase_1.ItemBase {
|
|
|
117
119
|
}
|
|
118
120
|
}
|
|
119
121
|
getConfiguration() {
|
|
120
|
-
|
|
122
|
+
const { root } = this;
|
|
123
|
+
return new BlockConfiguration_1.BlockConfiguration({ block: this, assetStore: root, collectionStore: root });
|
|
121
124
|
}
|
|
122
125
|
getConfig(fieldId) {
|
|
123
126
|
// get field (or throw)
|
|
@@ -2,10 +2,12 @@ import { BlockLayout, EventBus, Field, FieldModel, Schema } from '@nascentdigita
|
|
|
2
2
|
import { ListPanel, MessagePanel, PanelLayout, SlotVariation, VisualPanel } from '@nascentdigital/funnel-ui';
|
|
3
3
|
import { Block } from './Block';
|
|
4
4
|
import { IAssetStore } from './IAssetStore';
|
|
5
|
+
import { ICollectionStore } from './ICollectionStore';
|
|
5
6
|
import { SectionBlock } from './SectionBlock';
|
|
6
7
|
export declare class BlockConfiguration {
|
|
7
8
|
readonly eventBus: EventBus;
|
|
8
9
|
readonly assetStore: IAssetStore;
|
|
10
|
+
readonly collectionStore: ICollectionStore;
|
|
9
11
|
readonly sectionBlock?: SectionBlock;
|
|
10
12
|
readonly block: Block;
|
|
11
13
|
private _fields;
|
|
@@ -15,7 +17,7 @@ export declare class BlockConfiguration {
|
|
|
15
17
|
private _slotState;
|
|
16
18
|
private _defaultConfig?;
|
|
17
19
|
private _isConfigInDefault?;
|
|
18
|
-
constructor({ block: blockOrSectionBlock, assetStore }: BlockConfiguration.ConstructorArgs);
|
|
20
|
+
constructor({ block: blockOrSectionBlock, assetStore, collectionStore }: BlockConfiguration.ConstructorArgs);
|
|
19
21
|
get fields(): ReadonlyArray<FieldModel.Config>;
|
|
20
22
|
get editableFields(): ReadonlyArray<FieldModel.Config>;
|
|
21
23
|
set editableFields(fields: ReadonlyArray<FieldModel.Config>);
|
|
@@ -60,6 +62,7 @@ export declare namespace BlockConfiguration {
|
|
|
60
62
|
};
|
|
61
63
|
type ConstructorArgs = {
|
|
62
64
|
assetStore: IAssetStore;
|
|
65
|
+
collectionStore: ICollectionStore;
|
|
63
66
|
block: Block | SectionBlock;
|
|
64
67
|
};
|
|
65
68
|
interface Event extends EventBus.Event<'BlockConfiguration', Event.Type> {
|
|
@@ -7,10 +7,11 @@ const rxjs_1 = require("rxjs");
|
|
|
7
7
|
const SectionBlock_1 = require("./SectionBlock");
|
|
8
8
|
// model
|
|
9
9
|
class BlockConfiguration {
|
|
10
|
-
constructor({ block: blockOrSectionBlock, assetStore }) {
|
|
10
|
+
constructor({ block: blockOrSectionBlock, assetStore, collectionStore }) {
|
|
11
11
|
// initialize core fields
|
|
12
12
|
this.eventBus = new funnel_core_1.EventBus();
|
|
13
13
|
this.assetStore = assetStore;
|
|
14
|
+
this.collectionStore = collectionStore;
|
|
14
15
|
const fields = [];
|
|
15
16
|
this._fields = fields;
|
|
16
17
|
this._editableFields = fields;
|
|
@@ -30,6 +31,9 @@ class BlockConfiguration {
|
|
|
30
31
|
// sync
|
|
31
32
|
this.reset();
|
|
32
33
|
// force sync if a field is modified
|
|
34
|
+
this.block.fieldChanged$
|
|
35
|
+
.pipe((0, rxjs_1.debounceTime)(100))
|
|
36
|
+
.subscribe(() => this.sync());
|
|
33
37
|
this.eventBus.events$
|
|
34
38
|
.pipe((0, rxjs_1.filter)(event => funnel_core_1.Field.Event.filter(event) && event.type === 'changed'))
|
|
35
39
|
.subscribe(() => this.sync());
|
|
@@ -63,8 +67,9 @@ class BlockConfiguration {
|
|
|
63
67
|
].filter(funnel_core_1.Value.isDefined);
|
|
64
68
|
}
|
|
65
69
|
get blockFieldData() {
|
|
66
|
-
const { assetStore, block } = this;
|
|
70
|
+
const { assetStore, collectionStore, block } = this;
|
|
67
71
|
return block.fields.reduce((data, field) => {
|
|
72
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
68
73
|
// link assets
|
|
69
74
|
const fieldValue = field.value;
|
|
70
75
|
if ((fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.type) === 'asset') {
|
|
@@ -76,6 +81,56 @@ class BlockConfiguration {
|
|
|
76
81
|
? funnel_core_1.Schema.AssetField.LinkedValue.toData(funnel_core_1.Schema.AssetField.Value.toLinked(assetData, asset))
|
|
77
82
|
: fieldValue;
|
|
78
83
|
}
|
|
84
|
+
// link collections
|
|
85
|
+
else if ((fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.type) === 'collection') {
|
|
86
|
+
// resolve collection
|
|
87
|
+
const collection = funnel_core_1.Schema.CollectionField.Value.ForRef.filter(fieldValue.value)
|
|
88
|
+
? collectionStore.getCollection(fieldValue.value.id)
|
|
89
|
+
: fieldValue.value;
|
|
90
|
+
// bind fields if it's media
|
|
91
|
+
if (funnel_ui_1.Media.LinkedValue.filter(collection)) {
|
|
92
|
+
// clone (we need to deep clone or the linked collection/assets will get saved)
|
|
93
|
+
const media = funnel_core_1.ObjectUtils.clone(collection);
|
|
94
|
+
data[field.id] = funnel_core_1.Schema.CollectionField.Value.ForInline.toData(media);
|
|
95
|
+
// link image
|
|
96
|
+
if (funnel_ui_1.Media.LinkedValue.isImage(media)) {
|
|
97
|
+
// link desktop
|
|
98
|
+
const desktopAssetId = (_c = (_b = (_a = media.fields) === null || _a === void 0 ? void 0 : _a.image) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.id;
|
|
99
|
+
const desktopAsset = desktopAssetId ? assetStore.getAsset(desktopAssetId) : undefined;
|
|
100
|
+
if (desktopAsset) {
|
|
101
|
+
media.fields.image = funnel_core_1.Schema.AssetField.LinkedValue.toData(desktopAsset.value);
|
|
102
|
+
}
|
|
103
|
+
// link mobile
|
|
104
|
+
const mobileAssetId = (_f = (_e = (_d = media.fields) === null || _d === void 0 ? void 0 : _d.mobileImage) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.id;
|
|
105
|
+
const mobileAsset = mobileAssetId ? assetStore.getAsset(mobileAssetId) : undefined;
|
|
106
|
+
if (mobileAsset) {
|
|
107
|
+
media.fields.mobileImage = funnel_core_1.Schema.AssetField.LinkedValue.toData(mobileAsset.value);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// link video (if local)
|
|
111
|
+
else if (funnel_ui_1.Media.LinkedValue.isVideo(media)) {
|
|
112
|
+
// link video (if local)
|
|
113
|
+
if ((_k = (_j = (_h = (_g = media.fields) === null || _g === void 0 ? void 0 : _g.video) === null || _h === void 0 ? void 0 : _h.value) === null || _j === void 0 ? void 0 : _j.local) === null || _k === void 0 ? void 0 : _k.value) {
|
|
114
|
+
const videoAssetId = (_p = (_o = (_m = (_l = media.fields) === null || _l === void 0 ? void 0 : _l.video) === null || _m === void 0 ? void 0 : _m.value.local) === null || _o === void 0 ? void 0 : _o.value) === null || _p === void 0 ? void 0 : _p.id;
|
|
115
|
+
const videoAsset = videoAssetId ? assetStore.getAsset(videoAssetId) : undefined;
|
|
116
|
+
if (videoAsset) {
|
|
117
|
+
media.fields.video.value.local = funnel_core_1.Schema.AssetField.LinkedValue.toData(videoAsset.value);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// link cover
|
|
121
|
+
const coverAssetId = (_s = (_r = (_q = media.fields) === null || _q === void 0 ? void 0 : _q.cover) === null || _r === void 0 ? void 0 : _r.value) === null || _s === void 0 ? void 0 : _s.id;
|
|
122
|
+
const coverAsset = coverAssetId ? assetStore.getAsset(coverAssetId) : undefined;
|
|
123
|
+
if (coverAsset) {
|
|
124
|
+
media.fields.cover = funnel_core_1.Schema.AssetField.LinkedValue.toData(coverAsset.value);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// fields if it's media
|
|
129
|
+
else {
|
|
130
|
+
data[field.id] = fieldValue;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// or use as-is
|
|
79
134
|
else {
|
|
80
135
|
data[field.id] = field.value;
|
|
81
136
|
}
|
|
@@ -87,6 +142,7 @@ class BlockConfiguration {
|
|
|
87
142
|
return [
|
|
88
143
|
...Object.values(this.extendedFields),
|
|
89
144
|
this.getEditableField('contentAlign'),
|
|
145
|
+
this.getEditableField('contentSplit')
|
|
90
146
|
].filter(funnel_core_1.Value.isDefined);
|
|
91
147
|
}
|
|
92
148
|
get mobileFields() {
|
|
@@ -173,7 +229,11 @@ class BlockConfiguration {
|
|
|
173
229
|
aspect: this.getEditableField(keys.aspect),
|
|
174
230
|
anchor: this.getEditableField(keys.anchor),
|
|
175
231
|
width: this.getEditableField(keys.width),
|
|
176
|
-
horizontalAlign: this.getEditableField(keys.horizontalAlign)
|
|
232
|
+
horizontalAlign: this.getEditableField(keys.horizontalAlign),
|
|
233
|
+
controls: this.getEditableField(keys.controls),
|
|
234
|
+
autoPlay: this.getEditableField(keys.autoPlay),
|
|
235
|
+
loop: this.getEditableField(keys.loop),
|
|
236
|
+
mute: this.getEditableField(keys.mute)
|
|
177
237
|
};
|
|
178
238
|
}
|
|
179
239
|
get extendedFields() {
|
|
@@ -185,6 +245,7 @@ class BlockConfiguration {
|
|
|
185
245
|
'layout',
|
|
186
246
|
'slotVariation',
|
|
187
247
|
'contentAlign',
|
|
248
|
+
'contentSplit',
|
|
188
249
|
...Object.values(funnel_ui_1.MessagePanel.Config.getKeys('message')),
|
|
189
250
|
...Object.values(funnel_ui_1.ListPanel.Config.getKeys('list')),
|
|
190
251
|
...Object.values(funnel_ui_1.VisualPanel.Config.getKeys('visual'))
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { AssetClient, CollectionClient } from '@nascentdigital/funnel-cms';
|
|
2
|
-
import { EventBus, Field,
|
|
2
|
+
import { EventBus, Field, FieldModel, Language, Schema } from '@nascentdigital/funnel-core';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
import { Asset } from './Asset';
|
|
5
5
|
import { IAssetStore } from './IAssetStore';
|
|
6
|
+
import { ICollection } from './ICollection';
|
|
6
7
|
import { ICollectionStore } from './ICollectionStore';
|
|
8
|
+
import { IPage } from './IPage';
|
|
7
9
|
import { IPageRefStore } from './IPageRefStore';
|
|
8
10
|
import { ITagged } from './ITagged';
|
|
9
|
-
import { Item } from './Item';
|
|
10
|
-
import { Page } from './Page';
|
|
11
11
|
export declare class Collection implements IAssetStore, ICollectionStore, IPageRefStore, ITagged {
|
|
12
12
|
readonly template: Schema.Collection;
|
|
13
13
|
readonly eventBus: EventBus;
|
|
@@ -37,10 +37,10 @@ export declare class Collection implements IAssetStore, ICollectionStore, IPageR
|
|
|
37
37
|
private _modifiedOn?;
|
|
38
38
|
private _savingOn?;
|
|
39
39
|
constructor(args: Collection.ConstructorArgs);
|
|
40
|
-
get asRef():
|
|
41
|
-
get events$(): Observable<
|
|
40
|
+
get asRef(): ICollection.Ref;
|
|
41
|
+
get events$(): Observable<ICollection.Events>;
|
|
42
42
|
get stable$(): Observable<boolean>;
|
|
43
|
-
get state(): Schema.
|
|
43
|
+
get state(): Schema.Collection.State;
|
|
44
44
|
private set state(value);
|
|
45
45
|
get assets(): ReadonlyArray<Asset>;
|
|
46
46
|
get collections(): ReadonlyArray<Schema.Collection.Data.AsLink>;
|
|
@@ -60,9 +60,9 @@ export declare class Collection implements IAssetStore, ICollectionStore, IPageR
|
|
|
60
60
|
get changeSetId(): Schema.ChangeSet.Id | undefined;
|
|
61
61
|
get valid(): boolean;
|
|
62
62
|
get modified(): boolean;
|
|
63
|
-
get changes():
|
|
63
|
+
get changes(): ICollection.Changes;
|
|
64
64
|
get initialErrors(): boolean;
|
|
65
|
-
get errors():
|
|
65
|
+
get errors(): ICollection.Errors;
|
|
66
66
|
getField(fieldId: string): FieldModel;
|
|
67
67
|
getTextField(fieldId: string): Field<Schema.TextField> | undefined;
|
|
68
68
|
getAssetScope(range: Schema.AssetScope.Range): Schema.AssetScope;
|
|
@@ -73,8 +73,8 @@ export declare class Collection implements IAssetStore, ICollectionStore, IPageR
|
|
|
73
73
|
getCollection(collectionId: Schema.Collection.Id): Schema.Collection.Data.AsLink | undefined;
|
|
74
74
|
addCollection(collection: Schema.Collection.Data.AsLink): void;
|
|
75
75
|
removeCollection(collectionId: Schema.Collection.Id): boolean;
|
|
76
|
-
getPageRef(pageId: Schema.Page.Id | undefined):
|
|
77
|
-
addPageRef(page:
|
|
76
|
+
getPageRef(pageId: Schema.Page.Id | undefined): IPage.Ref | undefined;
|
|
77
|
+
addPageRef(page: IPage.Ref): void;
|
|
78
78
|
removePageRef(pageId: string): boolean;
|
|
79
79
|
onSaveStart(): void;
|
|
80
80
|
onSaveComplete(updatedOn: number, changeSetId: Schema.ChangeSet.Id): void;
|
|
@@ -105,22 +105,4 @@ export declare namespace Collection {
|
|
|
105
105
|
publishedOn?: number;
|
|
106
106
|
};
|
|
107
107
|
type Summary = CollectionClient.GetItems.Item;
|
|
108
|
-
type Ref = Pick<ConstructorArgs, 'id' | 'groupId' | 'brand' | 'template' | 'language' | 'version' | 'name' | 'tags' | 'state' | 'errors' | 'changeSetId' | 'snapshotId' | 'createdOn' | 'updatedOn' | 'publishedOn'>;
|
|
109
|
-
type Changes = {
|
|
110
|
-
collection: Collection;
|
|
111
|
-
fields: Array<FieldModel>;
|
|
112
|
-
};
|
|
113
|
-
type Errors = {
|
|
114
|
-
collection: Collection;
|
|
115
|
-
fields: Array<FieldModel>;
|
|
116
|
-
};
|
|
117
|
-
type Events = Event | Item.Event | Field.Event | ObjectField.Event | FieldList.Event;
|
|
118
|
-
interface Event extends EventBus.Event<'Collection', Event.Type> {
|
|
119
|
-
collection: Collection;
|
|
120
|
-
}
|
|
121
|
-
namespace Event {
|
|
122
|
-
type Type = 'changed' | 'modified';
|
|
123
|
-
function filter(event: EventBus.Event): event is Event;
|
|
124
|
-
function create(event: EventBus.Args<Event>): Event;
|
|
125
|
-
}
|
|
126
108
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Collection = void 0;
|
|
4
4
|
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
5
5
|
const rxjs_1 = require("rxjs");
|
|
6
|
+
const ICollection_1 = require("./ICollection");
|
|
6
7
|
const Item_1 = require("./Item");
|
|
7
8
|
// model
|
|
8
9
|
class Collection {
|
|
@@ -335,22 +336,7 @@ class Collection {
|
|
|
335
336
|
delete this._savingOn;
|
|
336
337
|
}
|
|
337
338
|
raiseEvent(type) {
|
|
338
|
-
this.eventBus.publish(
|
|
339
|
+
this.eventBus.publish(ICollection_1.ICollection.Event.create({ type, collection: this }));
|
|
339
340
|
}
|
|
340
341
|
}
|
|
341
342
|
exports.Collection = Collection;
|
|
342
|
-
// extension
|
|
343
|
-
(function (Collection) {
|
|
344
|
-
let Event;
|
|
345
|
-
(function (Event) {
|
|
346
|
-
// methods
|
|
347
|
-
function filter(event) {
|
|
348
|
-
return event.domain === 'Collection';
|
|
349
|
-
}
|
|
350
|
-
Event.filter = filter;
|
|
351
|
-
function create(event) {
|
|
352
|
-
return funnel_core_1.EventBus.createEvent(Object.assign({ domain: 'Collection' }, event));
|
|
353
|
-
}
|
|
354
|
-
Event.create = create;
|
|
355
|
-
})(Event = Collection.Event || (Collection.Event = {}));
|
|
356
|
-
})(Collection || (exports.Collection = Collection = {}));
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { EventBus, Schema } from '@nascentdigital/funnel-core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { EditorApiClient } from '../client';
|
|
4
|
+
import { ICollectionRepository } from '../repository';
|
|
4
5
|
import { CollectionSummary } from './CollectionSummary';
|
|
5
6
|
export declare class CollectionBrowser {
|
|
6
|
-
readonly
|
|
7
|
+
readonly repository: ICollectionRepository;
|
|
7
8
|
readonly overview: EditorApiClient.CollectionOverview;
|
|
8
9
|
private readonly _eventBus;
|
|
9
10
|
private _state;
|
|
@@ -26,7 +27,7 @@ export declare class CollectionBrowser {
|
|
|
26
27
|
export declare namespace CollectionBrowser {
|
|
27
28
|
type State = 'uninitialized' | 'initializing' | 'ready' | 'syncing' | 'error';
|
|
28
29
|
type ConstructorArgs = {
|
|
29
|
-
|
|
30
|
+
repository: ICollectionRepository;
|
|
30
31
|
overview: EditorApiClient.CollectionOverview;
|
|
31
32
|
};
|
|
32
33
|
interface Event extends EventBus.Event<'CollectionBrowser', Event.Type> {
|
|
@@ -7,7 +7,7 @@ const CollectionSummary_1 = require("./CollectionSummary");
|
|
|
7
7
|
class CollectionBrowser {
|
|
8
8
|
constructor(args) {
|
|
9
9
|
// initialize instance variables
|
|
10
|
-
this.
|
|
10
|
+
this.repository = args.repository;
|
|
11
11
|
this.overview = args.overview;
|
|
12
12
|
this._eventBus = new funnel_core_1.EventBus();
|
|
13
13
|
this._state = 'uninitialized';
|
|
@@ -64,10 +64,10 @@ class CollectionBrowser {
|
|
|
64
64
|
? 'initializing'
|
|
65
65
|
: 'syncing';
|
|
66
66
|
// load collections
|
|
67
|
-
const {
|
|
67
|
+
const { repository, type, template, defaultLanguage } = this;
|
|
68
68
|
const brand = funnel_core_1.AppConfig.brand();
|
|
69
69
|
const language = funnel_core_1.RegionsConfig.getDefaultLanguage(funnel_core_1.AppConfig.brandConfig().regionalization);
|
|
70
|
-
this._items = (await
|
|
70
|
+
this._items = (await repository.getItems({ version: 'draft', type, language }))
|
|
71
71
|
.filter(({ refs }) => Object.keys(refs).length > 0)
|
|
72
72
|
.map(({ groupId, name, refs }) => new CollectionSummary_1.CollectionSummary({
|
|
73
73
|
template,
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { AssetClient } from '@nascentdigital/funnel-cms';
|
|
2
|
-
import { EventBus, Field, FieldList, FieldModel, Language, ObjectField, Schema } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { EventBus, Field, FieldList, FieldModel, Language, ObjectField, Schema, SchemaToField } from '@nascentdigital/funnel-core';
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
|
-
import {
|
|
4
|
+
import { StringKeyOf } from 'type-fest';
|
|
5
|
+
import { ICollectionRepository } from '../repository';
|
|
5
6
|
import { Asset } from './Asset';
|
|
6
7
|
import { IAssetStore } from './IAssetStore';
|
|
7
8
|
import { ICollectionStore } from './ICollectionStore';
|
|
8
9
|
import { ITagged } from './ITagged';
|
|
9
10
|
import { Item } from './Item';
|
|
10
|
-
export declare class CollectionFieldProxy implements IAssetStore, ICollectionStore, ITagged {
|
|
11
|
-
readonly collectionRepository:
|
|
11
|
+
export declare class CollectionFieldProxy<TCollection extends Schema.Collection = Schema.Collection> implements IAssetStore, ICollectionStore, ITagged {
|
|
12
|
+
readonly collectionRepository: ICollectionRepository;
|
|
12
13
|
readonly collectionStore: ICollectionStore;
|
|
13
14
|
readonly assetStore: IAssetStore;
|
|
14
|
-
readonly schema: Schema.CollectionField
|
|
15
|
-
readonly collectionSchema:
|
|
15
|
+
readonly schema: Schema.CollectionField<TCollection>;
|
|
16
|
+
readonly collectionSchema: TCollection;
|
|
16
17
|
readonly language: Language;
|
|
17
18
|
readonly eventBus: EventBus;
|
|
18
19
|
private _initialValue?;
|
|
@@ -49,6 +50,7 @@ export declare class CollectionFieldProxy implements IAssetStore, ICollectionSto
|
|
|
49
50
|
get modified(): boolean;
|
|
50
51
|
get value(): Schema.CollectionField.Value;
|
|
51
52
|
getInlineData(): Schema.Collection.Data.AsInline;
|
|
53
|
+
getField<TFields extends CollectionFieldProxy.Fields<TCollection>, TFieldId extends StringKeyOf<TFields>>(fieldId: TFieldId): SchemaToField<TFields[TFieldId]>;
|
|
52
54
|
getAssetScope(range: Schema.AssetScope.Range): Schema.AssetScope;
|
|
53
55
|
getSearchScope(): AssetClient.GetAssets.Scope;
|
|
54
56
|
getAsset(assetId: Asset.Id): Asset | undefined;
|
|
@@ -61,7 +63,7 @@ export declare class CollectionFieldProxy implements IAssetStore, ICollectionSto
|
|
|
61
63
|
onSaveComplete(): void;
|
|
62
64
|
save(shared?: boolean): Promise<void>;
|
|
63
65
|
private raiseEvent;
|
|
64
|
-
static create(args: CollectionFieldProxy.CreateArgs): Promise<CollectionFieldProxy
|
|
66
|
+
static create<TCollection extends Schema.Collection = Schema.Collection>(args: CollectionFieldProxy.CreateArgs): Promise<CollectionFieldProxy<TCollection>>;
|
|
65
67
|
/**
|
|
66
68
|
* Data format could be either flattened data or inline data.
|
|
67
69
|
* Either way get the underlying inline collection data.
|
|
@@ -69,8 +71,10 @@ export declare class CollectionFieldProxy implements IAssetStore, ICollectionSto
|
|
|
69
71
|
private dataFrom;
|
|
70
72
|
}
|
|
71
73
|
export declare namespace CollectionFieldProxy {
|
|
74
|
+
type Fields<TCollection extends Schema.Collection> = Schema.Fields.UnwrapOptional<TCollection['fields']>;
|
|
75
|
+
type Keys<TCollection extends Schema.Collection> = StringKeyOf<Fields<TCollection>>;
|
|
72
76
|
type ConstructorArgs = {
|
|
73
|
-
collectionRepository:
|
|
77
|
+
collectionRepository: ICollectionRepository;
|
|
74
78
|
collectionStore: ICollectionStore;
|
|
75
79
|
assetStore: IAssetStore;
|
|
76
80
|
schema: Schema.CollectionField;
|
|
@@ -150,8 +150,6 @@ class CollectionFieldProxy {
|
|
|
150
150
|
this.raiseEvent('changed');
|
|
151
151
|
}
|
|
152
152
|
get valid() {
|
|
153
|
-
const valid = this.allFields.map(field => ({ id: field.id, valid: field.valid, field }));
|
|
154
|
-
console.debug('[CollectionFieldProxy/valid] validation: ', valid);
|
|
155
153
|
return this.allFields.every(field => field.valid);
|
|
156
154
|
}
|
|
157
155
|
get initialErrors() {
|
|
@@ -189,6 +187,15 @@ class CollectionFieldProxy {
|
|
|
189
187
|
}, {})
|
|
190
188
|
};
|
|
191
189
|
}
|
|
190
|
+
getField(fieldId) {
|
|
191
|
+
// find field (or throw)
|
|
192
|
+
const field = this.fields.find(field => field.id === fieldId);
|
|
193
|
+
if (!field) {
|
|
194
|
+
throw new funnel_core_1.IllegalStateError(`${this.schema.type} collection doesn't seem to have the ${fieldId} field`);
|
|
195
|
+
}
|
|
196
|
+
// return field
|
|
197
|
+
return field;
|
|
198
|
+
}
|
|
192
199
|
getAssetScope(range) {
|
|
193
200
|
switch (range) {
|
|
194
201
|
case 'global':
|
|
@@ -307,9 +314,8 @@ class CollectionFieldProxy {
|
|
|
307
314
|
if (!initialData) {
|
|
308
315
|
console.debug('[CollectionFieldProxy/save] creating remote instance');
|
|
309
316
|
// create item (fail if we don't get a collection - shouldn't happen)
|
|
310
|
-
const { collection: collectionData } = await collectionRepository.
|
|
311
|
-
|
|
312
|
-
version: collectionSchema.version,
|
|
317
|
+
const { collection: collectionData } = await collectionRepository.createRaw({
|
|
318
|
+
template: collectionSchema,
|
|
313
319
|
language,
|
|
314
320
|
name,
|
|
315
321
|
tags: []
|
|
@@ -328,13 +334,13 @@ class CollectionFieldProxy {
|
|
|
328
334
|
console.debug('[CollectionFieldProxy/save] updating remote instance', initialData);
|
|
329
335
|
// create update
|
|
330
336
|
const savables = [];
|
|
331
|
-
const update = collectionRepository.
|
|
337
|
+
const update = collectionRepository.serializeUpdate(this, savables);
|
|
332
338
|
console.debug('[CollectionFieldProxy/save] created update', update);
|
|
333
339
|
// start all updates
|
|
334
340
|
this.onSaveStart();
|
|
335
341
|
savables.forEach(savable => savable.onSaveStart());
|
|
336
342
|
// update page
|
|
337
|
-
const { collection } = await collectionRepository.
|
|
343
|
+
const { collection } = await collectionRepository.update(update);
|
|
338
344
|
// update collection in store and reset if updated
|
|
339
345
|
if (collection) {
|
|
340
346
|
// add to collection store
|
|
@@ -384,7 +390,7 @@ class CollectionFieldProxy {
|
|
|
384
390
|
let initialData;
|
|
385
391
|
const { collectionRepository, initialValue } = args;
|
|
386
392
|
if (funnel_core_1.Schema.CollectionField.Value.ForRef.filter(initialValue)) {
|
|
387
|
-
initialData = await collectionRepository.
|
|
393
|
+
initialData = await collectionRepository.get({ id: initialValue.id, version: 'draft' });
|
|
388
394
|
}
|
|
389
395
|
// or use initial value as data
|
|
390
396
|
else {
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { Schema } from '@nascentdigital/funnel-core';
|
|
2
|
-
import { Collection } from './Collection';
|
|
3
2
|
export declare class CollectionGroup {
|
|
4
3
|
readonly template: Schema.Collection;
|
|
5
4
|
readonly groupId: Schema.Collection.GroupId;
|
|
6
5
|
readonly brand?: string;
|
|
7
6
|
readonly name: string;
|
|
8
7
|
readonly collections: ReadonlyArray<CollectionGroup.CollectionRef>;
|
|
9
|
-
private _collection?;
|
|
10
8
|
constructor(args: CollectionGroup.ConstructorArgs);
|
|
11
|
-
get collection(): Collection | undefined;
|
|
12
|
-
set collection(collection: Collection | undefined);
|
|
13
9
|
}
|
|
14
10
|
export declare namespace CollectionGroup {
|
|
15
11
|
type ConstructorArgs = {
|
|
@@ -18,7 +14,6 @@ export declare namespace CollectionGroup {
|
|
|
18
14
|
brand?: string;
|
|
19
15
|
name: string;
|
|
20
16
|
collections: CollectionRef[];
|
|
21
|
-
collection?: Collection;
|
|
22
17
|
};
|
|
23
18
|
type CollectionRef = Schema.Collection.Data.AsGroup.Instance;
|
|
24
19
|
}
|
|
@@ -10,13 +10,6 @@ class CollectionGroup {
|
|
|
10
10
|
this.brand = args.brand;
|
|
11
11
|
this.name = args.name;
|
|
12
12
|
this.collections = args.collections;
|
|
13
|
-
this._collection = args.collection;
|
|
14
|
-
}
|
|
15
|
-
get collection() {
|
|
16
|
-
return this._collection;
|
|
17
|
-
}
|
|
18
|
-
set collection(collection) {
|
|
19
|
-
this._collection = collection;
|
|
20
13
|
}
|
|
21
14
|
}
|
|
22
15
|
exports.CollectionGroup = CollectionGroup;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Language, Schema } from '@nascentdigital/funnel-core';
|
|
2
|
-
import {
|
|
2
|
+
import { ICollection } from './ICollection';
|
|
3
3
|
export declare class CollectionSummary {
|
|
4
4
|
readonly template: Schema.Collection;
|
|
5
5
|
readonly brand: string;
|
|
@@ -13,7 +13,7 @@ export declare class CollectionSummary {
|
|
|
13
13
|
get type(): Schema.Collection.Type;
|
|
14
14
|
hasLanguage(language: Language): boolean;
|
|
15
15
|
findCollection({ language, fallbackLanguage }: CollectionSummary.GetClosestOptions): CollectionSummary.CollectionRef;
|
|
16
|
-
getClosestCollectionRef(language: Language, fallback?: Language):
|
|
16
|
+
getClosestCollectionRef(language: Language, fallback?: Language): ICollection.Ref | undefined;
|
|
17
17
|
}
|
|
18
18
|
export declare namespace CollectionSummary {
|
|
19
19
|
type Status = 'draft' | 'ready' | 'live' | 'changed' | 'empty';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { EventBus, Schema } from '@nascentdigital/funnel-core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { AppState } from '../app';
|
|
4
|
-
import {
|
|
4
|
+
import { ICollectionRepository } from '../repository';
|
|
5
5
|
import { CollectionBrowser } from './CollectionBrowser';
|
|
6
6
|
export declare class Collections {
|
|
7
7
|
readonly appState: AppState;
|
|
8
|
-
readonly
|
|
8
|
+
readonly repository: ICollectionRepository;
|
|
9
9
|
readonly schemas: ReadonlyArray<Schema.Collection>;
|
|
10
10
|
private readonly _eventBus;
|
|
11
11
|
private _state;
|
|
@@ -27,7 +27,7 @@ export declare namespace Collections {
|
|
|
27
27
|
type State = 'uninitialized' | 'initializing' | 'ready' | 'syncing' | 'error';
|
|
28
28
|
type ConstructorArgs = {
|
|
29
29
|
appState: AppState;
|
|
30
|
-
|
|
30
|
+
repository: ICollectionRepository;
|
|
31
31
|
};
|
|
32
32
|
interface Event extends EventBus.Event<'Collections', Event.Type> {
|
|
33
33
|
collections: Collections;
|
|
@@ -8,7 +8,7 @@ class Collections {
|
|
|
8
8
|
constructor(args) {
|
|
9
9
|
// initialize instance variables
|
|
10
10
|
this.appState = args.appState;
|
|
11
|
-
this.
|
|
11
|
+
this.repository = args.repository;
|
|
12
12
|
this.schemas = funnel_core_1.Schema.Site.current().collections;
|
|
13
13
|
this._eventBus = new funnel_core_1.EventBus();
|
|
14
14
|
this._state = 'uninitialized';
|
|
@@ -60,9 +60,9 @@ class Collections {
|
|
|
60
60
|
? 'initializing'
|
|
61
61
|
: 'syncing';
|
|
62
62
|
// load collections
|
|
63
|
-
const {
|
|
64
|
-
const overviews = await
|
|
65
|
-
this._collections = overviews.map(overview => new CollectionBrowser_1.CollectionBrowser({
|
|
63
|
+
const { repository } = this;
|
|
64
|
+
const overviews = await repository.getOverview({ version: 'draft' });
|
|
65
|
+
this._collections = overviews.map(overview => new CollectionBrowser_1.CollectionBrowser({ repository, overview }));
|
|
66
66
|
// mark as ready
|
|
67
67
|
this.state = 'ready';
|
|
68
68
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { EventBus, Field, FieldList, FieldModel, Language, ObjectField, Schema } from '@nascentdigital/funnel-core';
|
|
2
|
+
import type { Observable } from 'rxjs';
|
|
3
|
+
import type { Asset } from './Asset';
|
|
4
|
+
import type { IAssetStore } from './IAssetStore';
|
|
5
|
+
import type { ICollectionStore } from './ICollectionStore';
|
|
6
|
+
import type { IPageRefStore } from './IPageRefStore';
|
|
7
|
+
import type { ITagged } from './ITagged';
|
|
8
|
+
import type { Item } from './Item';
|
|
9
|
+
import type { CollectionGroup } from './CollectionGroup';
|
|
10
|
+
export interface ICollection extends IAssetStore, ICollectionStore, IPageRefStore, ITagged {
|
|
11
|
+
readonly template: Schema.Collection;
|
|
12
|
+
readonly id: Schema.Collection.Id;
|
|
13
|
+
readonly type: Schema.Collection.Type;
|
|
14
|
+
readonly groupId: Schema.Collection.GroupId;
|
|
15
|
+
readonly events$: Observable<ICollection.Events>;
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly nameField: Field<Schema.TextField>;
|
|
18
|
+
readonly fields: ReadonlyArray<FieldModel>;
|
|
19
|
+
readonly state: Schema.Collection.State;
|
|
20
|
+
readonly published: boolean;
|
|
21
|
+
readonly valid: boolean;
|
|
22
|
+
readonly errors: ICollection.Errors;
|
|
23
|
+
readonly changeSetId?: Schema.ChangeSet.Id;
|
|
24
|
+
readonly publishedOn?: number;
|
|
25
|
+
readonly createdOn: number;
|
|
26
|
+
readonly updatedOn: number;
|
|
27
|
+
}
|
|
28
|
+
export declare namespace ICollection {
|
|
29
|
+
type Ref = {
|
|
30
|
+
id: Schema.Collection.Id;
|
|
31
|
+
groupId: Schema.Collection.GroupId;
|
|
32
|
+
brand?: string;
|
|
33
|
+
template: Schema.Collection;
|
|
34
|
+
language: Language;
|
|
35
|
+
version: number;
|
|
36
|
+
name: string;
|
|
37
|
+
tags: Schema.Tag[];
|
|
38
|
+
state: Schema.Collection.State;
|
|
39
|
+
errors: boolean;
|
|
40
|
+
changeSetId?: Schema.ChangeSet.Id;
|
|
41
|
+
snapshotId?: Schema.CollectionSnapshot.Id;
|
|
42
|
+
createdOn: number;
|
|
43
|
+
updatedOn: number;
|
|
44
|
+
publishedOn?: number;
|
|
45
|
+
};
|
|
46
|
+
type References = {
|
|
47
|
+
collections: Schema.Collection.Data.AsLink[];
|
|
48
|
+
assets: Asset[];
|
|
49
|
+
};
|
|
50
|
+
type WithGroup = {
|
|
51
|
+
group: CollectionGroup;
|
|
52
|
+
collection?: ICollection;
|
|
53
|
+
};
|
|
54
|
+
type Changes = {
|
|
55
|
+
collection: ICollection;
|
|
56
|
+
fields: Array<FieldModel>;
|
|
57
|
+
};
|
|
58
|
+
type Errors = {
|
|
59
|
+
collection: ICollection;
|
|
60
|
+
fields: Array<FieldModel>;
|
|
61
|
+
};
|
|
62
|
+
type Events = Event | Item.Event | Field.Event | ObjectField.Event | FieldList.Event;
|
|
63
|
+
interface Event extends EventBus.Event<'Collection', Event.Type> {
|
|
64
|
+
collection: ICollection;
|
|
65
|
+
}
|
|
66
|
+
namespace Event {
|
|
67
|
+
type Type = 'changed' | 'modified';
|
|
68
|
+
function filter(event: EventBus.Event): event is Event;
|
|
69
|
+
function create(event: EventBus.Args<Event>): Event;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ICollection = void 0;
|
|
4
|
+
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
5
|
+
// extension
|
|
6
|
+
var ICollection;
|
|
7
|
+
(function (ICollection) {
|
|
8
|
+
let Event;
|
|
9
|
+
(function (Event) {
|
|
10
|
+
// methods
|
|
11
|
+
function filter(event) {
|
|
12
|
+
return event.domain === 'Collection';
|
|
13
|
+
}
|
|
14
|
+
Event.filter = filter;
|
|
15
|
+
function create(event) {
|
|
16
|
+
return funnel_core_1.EventBus.createEvent(Object.assign({ domain: 'Collection' }, event));
|
|
17
|
+
}
|
|
18
|
+
Event.create = create;
|
|
19
|
+
})(Event = ICollection.Event || (ICollection.Event = {}));
|
|
20
|
+
})(ICollection || (exports.ICollection = ICollection = {}));
|