node-red-contrib-mobius-flow-base 2.5.86-beta.57 → 2.5.86-beta.60

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,30 @@
1
- function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, globalIndex) {
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) {
24
+ console.log($(`#${opts.uriFieldName}`).val());
2
25
  //level dependent html
3
26
  let rows =
4
- level === 'rid'
27
+ useRid === true
5
28
  ? `
6
29
  <input type="text" id="instance-search-hid" style="width:13%;" placeholder="HID">
7
30
  <input type="text" id="instance-search-sid" style="width:8%;" placeholder="SID">
@@ -15,7 +38,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
15
38
  <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
16
39
  <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
17
40
  `;
18
- let alertMsg = level === 'rid' ? `and/or RID ` : ``;
41
+ let alertMsg = useRid === true ? `and/or RID ` : ``;
19
42
 
20
43
  //Add new html
21
44
  document.getElementById('mobsearch').innerHTML += `
@@ -219,18 +242,17 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
219
242
  function finishSearch() {
220
243
  $('#wildcard-alert-row').hide();
221
244
  let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`;
222
- if (level === 'rid') {
245
+ if (useRid) {
223
246
  uri = uri + `/${searchObject.rid}`;
224
247
  }
225
248
  if (uri.includes('#')) {
226
249
  uri = uri.substring(0, uri.indexOf('#') + 1);
227
250
  }
228
251
  if (listed) {
229
- list[globalIndex].uri = uri;
252
+ opts.list[opts.selectionIndex].uri = uri;
230
253
  updateList();
231
- // $('#node-input-mobjects-container-row').show();
232
254
  } else {
233
- $(`#${fieldName}`).val(uri);
255
+ $(`#${opts.uriFieldName}`).val(uri);
234
256
  }
235
257
  $('#node-search-accept').css('color', '#CCCCCC');
236
258
  readyToAccept = false;
@@ -243,7 +265,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
243
265
 
244
266
  //Function to update if accept button is grade out and functions based on conditions of fields
245
267
  function acceptCheck() {
246
- if (level === 'rid') {
268
+ if (useRid) {
247
269
  if (
248
270
  ($('#instance-search-hid').val() !== '' &&
249
271
  $('#instance-search-sid').val() !== '' &&
@@ -289,13 +311,29 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
289
311
  }
290
312
  }
291
313
 
314
+ function updateList() {
315
+ $(`#${opts.containerName}`)
316
+ .editableList('items')
317
+ .each(function (i) {
318
+ let item = $(this);
319
+ let secondField = item.find(`.${opts.containerSecondFieldName}`).val();
320
+ opts.list[i][Object.keys(opts.list[i])[1]] = secondField;
321
+ });
322
+ $(`#${opts.containerName}`).editableList('empty');
323
+ for (let i = 0; i < opts.list.length; i++) {
324
+ let item = opts.list[i];
325
+ $(`#${opts.containerName}`).editableList('addItem', item);
326
+ }
327
+ $(`#${opts.containerRowName}`).show();
328
+ }
329
+
292
330
  // Respond to clicks
293
331
  $('#node-lookup-instance').click(function () {
294
332
  //When search button is clicked
295
333
  $('#instance-search-sid').val('');
296
334
  $('#instance-search-pid').val('');
297
335
  $('#instance-search-ins').val('');
298
- if (level === 'rid') {
336
+ if (useRid) {
299
337
  $('#instance-search-rid').val('');
300
338
  }
301
339
  $('#node-lookup-instance').addClass('disabled');
@@ -310,7 +348,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
310
348
  $('#instance-search-ins').val('');
311
349
  searchObject.pid = '';
312
350
  searchObject.ins = '';
313
- if (level === 'rid') {
351
+ if (useRid) {
314
352
  searchObject.rid = '';
315
353
  }
316
354
  searchObject.objects = [];
@@ -322,7 +360,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
322
360
 
323
361
  searchObject.ins = '';
324
362
 
325
- if (level === 'rid') {
363
+ if (useRid) {
326
364
  $('#instance-search-rid').val('');
327
365
  searchObject.rid = '';
328
366
  }
@@ -332,7 +370,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
332
370
  });
333
371
  $('#instance-search-ins').click(function () {
334
372
  //INS field clicked
335
- if (level === 'rid') {
373
+ if (useRid) {
336
374
  $('#instance-search-rid').val('');
337
375
  searchObject.rid = '';
338
376
  }
@@ -341,7 +379,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
341
379
  }
342
380
  });
343
381
 
344
- if (level === 'rid') {
382
+ if (useRid) {
345
383
  $('#instance-search-rid').click(function () {
346
384
  //RID clicked
347
385
  if (
@@ -375,7 +413,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
375
413
  $('#instance-search-sid').val('');
376
414
  $('#instance-search-pid').val('');
377
415
  $('#instance-search-ins').val('');
378
- if (level === 'rid') {
416
+ if (useRid) {
379
417
  $('#instance-search-rid').val('');
380
418
  }
381
419
  });
@@ -391,7 +429,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
391
429
  searchObject.ins = $('#instance-search-ins').val();
392
430
  acceptCheck();
393
431
  });
394
- if (level === 'rid') {
432
+ if (useRid) {
395
433
  $('#instance-search-rid').change(function () {
396
434
  searchObject.rid = $('#instance-search-rid').val();
397
435
  acceptCheck();
@@ -150,21 +150,14 @@ POSSIBILITY OF SUCH DAMAGE.
150
150
 
151
151
  // *** MOBSEARCH *** //
152
152
 
153
- function updateList() {
154
- $("#node-input-resources-container").editableList('items').each(function (i) {
155
- let resource = $(this);
156
- let comment = resource.find(".node-input-resource-comment").val();
157
- node.resources[i].comment = comment;
158
- })
159
- $("#node-input-resources-container").editableList('empty');
160
- for (let i = 0; i < node.resources.length; i++) {
161
- let resource = node.resources[i];
162
- $("#node-input-resources-container").editableList('addItem', resource);
163
- }
164
- $('#node-input-resources-container-row').show();
165
- }
166
-
167
- getMobsearch(mobiusSrvc, 'rid', true, null, node.resources, updateList, globalIndex)
153
+ opts = {
154
+ list: node.resources,
155
+ selectionIndex: globalIndex,
156
+ containerRowName: 'node-input-resources-container-row',
157
+ containerName: 'node-input-resources-container',
158
+ containerSecondFieldName: 'node-input-resources-comment',
159
+ };
160
+ initMobsearch.toRidListed(mobiusSrvc, opts);
168
161
 
169
162
  // *** END MOBSEARCH *** //
170
163
 
@@ -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', false, 'node-input-instance', null, null, null)
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', false, 'node-input-resource', null, null, null);
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.57",
3
+ "version": "2.5.86-beta.60",
4
4
  "description": "Node-RED base nodes for Mobius Flow",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",