node-red-contrib-mobius-flow-base 2.5.86-beta.55 → 2.5.86-beta.59

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.
@@ -1,7 +1,29 @@
1
- function getMobsearch(mobiusSrvc, level, listed, fieldName, list) {
1
+ initMobsearch = {
2
+ toRid: (mobiusSrvc, opts) => {
3
+ getMobsearch(mobiusSrvc, true, false, opts);
4
+ },
5
+ toIns: (mobiusSrvc, opts) => {
6
+ getMobsearch(mobiusSrvc, false, false, opts);
7
+ },
8
+ toRidListed: (mobiusSrvc, opts) => {
9
+ getMobsearch(mobiusSrvc, true, true, opts);
10
+ },
11
+ toInsListed: (mobiusSrvc, opts) => {
12
+ getMobsearch(mobiusSrvc, false, true, opts);
13
+ },
14
+ };
15
+
16
+ // RID ONLY
17
+ // opts.uriFieldName
18
+ // opts.selectionIndex
19
+ // opts.containerRowName
20
+ // opts.containerName
21
+ // opts.containerSecondFieldName
22
+
23
+ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
2
24
  //level dependent html
3
25
  let rows =
4
- level === 'rid'
26
+ useRid === true
5
27
  ? `
6
28
  <input type="text" id="instance-search-hid" style="width:13%;" placeholder="HID">
7
29
  <input type="text" id="instance-search-sid" style="width:8%;" placeholder="SID">
@@ -15,7 +37,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list) {
15
37
  <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
16
38
  <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
17
39
  `;
18
- let alertMsg = level === 'rid' ? `and/or RID ` : ``;
40
+ let alertMsg = useRid === true ? `and/or RID ` : ``;
19
41
 
20
42
  //Add new html
21
43
  document.getElementById('mobsearch').innerHTML += `
@@ -219,17 +241,17 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list) {
219
241
  function finishSearch() {
220
242
  $('#wildcard-alert-row').hide();
221
243
  let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`;
222
- if (level === 'rid') {
244
+ if (useRid) {
223
245
  uri = uri + `/${searchObject.rid}`;
224
246
  }
225
247
  if (uri.includes('#')) {
226
248
  uri = uri.substring(0, uri.indexOf('#') + 1);
227
249
  }
228
250
  if (listed) {
229
- list[globalIndex].uri = uri;
251
+ opts.list[opts.selectionIndex].uri = uri;
230
252
  updateList();
231
253
  } else {
232
- $(`#${fieldName}`).val(uri);
254
+ $(`#${opts.uriFieldName}`).val(uri);
233
255
  }
234
256
  $('#node-search-accept').css('color', '#CCCCCC');
235
257
  readyToAccept = false;
@@ -242,7 +264,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list) {
242
264
 
243
265
  //Function to update if accept button is grade out and functions based on conditions of fields
244
266
  function acceptCheck() {
245
- if (level === 'rid') {
267
+ if (useRid) {
246
268
  if (
247
269
  ($('#instance-search-hid').val() !== '' &&
248
270
  $('#instance-search-sid').val() !== '' &&
@@ -288,13 +310,29 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list) {
288
310
  }
289
311
  }
290
312
 
313
+ function updateList() {
314
+ $(`#${opts.containerName}`)
315
+ .editableList('items')
316
+ .each(function (i) {
317
+ let resource = $(this);
318
+ let comment = resource.find(`.${opts.containerSecondFieldName}`).val();
319
+ node.resources[i].comment = comment;
320
+ });
321
+ $(`#${opts.containerName}`).editableList('empty');
322
+ for (let i = 0; i < node.resources.length; i++) {
323
+ let resource = node.resources[i];
324
+ $(`#${opts.containerName}`).editableList('addItem', resource);
325
+ }
326
+ $(`#${opts.containerRowName}`).show();
327
+ }
328
+
291
329
  // Respond to clicks
292
330
  $('#node-lookup-instance').click(function () {
293
331
  //When search button is clicked
294
332
  $('#instance-search-sid').val('');
295
333
  $('#instance-search-pid').val('');
296
334
  $('#instance-search-ins').val('');
297
- if (level === 'rid') {
335
+ if (useRid) {
298
336
  $('#instance-search-rid').val('');
299
337
  }
300
338
  $('#node-lookup-instance').addClass('disabled');
@@ -309,7 +347,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list) {
309
347
  $('#instance-search-ins').val('');
310
348
  searchObject.pid = '';
311
349
  searchObject.ins = '';
312
- if (level === 'rid') {
350
+ if (useRid) {
313
351
  searchObject.rid = '';
314
352
  }
315
353
  searchObject.objects = [];
@@ -321,7 +359,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list) {
321
359
 
322
360
  searchObject.ins = '';
323
361
 
324
- if (level === 'rid') {
362
+ if (useRid) {
325
363
  $('#instance-search-rid').val('');
326
364
  searchObject.rid = '';
327
365
  }
@@ -331,7 +369,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list) {
331
369
  });
332
370
  $('#instance-search-ins').click(function () {
333
371
  //INS field clicked
334
- if (level === 'rid') {
372
+ if (useRid) {
335
373
  $('#instance-search-rid').val('');
336
374
  searchObject.rid = '';
337
375
  }
@@ -340,7 +378,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list) {
340
378
  }
341
379
  });
342
380
 
343
- if (level === 'rid') {
381
+ if (useRid) {
344
382
  $('#instance-search-rid').click(function () {
345
383
  //RID clicked
346
384
  if (
@@ -374,7 +412,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list) {
374
412
  $('#instance-search-sid').val('');
375
413
  $('#instance-search-pid').val('');
376
414
  $('#instance-search-ins').val('');
377
- if (level === 'rid') {
415
+ if (useRid) {
378
416
  $('#instance-search-rid').val('');
379
417
  }
380
418
  });
@@ -390,7 +428,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list) {
390
428
  searchObject.ins = $('#instance-search-ins').val();
391
429
  acceptCheck();
392
430
  });
393
- if (level === 'rid') {
431
+ if (useRid) {
394
432
  $('#instance-search-rid').change(function () {
395
433
  searchObject.rid = $('#instance-search-rid').val();
396
434
  acceptCheck();
@@ -89,8 +89,6 @@ POSSIBILITY OF SUCH DAMAGE.
89
89
  let mobiusSrvc = $("#node-input-connection").val();
90
90
  let globalIndex = 0;
91
91
 
92
- getMobsearch(mobiusSrvc, 'rid', true, null, node.resources)
93
-
94
92
  /** Create the subs container and populate it */
95
93
  $('#node-input-resources-container').css('min-height', '300px').css('min-width', '450px').editableList ({
96
94
  addButton: "add",
@@ -152,18 +150,13 @@ POSSIBILITY OF SUCH DAMAGE.
152
150
 
153
151
  // *** MOBSEARCH *** //
154
152
 
155
- function updateList() {
156
- $("#node-input-resources-container").editableList('items').each(function (i) {
157
- let resource = $(this);
158
- let comment = resource.find(".node-input-resource-comment").val();
159
- node.resources[i].comment = comment;
160
- })
161
- $("#node-input-resources-container").editableList('empty');
162
- for (let i = 0; i < node.resources.length; i++) {
163
- let resource = node.resources[i];
164
- $("#node-input-resources-container").editableList('addItem', resource);
165
- }
166
- }
153
+ opts = {
154
+ selectionIndex: globalIndex,
155
+ containerRowName: 'node-input-resources-container-row',
156
+ containerName: 'node-input-resources-container',
157
+ containerSecondFieldName: 'node-input-resources-comment',
158
+ };
159
+ initMobsearch.toRidListed(mobiusSrvc, opts);
167
160
 
168
161
  // *** END MOBSEARCH *** //
169
162
 
@@ -106,7 +106,10 @@ POSSIBILITY OF SUCH DAMAGE.
106
106
  var node = this;
107
107
  let mobiusSrvc = $("#node-input-connection").val();
108
108
 
109
- getMobsearch(mobiusSrvc, 'ins', 'node-input-instance')
109
+ opts = {
110
+ uriFieldName: 'node-input-instance '
111
+ };
112
+ initMobsearch.toIns(mobiusSrvc, opts);
110
113
  },
111
114
  oneditsave: function() {
112
115
  if($("#node-input-detailedOutput").prop('checked')) {
@@ -98,7 +98,10 @@ POSSIBILITY OF SUCH DAMAGE.
98
98
  oneditprepare: function () {
99
99
  var node = this;
100
100
  let mobiusSrvc = $("#node-input-connection").val();
101
- getMobsearch(mobiusSrvc, 'rid', 'node-input-resource');
101
+ opts = {
102
+ uriFieldName: 'node-input-resource'
103
+ };
104
+ initMobsearch.toRid(mobiusSrvc, opts);
102
105
  },
103
106
  oneditsave: function() {
104
107
  if($("#node-input-detailedOutput").prop('checked')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-mobius-flow-base",
3
- "version": "2.5.86-beta.55",
3
+ "version": "2.5.86-beta.59",
4
4
  "description": "Node-RED base nodes for Mobius Flow",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",