pict 1.0.72 → 1.0.74
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/package.json +1 -1
- package/source/Pict-Application.js +1 -1
- package/source/Pict-Content-Assignment.js +150 -125
- package/source/Pict.js +17 -8
package/package.json
CHANGED
|
@@ -55,7 +55,7 @@ class PictApplication extends libFableServiceBase
|
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
initialize(
|
|
58
|
+
initialize()
|
|
59
59
|
{
|
|
60
60
|
this.log.info(`Pict Application ${this.options.Name}[${this.UUID}]::[${this.Hash}] beginning initialization...`);
|
|
61
61
|
this.internalInitialize();
|
|
@@ -4,133 +4,158 @@ class PictContentAssignment extends libFableServiceBase
|
|
|
4
4
|
{
|
|
5
5
|
constructor(pFable, pOptions, pServiceHash)
|
|
6
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
|
-
|
|
7
|
+
super(pFable, pOptions, pServiceHash);
|
|
8
|
+
|
|
9
|
+
this.serviceType = 'PictContentAssignment';
|
|
10
|
+
|
|
11
|
+
// Check to see if we are running in a browser
|
|
12
|
+
this.inBrowser = false;
|
|
13
|
+
this.hasDocument = false;
|
|
14
|
+
if (typeof (window) == 'object')
|
|
15
|
+
{
|
|
16
|
+
this.inBrowser = true;
|
|
17
|
+
// Now check that the browser has a document object
|
|
18
|
+
if ((typeof (window.document) != 'undefined') && (typeof (window.document.querySelectorAll) == 'function'))
|
|
19
|
+
{
|
|
20
|
+
this.hasDocument = true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// If we're in a browser, check to see if jQuery is available.
|
|
25
|
+
this.hasJquery = false;
|
|
26
|
+
this.jQuery = false;
|
|
27
|
+
if (this.inBrowser && typeof (window.jQuery) !== 'undefined')
|
|
28
|
+
{
|
|
29
|
+
this.hasJquery = true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// API Consumers can also craft their own assign function
|
|
33
|
+
this.customAssignFunction = false;
|
|
34
|
+
|
|
35
|
+
// API Consumers can also craft their own append function
|
|
36
|
+
this.customAppendFunction = false;
|
|
37
|
+
|
|
38
|
+
// API Consumers can also craft their own read function
|
|
39
|
+
this.customReadFunction = false;
|
|
40
|
+
|
|
41
|
+
// API Consumers can even craft their own get element function.
|
|
42
|
+
this.customGetElementFunction = false;
|
|
40
43
|
}
|
|
41
44
|
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
45
|
+
getElement(pAddress)
|
|
46
|
+
{
|
|
47
|
+
if (this.customGetElementFunction)
|
|
48
|
+
{
|
|
49
|
+
return this.customGetElementFunction(pAddress);
|
|
50
|
+
}
|
|
51
|
+
else if (this.hasJquery)
|
|
52
|
+
{
|
|
53
|
+
return window.jQuery(pAddress);
|
|
54
|
+
}
|
|
55
|
+
else if (this.inBrowser && this.hasDocument)
|
|
56
|
+
{
|
|
57
|
+
return window.document.querySelectorAll(pAddress);
|
|
58
|
+
}
|
|
59
|
+
else
|
|
60
|
+
{
|
|
61
|
+
// Just log it out for now
|
|
62
|
+
this.log.trace(`PICT Content GET ELEMENT for [${pAddress}]`);
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
assignContent(pAddress, pContent)
|
|
68
|
+
{
|
|
69
|
+
if (this.customAssignFunction)
|
|
70
|
+
{
|
|
71
|
+
return this.customAssignFunction(pAddress, pContent);
|
|
72
|
+
}
|
|
73
|
+
else if (this.hasJquery)
|
|
74
|
+
{
|
|
75
|
+
// Get the element
|
|
76
|
+
let tmpTargetElement = window.jQuery(pAddress);
|
|
77
|
+
|
|
78
|
+
// Should we ensure we matched 1 and exactly 1 element?
|
|
79
|
+
//if (tmpTargetElement && tmpTargetElement.length == 1)
|
|
80
|
+
//{
|
|
81
|
+
// Set the content
|
|
82
|
+
tmpTargetElement.html(pContent);
|
|
83
|
+
//}
|
|
84
|
+
}
|
|
85
|
+
else if (this.inBrowser && this.hasDocument)
|
|
86
|
+
{
|
|
87
|
+
let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
|
|
88
|
+
|
|
89
|
+
for (let i = 0; i < tmpTargetElementSet.length; i++)
|
|
90
|
+
{
|
|
91
|
+
tmpTargetElementSet[i].innerHTML = pContent;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else
|
|
95
|
+
{
|
|
96
|
+
// Just log it out for now
|
|
97
|
+
this.log.trace(`PICT Content ASSIGN to [${pAddress}]:`, pContent);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
appendContent(pAddress, pContent)
|
|
102
|
+
{
|
|
103
|
+
if (this.customAppendFunction)
|
|
104
|
+
{
|
|
105
|
+
return this.customAppendFunction(pAddress, pContent);
|
|
106
|
+
}
|
|
107
|
+
else if (this.hasJquery)
|
|
108
|
+
{
|
|
109
|
+
let tmpTargetElement = window.jQuery(pAddress);
|
|
110
|
+
tmpTargetElement.append(pContent);
|
|
111
|
+
}
|
|
112
|
+
else if (this.inBrowser && this.hasDocument)
|
|
113
|
+
{
|
|
114
|
+
let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
|
|
115
|
+
for (let i = 0; i < tmpTargetElementSet.length; i++)
|
|
116
|
+
{
|
|
117
|
+
tmpTargetElementSet[i].insertAdjacentHTML("beforeend", pContent);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else
|
|
121
|
+
{
|
|
122
|
+
// Just log it out for now -- nothing browser in our mix.
|
|
123
|
+
this.log.trace(`PICT Content APPEND to [${pAddress}]:`, pContent);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
readContent(pAddress, pContentType)
|
|
128
|
+
{
|
|
129
|
+
let tmpContentType = (typeof (pContentType) == 'string') ? pContentType : 'value';
|
|
130
|
+
|
|
131
|
+
if (this.customReadFunction)
|
|
132
|
+
{
|
|
133
|
+
return this.customReadFunction(pAddress, pContentType);
|
|
134
|
+
}
|
|
135
|
+
else if (this.hasJquery)
|
|
136
|
+
{
|
|
137
|
+
let tmpTargetElement = window.jQuery(pAddress);
|
|
138
|
+
return tmpTargetElement.html();
|
|
139
|
+
}
|
|
140
|
+
else if (this.inBrowser && this.hasDocument)
|
|
141
|
+
{
|
|
142
|
+
let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
|
|
143
|
+
if (tmpTargetElementSet.length < 1)
|
|
144
|
+
{
|
|
145
|
+
return '';
|
|
146
|
+
}
|
|
147
|
+
else if (tmpTargetElementSet.length == 1)
|
|
148
|
+
{
|
|
149
|
+
return tmpTargetElementSet[0].innerHTML;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else
|
|
153
|
+
{
|
|
154
|
+
// Just log it out for now -- nothing browser in our mix.
|
|
155
|
+
this.log.trace(`PICT Content READ from [${pAddress}] type [${tmpContentType}]...`);
|
|
156
|
+
return '';
|
|
157
|
+
}
|
|
158
|
+
}
|
|
134
159
|
}
|
|
135
160
|
|
|
136
161
|
module.exports = PictContentAssignment;
|
package/source/Pict.js
CHANGED
|
@@ -106,6 +106,8 @@ class Pict extends libFable
|
|
|
106
106
|
let fEntityRender = (pHash, pData, fCallback) =>
|
|
107
107
|
{
|
|
108
108
|
let tmpHash = pHash.trim();
|
|
109
|
+
let tmpData = (typeof(pData) === 'object') ? pData : {};
|
|
110
|
+
|
|
109
111
|
|
|
110
112
|
let tmpEntity = false;
|
|
111
113
|
let tmpEntityID = false;
|
|
@@ -140,7 +142,7 @@ class Pict extends libFable
|
|
|
140
142
|
else
|
|
141
143
|
{
|
|
142
144
|
// This is an address, so we need to get the value at the address
|
|
143
|
-
tmpEntityID = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:
|
|
145
|
+
tmpEntityID = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpEntityID);
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
// No Entity or EntityID
|
|
@@ -178,11 +180,12 @@ class Pict extends libFable
|
|
|
178
180
|
let fNotEmptyRender = (pHash, pData)=>
|
|
179
181
|
{
|
|
180
182
|
let tmpHash = pHash.trim();
|
|
183
|
+
let tmpData = (typeof(pData) === 'object') ? pData : {};
|
|
181
184
|
// Should switch this to indexOf so pipes can be in the content.
|
|
182
185
|
let tmpHashParts = tmpHash.split('|');
|
|
183
186
|
|
|
184
187
|
// For now just check truthiness
|
|
185
|
-
if (this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:
|
|
188
|
+
if (this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHashParts[0]))
|
|
186
189
|
{
|
|
187
190
|
return tmpHashParts[1];
|
|
188
191
|
}
|
|
@@ -198,6 +201,7 @@ class Pict extends libFable
|
|
|
198
201
|
let fTemplateRender = (pHash, pData)=>
|
|
199
202
|
{
|
|
200
203
|
let tmpHash = pHash.trim();
|
|
204
|
+
let tmpData = (typeof(pData) === 'object') ? pData : {};
|
|
201
205
|
|
|
202
206
|
let tmpTemplateHash = false;
|
|
203
207
|
let tmpAddressOfData = false;
|
|
@@ -228,7 +232,7 @@ class Pict extends libFable
|
|
|
228
232
|
}
|
|
229
233
|
else
|
|
230
234
|
{
|
|
231
|
-
return this.parseTemplateByHash(tmpTemplateHash, this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:
|
|
235
|
+
return this.parseTemplateByHash(tmpTemplateHash, this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpAddressOfData));
|
|
232
236
|
}
|
|
233
237
|
};
|
|
234
238
|
this.defaultServices.MetaTemplate.addPattern('{~T:', '~}', fTemplateRender);
|
|
@@ -238,6 +242,7 @@ class Pict extends libFable
|
|
|
238
242
|
let fTemplateSetRender = (pHash, pData)=>
|
|
239
243
|
{
|
|
240
244
|
let tmpHash = pHash.trim();
|
|
245
|
+
let tmpData = (typeof(pData) === 'object') ? pData : {};
|
|
241
246
|
|
|
242
247
|
let tmpTemplateHash = false;
|
|
243
248
|
let tmpAddressOfData = false;
|
|
@@ -268,7 +273,7 @@ class Pict extends libFable
|
|
|
268
273
|
}
|
|
269
274
|
else
|
|
270
275
|
{
|
|
271
|
-
return this.parseTemplateSetByHash(tmpTemplateHash, this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:
|
|
276
|
+
return this.parseTemplateSetByHash(tmpTemplateHash, this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpAddressOfData));
|
|
272
277
|
}
|
|
273
278
|
};
|
|
274
279
|
this.defaultServices.MetaTemplate.addPattern('{~TS:', '~}', fTemplateSetRender);
|
|
@@ -278,7 +283,8 @@ class Pict extends libFable
|
|
|
278
283
|
let fDataRender = (pHash, pData)=>
|
|
279
284
|
{
|
|
280
285
|
let tmpHash = pHash.trim();
|
|
281
|
-
let
|
|
286
|
+
let tmpData = (typeof(pData) === 'object') ? pData : {};
|
|
287
|
+
let tmpValue = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHash);
|
|
282
288
|
if ((tmpValue == null) || (tmpValue == 'undefined') || (typeof(tmpValue) == 'undefined'))
|
|
283
289
|
{
|
|
284
290
|
return '';
|
|
@@ -292,14 +298,16 @@ class Pict extends libFable
|
|
|
292
298
|
(pHash, pData)=>
|
|
293
299
|
{
|
|
294
300
|
let tmpHash = pHash.trim();
|
|
295
|
-
let
|
|
301
|
+
let tmpData = (typeof(pData) === 'object') ? pData : {};
|
|
302
|
+
let tmpColumnData = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHash);
|
|
296
303
|
return this.defaultServices.DataFormat.formatterDollars(tmpColumnData);
|
|
297
304
|
});
|
|
298
305
|
this.defaultServices.MetaTemplate.addPattern('{~Digits:', '~}',
|
|
299
306
|
(pHash, pData)=>
|
|
300
307
|
{
|
|
301
308
|
let tmpHash = pHash.trim();
|
|
302
|
-
let
|
|
309
|
+
let tmpData = (typeof(pData) === 'object') ? pData : {};
|
|
310
|
+
let tmpColumnData = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHash);
|
|
303
311
|
return this.defaultServices.DataFormat.formatterAddCommasToNumber(this.defaultServices.DataFormat.formatterRoundNumber(tmpColumnData, 2));
|
|
304
312
|
});
|
|
305
313
|
|
|
@@ -332,7 +340,8 @@ class Pict extends libFable
|
|
|
332
340
|
let fPascalCaseIdentifier = (pHash, pData)=>
|
|
333
341
|
{
|
|
334
342
|
let tmpHash = pHash.trim();
|
|
335
|
-
let
|
|
343
|
+
let tmpData = (typeof(pData) === 'object') ? pData : {};
|
|
344
|
+
let tmpValue = this.manifest.getValueByHash({AppData:this.AppData, Bundle:this.Bundle, Record:tmpData}, tmpHash);
|
|
336
345
|
if ((tmpValue == null) || (tmpValue == 'undefined') || (typeof(tmpValue) == 'undefined'))
|
|
337
346
|
{
|
|
338
347
|
return '';
|