dbm 1.2.2 → 1.2.3
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 +2 -2
- package/commands/SetProperty.js +1 -1
- package/core/source/SourceCommand.js +17 -0
- package/core/source/index.js +15 -0
- package/flow/updatefunctions/thirdparty/google/maps/AutoComplete.js +1 -8
- package/flow/updatefunctions/thirdparty/google/maps/PlaceDetails.js +1 -8
- package/flow/updatefunctions/thirdparty/google/maps/PlaceDetailsFromQuery.js +71 -0
- package/flow/updatefunctions/thirdparty/google/maps/index.js +2 -1
- package/graphapi/webclient/admin/ItemEditor.js +2 -2
- package/package.json +1 -1
- package/react/BaseObject.js +12 -1
- package/react/admin/objects/itemeditors/Field.js +26 -0
- package/react/admin/objects/itemeditors/FieldWithTranslations.js +38 -0
- package/react/admin/objects/itemeditors/Name.js +11 -21
- package/react/admin/objects/itemeditors/PageRepresentation.js +1 -1
- package/react/admin/objects/itemeditors/Title.js +20 -28
- package/react/admin/objects/itemeditors/index.js +2 -1
- package/react/area/SwitchableArea.js +39 -0
- package/react/area/index.js +1 -0
- package/react/blocks/index.js +12 -0
- package/react/interaction/ClickOutsideTrigger.js +53 -0
- package/react/interaction/CommandButton.js +7 -1
- package/react/interaction/ConfirmButton.js +56 -0
- package/react/interaction/index.js +3 -1
- package/utils/ArrayFunctions.js +47 -1
- package/utils/CompareFunctions.js +23 -1
- package/utils/thirdparty/google/index.js +1 -0
- package/utils/thirdparty/google/maps/PlaceFunctions.js +53 -0
- package/utils/thirdparty/google/maps/index.js +1 -0
- package/utils/thirdparty/index.js +2 -1
|
@@ -9,7 +9,7 @@ export default class CommandBaseObject extends Dbm.core.BaseObject {
|
|
|
9
9
|
//MENOTE: should be overridden
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
_resolveSource(aValueOrSource) {
|
|
12
|
+
_resolveSource(aValueOrSource, aFromObject = null, aData = null) {
|
|
13
13
|
if(aValueOrSource) {
|
|
14
14
|
if(aValueOrSource.isFlowProperty) {
|
|
15
15
|
return aValueOrSource.value;
|
|
@@ -22,7 +22,7 @@ export default class CommandBaseObject extends Dbm.core.BaseObject {
|
|
|
22
22
|
return aValueOrSource;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
_resolveSourceWithoutFlow(aValueOrSource) {
|
|
25
|
+
_resolveSourceWithoutFlow(aValueOrSource, aFromObject = null, aData = null) {
|
|
26
26
|
if(aValueOrSource && aValueOrSource.isSource) {
|
|
27
27
|
return aValueOrSource.getSource(aFromObject, aData);
|
|
28
28
|
}
|
package/commands/SetProperty.js
CHANGED
|
@@ -13,6 +13,6 @@ export default class SetProperty extends CommandBaseObject {
|
|
|
13
13
|
|
|
14
14
|
let value = this.getInput("value");
|
|
15
15
|
|
|
16
|
-
this._resolveSourceWithoutFlow(this.item.property).value = value;
|
|
16
|
+
this._resolveSourceWithoutFlow(this.item.property, aFromObject, aData).value = value;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class SourceCommand extends Dbm.core.source.SourceBaseObject {
|
|
4
|
+
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.item.setValue("object", null);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
getBaseObject(aFromObject, aEventData) {
|
|
12
|
+
|
|
13
|
+
let command = this.item.object;
|
|
14
|
+
|
|
15
|
+
return command.perform(aFromObject, aEventData);
|
|
16
|
+
}
|
|
17
|
+
}
|
package/core/source/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export {default as EventSource} from "./EventSource.js";
|
|
|
5
5
|
export {default as FromObject} from "./FromObject.js";
|
|
6
6
|
export {default as StaticSource} from "./StaticSource.js";
|
|
7
7
|
export {default as FirstSource} from "./FirstSource.js";
|
|
8
|
+
export {default as SourceCommand} from "./SourceCommand.js";
|
|
8
9
|
|
|
9
10
|
export const event = function(aPath = null) {
|
|
10
11
|
let newSource = new Dbm.core.source.EventSource();
|
|
@@ -50,3 +51,17 @@ export const firstWithDefault = function(...aSourcesAndDefault) {
|
|
|
50
51
|
|
|
51
52
|
return newSource;
|
|
52
53
|
}
|
|
54
|
+
|
|
55
|
+
export const command = function(aCommand) {
|
|
56
|
+
let newSource = new Dbm.core.source.SourceCommand();
|
|
57
|
+
|
|
58
|
+
newSource.item.object = aCommand;
|
|
59
|
+
|
|
60
|
+
return newSource;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const callFunction = function(aFunction, aArguments = []) {
|
|
64
|
+
let functionCommand = Dbm.commands.callFunction(aFunction, aArguments);
|
|
65
|
+
|
|
66
|
+
return command(functionCommand);
|
|
67
|
+
}
|
|
@@ -20,13 +20,7 @@ export default class AutoComplete extends Dbm.flow.FlowUpdateFunction {
|
|
|
20
20
|
loadScript() {
|
|
21
21
|
let key = Dbm.getRepositoryItem("googleMapsApi").apiKey;
|
|
22
22
|
let scriptLoader = Dbm.loading.loadScript("https://maps.googleapis.com/maps/api/js?key=" + key + "&libraries=places");
|
|
23
|
-
|
|
24
|
-
if(scriptLoader.item.properties.status === 1) {
|
|
25
|
-
this._scriptLoaded();
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
Dbm.flow.addUpdateCommandWhenMatched(scriptLoader.item.properties.status, 1, Dbm.commands.callFunction(this._scriptLoaded.bind(this)));
|
|
29
|
-
}
|
|
23
|
+
Dbm.flow.runWhenMatched(scriptLoader.item.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._scriptLoaded.bind(this)));
|
|
30
24
|
|
|
31
25
|
return this;
|
|
32
26
|
}
|
|
@@ -54,7 +48,6 @@ export default class AutoComplete extends Dbm.flow.FlowUpdateFunction {
|
|
|
54
48
|
_update() {
|
|
55
49
|
console.log("_update");
|
|
56
50
|
|
|
57
|
-
|
|
58
51
|
let text = this.input.text;
|
|
59
52
|
this._currentText = text;
|
|
60
53
|
this.output.updated = false;
|
|
@@ -21,14 +21,7 @@ export default class PlaceDetails extends Dbm.flow.FlowUpdateFunction {
|
|
|
21
21
|
console.log("loadScript");
|
|
22
22
|
let key = Dbm.getRepositoryItem("googleMapsApi").apiKey;
|
|
23
23
|
let scriptLoader = Dbm.loading.loadScript("https://maps.googleapis.com/maps/api/js?key=" + key + "&libraries=places");
|
|
24
|
-
|
|
25
|
-
console.log(scriptLoader.item.properties.status, scriptLoader);
|
|
26
|
-
if(scriptLoader.item.status === 1) {
|
|
27
|
-
this._scriptLoaded();
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
Dbm.flow.addUpdateCommandWhenMatched(scriptLoader.item.properties.status, 1, Dbm.commands.callFunction(this._scriptLoaded.bind(this)));
|
|
31
|
-
}
|
|
24
|
+
Dbm.flow.runWhenMatched(scriptLoader.item.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._scriptLoaded.bind(this)));
|
|
32
25
|
|
|
33
26
|
return this;
|
|
34
27
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import Dbm from "../../../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class PlaceDetailsDetailsFromQuery extends Dbm.flow.FlowUpdateFunction {
|
|
4
|
+
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.input.register("query", null);
|
|
9
|
+
this.input.register("fields", ["addressComponents", "location"]);
|
|
10
|
+
|
|
11
|
+
this._loadedScript = false;
|
|
12
|
+
this._currentId = "";
|
|
13
|
+
|
|
14
|
+
this.output.register("updated", true);
|
|
15
|
+
this.output.register("data", null);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
loadScript() {
|
|
19
|
+
console.log("loadScript");
|
|
20
|
+
let key = Dbm.getRepositoryItem("googleMapsApi").apiKey;
|
|
21
|
+
let scriptLoader = Dbm.loading.loadScript("https://maps.googleapis.com/maps/api/js?key=" + key + "&libraries=places");
|
|
22
|
+
Dbm.flow.runWhenMatched(scriptLoader.item.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._scriptLoaded.bind(this)));
|
|
23
|
+
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_scriptLoaded() {
|
|
28
|
+
console.log("_scriptLoaded");
|
|
29
|
+
if(!this._loadedScript) {
|
|
30
|
+
this._loadedScript = true;
|
|
31
|
+
this._update();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_update() {
|
|
36
|
+
console.log("_update");
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
let query = this.input.query;
|
|
40
|
+
this._currentQuery = query;
|
|
41
|
+
this.output.updated = false;
|
|
42
|
+
|
|
43
|
+
if(query) {
|
|
44
|
+
this.output.properties.data.isDirty = false;
|
|
45
|
+
this.output.properties.updated.isDirty = false;
|
|
46
|
+
|
|
47
|
+
if(this._loadedScript) {
|
|
48
|
+
|
|
49
|
+
let loadPromise = google.maps.places.Place.searchByText({
|
|
50
|
+
textQuery: query,
|
|
51
|
+
fields: this.input.fields,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
loadPromise.then((aResponse) => {
|
|
55
|
+
let place = aResponse.places[0];
|
|
56
|
+
this.output.properties.data._internal_setValueInFlowOutsideOfUpdate(place);
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.loadScript();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this.output.data = null;
|
|
65
|
+
this.output.updated = true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Dbm from "../../../../../index.js";
|
|
2
2
|
|
|
3
3
|
export {default as AutoComplete} from "./AutoComplete.js";
|
|
4
|
-
export {default as PlaceDetails} from "./PlaceDetails.js";
|
|
4
|
+
export {default as PlaceDetails} from "./PlaceDetails.js";
|
|
5
|
+
export {default as PlaceDetailsFromQuery} from "./PlaceDetailsFromQuery.js";
|
|
@@ -118,7 +118,7 @@ export default class ItemEditor extends Dbm.core.BaseObject {
|
|
|
118
118
|
|
|
119
119
|
getAdminMultipleIncomingRelationsEditor(aType, aObjectType) {
|
|
120
120
|
let name = "in_" + aType + "_" + aObjectType;
|
|
121
|
-
let valueEditor = this.item["
|
|
121
|
+
let valueEditor = this.item["editor_multipleRelations_" + name];
|
|
122
122
|
if(!valueEditor) {
|
|
123
123
|
let relations = Dbm.utils.ArrayFunctions.filterByField(Dbm.objectPath(this.item.editedItem, "relations/in." + aType + ".objects"), "objectTypes", aObjectType, "arrayContains");
|
|
124
124
|
let ids = Dbm.utils.ArrayFunctions.mapField(relations, "id");
|
|
@@ -131,7 +131,7 @@ export default class ItemEditor extends Dbm.core.BaseObject {
|
|
|
131
131
|
|
|
132
132
|
getAdminMultipleOutgoingRelationsEditor(aType, aObjectType) {
|
|
133
133
|
let name = "out_" + aType + "_" + aObjectType;
|
|
134
|
-
let valueEditor = this.item["
|
|
134
|
+
let valueEditor = this.item["editor_multipleRelations_" + name];
|
|
135
135
|
if(!valueEditor) {
|
|
136
136
|
let relations = Dbm.utils.ArrayFunctions.filterByField(Dbm.objectPath(this.item.editedItem, "relations/in." + aType + ".objects"), "objectTypes", aObjectType, "arrayContains");
|
|
137
137
|
let ids = Dbm.utils.ArrayFunctions.mapField(relations, "id");
|
package/package.json
CHANGED
package/react/BaseObject.js
CHANGED
|
@@ -130,7 +130,18 @@ export default class BaseObject extends Component {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
render() {
|
|
133
|
-
|
|
133
|
+
let returnObject;
|
|
134
|
+
|
|
135
|
+
//METODO: add switch for if it should be safe
|
|
136
|
+
try {
|
|
137
|
+
returnObject = this._renderMainElement();
|
|
138
|
+
}
|
|
139
|
+
catch(theError) {
|
|
140
|
+
console.error("Error while rendering", theError);
|
|
141
|
+
returnObject = React.createElement("div", {}, "Error");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return returnObject;
|
|
134
145
|
}
|
|
135
146
|
|
|
136
147
|
_renderMainElement() {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class Field extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_renderMainElement() {
|
|
10
|
+
|
|
11
|
+
let label = this.getPropValue("label");
|
|
12
|
+
let fieldName = this.getPropValue("fieldName");
|
|
13
|
+
|
|
14
|
+
let fieldNameSource = Dbm.react.source.contextVariable("fieldName");
|
|
15
|
+
let editorValueSource = Dbm.react.source.contextVariable("valueEditor.editValue.value");
|
|
16
|
+
|
|
17
|
+
return React.createElement("div", {},
|
|
18
|
+
React.createElement("label", {className: "standard-field-label"}, label),
|
|
19
|
+
React.createElement(Dbm.react.context.AddContextVariables, {values: {"fieldName": fieldName}},
|
|
20
|
+
React.createElement(Dbm.react.admin.editorsgroup.EditField, {"fieldName": fieldNameSource},
|
|
21
|
+
React.createElement(Dbm.react.form.FormField, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class FieldWithTranslations extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_renderMainElement() {
|
|
10
|
+
|
|
11
|
+
let label = this.getPropValue("label");
|
|
12
|
+
let fieldName = this.getPropValue("fieldName");
|
|
13
|
+
|
|
14
|
+
let fieldNameSource = Dbm.react.source.contextVariable("fieldName");
|
|
15
|
+
let editorValueSource = Dbm.react.source.contextVariable("valueEditor.editValue.value");
|
|
16
|
+
|
|
17
|
+
return React.createElement("div", {},
|
|
18
|
+
React.createElement("label", {className: "standard-field-label"}, label),
|
|
19
|
+
React.createElement(Dbm.react.context.AddContextVariables, {values: {"fieldName": fieldName}},
|
|
20
|
+
React.createElement(Dbm.react.admin.editorsgroup.EditField, {"fieldName": fieldNameSource},
|
|
21
|
+
React.createElement(Dbm.react.form.FormField, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
|
|
22
|
+
),
|
|
23
|
+
React.createElement(Dbm.react.area.List, {items: Dbm.getRepositoryItem("site").properties.availableLanguages, as: "language"},
|
|
24
|
+
React.createElement("div", {className: "flex-row small-item-spacing vertically-center-items"},
|
|
25
|
+
React.createElement("div", {className: "flex-row-item flex-no-resize"},
|
|
26
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("language.code"))
|
|
27
|
+
),
|
|
28
|
+
React.createElement("div", {className: "flex-row-item flex-resize"},
|
|
29
|
+
React.createElement(Dbm.react.admin.editorsgroup.EditFieldTranslation, {"fieldName": fieldNameSource, "language": Dbm.react.source.contextVariable("language.code")},
|
|
30
|
+
React.createElement(Dbm.react.form.FormField, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
|
|
31
|
+
),
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -8,19 +8,6 @@ export default class Name extends Dbm.react.BaseObject {
|
|
|
8
8
|
|
|
9
9
|
_renderMainElement() {
|
|
10
10
|
|
|
11
|
-
/*
|
|
12
|
-
React.createElement(Dbm.react.admin.editorsgroup.EditFieldTranslation, {"fieldName": fieldNameSource, "language": "sv"},
|
|
13
|
-
React.createElement(Dbm.react.form.FormField, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
|
|
14
|
-
),
|
|
15
|
-
React.createElement(Dbm.react.admin.editorsgroup.EditFieldTranslation, {"fieldName": fieldNameSource, "language": "en"},
|
|
16
|
-
React.createElement(Dbm.react.form.FormField, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
|
|
17
|
-
),
|
|
18
|
-
React.createElement(Dbm.react.admin.editorsgroup.EditFieldTranslation, {"fieldName": fieldNameSource, "language": "fi"},
|
|
19
|
-
React.createElement(Dbm.react.form.FormField, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
11
|
let label = "Name";
|
|
25
12
|
let fieldName = "name";
|
|
26
13
|
|
|
@@ -33,15 +20,18 @@ export default class Name extends Dbm.react.BaseObject {
|
|
|
33
20
|
React.createElement(Dbm.react.admin.editorsgroup.EditField, {"fieldName": fieldNameSource},
|
|
34
21
|
React.createElement(Dbm.react.form.FormField, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
|
|
35
22
|
),
|
|
36
|
-
React.createElement(Dbm.react.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
23
|
+
React.createElement(Dbm.react.area.List, {items: Dbm.getRepositoryItem("site").properties.availableLanguages, as: "language"},
|
|
24
|
+
React.createElement("div", {className: "flex-row small-item-spacing vertically-center-items"},
|
|
25
|
+
React.createElement("div", {className: "flex-row-item flex-no-resize"},
|
|
26
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("language.code"))
|
|
27
|
+
),
|
|
28
|
+
React.createElement("div", {className: "flex-row-item flex-resize"},
|
|
29
|
+
React.createElement(Dbm.react.admin.editorsgroup.EditFieldTranslation, {"fieldName": fieldNameSource, "language": Dbm.react.source.contextVariable("language.code")},
|
|
30
|
+
React.createElement(Dbm.react.form.FormField, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
|
|
31
|
+
),
|
|
32
|
+
)
|
|
44
33
|
)
|
|
34
|
+
)
|
|
45
35
|
)
|
|
46
36
|
)
|
|
47
37
|
}
|
|
@@ -34,7 +34,7 @@ export default class PageRepresentation extends Dbm.react.BaseObject {
|
|
|
34
34
|
return React.createElement("div", {},
|
|
35
35
|
|
|
36
36
|
React.createElement(Dbm.react.area.HasData, {check: this.item.properties.loaded},
|
|
37
|
-
React.createElement(Dbm.react.form.LabelledArea, {label: "
|
|
37
|
+
React.createElement(Dbm.react.form.LabelledArea, {label: "Representing page"},
|
|
38
38
|
React.createElement(Dbm.react.admin.editorsgroup.EditRelation, {"direction": "in", "relationType": "pageRepresentationFor", "objectType": "page"},
|
|
39
39
|
React.createElement(Dbm.react.form.GraphApiObjectSelection, {value: Dbm.react.source.contextVariable("valueEditor.editValue.value"), "objectType": "page", "encoding": "title", nameField: "title", className: "standard-field standard-field-padding full-width"})
|
|
40
40
|
)
|
|
@@ -4,43 +4,35 @@ import Dbm from "../../../../index.js";
|
|
|
4
4
|
export default class Title extends Dbm.react.BaseObject {
|
|
5
5
|
_construct() {
|
|
6
6
|
super._construct();
|
|
7
|
-
|
|
8
|
-
let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
|
|
9
|
-
|
|
10
|
-
let id = this.context.item.id;
|
|
11
|
-
|
|
12
|
-
let allLoaded = Dbm.flow.updatefunctions.logic.allAtValue(Dbm.loading.LoadingStatus.LOADED);
|
|
13
|
-
this.item.requireProperty("loaded", false);
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
let request = graphApi.requestRange(
|
|
17
|
-
[
|
|
18
|
-
{"type": "includePrivate"},
|
|
19
|
-
{"type": "includeDraft"},
|
|
20
|
-
{"type": "idSelection", "ids": [id]},
|
|
21
|
-
],
|
|
22
|
-
["title"]
|
|
23
|
-
);
|
|
24
|
-
allLoaded.addCheck(request.properties.status);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
this.item.properties.loaded.connectInput(allLoaded.output.properties.value);
|
|
28
7
|
}
|
|
29
8
|
|
|
30
9
|
_renderMainElement() {
|
|
31
10
|
|
|
32
|
-
let
|
|
11
|
+
let label = "Title";
|
|
12
|
+
let fieldName = "title";
|
|
13
|
+
|
|
14
|
+
let fieldNameSource = Dbm.react.source.contextVariable("fieldName");
|
|
15
|
+
let editorValueSource = Dbm.react.source.contextVariable("valueEditor.editValue.value");
|
|
33
16
|
|
|
34
17
|
return React.createElement("div", {},
|
|
35
|
-
|
|
36
|
-
React.createElement(Dbm.react.
|
|
37
|
-
React.createElement(Dbm.react.
|
|
38
|
-
React.createElement(Dbm.react.
|
|
39
|
-
|
|
18
|
+
React.createElement("label", {className: "standard-field-label"}, label),
|
|
19
|
+
React.createElement(Dbm.react.context.AddContextVariables, {values: {"fieldName": fieldName}},
|
|
20
|
+
React.createElement(Dbm.react.admin.editorsgroup.EditField, {"fieldName": fieldNameSource},
|
|
21
|
+
React.createElement(Dbm.react.form.FormField, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
|
|
22
|
+
),
|
|
23
|
+
React.createElement(Dbm.react.area.List, {items: Dbm.getRepositoryItem("site").properties.availableLanguages, as: "language"},
|
|
24
|
+
React.createElement("div", {className: "flex-row small-item-spacing vertically-center-items"},
|
|
25
|
+
React.createElement("div", {className: "flex-row-item flex-no-resize"},
|
|
26
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("language.code"))
|
|
27
|
+
),
|
|
28
|
+
React.createElement("div", {className: "flex-row-item flex-resize"},
|
|
29
|
+
React.createElement(Dbm.react.admin.editorsgroup.EditFieldTranslation, {"fieldName": fieldNameSource, "language": Dbm.react.source.contextVariable("language.code")},
|
|
30
|
+
React.createElement(Dbm.react.form.FormField, {value: editorValueSource, className: "standard-field standard-field-padding full-width"})
|
|
31
|
+
),
|
|
32
|
+
)
|
|
40
33
|
)
|
|
41
34
|
)
|
|
42
35
|
)
|
|
43
|
-
|
|
44
36
|
)
|
|
45
37
|
}
|
|
46
38
|
}
|
|
@@ -9,4 +9,5 @@ export {default as RichDescription} from "./RichDescription.js";
|
|
|
9
9
|
export {default as PageRepresentation} from "./PageRepresentation.js";
|
|
10
10
|
export {default as MainImage} from "./MainImage.js";
|
|
11
11
|
export {default as Identifier} from "./Identifier.js";
|
|
12
|
-
export {default as SingleRelation} from "./SingleRelation.js";
|
|
12
|
+
export {default as SingleRelation} from "./SingleRelation.js";
|
|
13
|
+
export {default as Field} from "./Field.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class SwitchableArea extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
let childrenProperty = this.getDynamicPropWithoutState("children", []);
|
|
9
|
+
let areaProperty = this.getDynamicPropWithoutState("area", null);
|
|
10
|
+
|
|
11
|
+
this.item.requireProperty("element", null);
|
|
12
|
+
|
|
13
|
+
Dbm.flow.addUpdateCommand(childrenProperty, Dbm.commands.callFunction(this._updateSlots.bind(this)));
|
|
14
|
+
Dbm.flow.addUpdateCommand(areaProperty, Dbm.commands.callFunction(this._updateSlots.bind(this)));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_updateSlots() {
|
|
18
|
+
let area = this.getPropValue("area");
|
|
19
|
+
let children = Dbm.utils.ArrayFunctions.singleOrArray(this.getPropValue("children"));
|
|
20
|
+
|
|
21
|
+
let slots = Dbm.react.ChildFunctions.splitIntoSlots(children);
|
|
22
|
+
|
|
23
|
+
let slotElement = slots[area];
|
|
24
|
+
let mainChildren = slots.main;
|
|
25
|
+
|
|
26
|
+
if(!slotElement) {
|
|
27
|
+
slotElement = mainChildren;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.item.element = React.createElement(React.Fragment, {key: slotElement}, slotElement);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_renderMainElement() {
|
|
34
|
+
let areaProperty = this.getDynamicPropWithoutState("area", null);
|
|
35
|
+
|
|
36
|
+
return React.createElement(Dbm.react.context.AddContextVariables, {values: {area: areaProperty}}, React.createElement(Dbm.react.area.InsertElement, {"element": this.item.properties.element}));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
package/react/area/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export {default as OpenCloseExpandableArea} from "./OpenCloseExpandableArea.js";
|
|
|
8
8
|
export {default as ResponsiveLayout} from "./ResponsiveLayout.js";
|
|
9
9
|
export {default as List} from "./List.js";
|
|
10
10
|
export {default as FixedWidthInfiniteSlideshow} from "./FixedWidthInfiniteSlideshow.js";
|
|
11
|
+
export {default as SwitchableArea} from "./SwitchableArea.js";
|
|
11
12
|
|
|
12
13
|
export const responsiveLayout = function(aDefaultLayout) {
|
|
13
14
|
let newResponsiveLayout = new Dbm.react.area.ResponsiveLayout();
|
package/react/blocks/index.js
CHANGED
|
@@ -395,6 +395,18 @@ export let registerAllBlocks = function() {
|
|
|
395
395
|
objectTypeEditor.editors = newArray;
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
+
{
|
|
399
|
+
let objectTypeEditor = Dbm.getInstance().repository.getItem("admin/objectTypeEditors/group");
|
|
400
|
+
if(!objectTypeEditor.editors) {
|
|
401
|
+
objectTypeEditor.setValue("editors", []);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
let newArray = [].concat(objectTypeEditor.editors);
|
|
405
|
+
newArray.push(Dbm.getInstance().repository.getItem("admin/itemEditors/name"));
|
|
406
|
+
|
|
407
|
+
objectTypeEditor.editors = newArray;
|
|
408
|
+
}
|
|
409
|
+
|
|
398
410
|
|
|
399
411
|
let admin = Dbm.getInstance().repository.getItem("admin");
|
|
400
412
|
admin.requireProperty("pageEditors", []);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class ClickOutsideTrigger extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this._callback_clickBound = this._callback_click.bind(this);
|
|
9
|
+
document.body.addEventListener("click", this._callback_clickBound, true);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
_callback_click(aEvent) {
|
|
13
|
+
|
|
14
|
+
let commands = this.getPropValue("commands");
|
|
15
|
+
if(!commands) {
|
|
16
|
+
commands = this.getPropValue("command");
|
|
17
|
+
}
|
|
18
|
+
if(commands) {
|
|
19
|
+
let currentElement = this.item["mainElement"];
|
|
20
|
+
if(!currentElement.contains(aEvent.srcElement)) {
|
|
21
|
+
commands = Dbm.utils.ArrayFunctions.singleOrArray(commands);
|
|
22
|
+
let currentArray = commands;
|
|
23
|
+
let currentArrayLength = currentArray.length;
|
|
24
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
25
|
+
let command = currentArray[i];
|
|
26
|
+
try {
|
|
27
|
+
command.perform(this, aEvent);
|
|
28
|
+
}
|
|
29
|
+
catch(theError) {
|
|
30
|
+
console.error("Error while running command", theError, command);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
else{
|
|
38
|
+
console.warn("Click outside doesn't have any commands", this);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
componentWillUnmount() {
|
|
43
|
+
super.componentWillUnmount();
|
|
44
|
+
|
|
45
|
+
document.body.removeEventListener("click", this._callback_clickBound, true);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_renderMainElement() {
|
|
49
|
+
|
|
50
|
+
return React.createElement("div", {"ref": this.createRef("mainElement")}, this.props.children);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
@@ -23,7 +23,13 @@ export default class CommandButton extends Dbm.react.BaseObject {
|
|
|
23
23
|
let currentArrayLength = currentArray.length;
|
|
24
24
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
25
25
|
let command = currentArray[i];
|
|
26
|
-
|
|
26
|
+
try {
|
|
27
|
+
command.perform(this, aEvent);
|
|
28
|
+
}
|
|
29
|
+
catch(theError) {
|
|
30
|
+
console.error("Error while running command", theError, command);
|
|
31
|
+
}
|
|
32
|
+
|
|
27
33
|
}
|
|
28
34
|
}
|
|
29
35
|
else{
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class ConfirmButton extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
let childrenProperty = this.getDynamicPropWithoutState("children", []);
|
|
9
|
+
let confirmProperty = this.getDynamicPropWithoutState("confirm", false);
|
|
10
|
+
let command = this.getDynamicPropWithoutState("command", null);
|
|
11
|
+
|
|
12
|
+
this.item.requireProperty("idleElement", null);
|
|
13
|
+
this.item.requireProperty("confirmElement", null);
|
|
14
|
+
|
|
15
|
+
Dbm.flow.addUpdateCommand(childrenProperty, Dbm.commands.callFunction(this._updateSlots.bind(this)));
|
|
16
|
+
|
|
17
|
+
//METODO: change this to highest property
|
|
18
|
+
|
|
19
|
+
let switchValue = Dbm.flow.updatefunctions.logic.switchValue(confirmProperty);
|
|
20
|
+
switchValue.setDefaultValue(React.createElement(Dbm.react.interaction.CommandButton, {"key": "idle", "command": Dbm.commands.setProperty(confirmProperty, true)},
|
|
21
|
+
React.createElement("div", {}, React.createElement(Dbm.react.area.InsertElement, {"element": this.item.properties.idleElement}))
|
|
22
|
+
|
|
23
|
+
));
|
|
24
|
+
|
|
25
|
+
switchValue.addCase(true, React.createElement(Dbm.react.interaction.ClickOutsideTrigger, {command: Dbm.commands.setProperty(confirmProperty, false)},
|
|
26
|
+
React.createElement(Dbm.react.interaction.CommandButton, {"key": "confirm", "command": command},
|
|
27
|
+
React.createElement("div", {}, React.createElement(Dbm.react.area.InsertElement, {"element": this.item.properties.confirmElement}))
|
|
28
|
+
)
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
this.item.setValue("switchValue", switchValue);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_updateSlots() {
|
|
35
|
+
let children = Dbm.utils.ArrayFunctions.singleOrArray(this.getPropValue("children"));
|
|
36
|
+
|
|
37
|
+
let slots = Dbm.react.ChildFunctions.splitIntoSlots(children);
|
|
38
|
+
|
|
39
|
+
let confirmElement = slots.confirm;
|
|
40
|
+
let mainChildren = slots.main;
|
|
41
|
+
|
|
42
|
+
if(!confirmElement) {
|
|
43
|
+
confirmElement = mainChildren;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.item.idleElement = mainChildren;
|
|
47
|
+
this.item.confirmElement = confirmElement;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
_renderMainElement() {
|
|
51
|
+
let confirmProperty = this.getDynamicPropWithoutState("confirm", false);
|
|
52
|
+
|
|
53
|
+
return React.createElement(Dbm.react.context.AddContextVariables, {values: {confirm: confirmProperty}}, React.createElement(Dbm.react.area.InsertElement, {"element": this.item.switchValue.output.properties.value}));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import Dbm from "../../index.js";
|
|
2
2
|
|
|
3
|
-
export {default as CommandButton} from "./CommandButton.js";
|
|
3
|
+
export {default as CommandButton} from "./CommandButton.js";
|
|
4
|
+
export {default as ConfirmButton} from "./ConfirmButton.js";
|
|
5
|
+
export {default as ClickOutsideTrigger} from "./ClickOutsideTrigger.js";
|
package/utils/ArrayFunctions.js
CHANGED
|
@@ -187,7 +187,41 @@ export const group = function(aArray, aField) {
|
|
|
187
187
|
let currentArrayLength = currentArray.length;
|
|
188
188
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
189
189
|
let currentObject = aArray[i];
|
|
190
|
-
let groupValue = Dbm.objectPath(
|
|
190
|
+
let groupValue = Dbm.objectPath(currentObject, aField);
|
|
191
|
+
|
|
192
|
+
if(!groups.has(groupValue)) {
|
|
193
|
+
groups.set(groupValue, []);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
groups.get(groupValue).push(currentObject);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
let returnArray = [];
|
|
200
|
+
|
|
201
|
+
for (const value of groups.entries()) {
|
|
202
|
+
returnArray.push({"key": value[0], "value": value[1]});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return returnArray;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export const groupOnMultipleFields = function(aArray, aFields, aSeparator = "-") {
|
|
209
|
+
|
|
210
|
+
let groups = new Map();
|
|
211
|
+
|
|
212
|
+
let currentArray2 = aFields;
|
|
213
|
+
let currentArray2Length = currentArray2.length;
|
|
214
|
+
|
|
215
|
+
let currentArray = aArray;
|
|
216
|
+
let currentArrayLength = currentArray.length;
|
|
217
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
218
|
+
let currentObject = aArray[i];
|
|
219
|
+
let groupValues = [];
|
|
220
|
+
|
|
221
|
+
for(let j = 0; j < currentArray2Length; j++) {
|
|
222
|
+
groupValues.push(Dbm.objectPath(currentObject, currentArray2[j]));
|
|
223
|
+
}
|
|
224
|
+
let groupValue = groupValues.join(aSeparator);
|
|
191
225
|
|
|
192
226
|
if(!groups.has(groupValue)) {
|
|
193
227
|
groups.set(groupValue, []);
|
|
@@ -326,4 +360,16 @@ export const sum = function(aArray) {
|
|
|
326
360
|
}
|
|
327
361
|
|
|
328
362
|
return sum;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export const stepFromCenter = function(aStep, aLength) {
|
|
366
|
+
let halfPoint = (aLength-1)/2;
|
|
367
|
+
let startIndex = Math.ceil(halfPoint);
|
|
368
|
+
let direction = (startIndex > halfPoint) ? -1 : 1;
|
|
369
|
+
|
|
370
|
+
let step = Math.ceil(aStep/2);
|
|
371
|
+
let swing = (aStep%2)*2-1;
|
|
372
|
+
let index = startIndex + step * (swing * direction);
|
|
373
|
+
|
|
374
|
+
return index;
|
|
329
375
|
}
|
|
@@ -47,6 +47,22 @@ export const notEmpty = function(aA, aB) {
|
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
export const greaterThan = function(aA, aB) {
|
|
51
|
+
if(aA > aB) {
|
|
52
|
+
return true
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const lesserThan = function(aA, aB) {
|
|
59
|
+
if(aA < aB) {
|
|
60
|
+
return true
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
50
66
|
export const fullSetup = function() {
|
|
51
67
|
Dbm.getInstance().repository.getItem("compareFunctions/objectExists").setValue("compare", objectExists);
|
|
52
68
|
|
|
@@ -65,5 +81,11 @@ export const fullSetup = function() {
|
|
|
65
81
|
Dbm.getInstance().repository.getItem("compareFunctions/arrayContains").setValue("compare", arrayContains);
|
|
66
82
|
Dbm.getInstance().repository.getItem("compareFunctions/inArray").setValue("compare", inArray);
|
|
67
83
|
|
|
68
|
-
|
|
84
|
+
Dbm.getInstance().repository.getItem("compareFunctions/notEmpty").setValue("compare", notEmpty);
|
|
85
|
+
|
|
86
|
+
Dbm.getInstance().repository.getItem("compareFunctions/>").setValue("compare", greaterThan);
|
|
87
|
+
Dbm.getInstance().repository.getItem("compareFunctions/greaterThan").setValue("compare", greaterThan);
|
|
88
|
+
|
|
89
|
+
Dbm.getInstance().repository.getItem("compareFunctions/<").setValue("compare", lesserThan);
|
|
90
|
+
Dbm.getInstance().repository.getItem("compareFunctions/lesserThan").setValue("compare", lesserThan);
|
|
69
91
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as maps from "./maps/index.js";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const getAddressFromComponents = function(aComponents) {
|
|
2
|
+
const returnObject = {};
|
|
3
|
+
|
|
4
|
+
let currentArray = aComponents;
|
|
5
|
+
let currentArrayLength = currentArray.length;
|
|
6
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
7
|
+
let currentComponent = currentArray[i];
|
|
8
|
+
let types = currentComponent.types;
|
|
9
|
+
|
|
10
|
+
if(types.includes("street_number")) {
|
|
11
|
+
returnObject.streetNumber = currentComponent.longText;
|
|
12
|
+
}
|
|
13
|
+
else if(types.includes("route")) {
|
|
14
|
+
returnObject.street = currentComponent.longText;
|
|
15
|
+
}
|
|
16
|
+
else if(types.includes("subpremise")) {
|
|
17
|
+
returnObject.unit = currentComponent.longText;
|
|
18
|
+
}
|
|
19
|
+
else if(types.includes("floor")) {
|
|
20
|
+
returnObject.floor = currentComponent.longText;
|
|
21
|
+
}
|
|
22
|
+
else if(types.includes("room")) {
|
|
23
|
+
returnObject.room = currentComponent.longText;
|
|
24
|
+
}
|
|
25
|
+
else if(types.includes("postal_code")) {
|
|
26
|
+
returnObject.postCode = currentComponent.longText;
|
|
27
|
+
}
|
|
28
|
+
else if(types.includes("locality")) {
|
|
29
|
+
returnObject.city = currentComponent.longText;
|
|
30
|
+
}
|
|
31
|
+
else if(types.includes("postal_town")) {
|
|
32
|
+
if(!returnObject.city) {
|
|
33
|
+
returnObject.city = currentComponent.longText;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else if(types.includes("administrative_area_level_2")) {
|
|
37
|
+
if(!returnObject.city) {
|
|
38
|
+
returnObject.city = currentComponent.longText;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else if(types.includes("administrative_area_level_1")) {
|
|
42
|
+
if(!returnObject.state) {
|
|
43
|
+
returnObject.state = currentComponent.longText;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
else if(types.includes("country")) {
|
|
48
|
+
returnObject.country = currentComponent.shortText;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return returnObject;
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as PlaceFunctions from "./PlaceFunctions.js";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * as wprrapi from "./wprrapi/index.js";
|
|
1
|
+
export * as wprrapi from "./wprrapi/index.js";
|
|
2
|
+
export * as google from "./google/index.js";
|