-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathABStepCore.js
More file actions
120 lines (104 loc) · 3.08 KB
/
ABStepCore.js
File metadata and controls
120 lines (104 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// import ABApplication from "./ABApplication"
var ABMLClass = require("../platform/ABMLClass");
const _concat = require("lodash/concat");
module.exports = class ABStepCore extends ABMLClass {
constructor(attributes, AB) {
super(["name", "text"], AB);
this.fromValues(attributes);
// indicate we are ready.
// this.elements().forEach((e) => {
// e.onProcessReady();
// });
}
///
/// Static Methods
///
/// Available to the Class level object. These methods are not dependent
/// on the instance values of the Application.
///
fromValues(attributes) {
/*
{
id: uuid(),
name: 'name',
type: 'xxxxx',
json: "{json}"
}
*/
this.id = attributes.id;
this.name = attributes.name || "New Step";
this.type = attributes.type || "step";
this.text = attributes.text || "";
this.settings = attributes.settings || {};
this.settings.event = attributes?.settings?.event || "click";
this.settings.el = attributes?.settings?.el || "";
// this.xmlDefinition = attributes.xmlDefinition || null;
super.fromValues(attributes); // perform translation on this object.
// NOTE: keep this at the end of .fromValues();
if (!this.label) {
this.label = this.name;
}
}
/**
* @method toObj()
* properly compile the current state of this ABProcess instance
* into the values needed for saving to the DB.
* @return {json}
*/
toObj() {
// debugger;
// default label value
if (!this.label) {
this.label = this.name;
}
// OP.Multilingual.unTranslate(this, this, ["label"]);
var data = super.toObj();
var fieldsToSave = ["id", "name", "settings", "type"];
fieldsToSave.forEach((f) => {
data[f] = this[f];
});
return data;
}
// /**
// * steps()
// * return an array of steps that match the given filter (or all steps
// * if no filter is provided).
// * @param {fn} fn an iterator that returns true if the provided element
// * should be returned.
// * @return {[ABStep]}
// */
// steps(fn = () => true) {
// var allSteps = Object.keys(this._steps).map((e) => {
// return this._steps[e];
// });
// return allSteps.filter(fn);
// }
// /**
// * stepAdd()
// * insert a step to be added to this hint.
// * @param {ABStep} element
// * the full instance of an ABStep to track.
// */
// stepAdd(step) {
// this._steps[step.id] = step;
// }
// /**
// * stepByID()
// * return the {ABStep} that has the given .id
// * @param {string} id
// * @return {ABStep[OBJ]}
// */
// stepByID(id) {
// return this._step[id] ?? null;
// }
// /**
// * stepRemove()
// * remove a step from being displayed by this hint.
// * @param {obj|ABStep} def
// * a definition of, or full Object instance of the ABStep
// * to remove.
// */
// stepRemove(def) {
// delete this._steps[def.id];
// }
};