-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathPrompt.js
More file actions
130 lines (122 loc) · 3.01 KB
/
Prompt.js
File metadata and controls
130 lines (122 loc) · 3.01 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
121
122
123
124
125
126
127
128
129
130
/**
* @license
* Copyright 2025 The FOAM Authors. All Rights Reserved.
* http://www.apache.org/licenses/LICENSE-2.0
*/
// TODO: Temporarily hide 'type' Property until it can be handled properly.
// Is currently used for String queries not as objects.
foam.CLASS({
package: 'foam.core.reflow',
name: 'Prompt',
imports: [ 'params' ],
sections: [
{
name: '_defaultSection',
title: 'General'
},
{
name: 'viewSection',
title: 'View'
}
],
properties: [
{
class: 'String',
name: 'label'
},
{
class: 'String',
name: 'supportingLabel'
},
{
class: 'String',
name: 'urlParameter'
},
{
class: 'String',
name: 'type',
value: 'String',
hidden: true,
reactive: false,
postSet: function() { this.value = undefined; this.value; },
view: { class: 'foam.u2.view.ChoiceView', choices: [
[ 'String', 'Abc' ],
[ 'Long', '##' ],
[ 'Double', '##.##' ],
[ 'Boolean', 'Y/N' ],
// [ 'Date', 'YYYY/MM/DD' ],
// [ 'DateTime', 'YYY/MM/DD HH:MM:SS' ],
[ 'EMail', 'username@email.com' ],
'Color'
] }
},
{
name: 'defaultValue',
postSet: function(o, n) {
if ( ! this.value )
// this.value = foam.lang[this.type].ADAPT.value(null, this.defaultValue);
this.value = n;
}
},
{
class: 'foam.u2.ViewSpec',
name: 'view',
section: 'viewSection',
label: '',
view: function (_, X) {
return { class: 'foam.u2.view.ViewConfiguratorView', traceId$: X.data$.dot('traceId') };
}
},
{
name: 'traceId',
hidden: true,
transient: true
},
{
name: 'value',
transient: true,
visibility: 'RO',
view: function(_, X) {
return X.data.prop.view || { class: 'foam.u2.view.ValueView' };
},
factory: function() {
if ( this.params && this.params[this.urlParameter] != undefined ) {
return this.params[this.urlParameter];
}
return this.defaultValue;
}
},
{
name: 'prop',
hidden: true,
transient: true
}
],
methods: [
function toString() {
return this.value.toString();
},
function valueOf() {
return this.value.valueOf();
},
function addToE(e) {
var self = this;
e.add(this.dynamic(function(type) {
var prop = self.prop = foam.lang[type].create({ name: 'value' });
let traceId = 'el-' + foam.next$UID();
prop.view = {...(self.view || prop.view), id: traceId};
this.startContext({data: self})
.start(prop.__, { config: { label$: self.label$ } })
.call(function() {
// Now in the context of the property border
this.prop.supportingLabel$.mapFrom(self.supportingLabel$, v => {
return v;
})
})
.end()
.endContext();
self.traceId = traceId;
}));
}
]
});