dbm 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/source/FirstSource.js +36 -0
- package/core/source/index.js +21 -0
- package/dbm.js +8 -0
- package/flow/controllers/index.js +2 -1
- package/flow/controllers/select/InArray.js +67 -0
- package/flow/controllers/select/index.js +2 -1
- package/flow/controllers/timing/IntervalStep.js +60 -0
- package/flow/controllers/timing/index.js +1 -0
- package/flow/index.js +13 -3
- package/flow/updatefunctions/animation/AnimateValue.js +39 -0
- package/flow/updatefunctions/animation/index.js +13 -0
- package/flow/updatefunctions/basic/MappedList.js +49 -0
- package/flow/updatefunctions/basic/PropertyOf.js +1 -1
- package/flow/updatefunctions/basic/PropertyOfWithDefault.js +28 -0
- package/flow/updatefunctions/basic/Translation.js +71 -0
- package/flow/updatefunctions/basic/index.js +77 -0
- package/flow/updatefunctions/index.js +1 -0
- package/flow/updatefunctions/logic/FloatMod.js +26 -0
- package/flow/updatefunctions/logic/PositionedItems.js +1 -1
- package/flow/updatefunctions/logic/index.js +18 -0
- package/flow/updatefunctions/thirdparty/google/index.js +3 -0
- package/flow/updatefunctions/thirdparty/google/maps/AutoComplete.js +132 -0
- package/flow/updatefunctions/thirdparty/google/maps/PlaceDetails.js +80 -0
- package/flow/updatefunctions/thirdparty/google/maps/index.js +4 -0
- package/flow/updatefunctions/thirdparty/index.js +2 -1
- package/graphapi/webclient/ApiConnection.js +2 -0
- package/graphapi/webclient/WebSocketConnection.js +1 -0
- package/graphapi/webclient/admin/EditorGroup.js +1 -1
- package/graphapi/webclient/admin/ItemEditor.js +39 -0
- package/graphapi/webclient/admin/ItemSaveData.js +6 -0
- package/graphapi/webclient/admin/SaveFunctions.js +4 -0
- package/graphapi/webclient/admin/ValueEditor.js +15 -0
- package/graphapi/webclient/decode/DecodeBaseObject.js +4 -0
- package/graphapi/webclient/decode/index.js +32 -1
- package/graphapi/webclient/index.js +41 -0
- package/package.json +1 -1
- package/react/admin/EditObject.js +52 -0
- package/react/admin/EditObjectById.js +2 -3
- package/react/admin/EditPage.js +18 -0
- package/react/admin/EditorGroup.js +23 -0
- package/react/admin/SaveAllButton.js +34 -0
- package/react/admin/editorsgroup/EditField.js +2 -2
- package/react/admin/editorsgroup/EditFieldTranslation.js +27 -0
- package/react/admin/editorsgroup/EditIdentifer.js +3 -3
- package/react/admin/editorsgroup/EditItem.js +1 -1
- package/react/admin/editorsgroup/EditRelation.js +2 -2
- package/react/admin/editorsgroup/EditVisibility.js +2 -2
- package/react/admin/editorsgroup/index.js +2 -1
- package/react/admin/index.js +3 -0
- package/react/admin/objects/EditObject.js +9 -4
- package/react/admin/objects/itemeditors/Name.js +31 -29
- package/react/admin/pageeditors/LinkPreviews.js +98 -0
- package/react/admin/pageeditors/index.js +1 -0
- package/react/area/FixedWidthInfiniteSlideshow.js +50 -0
- package/react/area/List.js +4 -0
- package/react/area/index.js +1 -0
- package/react/blocks/admin/objects/RunObjectCommands.js +0 -14
- package/react/blocks/admin/objects/User.js +29 -1
- package/react/blocks/content/LinkList.js +67 -0
- package/react/blocks/content/LinkListCard.js +83 -0
- package/react/blocks/content/index.js +3 -1
- package/react/blocks/faq/AskAQuestion.js +1 -1
- package/react/blocks/index.js +34 -0
- package/react/form/Option.js +18 -0
- package/react/form/index.js +2 -1
- package/react/text/HtmlText.js +6 -1
- package/react/text/NumberDisplay.js +30 -0
- package/react/text/OptionalLink.js +21 -0
- package/react/text/TranslatedText.js +25 -0
- package/react/text/TranslationGroup.js +24 -0
- package/react/text/index.js +10 -2
- package/site/SiteDataLoader.js +8 -13
- package/site/index.js +2 -0
- package/site/translation/TranslationLoader.js +59 -0
- package/site/translation/index.js +27 -0
- package/utils/ArrayFunctions.js +16 -0
- package/utils/CompareFunctions.js +24 -0
- package/utils/StringFunctions.js +18 -3
- package/utils/index.js +3 -1
- package/utils/thirdparty/index.js +1 -0
- package/utils/thirdparty/wprrapi/WprrApiParser.js +31 -0
- package/utils/thirdparty/wprrapi/index.js +3 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class FirstSource extends Dbm.core.source.SourceBaseObject {
|
|
4
|
+
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.item.setValue("defaultValue", null);
|
|
9
|
+
this.item.setValue("sources", []);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getSource(aFromObject, aEventData = null) {
|
|
13
|
+
//console.log("getSource");
|
|
14
|
+
|
|
15
|
+
let currentArray = this.item.sources;
|
|
16
|
+
let currentArrayLength = currentArray.length;
|
|
17
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
18
|
+
let currentSource = currentArray[i];
|
|
19
|
+
|
|
20
|
+
let value = currentSource.getSource(aFromObject, aEventData);
|
|
21
|
+
if(this._log) {
|
|
22
|
+
console.log("Source first>>>>>", i, currentSource, value);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if(value) {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if(this._log) {
|
|
31
|
+
console.log("Source first>>>>> default", this.item.defaultValue);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return this.item.defaultValue;
|
|
35
|
+
}
|
|
36
|
+
}
|
package/core/source/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export {default as SourceBaseObject} from "./SourceBaseObject.js";
|
|
|
4
4
|
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
|
+
export {default as FirstSource} from "./FirstSource.js";
|
|
7
8
|
|
|
8
9
|
export const event = function(aPath = null) {
|
|
9
10
|
let newSource = new Dbm.core.source.EventSource();
|
|
@@ -29,3 +30,23 @@ export const staticObject = function(aObject, aPath = null) {
|
|
|
29
30
|
|
|
30
31
|
return newSource;
|
|
31
32
|
}
|
|
33
|
+
|
|
34
|
+
export const first = function(...aSources) {
|
|
35
|
+
let newSource = new Dbm.core.source.FirstSource();
|
|
36
|
+
|
|
37
|
+
newSource.item.sources = [].concat(aSources);
|
|
38
|
+
|
|
39
|
+
return newSource;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const firstWithDefault = function(...aSourcesAndDefault) {
|
|
43
|
+
let newSource = new Dbm.core.source.FirstSource();
|
|
44
|
+
|
|
45
|
+
let sources = [].concat(aSourcesAndDefault);
|
|
46
|
+
let defaultValue = sources.pop();
|
|
47
|
+
|
|
48
|
+
newSource.item.sources = sources;
|
|
49
|
+
newSource.item.properties.defaultValue.setOrConnect(defaultValue);
|
|
50
|
+
|
|
51
|
+
return newSource;
|
|
52
|
+
}
|
package/dbm.js
CHANGED
|
@@ -85,6 +85,14 @@ export const setAtObjectPath = function(aObject, aPath, aValue) {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
export const getRepositoryItem = function(aName) {
|
|
89
|
+
return getInstance().repository.getItem(aName);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const getGraphApi = function() {
|
|
93
|
+
return getRepositoryItem("graphApi").controller;
|
|
94
|
+
}
|
|
95
|
+
|
|
88
96
|
export * as utils from "./utils/index.js";
|
|
89
97
|
export * as core from "./core/index.js";
|
|
90
98
|
export * as loading from "./loading/index.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * as select from "./select/index.js";
|
|
2
2
|
export * as edit from "./edit/index.js";
|
|
3
3
|
export * as transform from "./transform/index.js";
|
|
4
|
-
export * as interaction from "./interaction/index.js";
|
|
4
|
+
export * as interaction from "./interaction/index.js";
|
|
5
|
+
export * as timing from "./timing/index.js";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class InArray extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
let valuesUpdatedCommand = Dbm.commands.callFunction(this._valuesUpdated.bind(this));
|
|
8
|
+
|
|
9
|
+
this._selectionChangedBound = this._selectionChanged.bind(this);
|
|
10
|
+
|
|
11
|
+
Dbm.flow.addUpdateCommand(this.item.requireProperty("values", null), valuesUpdatedCommand);
|
|
12
|
+
this.item.requireProperty("selections", []);
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getSelectionForValue(aValue) {
|
|
17
|
+
let selections = this.item.selections;
|
|
18
|
+
let currentSelection = Dbm.utils.ArrayFunctions.getItemBy(selections, "value", aValue);
|
|
19
|
+
|
|
20
|
+
if(!currentSelection) {
|
|
21
|
+
let selections = [].concat(this.item.selections);
|
|
22
|
+
let property = new Dbm.flow.FlowProperty();
|
|
23
|
+
property.setValue(false);
|
|
24
|
+
Dbm.flow.addUpdateCommand(property, Dbm.commands.callFunction(this._selectionChangedBound, [property, aValue]));
|
|
25
|
+
|
|
26
|
+
currentSelection = {"value": aValue, "property": property};
|
|
27
|
+
selections.push(currentSelection);
|
|
28
|
+
this.item.selections = selections;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return currentSelection.property;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_selectionChanged(aSelected, aValue) {
|
|
35
|
+
console.log("_selectionChanged");
|
|
36
|
+
|
|
37
|
+
let newValues = [].concat(this.item.values);
|
|
38
|
+
if(aSelected) {
|
|
39
|
+
newValues.push(aValue);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
let index = newValues.indexOf(aValue);
|
|
43
|
+
if(index >= 0) {
|
|
44
|
+
newValues.splice(index, 1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.item.properties.values.getMostUpstreamProperty().setValue(newValues);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_valuesUpdated() {
|
|
52
|
+
//console.log("_valuesUpdated");
|
|
53
|
+
let values = this.item.values;
|
|
54
|
+
|
|
55
|
+
let currentArray = this.item.selections;
|
|
56
|
+
let currentArrayLength = currentArray.length;
|
|
57
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
58
|
+
let currentSelection = currentArray[i];
|
|
59
|
+
if(values.indexOf(currentSelection.value) !== -1) {
|
|
60
|
+
currentSelection.property.getMostUpstreamProperty().setValue(true);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
currentSelection.property.getMostUpstreamProperty().setValue(false);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {default as SingleSelection} from "./SingleSelection.js";
|
|
1
|
+
export {default as SingleSelection} from "./SingleSelection.js";
|
|
2
|
+
export {default as InArray} from "./InArray.js";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class IntervalStep extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
this.item.requireProperty("value", 0);
|
|
8
|
+
this.item.requireProperty("step", 1);
|
|
9
|
+
Dbm.flow.addUpdateCommand(this.item.requireProperty("interval", 1), Dbm.commands.callFunction(this.resetInterval.bind(this)));
|
|
10
|
+
|
|
11
|
+
this._started = false;
|
|
12
|
+
this._intervalId = -1;
|
|
13
|
+
this._callback_nextStepBound = this._callback_nextStep.bind(this);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
start() {
|
|
17
|
+
this._started = true;
|
|
18
|
+
this._startInterval();
|
|
19
|
+
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
stop() {
|
|
24
|
+
this._started = false;
|
|
25
|
+
this._stopInterval();
|
|
26
|
+
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
setValue(aValue) {
|
|
31
|
+
this.item.properties.value.getMostUpstreamProperty().value = aValue;
|
|
32
|
+
this.resetInterval();
|
|
33
|
+
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_callback_nextStep() {
|
|
38
|
+
this.item.properties.value.getMostUpstreamProperty().value += this.item.step;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
_startInterval() {
|
|
42
|
+
if(this._intervalId === -1) {
|
|
43
|
+
this._intervalId = setInterval(this._callback_nextStepBound, this.item.interval*1000);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_stopInterval() {
|
|
48
|
+
if(this._intervalId !== -1) {
|
|
49
|
+
clearInterval(this._intervalId);
|
|
50
|
+
this._intervalId = -1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
resetInterval() {
|
|
55
|
+
if(this._started) {
|
|
56
|
+
this._stopInterval();
|
|
57
|
+
this._startInterval();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as IntervalStep} from "./IntervalStep.js";
|
package/flow/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export {default as FlowPropertyWithExternalInput} from "./FlowPropertyWithExtern
|
|
|
11
11
|
export * as updatefunctions from "./updatefunctions/index.js";
|
|
12
12
|
export * as controllers from "./controllers/index.js";
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export const addUpdateCommand = function(aProperty, aCommand) {
|
|
15
15
|
let updateFunction = new Dbm.flow.updatefunctions.basic.RunCommand();
|
|
16
16
|
updateFunction.input.properties.value.connectInput(aProperty);
|
|
17
17
|
updateFunction.input.command = aCommand;
|
|
@@ -26,7 +26,7 @@ export let addUpdateCommand = function(aProperty, aCommand) {
|
|
|
26
26
|
return {"updateFunction": updateFunction, "dirtyCommands": dirtyCommands};
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export
|
|
29
|
+
export const addDirectUpdateCommand = function(aProperty, aCommand) {
|
|
30
30
|
let updateFunction = new Dbm.flow.updatefunctions.basic.RunCommand();
|
|
31
31
|
updateFunction.input.properties.value.connectInput(aProperty);
|
|
32
32
|
updateFunction.input.command = aCommand;
|
|
@@ -41,7 +41,7 @@ export let addDirectUpdateCommand = function(aProperty, aCommand) {
|
|
|
41
41
|
return {"updateFunction": updateFunction, "dirtyCommands": dirtyCommands};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export
|
|
44
|
+
export const addUpdateCommandWhenMatched = function(aProperty, aMatchValue, aCommand) {
|
|
45
45
|
let whenMatched = Dbm.flow.updatefunctions.logic.whenMatched(aProperty, aMatchValue);
|
|
46
46
|
|
|
47
47
|
let updateData = Dbm.flow.addUpdateCommand(whenMatched.output.properties.value, aCommand);
|
|
@@ -51,6 +51,16 @@ export let addUpdateCommandWhenMatched = function(aProperty, aMatchValue, aComma
|
|
|
51
51
|
return whenMatched;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
export const runWhenMatched = function(aProperty, aMatchValue, aCommand) {
|
|
55
|
+
if(aProperty.value === aMatchValue) {
|
|
56
|
+
aCommand.perform(null, null);
|
|
57
|
+
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return addUpdateCommandWhenMatched(aProperty, aMatchValue, aCommand);
|
|
62
|
+
}
|
|
63
|
+
|
|
54
64
|
export const animateValue = function(aValue, aTime = 0.5, aEasing = null) {
|
|
55
65
|
|
|
56
66
|
let returnObject = new Dbm.repository.Item();
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class AnimateValue extends Dbm.flow.FlowUpdateFunction {
|
|
4
|
+
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this._animationInputValue = new Dbm.flow.FlowProperty();
|
|
9
|
+
this._animationInputValue.value = 0;
|
|
10
|
+
Dbm.flow.addUpdateCommand(this._animationInputValue, Dbm.commands.callFunction(this._updateAnimation.bind(this)));
|
|
11
|
+
|
|
12
|
+
this._animatedValue = new Dbm.flow.FlowProperty();
|
|
13
|
+
this._animatedValue.value = 0;
|
|
14
|
+
Dbm.flow.addUpdateCommand(this._animatedValue, Dbm.commands.callFunction(this._animationUpdated.bind(this)));
|
|
15
|
+
|
|
16
|
+
this.input.register("value", 0);
|
|
17
|
+
this._animationInputValue.connectInput(this.input.properties.value);
|
|
18
|
+
this.input.register("time", 0.5);
|
|
19
|
+
this.input.register("easing", null);
|
|
20
|
+
this.input.register("delay", 0);
|
|
21
|
+
this.output.register("value", 0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_update() {
|
|
25
|
+
//console.log("_update");
|
|
26
|
+
|
|
27
|
+
//this._animationInputValue.value = this.input.value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_updateAnimation() {
|
|
31
|
+
//console.log("_updateAnimation");
|
|
32
|
+
this._animatedValue.animateValue(this._animationInputValue.value, this.input.time, this.input.delay, this.input.easing);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_animationUpdated() {
|
|
36
|
+
//console.log("_animationUpdated");
|
|
37
|
+
this.output.properties.value._internal_setValueInFlowOutsideOfUpdate(this._animatedValue.value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export {default as AnimateValue} from "./AnimateValue.js";
|
|
4
|
+
|
|
5
|
+
export let animateValue = function(aValue = 0, aTime = 0.5, aDelay = 0, aEasing = null) {
|
|
6
|
+
let updateFunction = new Dbm.flow.updatefunctions.animation.AnimateValue();
|
|
7
|
+
updateFunction.input.properties.value.setOrConnect(aValue);
|
|
8
|
+
updateFunction.input.properties.time.setOrConnect(aTime);
|
|
9
|
+
updateFunction.input.properties.delay.setOrConnect(aDelay);
|
|
10
|
+
updateFunction.input.properties.easing.setOrConnect(aEasing);
|
|
11
|
+
|
|
12
|
+
return updateFunction;
|
|
13
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class MappedList extends Dbm.flow.FlowUpdateFunction {
|
|
4
|
+
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.input.register("items", []);
|
|
9
|
+
this.input.register("itemReferenceName", "forItem");
|
|
10
|
+
this.input.register("newItemCommands", []);
|
|
11
|
+
|
|
12
|
+
this.output.register("items", []);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_update() {
|
|
16
|
+
console.log("MappedList::_update");
|
|
17
|
+
|
|
18
|
+
let currentArray = this.input.items;
|
|
19
|
+
let currentArrayLength = currentArray.length;
|
|
20
|
+
|
|
21
|
+
let itemReferenceName = this.input.itemReferenceName;
|
|
22
|
+
let newItemCommands = this.input.newItemCommands;
|
|
23
|
+
|
|
24
|
+
let currentMappedList = this.output.properties.items.getValueWithoutFlow();
|
|
25
|
+
|
|
26
|
+
let returnArray = new Array(currentArrayLength);
|
|
27
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
28
|
+
let currentItem = currentArray[i];
|
|
29
|
+
|
|
30
|
+
let index = Dbm.utils.ArrayFunctions.getItemIndexByIfExists(currentMappedList, itemReferenceName, currentItem);
|
|
31
|
+
|
|
32
|
+
if(index !== -1) {
|
|
33
|
+
returnArray[i] = currentMappedList[index];
|
|
34
|
+
currentMappedList.splice(index, 1);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
let newItem = new Dbm.repository.Item();
|
|
38
|
+
newItem.setId("mapped_" + Dbm.getInstance().getNextId());
|
|
39
|
+
newItem.setValue(itemReferenceName, currentItem);
|
|
40
|
+
Dbm.commands.performCommands(newItemCommands, this, {"mappedItem": newItem, "item": currentItem, "itemReferenceName": itemReferenceName});
|
|
41
|
+
returnArray[i] = newItem;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//METODO: clean up unused items
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
this.output.items = returnArray;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class PropertyOfWithDefault extends Dbm.flow.FlowUpdateFunction {
|
|
4
|
+
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.input.register("value", "");
|
|
9
|
+
this.input.register("propertyName", "");
|
|
10
|
+
this.input.register("defaultValue", null);
|
|
11
|
+
|
|
12
|
+
this.output.register("value", null);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_update() {
|
|
16
|
+
//console.log("_update");
|
|
17
|
+
|
|
18
|
+
let value = this.input.value;
|
|
19
|
+
|
|
20
|
+
let outputValue = Dbm.objectPath(value, this.input.propertyName);
|
|
21
|
+
|
|
22
|
+
if(!outputValue) {
|
|
23
|
+
outputValue = this.input.defaultValue;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
this.output.value = outputValue
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class Translation extends Dbm.flow.FlowUpdateFunction {
|
|
4
|
+
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.input.register("translations", {});
|
|
9
|
+
this.input.register("path", null);
|
|
10
|
+
this.input.register("additionalPath", null);
|
|
11
|
+
this.input.register("id", "");
|
|
12
|
+
this.input.register("defaultValue", null);
|
|
13
|
+
|
|
14
|
+
this.output.register("value", null);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_update() {
|
|
18
|
+
//console.log("_update");
|
|
19
|
+
|
|
20
|
+
let translations = this.input.translations;
|
|
21
|
+
|
|
22
|
+
let path = this.input.path;
|
|
23
|
+
let additionalPath = this.input.additionalPath;
|
|
24
|
+
let id = this.input.id;
|
|
25
|
+
|
|
26
|
+
while(path) {
|
|
27
|
+
|
|
28
|
+
let currentAdditionalPath = additionalPath;
|
|
29
|
+
while(currentAdditionalPath) {
|
|
30
|
+
|
|
31
|
+
let currentValue = translations[path + "/" + currentAdditionalPath + "/" + id];
|
|
32
|
+
if(currentValue) {
|
|
33
|
+
this.output.value = currentValue;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let nextIndex = currentAdditionalPath.lastIndexOf("/");
|
|
38
|
+
if(nextIndex >= 0) {
|
|
39
|
+
currentAdditionalPath = currentAdditionalPath.substring(0, nextIndex);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
currentAdditionalPath = null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let currentValue = translations[path + "/" + id];
|
|
47
|
+
if(currentValue) {
|
|
48
|
+
this.output.value = currentValue;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let nextIndex = path.lastIndexOf("/");
|
|
53
|
+
if(nextIndex >= 0) {
|
|
54
|
+
path = path.substring(0, nextIndex);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
path = null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let currentValue = translations[id];
|
|
62
|
+
if(currentValue) {
|
|
63
|
+
this.output.value = currentValue;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//METODO: report missing translation
|
|
68
|
+
|
|
69
|
+
this.output.value = this.input.defaultValue;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -4,6 +4,9 @@ export {default as RunCommand} from "./RunCommand.js";
|
|
|
4
4
|
export {default as CombineString} from "./CombineString.js";
|
|
5
5
|
export {default as Length} from "./Length.js";
|
|
6
6
|
export {default as PropertyOf} from "./PropertyOf.js";
|
|
7
|
+
export {default as PropertyOfWithDefault} from "./PropertyOfWithDefault.js";
|
|
8
|
+
export {default as MappedList} from "./MappedList.js";
|
|
9
|
+
export {default as Translation} from "./Translation.js";
|
|
7
10
|
|
|
8
11
|
export const runCommand = function(aValue, aCommand) {
|
|
9
12
|
let updateFunction = new Dbm.flow.updatefunctions.basic.RunCommand();
|
|
@@ -34,6 +37,15 @@ export const propertyOf = function(aValue, aPropertyName) {
|
|
|
34
37
|
return updateFunction;
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
export const propertyOfWithDefault = function(aValue, aPropertyName, aDefaultValue) {
|
|
41
|
+
let updateFunction = new Dbm.flow.updatefunctions.basic.PropertyOfWithDefault();
|
|
42
|
+
updateFunction.input.properties.value.setOrConnect(aValue);
|
|
43
|
+
updateFunction.input.properties.propertyName.setOrConnect(aPropertyName);
|
|
44
|
+
updateFunction.input.properties.defaultValue.setOrConnect(aDefaultValue);
|
|
45
|
+
|
|
46
|
+
return updateFunction;
|
|
47
|
+
}
|
|
48
|
+
|
|
37
49
|
export const combine = function(...aValues) {
|
|
38
50
|
let updateFunction = new Dbm.flow.updatefunctions.basic.CombineString();
|
|
39
51
|
|
|
@@ -46,4 +58,69 @@ export const combine = function(...aValues) {
|
|
|
46
58
|
|
|
47
59
|
|
|
48
60
|
return updateFunction;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const mappedList = function(aItems, aNewItemCommands = []) {
|
|
64
|
+
let updateFunction = new Dbm.flow.updatefunctions.basic.MappedList();
|
|
65
|
+
updateFunction.input.properties.items.setOrConnect(aItems);
|
|
66
|
+
updateFunction.input.properties.newItemCommands.setOrConnect(aNewItemCommands);
|
|
67
|
+
|
|
68
|
+
return updateFunction;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const mappedListWithFunction = function(aItems, aNewItemFunction) {
|
|
72
|
+
let command = Dbm.commands.callFunction(aNewItemFunction, [Dbm.core.source.event("mappedItem"), Dbm.core.source.fromObject()]);
|
|
73
|
+
|
|
74
|
+
return mappedList(aItems, [command]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
export const activeMappedList = function(aItems, aActiveFromStart = false) {
|
|
80
|
+
|
|
81
|
+
let item = new Dbm.repository.Item();
|
|
82
|
+
|
|
83
|
+
item.requireProperty("items", []).setOrConnect(aItems);
|
|
84
|
+
item.requireProperty("activeItems", []);
|
|
85
|
+
item.requireProperty("selectionItems", []);
|
|
86
|
+
|
|
87
|
+
let activeItems = new Dbm.flow.controllers.select.InArray();
|
|
88
|
+
|
|
89
|
+
let createActiveField = function(aItem, aUpdateFunction) {
|
|
90
|
+
let activeProperty = aItem.requireProperty("active", aUpdateFunction.activeFromStart);
|
|
91
|
+
let inArrayProperty = activeItems.getSelectionForValue(aItem[aUpdateFunction.input.itemReferenceName]);
|
|
92
|
+
inArrayProperty.connectInput(activeProperty);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let updateFunction = mappedListWithFunction(item.properties.items, createActiveField);
|
|
96
|
+
updateFunction.activeFromStart = aActiveFromStart;
|
|
97
|
+
item.setValue("mappedList", updateFunction);
|
|
98
|
+
item.properties.selectionItems.connectInput(updateFunction.output.properties.items);
|
|
99
|
+
|
|
100
|
+
activeItems.item.properties.values.connectInput(item.properties.activeItems);
|
|
101
|
+
item.setValue("inArray", activeItems);
|
|
102
|
+
|
|
103
|
+
return item;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const translation = function(aId, aDefaultValue = null, aPath = null, aAdditionalPath = null, aTranslations = null) {
|
|
107
|
+
let updateFunction = new Dbm.flow.updatefunctions.basic.Translation();
|
|
108
|
+
|
|
109
|
+
updateFunction.input.properties.id.setOrConnect(aId);
|
|
110
|
+
updateFunction.input.properties.defaultValue.setOrConnect(aDefaultValue);
|
|
111
|
+
updateFunction.input.properties.path.setOrConnect(aPath);
|
|
112
|
+
updateFunction.input.properties.additionalPath.setOrConnect(aAdditionalPath);
|
|
113
|
+
|
|
114
|
+
if(!aTranslations) {
|
|
115
|
+
aTranslations = Dbm.getRepositoryItem("site/translations").requireProperty("data");
|
|
116
|
+
}
|
|
117
|
+
updateFunction.input.properties.translations.setOrConnect(aTranslations);
|
|
118
|
+
|
|
119
|
+
return updateFunction;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const translationProperty = function(aId, aDefaultValue = null, aPath = null, aAdditionalPath = null, aTranslations = null) {
|
|
123
|
+
let updateFunction = translation(aId, aDefaultValue, aPath, aAdditionalPath, aTranslations);
|
|
124
|
+
|
|
125
|
+
return updateFunction.output.properties.value;
|
|
49
126
|
}
|
|
@@ -3,4 +3,5 @@ export * as debug from "./debug/index.js";
|
|
|
3
3
|
export * as react from "./react/index.js";
|
|
4
4
|
export * as basic from "./basic/index.js";
|
|
5
5
|
export * as dom from "./dom/index.js";
|
|
6
|
+
export * as animation from "./animation/index.js";
|
|
6
7
|
export * as thirdparty from "./thirdparty/index.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class FloatMod extends Dbm.flow.FlowUpdateFunction {
|
|
4
|
+
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.input.register("input", 0);
|
|
9
|
+
this.input.register("min", 0);
|
|
10
|
+
this.input.register("max", 1);
|
|
11
|
+
|
|
12
|
+
this.output.register("result", 0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_update() {
|
|
16
|
+
//console.log("_update");
|
|
17
|
+
|
|
18
|
+
let relativeValue = this.input.input-this.input.min;
|
|
19
|
+
let length = this.input.max-this.input.min;
|
|
20
|
+
|
|
21
|
+
let times = Math.floor(relativeValue/length);
|
|
22
|
+
let clampledValue = relativeValue-(length*times);
|
|
23
|
+
|
|
24
|
+
this.output.result = this.input.min+clampledValue;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -12,6 +12,7 @@ export {default as AllAtValue} from "./AllAtValue.js";
|
|
|
12
12
|
export {default as WhenMatched} from "./WhenMatched.js";
|
|
13
13
|
export {default as Invert} from "./Invert.js";
|
|
14
14
|
export {default as PositionedItems} from "./PositionedItems.js";
|
|
15
|
+
export {default as FloatMod} from "./FloatMod.js";
|
|
15
16
|
|
|
16
17
|
export let subtract = function(aInput1 = 0, aInput2 = 0) {
|
|
17
18
|
let updateFunction = new Dbm.flow.updatefunctions.logic.Subtraction();
|
|
@@ -111,5 +112,22 @@ export let switchValue = function(aValue = null) {
|
|
|
111
112
|
let updateFunction = new Dbm.flow.updatefunctions.logic.Switch();
|
|
112
113
|
updateFunction.input.properties.value.setOrConnect(aValue);
|
|
113
114
|
|
|
115
|
+
return updateFunction;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export let floatMod = function(aValue = null, aMax = 1) {
|
|
119
|
+
let updateFunction = new Dbm.flow.updatefunctions.logic.FloatMod();
|
|
120
|
+
updateFunction.input.properties.input.setOrConnect(aValue);
|
|
121
|
+
updateFunction.input.properties.max.setOrConnect(aMax);
|
|
122
|
+
|
|
123
|
+
return updateFunction;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export let floatModRange = function(aValue = null, aMin = 0, aMax = 1) {
|
|
127
|
+
let updateFunction = new Dbm.flow.updatefunctions.logic.FloatMod();
|
|
128
|
+
updateFunction.input.properties.input.setOrConnect(aValue);
|
|
129
|
+
updateFunction.input.properties.min.setOrConnect(aMin);
|
|
130
|
+
updateFunction.input.properties.max.setOrConnect(aMax);
|
|
131
|
+
|
|
114
132
|
return updateFunction;
|
|
115
133
|
}
|