node-red-contrib-mobius-flow-base 2.5.86-beta.58 → 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,22 +1,29 @@
1
1
  initMobsearch = {
2
- toRid: () => {
3
- return 'Hello World';
2
+ toRid: (mobiusSrvc, opts) => {
3
+ getMobsearch(mobiusSrvc, true, false, opts);
4
4
  },
5
- toIns: () => {
6
- return 'Hello World';
5
+ toIns: (mobiusSrvc, opts) => {
6
+ getMobsearch(mobiusSrvc, false, false, opts);
7
7
  },
8
- toRidList: () => {
9
- return 'Hello World';
8
+ toRidListed: (mobiusSrvc, opts) => {
9
+ getMobsearch(mobiusSrvc, true, true, opts);
10
10
  },
11
- toInsList: () => {
12
- return 'Hello World';
11
+ toInsListed: (mobiusSrvc, opts) => {
12
+ getMobsearch(mobiusSrvc, false, true, opts);
13
13
  },
14
14
  };
15
15
 
16
- function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, globalIndex) {
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) {
17
24
  //level dependent html
18
25
  let rows =
19
- level === 'rid'
26
+ useRid === true
20
27
  ? `
21
28
  <input type="text" id="instance-search-hid" style="width:13%;" placeholder="HID">
22
29
  <input type="text" id="instance-search-sid" style="width:8%;" placeholder="SID">
@@ -30,7 +37,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
30
37
  <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
31
38
  <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
32
39
  `;
33
- let alertMsg = level === 'rid' ? `and/or RID ` : ``;
40
+ let alertMsg = useRid === true ? `and/or RID ` : ``;
34
41
 
35
42
  //Add new html
36
43
  document.getElementById('mobsearch').innerHTML += `
@@ -234,17 +241,17 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
234
241
  function finishSearch() {
235
242
  $('#wildcard-alert-row').hide();
236
243
  let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`;
237
- if (level === 'rid') {
244
+ if (useRid) {
238
245
  uri = uri + `/${searchObject.rid}`;
239
246
  }
240
247
  if (uri.includes('#')) {
241
248
  uri = uri.substring(0, uri.indexOf('#') + 1);
242
249
  }
243
250
  if (listed) {
244
- list[globalIndex].uri = uri;
251
+ opts.list[opts.selectionIndex].uri = uri;
245
252
  updateList();
246
253
  } else {
247
- $(`#${fieldName}`).val(uri);
254
+ $(`#${opts.uriFieldName}`).val(uri);
248
255
  }
249
256
  $('#node-search-accept').css('color', '#CCCCCC');
250
257
  readyToAccept = false;
@@ -257,7 +264,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
257
264
 
258
265
  //Function to update if accept button is grade out and functions based on conditions of fields
259
266
  function acceptCheck() {
260
- if (level === 'rid') {
267
+ if (useRid) {
261
268
  if (
262
269
  ($('#instance-search-hid').val() !== '' &&
263
270
  $('#instance-search-sid').val() !== '' &&
@@ -303,13 +310,29 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
303
310
  }
304
311
  }
305
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
+
306
329
  // Respond to clicks
307
330
  $('#node-lookup-instance').click(function () {
308
331
  //When search button is clicked
309
332
  $('#instance-search-sid').val('');
310
333
  $('#instance-search-pid').val('');
311
334
  $('#instance-search-ins').val('');
312
- if (level === 'rid') {
335
+ if (useRid) {
313
336
  $('#instance-search-rid').val('');
314
337
  }
315
338
  $('#node-lookup-instance').addClass('disabled');
@@ -324,7 +347,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
324
347
  $('#instance-search-ins').val('');
325
348
  searchObject.pid = '';
326
349
  searchObject.ins = '';
327
- if (level === 'rid') {
350
+ if (useRid) {
328
351
  searchObject.rid = '';
329
352
  }
330
353
  searchObject.objects = [];
@@ -336,7 +359,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
336
359
 
337
360
  searchObject.ins = '';
338
361
 
339
- if (level === 'rid') {
362
+ if (useRid) {
340
363
  $('#instance-search-rid').val('');
341
364
  searchObject.rid = '';
342
365
  }
@@ -346,7 +369,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
346
369
  });
347
370
  $('#instance-search-ins').click(function () {
348
371
  //INS field clicked
349
- if (level === 'rid') {
372
+ if (useRid) {
350
373
  $('#instance-search-rid').val('');
351
374
  searchObject.rid = '';
352
375
  }
@@ -355,7 +378,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
355
378
  }
356
379
  });
357
380
 
358
- if (level === 'rid') {
381
+ if (useRid) {
359
382
  $('#instance-search-rid').click(function () {
360
383
  //RID clicked
361
384
  if (
@@ -389,7 +412,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
389
412
  $('#instance-search-sid').val('');
390
413
  $('#instance-search-pid').val('');
391
414
  $('#instance-search-ins').val('');
392
- if (level === 'rid') {
415
+ if (useRid) {
393
416
  $('#instance-search-rid').val('');
394
417
  }
395
418
  });
@@ -405,7 +428,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
405
428
  searchObject.ins = $('#instance-search-ins').val();
406
429
  acceptCheck();
407
430
  });
408
- if (level === 'rid') {
431
+ if (useRid) {
409
432
  $('#instance-search-rid').change(function () {
410
433
  searchObject.rid = $('#instance-search-rid').val();
411
434
  acceptCheck();
@@ -150,21 +150,13 @@ 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
+ 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);
168
160
 
169
161
  // *** END MOBSEARCH *** //
170
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', 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,8 +98,10 @@ POSSIBILITY OF SUCH DAMAGE.
98
98
  oneditprepare: function () {
99
99
  var node = this;
100
100
  let mobiusSrvc = $("#node-input-connection").val();
101
- console.log(initMobsearch.toRid());
102
- getMobsearch(mobiusSrvc, 'rid', false, 'node-input-resource', null, null, null);
101
+ opts = {
102
+ uriFieldName: 'node-input-resource'
103
+ };
104
+ initMobsearch.toRid(mobiusSrvc, opts);
103
105
  },
104
106
  oneditsave: function() {
105
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.58",
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",