pict-section-recordset 1.3.0 → 1.4.0
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/views/Filter-PersistenceView.js +5 -1
- package/source/views/RecordSet-Filters.js +51 -6
- package/source/views/filters/RecordSet-Filter-EntityReference-Base.js +291 -0
- package/source/views/filters/RecordSet-Filter-ExternalJoinSelectedValue.js +10 -256
- package/source/views/filters/RecordSet-Filter-ExternalJoinSelectedValueList.js +10 -263
- package/source/views/filters/RecordSet-Filter-InternalJoinSelectedValue.js +10 -256
- package/source/views/filters/RecordSet-Filter-InternalJoinSelectedValueList.js +10 -263
- package/types/views/Filter-PersistenceView.d.ts.map +1 -1
- package/types/views/RecordSet-Filters.d.ts +8 -0
- package/types/views/RecordSet-Filters.d.ts.map +1 -1
- package/types/views/filters/RecordSet-Filter-EntityReference-Base.d.ts +37 -0
- package/types/views/filters/RecordSet-Filter-EntityReference-Base.d.ts.map +1 -0
- package/types/views/filters/RecordSet-Filter-ExternalJoinSelectedValue.d.ts +13 -18
- package/types/views/filters/RecordSet-Filter-ExternalJoinSelectedValue.d.ts.map +1 -1
- package/types/views/filters/RecordSet-Filter-ExternalJoinSelectedValueList.d.ts +13 -18
- package/types/views/filters/RecordSet-Filter-ExternalJoinSelectedValueList.d.ts.map +1 -1
- package/types/views/filters/RecordSet-Filter-InternalJoinSelectedValue.d.ts +13 -18
- package/types/views/filters/RecordSet-Filter-InternalJoinSelectedValue.d.ts.map +1 -1
- package/types/views/filters/RecordSet-Filter-InternalJoinSelectedValueList.d.ts +13 -18
- package/types/views/filters/RecordSet-Filter-InternalJoinSelectedValueList.d.ts.map +1 -1
|
@@ -1,271 +1,25 @@
|
|
|
1
|
+
const ViewRecordSetSUBSETFilterEntityReferenceBase = require('./RecordSet-Filter-EntityReference-Base');
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
3
|
+
// External-join (through a junction table), single-select entity-reference filter. Shared base;
|
|
4
|
+
// entity seam = ExternalFilterByTable, single-select (replace, not append).
|
|
5
|
+
const _DEFAULT_CONFIGURATION =
|
|
5
6
|
{
|
|
6
7
|
ViewIdentifier: 'PRSP-FilterType-ExternalJoinSelectedValue',
|
|
7
|
-
|
|
8
|
-
Templates:
|
|
9
|
-
[
|
|
10
|
-
{
|
|
11
|
-
Hash: 'PRSP-Filter-ExternalJoin-SelectedValue-Template',
|
|
12
|
-
Template: /*html*/`
|
|
13
|
-
<!-- DefaultPackage pict view template: [PRSP-Filter-ExternalJoin-SelectedValue-Template] -->
|
|
14
|
-
<table>
|
|
15
|
-
<tbody>
|
|
16
|
-
<td valign="top">{~T:PRSP-Filter-ExternalJoin-SelectedValue-SearchResults~}</td><td valign="top">{~T:PRSP-Filter-ExternalJoin-SelectedValue-SelectedValues~}</td>
|
|
17
|
-
</tbody>
|
|
18
|
-
</table>
|
|
19
|
-
<!-- DefaultPackage end view template: [PRSP-Filter-ExternalJoin-SelectedValue-Template] -->
|
|
20
|
-
`
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
Hash: 'PRSP-Filter-ExternalJoin-SelectedValue-SearchResults',
|
|
24
|
-
Template: /*html*/`
|
|
25
|
-
<!-- DefaultPackage pict view template: [PRSP-Filter-ExternalJoin-SearchResults] -->
|
|
26
|
-
<form id="PRSP_Filter_{~D:Record.Hash~}_Search_Form" onsubmit="_Pict.views['{~D:Context[0].Hash~}'].performSearch(event, '{~D:Record.ClauseAddress~}', '{~D:Record.Hash~}'); return false;">
|
|
27
|
-
<input id="PRSP_Filter_{~D:Record.Hash~}_Search_Value" type="text" placeholder="Search..." value="{~D:Record.SearchInputValue~}" />
|
|
28
|
-
<button type="submit" id="PRSP_Filter_{~D:Record.Hash~}_Button_Search" onclick="_Pict.views['{~D:Context[0].Hash~}'].performSearch(event, '{~D:Record.ClauseAddress~}', '{~D:Record.Hash~}')">Search</button>
|
|
29
|
-
</form>
|
|
30
|
-
<table>
|
|
31
|
-
<thead>
|
|
32
|
-
<tr><th colspan="2">{~D:Record.Label~}</th></tr>
|
|
33
|
-
</thead>
|
|
34
|
-
<tbody>
|
|
35
|
-
{~TSWP:PRSP-Filter-ExternalJoin-SelectedValue-SearchResults-Entry:Record.SearchResults:Record~}
|
|
36
|
-
</tbody>
|
|
37
|
-
</table>
|
|
38
|
-
<button type="button" id="PRSP_Filter_{~D:Record.Hash~}_Button_LoadMore" class="is-hidden" onclick="_Pict.views['{~D:Context[0].Hash~}'].loadMore(event, '{~D:Record.ClauseAddress~}', '{~D:Record.Hash~}', {~D:Record.SearchResultsOffset:0~})">Load More</button>
|
|
39
|
-
<!-- DefaultPackage end view template: [PRSP-Filter-ExternalJoin-SearchResults] -->
|
|
40
|
-
`
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
Hash: 'PRSP-Filter-ExternalJoin-SelectedValue-SelectedValues',
|
|
44
|
-
Template: /*html*/`
|
|
45
|
-
<!-- DefaultPackage view template: [PRSP-Filter-ExternalJoin-SelectedValue-SelectedValues] -->
|
|
46
|
-
<table>
|
|
47
|
-
<thead>
|
|
48
|
-
<tr><th colspan="2">Selection</th></tr>
|
|
49
|
-
</thead>
|
|
50
|
-
<tbody>
|
|
51
|
-
{~TSWP:PRSP-Filter-ExternalJoin-SelectedValue-SelectedValues-Entry:Record.SelectedValues:Record~}
|
|
52
|
-
</tbody>
|
|
53
|
-
</table>
|
|
54
|
-
<!-- DefaultPackage end view template: [PRSP-Filter-ExternalJoin-SelectedValue-SelectedValues] -->
|
|
55
|
-
`
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
Hash: 'PRSP-Filter-ExternalJoin-SelectedValue-SearchResults-Entry',
|
|
59
|
-
Template: /*html*/`
|
|
60
|
-
<!-- DefaultPackage pict view template: [PRSP-Filter-ExternalJoin-SelectedValue-Template] -->
|
|
61
|
-
<tr><td><button onclick="_Pict.views['{~D:Context[0].Hash~}'].handleSelect(event, {~DVBK:Record.Data:Record.Payload.ExternalFilterTableLookupColumn~}, '{~D:Record.Payload.ClauseAddress~}', '{~D:Record.Payload.Hash~}')">Select</button></td><td>{~TFA:Record.Payload.ExternalRecordDisplayTemplate:Record~}</td></tr>
|
|
62
|
-
<!-- DefaultPackage end view template: [PRSP-Filter-ExternalJoin-SelectedValue-Template] -->
|
|
63
|
-
`
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
Hash: 'PRSP-Filter-ExternalJoin-SelectedValue-SelectedValues-Entry',
|
|
67
|
-
Template: /*html*/`
|
|
68
|
-
<!-- DefaultPackage pict view template: [PRSP-Filter-ExternalJoin-SelectedValue-SelectedValues-Entry] -->
|
|
69
|
-
<tr><td><button onclick="_Pict.views['{~D:Context[0].Hash~}'].handleRemove(event, {~DVBK:Record.Data:Record.Payload.ExternalFilterTableLookupColumn~}, '{~D:Record.Payload.ClauseAddress~}', '{~D:Record.Payload.Hash~}')">Remove</button></td><td>{~TFA:Record.Payload.ExternalRecordDisplayTemplate:Record~}</td></tr>
|
|
70
|
-
<!-- DefaultPackage end view template: [PRSP-Filter-ExternalJoin-SelectedValue-SelectedValues-Entry] -->
|
|
71
|
-
`
|
|
72
|
-
}
|
|
73
|
-
],
|
|
74
8
|
};
|
|
75
9
|
|
|
76
|
-
class ViewRecordSetSUBSETFilterExternalJoinSelectedValue extends
|
|
10
|
+
class ViewRecordSetSUBSETFilterExternalJoinSelectedValue extends ViewRecordSetSUBSETFilterEntityReferenceBase
|
|
77
11
|
{
|
|
78
|
-
|
|
79
|
-
{
|
|
80
|
-
if (!pOptions.PageSize)
|
|
81
|
-
{
|
|
82
|
-
pOptions.PageSize = 15; // default page size for search results
|
|
83
|
-
}
|
|
84
|
-
super(pFable, pOptions, pServiceHash);
|
|
85
|
-
/*
|
|
86
|
-
* show / hide the complex editor since it'll be large ?
|
|
87
|
-
* selected record lookup values
|
|
88
|
-
* using bundle to load those records (if any)
|
|
89
|
-
* templating out the selection
|
|
90
|
-
* templating out the search results
|
|
91
|
-
* controls to add search result values to selection
|
|
92
|
-
*/
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @param {Record<string, any>} pRecord
|
|
97
|
-
*/
|
|
98
|
-
prepareRecord(pRecord)
|
|
99
|
-
{
|
|
100
|
-
super.prepareRecord(pRecord);
|
|
101
|
-
|
|
102
|
-
pRecord.ClauseDescriptor.DataType = pRecord.DataType || 'Number';
|
|
103
|
-
pRecord.ClauseDescriptor.PictForm = pRecord.PictForm || {};
|
|
104
|
-
if (!pRecord.ExternalFilterTableLookupColumn)
|
|
105
|
-
{
|
|
106
|
-
pRecord.ExternalFilterTableLookupColumn = `ID${pRecord.ExternalFilterByTable}`;
|
|
107
|
-
}
|
|
108
|
-
if (!pRecord.SearchResults)
|
|
109
|
-
{
|
|
110
|
-
pRecord.SearchResults = [];
|
|
111
|
-
}
|
|
112
|
-
if (!pRecord.SelectedValues)
|
|
113
|
-
{
|
|
114
|
-
pRecord.SelectedValues = [];
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
getFilterFormTemplate()
|
|
119
|
-
{
|
|
120
|
-
return 'PRSP-Filter-ExternalJoin-SelectedValue-Template';
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @param {UIEvent} pEvent
|
|
125
|
-
* @param {string} pClauseInformaryAddress
|
|
126
|
-
* @param {string} pClauseHash
|
|
127
|
-
*/
|
|
128
|
-
loadMore(pEvent, pClauseInformaryAddress, pClauseHash, pCurrentOffset = 0)
|
|
129
|
-
{
|
|
130
|
-
this.performSearch(pEvent, pClauseInformaryAddress, pClauseHash, pCurrentOffset + this.options.PageSize);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* @param {UIEvent} pEvent
|
|
135
|
-
* @param {string} pClauseInformaryAddress
|
|
136
|
-
* @param {string} pClauseHash
|
|
137
|
-
* @param {number} [pOffset=0] - The offset for the search results, defaults to 0
|
|
138
|
-
*/
|
|
139
|
-
performSearch(pEvent, pClauseInformaryAddress, pClauseHash, pOffset = 0)
|
|
140
|
-
{
|
|
141
|
-
pEvent.preventDefault();
|
|
142
|
-
const tmpClause = this.getInformaryScopedValue(pClauseInformaryAddress);
|
|
143
|
-
if (!tmpClause)
|
|
144
|
-
{
|
|
145
|
-
this.pict.log.error(`[Filter-ExternalJoinSelectedValue] No clause found for address: ${pClauseInformaryAddress}`);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
tmpClause.SearchResultsOffset = pOffset;
|
|
149
|
-
// get the input value (search box)
|
|
150
|
-
const tmpSearchInputValue = pOffset > 0 ? tmpClause.SearchInputValue : this.pict.ContentAssignment.readContent(`#PRSP_Filter_${tmpClause.Hash}_Search_Value`);
|
|
151
|
-
tmpClause.SearchInputValue = tmpSearchInputValue;
|
|
152
|
-
if (!tmpSearchInputValue)
|
|
153
|
-
{
|
|
154
|
-
tmpClause.SearchResults = [];
|
|
155
|
-
tmpClause.LoadMoreEnabled = false;
|
|
156
|
-
const tmpRecord = Object.assign({ ClauseAddress: pClauseInformaryAddress }, tmpClause);
|
|
157
|
-
this.prepareRecord(tmpRecord);
|
|
158
|
-
const tmpDestinationAddress = `#PRSP_Filter_Container_${pClauseHash}`;
|
|
159
|
-
this.render(null, tmpDestinationAddress, tmpRecord);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
const tmpFilterByColumns = tmpClause.ExternalFilterByColumns || (tmpClause.ExternalFilterByColumn ? [ tmpClause.ExternalFilterByColumn ] : [ 'Name' ]);
|
|
163
|
-
const tmpMeadowFilter = tmpFilterByColumns.map((pColumn) => `FBVOR~${pColumn}~LK~${encodeURIComponent(`%${tmpSearchInputValue}%`)}`).join('~');
|
|
164
|
-
// bundle load the remote records and put them in the clause
|
|
165
|
-
this.pict.EntityProvider.gatherDataFromServer(
|
|
166
|
-
[
|
|
167
|
-
{
|
|
168
|
-
Entity: tmpClause.ExternalFilterByTable,
|
|
169
|
-
Filter: tmpMeadowFilter,
|
|
170
|
-
Destination: pOffset > 0 ? `${this.getInformaryAddressPrefix()}${pClauseInformaryAddress}.SearchResultsAppend` : `${this.getInformaryAddressPrefix()}${pClauseInformaryAddress}.SearchResults`,
|
|
171
|
-
RecordStartCursor: pOffset,
|
|
172
|
-
PageSize: this.options.PageSize,
|
|
173
|
-
}
|
|
174
|
-
],
|
|
175
|
-
(pError, pResult) =>
|
|
176
|
-
{
|
|
177
|
-
if (pOffset > 0 && tmpClause.SearchResultsAppend?.length > 0)
|
|
178
|
-
{
|
|
179
|
-
tmpClause.SearchResults = tmpClause.SearchResults.concat(tmpClause.SearchResultsAppend);
|
|
180
|
-
}
|
|
181
|
-
delete tmpClause.SearchResultsAppend;
|
|
182
|
-
tmpClause.SearchResultsOffset = pOffset;
|
|
183
|
-
const tmpRecord = Object.assign({ ClauseAddress: pClauseInformaryAddress }, tmpClause);
|
|
184
|
-
this.prepareRecord(tmpRecord);
|
|
185
|
-
const tmpDestinationAddress = `#PRSP_Filter_Container_${pClauseHash}`;
|
|
186
|
-
this.render(null, tmpDestinationAddress, tmpRecord);
|
|
187
|
-
const tmpLoadedRecords = pOffset > 0 ? tmpClause.SearchResultsAppend : tmpClause.SearchResults;
|
|
188
|
-
const tmpLoadMoreEnabled = tmpLoadedRecords && tmpLoadedRecords.length >= this.options.PageSize;
|
|
189
|
-
tmpClause.LoadMoreEnabled = tmpLoadMoreEnabled;
|
|
190
|
-
if (tmpClause.LoadMoreEnabled)
|
|
191
|
-
{
|
|
192
|
-
this.pict.ContentAssignment.removeClass(`#PRSP_Filter_${tmpClause.Hash}_Button_LoadMore`, 'is-hidden');
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
handleSelect(pEvent, pRecordLookupValue, pClauseInformaryAddress, pClauseHash)
|
|
12
|
+
getSearchEntity(pClause)
|
|
198
13
|
{
|
|
199
|
-
|
|
200
|
-
const tmpClause = this.getInformaryScopedValue(pClauseInformaryAddress);
|
|
201
|
-
if (!tmpClause)
|
|
202
|
-
{
|
|
203
|
-
this.pict.log.error(`[Filter-ExternalJoinSelectedValue] No clause found for address: ${pClauseInformaryAddress}`);
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
const tmpRecordLookupColumn = tmpClause.ExternalFilterTableLookupColumn || `ID${tmpClause.ExternalFilterByTable}`;
|
|
207
|
-
const tmpRecordToSelect = tmpClause.SearchResults.find((r) => r[tmpRecordLookupColumn] == pRecordLookupValue);
|
|
208
|
-
if (!tmpRecordToSelect)
|
|
209
|
-
{
|
|
210
|
-
this.pict.log.error(`[Filter-ExternalJoinSelectedValue] No record found to add for value: ${pRecordLookupValue}`);
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
if (!tmpClause.SelectedValues)
|
|
214
|
-
{
|
|
215
|
-
tmpClause.SelectedValues = [];
|
|
216
|
-
}
|
|
217
|
-
if (tmpClause.SelectedValues.some((pSV) => pSV[tmpRecordLookupColumn] == pRecordLookupValue))
|
|
218
|
-
{
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
const tmpValue = tmpRecordToSelect[tmpRecordLookupColumn];
|
|
222
|
-
if (tmpValue == null)
|
|
223
|
-
{
|
|
224
|
-
this.pict.log.error(`[Filter-ExternalJoinSelectedValue] No value found in record to add: ${JSON.stringify(tmpRecordToSelect)}`);
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
tmpClause.SelectedValues = [ tmpRecordToSelect ];
|
|
228
|
-
tmpClause.Values = [ tmpValue ];
|
|
229
|
-
const tmpRecord = Object.assign({ ClauseAddress: pClauseInformaryAddress }, tmpClause);
|
|
230
|
-
this.prepareRecord(tmpRecord);
|
|
231
|
-
const tmpDestinationAddress = `#PRSP_Filter_Container_${pClauseHash}`;
|
|
232
|
-
this.render(null, tmpDestinationAddress, tmpRecord);
|
|
233
|
-
if (tmpClause.LoadMoreEnabled)
|
|
234
|
-
{
|
|
235
|
-
this.pict.ContentAssignment.removeClass(`#PRSP_Filter_${tmpClause.Hash}_Button_LoadMore`, 'is-hidden');
|
|
236
|
-
}
|
|
14
|
+
return pClause.ExternalFilterByTable;
|
|
237
15
|
}
|
|
238
16
|
|
|
239
|
-
|
|
17
|
+
isMultiSelect()
|
|
240
18
|
{
|
|
241
|
-
|
|
242
|
-
const tmpClause = this.getInformaryScopedValue(pClauseInformaryAddress);
|
|
243
|
-
if (!tmpClause)
|
|
244
|
-
{
|
|
245
|
-
this.pict.log.error(`[Filter-ExternalJoinSelectedValue] No clause found for address: ${pClauseInformaryAddress}`);
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
const tmpRecordLookupColumn = tmpClause.ExternalFilterTableLookupColumn || `ID${tmpClause.ExternalFilterByTable}`;
|
|
249
|
-
const tmpRecordIndexToRemove = tmpClause.SelectedValues.findIndex((r) => r[tmpRecordLookupColumn] == pRecordLookupValue);
|
|
250
|
-
if (tmpRecordIndexToRemove < 0)
|
|
251
|
-
{
|
|
252
|
-
this.pict.log.error(`[Filter-ExternalJoinSelectedValue] No record found to remove for value: ${pRecordLookupValue}`);
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
const tmpRecordToRemove = tmpClause.SelectedValues.splice(tmpRecordIndexToRemove, 1)[0];
|
|
256
|
-
const tmpValue = tmpRecordToRemove[tmpRecordLookupColumn];
|
|
257
|
-
tmpClause.Values = tmpClause.Values.filter((pV) => pV !== tmpValue);
|
|
258
|
-
const tmpRecord = Object.assign({ ClauseAddress: pClauseInformaryAddress }, tmpClause);
|
|
259
|
-
this.prepareRecord(tmpRecord);
|
|
260
|
-
const tmpDestinationAddress = `#PRSP_Filter_Container_${pClauseHash}`;
|
|
261
|
-
this.render(null, tmpDestinationAddress, tmpRecord);
|
|
262
|
-
if (tmpClause.LoadMoreEnabled)
|
|
263
|
-
{
|
|
264
|
-
this.pict.ContentAssignment.removeClass(`#PRSP_Filter_${tmpClause.Hash}_Button_LoadMore`, 'is-hidden');
|
|
265
|
-
}
|
|
19
|
+
return false;
|
|
266
20
|
}
|
|
267
21
|
}
|
|
268
22
|
|
|
269
23
|
module.exports = ViewRecordSetSUBSETFilterExternalJoinSelectedValue;
|
|
270
24
|
|
|
271
|
-
module.exports.default_configuration = Object.assign({},
|
|
25
|
+
module.exports.default_configuration = Object.assign({}, ViewRecordSetSUBSETFilterEntityReferenceBase.default_configuration, _DEFAULT_CONFIGURATION);
|
|
@@ -1,278 +1,25 @@
|
|
|
1
|
+
const ViewRecordSetSUBSETFilterEntityReferenceBase = require('./RecordSet-Filter-EntityReference-Base');
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
3
|
+
// External-join (through a junction table), multi-select entity-reference filter. Shared base;
|
|
4
|
+
// entity seam = ExternalFilterByTable.
|
|
5
|
+
const _DEFAULT_CONFIGURATION =
|
|
5
6
|
{
|
|
6
7
|
ViewIdentifier: 'PRSP-FilterType-ExternalJoinSelectedValueList',
|
|
7
|
-
|
|
8
|
-
Templates:
|
|
9
|
-
[
|
|
10
|
-
{
|
|
11
|
-
Hash: 'PRSP-Filter-ExternalJoin-SelectedValueList-Template',
|
|
12
|
-
Template: /*html*/`
|
|
13
|
-
<!-- DefaultPackage pict view template: [PRSP-Filter-ExternalJoin-SelectedValueList-Template] -->
|
|
14
|
-
<table>
|
|
15
|
-
<tbody>
|
|
16
|
-
<td valign="top">{~T:PRSP-Filter-ExternalJoin-SelectedValueList-SearchResults~}</td><td valign="top">{~T:PRSP-Filter-ExternalJoin-SelectedValueList-SelectedValues~}</td>
|
|
17
|
-
</tbody>
|
|
18
|
-
</table>
|
|
19
|
-
<!-- DefaultPackage end view template: [PRSP-Filter-ExternalJoin-SelectedValueList-Template] -->
|
|
20
|
-
`
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
Hash: 'PRSP-Filter-ExternalJoin-SelectedValueList-SearchResults',
|
|
24
|
-
Template: /*html*/`
|
|
25
|
-
<!-- DefaultPackage pict view template: [PRSP-Filter-ExternalJoin-SearchResults] -->
|
|
26
|
-
<form id="PRSP_Filter_{~D:Record.Hash~}_Search_Form" onsubmit="_Pict.views['{~D:Context[0].Hash~}'].performSearch(event, '{~D:Record.ClauseAddress~}', '{~D:Record.Hash~}'); return false;">
|
|
27
|
-
<input id="PRSP_Filter_{~D:Record.Hash~}_Search_Value" type="text" placeholder="Search..." value="{~D:Record.SearchInputValue~}" />
|
|
28
|
-
<button type="submit" id="PRSP_Filter_{~D:Record.Hash~}_Button_Search" onclick="_Pict.views['{~D:Context[0].Hash~}'].performSearch(event, '{~D:Record.ClauseAddress~}', '{~D:Record.Hash~}')">Search</button>
|
|
29
|
-
</form>
|
|
30
|
-
<table>
|
|
31
|
-
<thead>
|
|
32
|
-
<tr><th colspan="2">{~D:Record.Label~}</th></tr>
|
|
33
|
-
</thead>
|
|
34
|
-
<tbody>
|
|
35
|
-
{~TSWP:PRSP-Filter-ExternalJoin-SelectedValueList-SearchResults-Entry:Record.SearchResults:Record~}
|
|
36
|
-
</tbody>
|
|
37
|
-
</table>
|
|
38
|
-
<button type="button" id="PRSP_Filter_{~D:Record.Hash~}_Button_LoadMore" class="is-hidden" onclick="_Pict.views['{~D:Context[0].Hash~}'].loadMore(event, '{~D:Record.ClauseAddress~}', '{~D:Record.Hash~}', {~D:Record.SearchResultsOffset:0~})">Load More</button>
|
|
39
|
-
<!-- DefaultPackage end view template: [PRSP-Filter-ExternalJoin-SearchResults] -->
|
|
40
|
-
`
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
Hash: 'PRSP-Filter-ExternalJoin-SelectedValueList-SelectedValues',
|
|
44
|
-
Template: /*html*/`
|
|
45
|
-
<!-- DefaultPackage view template: [PRSP-Filter-ExternalJoin-SelectedValueList-SelectedValues] -->
|
|
46
|
-
<table>
|
|
47
|
-
<thead>
|
|
48
|
-
<tr><th colspan="2">Selection</th></tr>
|
|
49
|
-
</thead>
|
|
50
|
-
<tbody>
|
|
51
|
-
{~TSWP:PRSP-Filter-ExternalJoin-SelectedValueList-SelectedValues-Entry:Record.SelectedValues:Record~}
|
|
52
|
-
</tbody>
|
|
53
|
-
</table>
|
|
54
|
-
<!-- DefaultPackage end view template: [PRSP-Filter-ExternalJoin-SelectedValueList-SelectedValues] -->
|
|
55
|
-
`
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
Hash: 'PRSP-Filter-ExternalJoin-SelectedValueList-SearchResults-Entry',
|
|
59
|
-
Template: /*html*/`
|
|
60
|
-
<!-- DefaultPackage pict view template: [PRSP-Filter-ExternalJoin-SelectedValueList-Template] -->
|
|
61
|
-
<tr><td><button onclick="_Pict.views['{~D:Context[0].Hash~}'].handleAdd(event, {~DVBK:Record.Data:Record.Payload.ExternalFilterTableLookupColumn~}, '{~D:Record.Payload.ClauseAddress~}', '{~D:Record.Payload.Hash~}')">Add</button></td><td>{~TFA:Record.Payload.ExternalRecordDisplayTemplate:Record~}</td></tr>
|
|
62
|
-
<!-- DefaultPackage end view template: [PRSP-Filter-ExternalJoin-SelectedValueList-Template] -->
|
|
63
|
-
`
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
Hash: 'PRSP-Filter-ExternalJoin-SelectedValueList-SelectedValues-Entry',
|
|
67
|
-
Template: /*html*/`
|
|
68
|
-
<!-- DefaultPackage pict view template: [PRSP-Filter-ExternalJoin-SelectedValueList-SelectedValues-Entry] -->
|
|
69
|
-
<tr><td><button onclick="_Pict.views['{~D:Context[0].Hash~}'].handleRemove(event, {~DVBK:Record.Data:Record.Payload.ExternalFilterTableLookupColumn~}, '{~D:Record.Payload.ClauseAddress~}', '{~D:Record.Payload.Hash~}')">Remove</button></td><td>{~TFA:Record.Payload.ExternalRecordDisplayTemplate:Record~}</td></tr>
|
|
70
|
-
<!-- DefaultPackage end view template: [PRSP-Filter-ExternalJoin-SelectedValueList-SelectedValues-Entry] -->
|
|
71
|
-
`
|
|
72
|
-
}
|
|
73
|
-
],
|
|
74
8
|
};
|
|
75
9
|
|
|
76
|
-
class ViewRecordSetSUBSETFilterExternalJoinSelectedValueList extends
|
|
10
|
+
class ViewRecordSetSUBSETFilterExternalJoinSelectedValueList extends ViewRecordSetSUBSETFilterEntityReferenceBase
|
|
77
11
|
{
|
|
78
|
-
|
|
79
|
-
{
|
|
80
|
-
if (!pOptions.PageSize)
|
|
81
|
-
{
|
|
82
|
-
pOptions.PageSize = 15; // default page size for search results
|
|
83
|
-
}
|
|
84
|
-
super(pFable, pOptions, pServiceHash);
|
|
85
|
-
/*
|
|
86
|
-
* show / hide the complex editor since it'll be large ?
|
|
87
|
-
* selected record lookup values
|
|
88
|
-
* using bundle to load those records (if any)
|
|
89
|
-
* templating out the selection
|
|
90
|
-
* templating out the search results
|
|
91
|
-
* controls to add search result values to selection
|
|
92
|
-
*/
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @param {Record<string, any>} pRecord
|
|
97
|
-
*/
|
|
98
|
-
prepareRecord(pRecord)
|
|
99
|
-
{
|
|
100
|
-
super.prepareRecord(pRecord);
|
|
101
|
-
|
|
102
|
-
pRecord.ClauseDescriptor.DataType = pRecord.DataType || 'Number';
|
|
103
|
-
pRecord.ClauseDescriptor.PictForm = pRecord.PictForm || {};
|
|
104
|
-
if (!pRecord.ExternalFilterTableLookupColumn)
|
|
105
|
-
{
|
|
106
|
-
pRecord.ExternalFilterTableLookupColumn = `ID${pRecord.ExternalFilterByTable}`;
|
|
107
|
-
}
|
|
108
|
-
if (!pRecord.SearchResults)
|
|
109
|
-
{
|
|
110
|
-
pRecord.SearchResults = [];
|
|
111
|
-
}
|
|
112
|
-
if (!pRecord.SelectedValues)
|
|
113
|
-
{
|
|
114
|
-
pRecord.SelectedValues = [];
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
getFilterFormTemplate()
|
|
119
|
-
{
|
|
120
|
-
return 'PRSP-Filter-ExternalJoin-SelectedValueList-Template';
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @param {UIEvent} pEvent
|
|
125
|
-
* @param {string} pClauseInformaryAddress
|
|
126
|
-
* @param {string} pClauseHash
|
|
127
|
-
*/
|
|
128
|
-
loadMore(pEvent, pClauseInformaryAddress, pClauseHash, pCurrentOffset = 0)
|
|
129
|
-
{
|
|
130
|
-
this.performSearch(pEvent, pClauseInformaryAddress, pClauseHash, pCurrentOffset + this.options.PageSize);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* @param {UIEvent} pEvent
|
|
135
|
-
* @param {string} pClauseInformaryAddress
|
|
136
|
-
* @param {string} pClauseHash
|
|
137
|
-
* @param {number} [pOffset=0] - The offset for the search results, defaults to 0
|
|
138
|
-
*/
|
|
139
|
-
performSearch(pEvent, pClauseInformaryAddress, pClauseHash, pOffset = 0)
|
|
140
|
-
{
|
|
141
|
-
pEvent.preventDefault();
|
|
142
|
-
const tmpClause = this.getInformaryScopedValue(pClauseInformaryAddress);
|
|
143
|
-
if (!tmpClause)
|
|
144
|
-
{
|
|
145
|
-
this.pict.log.error(`[Filter-ExternalJoinSelectedValueList] No clause found for address: ${pClauseInformaryAddress}`);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
tmpClause.SearchResultsOffset = pOffset;
|
|
149
|
-
// get the input value (search box)
|
|
150
|
-
const tmpSearchInputValue = pOffset > 0 ? tmpClause.SearchInputValue : this.pict.ContentAssignment.readContent(`#PRSP_Filter_${tmpClause.Hash}_Search_Value`);
|
|
151
|
-
tmpClause.SearchInputValue = tmpSearchInputValue;
|
|
152
|
-
if (!tmpSearchInputValue)
|
|
153
|
-
{
|
|
154
|
-
tmpClause.SearchResults = [];
|
|
155
|
-
tmpClause.LoadMoreEnabled = false;
|
|
156
|
-
const tmpRecord = Object.assign({ ClauseAddress: pClauseInformaryAddress }, tmpClause);
|
|
157
|
-
this.prepareRecord(tmpRecord);
|
|
158
|
-
const tmpDestinationAddress = `#PRSP_Filter_Container_${pClauseHash}`;
|
|
159
|
-
this.render(null, tmpDestinationAddress, tmpRecord);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
const tmpFilterByColumns = tmpClause.ExternalFilterByColumns || (tmpClause.ExternalFilterByColumn ? [ tmpClause.ExternalFilterByColumn ] : [ 'Name' ]);
|
|
163
|
-
const tmpMeadowFilter = tmpFilterByColumns.map((pColumn) => `FBVOR~${pColumn}~LK~${encodeURIComponent(`%${tmpSearchInputValue}%`)}`).join('~');
|
|
164
|
-
// bundle load the remote records and put them in the clause
|
|
165
|
-
this.pict.EntityProvider.gatherDataFromServer(
|
|
166
|
-
[
|
|
167
|
-
{
|
|
168
|
-
Entity: tmpClause.ExternalFilterByTable,
|
|
169
|
-
Filter: tmpMeadowFilter,
|
|
170
|
-
Destination: pOffset > 0 ? `${this.getInformaryAddressPrefix()}${pClauseInformaryAddress}.SearchResultsAppend` : `${this.getInformaryAddressPrefix()}${pClauseInformaryAddress}.SearchResults`,
|
|
171
|
-
RecordStartCursor: pOffset,
|
|
172
|
-
PageSize: this.options.PageSize,
|
|
173
|
-
}
|
|
174
|
-
],
|
|
175
|
-
(pError, pResult) =>
|
|
176
|
-
{
|
|
177
|
-
if (pOffset > 0 && tmpClause.SearchResultsAppend?.length > 0)
|
|
178
|
-
{
|
|
179
|
-
tmpClause.SearchResults = tmpClause.SearchResults.concat(tmpClause.SearchResultsAppend);
|
|
180
|
-
}
|
|
181
|
-
delete tmpClause.SearchResultsAppend;
|
|
182
|
-
tmpClause.SearchResultsOffset = pOffset;
|
|
183
|
-
const tmpRecord = Object.assign({ ClauseAddress: pClauseInformaryAddress }, tmpClause);
|
|
184
|
-
this.prepareRecord(tmpRecord);
|
|
185
|
-
const tmpDestinationAddress = `#PRSP_Filter_Container_${pClauseHash}`;
|
|
186
|
-
this.render(null, tmpDestinationAddress, tmpRecord);
|
|
187
|
-
const tmpLoadedRecords = pOffset > 0 ? tmpClause.SearchResultsAppend : tmpClause.SearchResults;
|
|
188
|
-
const tmpLoadMoreEnabled = tmpLoadedRecords && tmpLoadedRecords.length >= this.options.PageSize;
|
|
189
|
-
tmpClause.LoadMoreEnabled = tmpLoadMoreEnabled;
|
|
190
|
-
if (tmpClause.LoadMoreEnabled)
|
|
191
|
-
{
|
|
192
|
-
this.pict.ContentAssignment.removeClass(`#PRSP_Filter_${tmpClause.Hash}_Button_LoadMore`, 'is-hidden');
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
handleAdd(pEvent, pRecordLookupValue, pClauseInformaryAddress, pClauseHash)
|
|
12
|
+
getSearchEntity(pClause)
|
|
198
13
|
{
|
|
199
|
-
|
|
200
|
-
const tmpClause = this.getInformaryScopedValue(pClauseInformaryAddress);
|
|
201
|
-
if (!tmpClause)
|
|
202
|
-
{
|
|
203
|
-
this.pict.log.error(`[Filter-ExternalJoinSelectedValueList] No clause found for address: ${pClauseInformaryAddress}`);
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
const tmpRecordLookupColumn = tmpClause.ExternalFilterTableLookupColumn || `ID${tmpClause.ExternalFilterByTable}`;
|
|
207
|
-
const tmpRecordToAdd = tmpClause.SearchResults.find((r) => r[tmpRecordLookupColumn] == pRecordLookupValue);
|
|
208
|
-
if (!tmpRecordToAdd)
|
|
209
|
-
{
|
|
210
|
-
this.pict.log.error(`[Filter-ExternalJoinSelectedValueList] No record found to add for value: ${pRecordLookupValue}`);
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
if (!tmpClause.SelectedValues)
|
|
214
|
-
{
|
|
215
|
-
tmpClause.SelectedValues = [];
|
|
216
|
-
}
|
|
217
|
-
if (tmpClause.SelectedValues.some((pSV) => pSV[tmpRecordLookupColumn] == pRecordLookupValue))
|
|
218
|
-
{
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
const tmpValue = tmpRecordToAdd[tmpRecordLookupColumn];
|
|
222
|
-
if (tmpValue == null)
|
|
223
|
-
{
|
|
224
|
-
this.pict.log.error(`[Filter-ExternalJoinSelectedValueList] No value found in record to add: ${JSON.stringify(tmpRecordToAdd)}`);
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
tmpClause.SelectedValues.push(tmpRecordToAdd);
|
|
228
|
-
if (!tmpClause.Values)
|
|
229
|
-
{
|
|
230
|
-
tmpClause.Values = [];
|
|
231
|
-
}
|
|
232
|
-
if (!tmpClause.Values.some((pV) => pV == tmpValue))
|
|
233
|
-
{
|
|
234
|
-
tmpClause.Values.push(tmpValue);
|
|
235
|
-
}
|
|
236
|
-
const tmpRecord = Object.assign({ ClauseAddress: pClauseInformaryAddress }, tmpClause);
|
|
237
|
-
this.prepareRecord(tmpRecord);
|
|
238
|
-
const tmpDestinationAddress = `#PRSP_Filter_Container_${pClauseHash}`;
|
|
239
|
-
this.render(null, tmpDestinationAddress, tmpRecord);
|
|
240
|
-
if (tmpClause.LoadMoreEnabled)
|
|
241
|
-
{
|
|
242
|
-
this.pict.ContentAssignment.removeClass(`#PRSP_Filter_${tmpClause.Hash}_Button_LoadMore`, 'is-hidden');
|
|
243
|
-
}
|
|
14
|
+
return pClause.ExternalFilterByTable;
|
|
244
15
|
}
|
|
245
16
|
|
|
246
|
-
|
|
17
|
+
isMultiSelect()
|
|
247
18
|
{
|
|
248
|
-
|
|
249
|
-
const tmpClause = this.getInformaryScopedValue(pClauseInformaryAddress);
|
|
250
|
-
if (!tmpClause)
|
|
251
|
-
{
|
|
252
|
-
this.pict.log.error(`[Filter-ExternalJoinSelectedValueList] No clause found for address: ${pClauseInformaryAddress}`);
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
const tmpRecordLookupColumn = tmpClause.ExternalFilterTableLookupColumn || `ID${tmpClause.ExternalFilterByTable}`;
|
|
256
|
-
const tmpRecordIndexToRemove = tmpClause.SelectedValues.findIndex((r) => r[tmpRecordLookupColumn] == pRecordLookupValue);
|
|
257
|
-
if (tmpRecordIndexToRemove < 0)
|
|
258
|
-
{
|
|
259
|
-
this.pict.log.error(`[Filter-ExternalJoinSelectedValueList] No record found to remove for value: ${pRecordLookupValue}`);
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
const tmpRecordToRemove = tmpClause.SelectedValues.splice(tmpRecordIndexToRemove, 1)[0];
|
|
263
|
-
const tmpValue = tmpRecordToRemove[tmpRecordLookupColumn];
|
|
264
|
-
tmpClause.Values = tmpClause.Values.filter((pV) => pV !== tmpValue);
|
|
265
|
-
const tmpRecord = Object.assign({ ClauseAddress: pClauseInformaryAddress }, tmpClause);
|
|
266
|
-
this.prepareRecord(tmpRecord);
|
|
267
|
-
const tmpDestinationAddress = `#PRSP_Filter_Container_${pClauseHash}`;
|
|
268
|
-
this.render(null, tmpDestinationAddress, tmpRecord);
|
|
269
|
-
if (tmpClause.LoadMoreEnabled)
|
|
270
|
-
{
|
|
271
|
-
this.pict.ContentAssignment.removeClass(`#PRSP_Filter_${tmpClause.Hash}_Button_LoadMore`, 'is-hidden');
|
|
272
|
-
}
|
|
19
|
+
return true;
|
|
273
20
|
}
|
|
274
21
|
}
|
|
275
22
|
|
|
276
23
|
module.exports = ViewRecordSetSUBSETFilterExternalJoinSelectedValueList;
|
|
277
24
|
|
|
278
|
-
module.exports.default_configuration = Object.assign({},
|
|
25
|
+
module.exports.default_configuration = Object.assign({}, ViewRecordSetSUBSETFilterEntityReferenceBase.default_configuration, _DEFAULT_CONFIGURATION);
|