dbm 1.2.6 → 1.2.8
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/commands/CommandBaseObject.js +4 -0
- package/commands/SetProperty.js +2 -2
- package/commands/index.js +6 -1
- package/ecommerce/CartLineItem.js +2 -2
- package/ecommerce/LocalStorageCartLoader.js +0 -2
- package/flow/updatefunctions/dom/ElementPosition.js +10 -1
- package/flow/updatefunctions/thirdparty/google/maps/AutoComplete.js +2 -2
- package/graphapi/index.js +1 -2
- package/graphapi/webclient/WebSocketConnection.js +2 -0
- package/graphapi/webclient/admin/ItemEditor.js +54 -0
- package/graphapi/webclient/decode/index.js +9 -0
- package/package.json +1 -1
- package/react/AddProps.js +127 -0
- package/react/BaseObject.js +1 -1
- package/react/ChildFunctions.js +55 -1
- package/react/admin/EditLanguage.js +91 -0
- package/react/admin/EditObject.js +1 -1
- package/react/admin/EditObjectById.js +1 -1
- package/react/admin/EditPage.js +25 -35
- package/react/admin/EditTranslationGroup.js +174 -0
- package/react/admin/PageTranslations.js +226 -0
- package/react/admin/SelectTranslation.js +72 -0
- package/react/admin/editorsgroup/EditItem.js +1 -1
- package/react/admin/editorsgroup/EditMultipleRelations.js +39 -0
- package/react/admin/editorsgroup/EditPartOfObject.js +32 -0
- package/react/admin/editorsgroup/EditRelation.js +2 -7
- package/react/admin/editorsgroup/EditUrl.js +22 -0
- package/react/admin/editorsgroup/index.js +4 -1
- package/react/admin/index.js +4 -0
- package/react/admin/objects/itemeditors/DraggableHierarchyDisplay.js +45 -0
- package/react/admin/objects/itemeditors/HierarchyOrderedRelationsList.js +335 -0
- package/react/admin/objects/itemeditors/RelationsList.js +77 -0
- package/react/admin/objects/itemeditors/Url.js +21 -0
- package/react/admin/objects/itemeditors/index.js +5 -1
- package/react/animation/AnimatedElement.js +4 -0
- package/react/area/FixedWidthInfiniteSlideshow.js +8 -1
- package/react/area/HasData.js +1 -1
- package/react/area/InsertElement.js +9 -2
- package/react/area/InsertElementWithChildren.js +33 -0
- package/react/area/OpenCloseExpandableArea.js +10 -3
- package/react/area/PopoverLayer.js +64 -0
- package/react/area/index.js +2 -0
- package/react/blocks/admin/objects/Edit.js +1 -1
- package/react/blocks/index.js +169 -3
- package/react/blocks/redirect/SignedInRedirect.js +38 -0
- package/react/blocks/redirect/index.js +1 -0
- package/react/blocks/section/ColoredBackgroundSection.js +32 -0
- package/react/blocks/section/ColoredBoxSection.js +30 -0
- package/react/blocks/section/index.js +2 -0
- package/react/blocks/signin/SignIn.js +14 -0
- package/react/blocks/signin/index.js +1 -0
- package/react/context/AddItemByIdToContext.js +5 -2
- package/react/form/Dropdown.js +46 -0
- package/react/form/Option.js +1 -1
- package/react/form/index.js +2 -1
- package/react/interaction/CommandButton.js +12 -64
- package/react/interaction/HoverArea.js +77 -0
- package/react/interaction/HoverDropdown.js +38 -0
- package/react/interaction/drag/DraggableItem.js +94 -0
- package/react/interaction/drag/index.js +3 -0
- package/react/interaction/index.js +5 -1
- package/react/login/LoginForm.js +4 -4
- package/react/source/index.js +10 -2
- package/site/index.js +3 -0
- package/site/translation/TranslationLoader.js +3 -3
- package/tracking/index.js +1 -1
- package/utils/ArrayFunctions.js +21 -16
- package/utils/TranslationFunctions.js +49 -0
- package/utils/index.js +1 -0
- package/graphapi/admin/EditGroup.js +0 -50
- package/graphapi/admin/index.js +0 -1
package/react/admin/EditPage.js
CHANGED
|
@@ -19,8 +19,8 @@ export default class EditPage extends Dbm.react.BaseObject {
|
|
|
19
19
|
itemEditor.addFieldEditor("content", page.content, "content");
|
|
20
20
|
itemEditor.addFieldEditor("publishDate", page.publishDate, "urlRequest");
|
|
21
21
|
itemEditor.addOutgoingRelationEditor("in", "group/pageCategory", page.category ? page.category.id : 0, "urlRequest");
|
|
22
|
-
itemEditor.addIncomingRelationEditor("for", "language", page.language ? page.language.id : 0, "urlRequest");
|
|
23
|
-
itemEditor.addOutgoingRelationEditor("in", "group/translationGroup", page.translations ? page.translations.id : 0, "urlRequest");
|
|
22
|
+
//itemEditor.addIncomingRelationEditor("for", "language", page.language ? page.language.id : 0, "urlRequest");
|
|
23
|
+
//itemEditor.addOutgoingRelationEditor("in", "group/translationGroup", page.translations ? page.translations.id : 0, "urlRequest");
|
|
24
24
|
itemEditor.addEditor("url", page.url, Dbm.graphapi.webclient.admin.SaveFunctions.setUrl, "url");
|
|
25
25
|
|
|
26
26
|
let descriptionEditor = itemEditor.addFieldEditor("meta/description", page["meta/description"], "meta/description");
|
|
@@ -50,7 +50,7 @@ export default class EditPage extends Dbm.react.BaseObject {
|
|
|
50
50
|
let preloadImages = [];
|
|
51
51
|
|
|
52
52
|
let pageEditorItem = Dbm.getInstance().repository.getItem("admin/editor/pageEditor");
|
|
53
|
-
if(pageEditorItem.generateContentPreload) {
|
|
53
|
+
if(pageEditorItem.generateContentPreload && content) {
|
|
54
54
|
preloadImages = pageEditorItem.generateContentPreload(content);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -184,32 +184,36 @@ export default class EditPage extends Dbm.react.BaseObject {
|
|
|
184
184
|
React.createElement(Dbm.react.context.AddContextVariables, {values: {"editorGroup": editorGroup, "itemEditor": itemEditor}},
|
|
185
185
|
React.createElement(Dbm.react.admin.EditObjectById, {id: page.id},
|
|
186
186
|
React.createElement("div", {"className": "dbm-admin-box dbm-admin-box-padding"},
|
|
187
|
-
React.createElement("div", {},
|
|
188
|
-
React.createElement("
|
|
189
|
-
"
|
|
187
|
+
React.createElement("div", {"className": "flex-row small-item-spacing"},
|
|
188
|
+
React.createElement("div", {"className": "flex-row-item flex-resize"},
|
|
189
|
+
React.createElement(Dbm.react.form.FormField, {"value": itemEditor.getEditor("title").item.editValue.value, className: "standard-field standard-field-padding full-width page-title-form-field", placeholder: "Title"})
|
|
190
190
|
),
|
|
191
|
-
React.createElement(
|
|
192
|
-
|
|
193
|
-
React.createElement("div", {className: "spacing standard"}),
|
|
194
|
-
React.createElement("div", {},
|
|
195
|
-
React.createElement("label", {className: "standard-field-label"},
|
|
196
|
-
"Navigation name"
|
|
191
|
+
React.createElement("div", {"className": "flex-row-item flex-no-resize"},
|
|
192
|
+
React.createElement(Dbm.react.form.FormField, {"value": itemEditor.getEditor("publishDate").item.editValue.value, className: "standard-field standard-field-padding full-width", placeholder: "YYYY-MM-DD", "type": "date"})
|
|
197
193
|
),
|
|
198
|
-
React.createElement(Dbm.react.
|
|
194
|
+
React.createElement(Dbm.react.area.HasData, {check: Dbm.getRepositoryItem("site").properties.availableLanguages, checkType:"notEmpty"},
|
|
195
|
+
React.createElement("div", {"className": "flex-row-item flex-no-resize"},
|
|
196
|
+
React.createElement(Dbm.react.admin.EditLanguage, {})
|
|
197
|
+
)
|
|
198
|
+
)
|
|
199
199
|
),
|
|
200
|
-
React.createElement("div", {className: "spacing
|
|
201
|
-
React.createElement("div", {},
|
|
202
|
-
React.createElement("
|
|
203
|
-
"Url"
|
|
200
|
+
React.createElement("div", {className: "spacing small"}),
|
|
201
|
+
React.createElement("div", {"className": "flex-row small-item-spacing vertically-center-items"},
|
|
202
|
+
React.createElement("div", {"className": "flex-row-item flex-resize"},
|
|
203
|
+
React.createElement(Dbm.react.form.FormField, {"value": itemEditor.getEditor("url").item.editValue.value, className: "standard-field standard-field-padding full-width", placeholder: "Url"})
|
|
204
204
|
),
|
|
205
|
-
React.createElement(Dbm.react.
|
|
205
|
+
React.createElement(Dbm.react.area.HasData, {check: Dbm.getRepositoryItem("site").properties.availableLanguages, checkType:"notEmpty"},
|
|
206
|
+
React.createElement("div", {"className": "flex-row-item flex-no-resize"},
|
|
207
|
+
React.createElement(Dbm.react.admin.PageTranslations, {})
|
|
208
|
+
)
|
|
209
|
+
)
|
|
206
210
|
),
|
|
207
211
|
React.createElement("div", {className: "spacing standard"}),
|
|
208
212
|
React.createElement("div", {},
|
|
209
213
|
React.createElement("label", {className: "standard-field-label"},
|
|
210
|
-
"
|
|
214
|
+
"Navigation name"
|
|
211
215
|
),
|
|
212
|
-
React.createElement(Dbm.react.form.FormField, {"value": itemEditor.getEditor("
|
|
216
|
+
React.createElement(Dbm.react.form.FormField, {"value": itemEditor.getEditor("navigationName").item.editValue.value, className: "standard-field standard-field-padding full-width", placeholder: "Name showed in menues and breadcrumbs"}),
|
|
213
217
|
),
|
|
214
218
|
React.createElement("div", {className: "spacing standard"}),
|
|
215
219
|
React.createElement("div", {},
|
|
@@ -217,21 +221,7 @@ export default class EditPage extends Dbm.react.BaseObject {
|
|
|
217
221
|
"Category"
|
|
218
222
|
),
|
|
219
223
|
React.createElement(Dbm.react.form.GraphApiObjectSelection, {"value": itemEditor.getEditor("relation_out_in_group/pageCategory").item.editValue.value, objectType: "group/pageCategory", className: "standard-field standard-field-padding full-width"}),
|
|
220
|
-
)
|
|
221
|
-
React.createElement("div", {className: "spacing standard"}),
|
|
222
|
-
React.createElement("div", {},
|
|
223
|
-
React.createElement("label", {className: "standard-field-label"},
|
|
224
|
-
"Language"
|
|
225
|
-
),
|
|
226
|
-
React.createElement(Dbm.react.form.GraphApiObjectSelection, {"value": itemEditor.getEditor("relation_in_for_language").item.editValue.value, objectType: "language", className: "standard-field standard-field-padding full-width"}),
|
|
227
|
-
),
|
|
228
|
-
React.createElement("div", {className: "spacing standard"}),
|
|
229
|
-
React.createElement("div", {},
|
|
230
|
-
React.createElement("label", {className: "standard-field-label"},
|
|
231
|
-
"Translations"
|
|
232
|
-
),
|
|
233
|
-
React.createElement(Dbm.react.form.GraphApiObjectSelection, {"value": itemEditor.getEditor("relation_out_in_group/translationGroup").item.editValue.value, objectType: "group/translationGroup", className: "standard-field standard-field-padding full-width"}),
|
|
234
|
-
),
|
|
224
|
+
)
|
|
235
225
|
),
|
|
236
226
|
React.createElement("div", {className: "spacing standard"}),
|
|
237
227
|
React.createElement("div", {"className": "dbm-admin-box dbm-admin-box-padding"},
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class EditTranslationGroup extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.item.requireProperty("translations", []);
|
|
9
|
+
this.item.requireProperty("missingLanguages", []);
|
|
10
|
+
|
|
11
|
+
let updateTranslationsCommand = Dbm.commands.callFunction(this._updateActiveTranslations.bind(this));
|
|
12
|
+
|
|
13
|
+
let itemEditor = this.context.itemEditor;
|
|
14
|
+
let language = this.context.language;
|
|
15
|
+
|
|
16
|
+
let editor = itemEditor.getAdminMultipleIncomingRelationsEditor("in", "page");
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
Dbm.flow.addUpdateCommand(editor.valueProperty, updateTranslationsCommand);
|
|
20
|
+
Dbm.flow.addUpdateCommand(this.item.requireProperty("availableLanguages", []), updateTranslationsCommand);
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
let request = Dbm.getGraphApi().requestRange([{"type": "byObjectType", "objectType": "page"}], ["urlRequest"]);
|
|
24
|
+
this.item.propertyInput("pages", request.properties.items);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
{
|
|
28
|
+
let request = Dbm.getGraphApi().requestRange([{"type": "byObjectType", "objectType": "language"}], ["type"]);
|
|
29
|
+
this.item.propertyInput("languages", request.properties.items);
|
|
30
|
+
Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._languagesLoaded.bind(this), []));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_languagesLoaded() {
|
|
35
|
+
//console.log("_languagesLoaded");
|
|
36
|
+
//console.log(this.item.languages);
|
|
37
|
+
|
|
38
|
+
let availableLanguageCodes = Dbm.utils.ArrayFunctions.mapField(Dbm.getRepositoryItem("site").availableLanguages, "code");
|
|
39
|
+
|
|
40
|
+
let filteredLanguages = Dbm.utils.ArrayFunctions.filterByField(this.item.languages, "identifier", availableLanguageCodes, "inArray");
|
|
41
|
+
this.item.availableLanguages = filteredLanguages;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
_updateActiveTranslations() {
|
|
45
|
+
console.log("_updateActiveTranslations");
|
|
46
|
+
let itemEditor = this.context.itemEditor;
|
|
47
|
+
let language = this.context.language;
|
|
48
|
+
|
|
49
|
+
let availableTranslatedLanguages = Dbm.utils.ArrayFunctions.filterByField(this.item.availableLanguages, "id", language.id, "!==");
|
|
50
|
+
|
|
51
|
+
console.log(itemEditor, itemEditor.item.editedItem.id, availableTranslatedLanguages, language);
|
|
52
|
+
|
|
53
|
+
let editor = itemEditor.getAdminMultipleIncomingRelationsEditor("in", "page");
|
|
54
|
+
|
|
55
|
+
let allTranslations = Dbm.getInstance().repository.getItems(editor.value);
|
|
56
|
+
let translations = Dbm.utils.ArrayFunctions.filterByField(allTranslations, "language", availableTranslatedLanguages, "inArray");
|
|
57
|
+
|
|
58
|
+
let missingLanguages = Dbm.utils.TranslationFunctions.getMissingTranslations(allTranslations, availableTranslatedLanguages);
|
|
59
|
+
|
|
60
|
+
this.item.translations = translations;
|
|
61
|
+
this.item.missingLanguages = missingLanguages;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
_createTranslation(aLanguage) {
|
|
65
|
+
console.log("_createTranslation");
|
|
66
|
+
console.log(aLanguage);
|
|
67
|
+
|
|
68
|
+
let currentPage = this.context.page;
|
|
69
|
+
console.log(currentPage, this.item.pages);
|
|
70
|
+
|
|
71
|
+
let currentUrl = currentPage.url;
|
|
72
|
+
let newUrl = "/" + aLanguage.identifier + currentUrl;
|
|
73
|
+
if(currentUrl !== "/") {
|
|
74
|
+
let tempArray = currentUrl.split("/");
|
|
75
|
+
console.log(currentUrl, tempArray);
|
|
76
|
+
tempArray.pop(); //MENOTE: remove trailing slash
|
|
77
|
+
let currentSlug = tempArray.pop();
|
|
78
|
+
let parentUrl = tempArray.join("/") + "/";
|
|
79
|
+
console.log(parentUrl);
|
|
80
|
+
let parentPage = Dbm.utils.ArrayFunctions.getItemByIfExists(this.item.pages, "url", parentUrl);
|
|
81
|
+
let translations = Dbm.objectPath(parentPage, "translations.pages");
|
|
82
|
+
console.log(parentPage, translations);
|
|
83
|
+
if(translations) {
|
|
84
|
+
let translationInLanguage = Dbm.utils.ArrayFunctions.getItemByIfExists(translations, "language", aLanguage);
|
|
85
|
+
console.log(translationInLanguage);
|
|
86
|
+
if(translationInLanguage) {
|
|
87
|
+
newUrl = translationInLanguage.url + currentSlug + "/";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
console.log(newUrl);
|
|
93
|
+
|
|
94
|
+
let currentDate = (new Date()).toISOString().split("T")[0];
|
|
95
|
+
|
|
96
|
+
let changes = [
|
|
97
|
+
{"type": "setField", "data": {"value": currentPage.title, "field": "title"}},
|
|
98
|
+
{"type": "setField", "data": {"value": currentDate, "field": "publishDate"}},
|
|
99
|
+
{"type": "setUrl", "data": {"value": newUrl}},
|
|
100
|
+
{"type": "addIncomingRelation", "data": {"value": aLanguage.id, "type": "for"}}
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
let request = Dbm.getGraphApi().createItem(["page"], "public", changes, ["urlRequest"]);
|
|
104
|
+
|
|
105
|
+
Dbm.flow.addUpdateCommand(request.properties.status, Dbm.commands.callFunction(this._addTranslation.bind(this), [Dbm.core.source.staticObject(request, "item")]));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
_addTranslation(aPage) {
|
|
109
|
+
//console.log("_addTranslation");
|
|
110
|
+
//console.log(aPage);
|
|
111
|
+
|
|
112
|
+
let itemEditor = this.context.itemEditor;
|
|
113
|
+
let editor = itemEditor.getAdminMultipleIncomingRelationsEditor("in", "page");
|
|
114
|
+
|
|
115
|
+
let newValues = [].concat(editor.value);
|
|
116
|
+
newValues.push(aPage.id);
|
|
117
|
+
editor.value = newValues;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
getFlagUrl(aLanguageCode) {
|
|
121
|
+
|
|
122
|
+
let countryCode = aLanguageCode;
|
|
123
|
+
if(aLanguageCode === "en") {
|
|
124
|
+
countryCode = "gb";
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return "https://flagcdn.com/" + countryCode + ".svg";
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
_renderMainElement() {
|
|
131
|
+
|
|
132
|
+
return React.createElement("div", {},
|
|
133
|
+
React.createElement(Dbm.react.area.List, {items: this.item.properties.translations, "as": "translation"},
|
|
134
|
+
React.createElement(Dbm.react.form.Dropdown, {},
|
|
135
|
+
React.createElement("div", {"data-slot": "button", "className": "language-circle centered-cell-holder"}, Dbm.react.text.text(Dbm.react.source.contextVariable("translation.language.identifier"))),
|
|
136
|
+
React.createElement("div", {"className": "dropdown-menu-max-height standard-dropdown"},
|
|
137
|
+
React.createElement(Dbm.react.text.Link, {"href": Dbm.react.source.contextVariable("translation.url"), "target": "_blank", "className": "custom-styled-link"},
|
|
138
|
+
React.createElement("div", {className: "standard-dropdown-row standard-dropdown-row-padding hover-row cursor-pointer"}, "View")
|
|
139
|
+
)
|
|
140
|
+
),
|
|
141
|
+
)
|
|
142
|
+
),
|
|
143
|
+
React.createElement(Dbm.react.area.List, {items: this.item.properties.missingLanguages, "as": "translationLanguage"},
|
|
144
|
+
React.createElement(Dbm.react.form.Dropdown, {},
|
|
145
|
+
React.createElement("div", {"data-slot": "button", "className": "language-circle centered-cell-holder"},
|
|
146
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("translationLanguage.identifier")),
|
|
147
|
+
"+"
|
|
148
|
+
),
|
|
149
|
+
React.createElement("div", {"className": "dropdown-menu-max-height standard-dropdown"},
|
|
150
|
+
React.createElement(Dbm.react.interaction.CommandButton, {"commands": [
|
|
151
|
+
Dbm.commands.callFunction(this._createTranslation.bind(this), [Dbm.react.source.contextVariable("translationLanguage")]),
|
|
152
|
+
Dbm.commands.setProperty(Dbm.react.source.contextVariable("open"), false)
|
|
153
|
+
]},
|
|
154
|
+
React.createElement("div", {className: "standard-dropdown-row standard-dropdown-row-padding hover-row cursor-pointer"}, "Create page")
|
|
155
|
+
),
|
|
156
|
+
|
|
157
|
+
React.createElement("div", {}, "Link translation"),
|
|
158
|
+
React.createElement(Dbm.react.admin.SelectTranslation, {"commands": [
|
|
159
|
+
Dbm.commands.callFunction(this._addTranslation.bind(this), [Dbm.core.source.event("page")]),
|
|
160
|
+
Dbm.commands.setProperty(Dbm.react.source.contextVariable("open"), false)
|
|
161
|
+
]},
|
|
162
|
+
React.createElement("div", {"className": "standard-dropdown-row standard-dropdown-row-padding hover-row cursor-pointer"},
|
|
163
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("translatedPage.url")),
|
|
164
|
+
" - ",
|
|
165
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("translatedPage.title"))
|
|
166
|
+
)
|
|
167
|
+
)
|
|
168
|
+
)
|
|
169
|
+
)
|
|
170
|
+
)
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class PageTranslations extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
let updateTranslationsCommand = Dbm.commands.callFunction(this._updateTranslatedLanguages.bind(this));
|
|
9
|
+
|
|
10
|
+
let itemEditor = this.context.itemEditor;
|
|
11
|
+
let languageEditor = itemEditor.getDefaultIncomingRelationEditor("for", "language");
|
|
12
|
+
Dbm.flow.addUpdateCommand(languageEditor.valueProperty, updateTranslationsCommand);
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
Dbm.flow.addUpdateCommand(this.item.requireProperty("availableLanguages", []), updateTranslationsCommand);
|
|
17
|
+
this.item.requireProperty("availableTranslations", [])
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
let request = Dbm.getGraphApi().requestRange([{"type": "byObjectType", "objectType": "page"}], ["urlRequest"]);
|
|
21
|
+
this.item.propertyInput("pages", request.properties.items);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
{
|
|
25
|
+
let request = Dbm.getGraphApi().requestRange([{"type": "byObjectType", "objectType": "language"}], ["type"]);
|
|
26
|
+
this.item.propertyInput("languages", request.properties.items);
|
|
27
|
+
Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._languagesLoaded.bind(this), []));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_languagesLoaded() {
|
|
32
|
+
//console.log("_languagesLoaded");
|
|
33
|
+
//console.log(this.item.languages);
|
|
34
|
+
|
|
35
|
+
let availableLanguageCodes = Dbm.utils.ArrayFunctions.mapField(Dbm.getRepositoryItem("site").availableLanguages, "code");
|
|
36
|
+
|
|
37
|
+
let filteredLanguages = Dbm.utils.ArrayFunctions.filterByField(this.item.languages, "identifier", availableLanguageCodes, "inArray");
|
|
38
|
+
this.item.availableLanguages = filteredLanguages;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
_updateTranslatedLanguages() {
|
|
42
|
+
//console.log("_updateTranslatedLanguages");
|
|
43
|
+
let itemEditor = this.context.itemEditor;
|
|
44
|
+
let languageEditor = itemEditor.getDefaultIncomingRelationEditor("for", "language");
|
|
45
|
+
|
|
46
|
+
let filteredLanguages = Dbm.utils.ArrayFunctions.filterByField(this.item.availableLanguages, "id", languageEditor.value, "!=");
|
|
47
|
+
this.item.availableTranslations = filteredLanguages;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
_createTranslation(aLanguage) {
|
|
51
|
+
console.log("_createTranslation");
|
|
52
|
+
console.log(aLanguage);
|
|
53
|
+
|
|
54
|
+
let itemEditor = this.context.itemEditor;
|
|
55
|
+
let currentPage = itemEditor.item.editedItem;
|
|
56
|
+
console.log(currentPage, this.item.pages);
|
|
57
|
+
|
|
58
|
+
let currentUrl = currentPage.url;
|
|
59
|
+
let newUrl = "/" + aLanguage.identifier + currentUrl;
|
|
60
|
+
if(currentUrl !== "/") {
|
|
61
|
+
let tempArray = currentUrl.split("/");
|
|
62
|
+
console.log(currentUrl, tempArray);
|
|
63
|
+
tempArray.pop(); //MENOTE: remove trailing slash
|
|
64
|
+
let currentSlug = tempArray.pop();
|
|
65
|
+
let parentUrl = tempArray.join("/") + "/";
|
|
66
|
+
console.log(parentUrl);
|
|
67
|
+
let parentPage = Dbm.utils.ArrayFunctions.getItemByIfExists(this.item.pages, "url", parentUrl);
|
|
68
|
+
let translations = Dbm.objectPath(parentPage, "translations.pages");
|
|
69
|
+
console.log(parentPage, translations);
|
|
70
|
+
if(translations) {
|
|
71
|
+
let translationInLanguage = Dbm.utils.ArrayFunctions.getItemByIfExists(translations, "language", aLanguage);
|
|
72
|
+
console.log(translationInLanguage);
|
|
73
|
+
if(translationInLanguage) {
|
|
74
|
+
newUrl = translationInLanguage.url + currentSlug + "/";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log(newUrl);
|
|
80
|
+
|
|
81
|
+
let currentDate = (new Date()).toISOString().split("T")[0];
|
|
82
|
+
|
|
83
|
+
let changes = [
|
|
84
|
+
{"type": "setField", "data": {"value": currentPage.title, "field": "title"}},
|
|
85
|
+
{"type": "setField", "data": {"value": currentDate, "field": "publishDate"}},
|
|
86
|
+
{"type": "setUrl", "data": {"value": newUrl}},
|
|
87
|
+
{"type": "addIncomingRelation", "data": {"value": aLanguage.id, "type": "for"}}
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
let request = Dbm.getGraphApi().createItem(["page"], "public", changes, ["urlRequest"]);
|
|
91
|
+
|
|
92
|
+
Dbm.flow.addUpdateCommand(request.properties.status, Dbm.commands.callFunction(this._pageCreated.bind(this), [Dbm.core.source.staticObject(request, "item")]));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
_pageCreated(aPage) {
|
|
96
|
+
let itemEditor = this.context.itemEditor;
|
|
97
|
+
let currentPage = itemEditor.item.editedItem;
|
|
98
|
+
|
|
99
|
+
let request = this._createTranslationGroup();
|
|
100
|
+
Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._addPageToGroup.bind(this), [Dbm.core.source.staticObject(request, "item"), aPage]));
|
|
101
|
+
Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._addPageToGroup.bind(this), [Dbm.core.source.staticObject(request, "item"), currentPage]));
|
|
102
|
+
Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._groupCreated.bind(this), [Dbm.core.source.staticObject(request, "item")]));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_addToTranslation(aPage) {
|
|
106
|
+
console.log("_createTranslation");
|
|
107
|
+
console.log(aPage);
|
|
108
|
+
|
|
109
|
+
let itemEditor = this.context.itemEditor;
|
|
110
|
+
let currentPage = itemEditor.item.editedItem;
|
|
111
|
+
|
|
112
|
+
let exisitingTranslationGroup = Dbm.objectPath(aPage, "translations");
|
|
113
|
+
if(!exisitingTranslationGroup) {
|
|
114
|
+
let request = this._createTranslationGroup();
|
|
115
|
+
Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._addPageToGroup.bind(this), [Dbm.core.source.staticObject(request, "item"), aPage]));
|
|
116
|
+
Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._addPageToGroup.bind(this), [Dbm.core.source.staticObject(request, "item"), currentPage]));
|
|
117
|
+
Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._groupCreated.bind(this), [Dbm.core.source.staticObject(request, "item")]));
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
let request = this._loadTranslationGroup(exisitingTranslationGroup);
|
|
121
|
+
Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._addPageToGroup.bind(this), [Dbm.core.source.staticObject(request, "item"), currentPage]));
|
|
122
|
+
Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._groupCreated.bind(this), [Dbm.core.source.staticObject(request, "item")]));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_createTranslationGroup() {
|
|
127
|
+
|
|
128
|
+
let itemEditor = this.context.itemEditor;
|
|
129
|
+
let currentPage = itemEditor.item.editedItem;
|
|
130
|
+
|
|
131
|
+
let changes = [
|
|
132
|
+
{"type": "setField", "data": {"value": currentPage.title, "field": "name"}}
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
let request = Dbm.getGraphApi().createItem(["group/translationGroup", "group"], "draft", changes, ["admin_fields", "admin_fieldTranslations", "relations", "visibility"]);
|
|
136
|
+
|
|
137
|
+
return request;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
_addPageToGroup(aGroup, aPage) {
|
|
141
|
+
let editorGroup = this.context.editorGroup;
|
|
142
|
+
|
|
143
|
+
let itemEditor = editorGroup.getItemEditor(aGroup.id);
|
|
144
|
+
|
|
145
|
+
let editor = itemEditor.getAdminMultipleIncomingRelationsEditor("in", "page");
|
|
146
|
+
|
|
147
|
+
let newValues = [].concat(editor.value);
|
|
148
|
+
newValues.push(aPage.id);
|
|
149
|
+
editor.value = newValues;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
_groupCreated(aGroup) {
|
|
153
|
+
console.log("_groupCreated");
|
|
154
|
+
console.log(aGroup);
|
|
155
|
+
|
|
156
|
+
let editorGroup = this.context.editorGroup;
|
|
157
|
+
|
|
158
|
+
let groupItemEditor = editorGroup.getItemEditor(aGroup.id);
|
|
159
|
+
groupItemEditor.getVisibilityEditor(aGroup.visibility).value = "public";
|
|
160
|
+
|
|
161
|
+
let itemEditor = this.context.itemEditor;
|
|
162
|
+
let currentPage = itemEditor.item.editedItem;
|
|
163
|
+
|
|
164
|
+
let relationEditor = itemEditor.getDefaultOutgoingRelationEditor("in", "group/translationGroup");
|
|
165
|
+
relationEditor.value = aGroup.id;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_loadTranslationGroup(aGroup) {
|
|
169
|
+
console.log("_loadTranslationGroup");
|
|
170
|
+
let request = Dbm.getGraphApi().requestItem(aGroup.id, ["admin_fields", "admin_fieldTranslations", "relations", "visibility"]);
|
|
171
|
+
|
|
172
|
+
return request;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
_renderMainElement() {
|
|
176
|
+
|
|
177
|
+
let selectTranslationElement = React.createElement(Dbm.react.form.Dropdown, {},
|
|
178
|
+
React.createElement("div", {"data-slot": "button", "className": "language-circle centered-cell-holder"},
|
|
179
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("translationLanguage.identifier")),
|
|
180
|
+
"+"
|
|
181
|
+
),
|
|
182
|
+
React.createElement("div", {"className": "dropdown-menu-max-height standard-dropdown"},
|
|
183
|
+
React.createElement(Dbm.react.interaction.CommandButton, {"commands": [
|
|
184
|
+
Dbm.commands.callFunction(this._createTranslation.bind(this), [Dbm.react.source.contextVariable("translationLanguage")]),
|
|
185
|
+
Dbm.commands.setProperty(Dbm.react.source.contextVariable("open"), false)
|
|
186
|
+
]},
|
|
187
|
+
React.createElement("div", {className: "standard-dropdown-row standard-dropdown-row-padding hover-row cursor-pointer"}, "New translated page")
|
|
188
|
+
),
|
|
189
|
+
|
|
190
|
+
React.createElement("div", {"className": "standard-field-label"}, "Link translation"),
|
|
191
|
+
React.createElement(Dbm.react.admin.SelectTranslation, {"commands": [
|
|
192
|
+
Dbm.commands.callFunction(this._addToTranslation.bind(this), [Dbm.core.source.event("page")]),
|
|
193
|
+
Dbm.commands.setProperty(Dbm.react.source.contextVariable("open"), false)
|
|
194
|
+
]},
|
|
195
|
+
React.createElement("div", {"className": "standard-dropdown-row standard-dropdown-row-padding hover-row cursor-pointer"},
|
|
196
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("translatedPage.url")),
|
|
197
|
+
" - ",
|
|
198
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("translatedPage.title"))
|
|
199
|
+
)
|
|
200
|
+
)
|
|
201
|
+
)
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
return React.createElement("div", {},
|
|
205
|
+
React.createElement(Dbm.react.admin.editorsgroup.EditRelation, {direction: "in", relationType: "for", objectType: "language"},
|
|
206
|
+
React.createElement(Dbm.react.context.AddItemByIdToContext, {"id": Dbm.react.source.contextVariable("valueEditor.editValue.value"), "as": "language"},
|
|
207
|
+
React.createElement(Dbm.react.admin.editorsgroup.EditRelation, {direction: "out", relationType: "in", objectType: "group/translationGroup"},
|
|
208
|
+
React.createElement(Dbm.react.area.HasData, {check: Dbm.react.source.contextVariable("valueEditor.editValue.value"), checkType: ">", compareValue: 0},
|
|
209
|
+
React.createElement(Dbm.react.admin.EditObjectById, {"id": Dbm.react.source.contextVariable("valueEditor.editValue.value")},
|
|
210
|
+
React.createElement(Dbm.react.admin.EditTranslationGroup, {})
|
|
211
|
+
)
|
|
212
|
+
),
|
|
213
|
+
React.createElement(Dbm.react.area.HasData, {check: Dbm.react.source.contextVariable("valueEditor.editValue.value"), checkType: "invert/>", compareValue: 0},
|
|
214
|
+
React.createElement(Dbm.react.area.HasData, {check: Dbm.react.source.contextVariable("language.id")},
|
|
215
|
+
React.createElement(Dbm.react.area.List, {items: this.item.properties.availableTranslations, "as": "translationLanguage"},
|
|
216
|
+
selectTranslationElement
|
|
217
|
+
)
|
|
218
|
+
)
|
|
219
|
+
)
|
|
220
|
+
)
|
|
221
|
+
)
|
|
222
|
+
),
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class SelectTranslation extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.item.requireProperty("availablePages", []);
|
|
9
|
+
|
|
10
|
+
{
|
|
11
|
+
let request = Dbm.getGraphApi().requestRange([{"type": "byObjectType", "objectType": "page"}], ["urlRequest"]);
|
|
12
|
+
this.item.propertyInput("pages", request.properties.items);
|
|
13
|
+
Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._pagesLoaded.bind(this), []));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_pagesLoaded() {
|
|
18
|
+
let language = this.context.language;
|
|
19
|
+
let translationLanguage = this.context.translationLanguage;
|
|
20
|
+
|
|
21
|
+
let availablePages = Dbm.utils.TranslationFunctions.getPagesForTranslation(this.item.pages, language, translationLanguage);
|
|
22
|
+
|
|
23
|
+
this.item.availablePages = availablePages;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
_pageSelected(aPage) {
|
|
27
|
+
let commands = this.getPropValue("commands");
|
|
28
|
+
if(!commands) {
|
|
29
|
+
commands = this.getPropValue("command");
|
|
30
|
+
}
|
|
31
|
+
if(commands) {
|
|
32
|
+
commands = Dbm.utils.ArrayFunctions.singleOrArray(commands);
|
|
33
|
+
|
|
34
|
+
let currentArray = commands;
|
|
35
|
+
let currentArrayLength = currentArray.length;
|
|
36
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
37
|
+
let command = currentArray[i];
|
|
38
|
+
try {
|
|
39
|
+
command.perform(this, {"page": aPage});
|
|
40
|
+
}
|
|
41
|
+
catch(theError) {
|
|
42
|
+
console.error("Error while running command", theError, command);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else{
|
|
48
|
+
console.warn("SelectTranslation doesn't have any commands", this);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_renderMainElement() {
|
|
53
|
+
|
|
54
|
+
let children = this.getPropValue("children");
|
|
55
|
+
if(!children) {
|
|
56
|
+
children = React.createElement("div", {"className": "cursor-pointer"},
|
|
57
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("translatedPage.url")),
|
|
58
|
+
" - ",
|
|
59
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("translatedPage.title"))
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return React.createElement(React.Fragment, {},
|
|
64
|
+
React.createElement(Dbm.react.area.List, {items: this.item.properties.availablePages, "as": "translatedPage"},
|
|
65
|
+
React.createElement(Dbm.react.interaction.CommandButton, {"command": Dbm.commands.callFunction(this._pageSelected.bind(this), [Dbm.react.source.contextVariable("translatedPage")])},
|
|
66
|
+
children
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
@@ -22,7 +22,7 @@ export default class EditItem extends Dbm.react.BaseObject {
|
|
|
22
22
|
{"type": "includeDraft"},
|
|
23
23
|
{"type": "idSelection", "ids": [item.id]},
|
|
24
24
|
],
|
|
25
|
-
["admin_fields", "admin_fieldTranslations", "relations", "visibility"]
|
|
25
|
+
["admin_fields", "admin_fieldTranslations", "relations", "url", "identifier", "visibility"]
|
|
26
26
|
);
|
|
27
27
|
allLoaded.addCheck(request.properties.status);
|
|
28
28
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class EditMultipleRelations extends Dbm.react.BaseObject {
|
|
5
|
+
_constructAfterProps() {
|
|
6
|
+
super._constructAfterProps();
|
|
7
|
+
|
|
8
|
+
let itemEditor = this.context.itemEditor;
|
|
9
|
+
let editor;
|
|
10
|
+
|
|
11
|
+
let direction = this.getPropValue("direction");
|
|
12
|
+
let relationType = this.getPropValue("relationType");
|
|
13
|
+
let objectType = this.getPropValue("objectType");
|
|
14
|
+
|
|
15
|
+
if(direction == "in") {
|
|
16
|
+
editor = itemEditor.getAdminMultipleIncomingRelationsEditor(relationType, objectType);
|
|
17
|
+
}
|
|
18
|
+
else if(direction == "out") {
|
|
19
|
+
editor = itemEditor.getAdminMultipleOutgoingRelationsEditor(relationType, objectType);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
console.error("Unknown direction", direction, this);
|
|
23
|
+
editor = null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if(editor) {
|
|
27
|
+
this.item.setValue("editor", editor.item);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
_renderMainElement() {
|
|
32
|
+
|
|
33
|
+
let children = this.getPropValue("children")
|
|
34
|
+
|
|
35
|
+
return React.createElement("div", {},
|
|
36
|
+
React.createElement(Dbm.react.context.AddContextVariables, {"values": {"valueEditor": this.item.editor}}, children)
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class EditPartOfObject extends Dbm.react.BaseObject {
|
|
5
|
+
_constructAfterProps() {
|
|
6
|
+
super._constructAfterProps();
|
|
7
|
+
|
|
8
|
+
let valueProperty = this.getDynamicPropWithoutState("value", {});
|
|
9
|
+
|
|
10
|
+
let partObject = new Dbm.flow.controllers.transform.PartOfObject();
|
|
11
|
+
this.item.setValue("partOfObject", partObject);
|
|
12
|
+
let path = this.getPropValue("path");
|
|
13
|
+
|
|
14
|
+
if(!valueProperty.value) {
|
|
15
|
+
valueProperty.getMostUpstreamProperty().value = {};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
partObject.item.properties.object.connectInput(valueProperty);
|
|
19
|
+
partObject.item.path = path;
|
|
20
|
+
|
|
21
|
+
this.item.requireProperty("valuePart", null).connectInput(partObject.item.properties.value);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_renderMainElement() {
|
|
25
|
+
|
|
26
|
+
let children = this.getPropValue("children")
|
|
27
|
+
|
|
28
|
+
return React.createElement("div", {},
|
|
29
|
+
React.createElement(Dbm.react.context.AddContextVariables, {"values": {"value": this.item.properties.valuePart}}, children)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|