node-red-contrib-mobius-flow-base 2.5.86-beta.58 → 2.5.86-beta.61

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,51 @@
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
+ let selectionIndex = 0;
24
+
25
+ function addSearchButton(field, i) {
26
+ field.click(function () {
27
+ selectionIndex = i;
28
+ $('#node-input-resources-container-row').hide();
29
+ $('#instance-search-sid').val('');
30
+ $('#instance-search-pid').val('');
31
+ $('#instance-search-ins').val('');
32
+ $('#instance-search-rid').val('');
33
+ $('#node-search-return').removeClass('disabled');
34
+ $('#node-search-accept').removeClass('disabled');
35
+ $('#instance-search-row').show();
36
+ });
37
+ }
38
+
39
+ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
40
+ selectionIndex = 0;
41
+
42
+ if (useRid) {
43
+ $(`#${opts.uriFieldName}`).val($(`#${opts.uriFieldName}`).val());
44
+ }
45
+
17
46
  //level dependent html
18
47
  let rows =
19
- level === 'rid'
48
+ useRid === true
20
49
  ? `
21
50
  <input type="text" id="instance-search-hid" style="width:13%;" placeholder="HID">
22
51
  <input type="text" id="instance-search-sid" style="width:8%;" placeholder="SID">
@@ -30,7 +59,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
30
59
  <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
31
60
  <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
32
61
  `;
33
- let alertMsg = level === 'rid' ? `and/or RID ` : ``;
62
+ let alertMsg = useRid === true ? `and/or RID ` : ``;
34
63
 
35
64
  //Add new html
36
65
  document.getElementById('mobsearch').innerHTML += `
@@ -234,17 +263,17 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
234
263
  function finishSearch() {
235
264
  $('#wildcard-alert-row').hide();
236
265
  let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`;
237
- if (level === 'rid') {
266
+ if (useRid) {
238
267
  uri = uri + `/${searchObject.rid}`;
239
268
  }
240
269
  if (uri.includes('#')) {
241
270
  uri = uri.substring(0, uri.indexOf('#') + 1);
242
271
  }
243
272
  if (listed) {
244
- list[globalIndex].uri = uri;
273
+ opts.list[selectionIndex].uri = uri;
245
274
  updateList();
246
275
  } else {
247
- $(`#${fieldName}`).val(uri);
276
+ $(`#${opts.uriFieldName}`).val(uri);
248
277
  }
249
278
  $('#node-search-accept').css('color', '#CCCCCC');
250
279
  readyToAccept = false;
@@ -257,7 +286,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
257
286
 
258
287
  //Function to update if accept button is grade out and functions based on conditions of fields
259
288
  function acceptCheck() {
260
- if (level === 'rid') {
289
+ if (useRid) {
261
290
  if (
262
291
  ($('#instance-search-hid').val() !== '' &&
263
292
  $('#instance-search-sid').val() !== '' &&
@@ -303,13 +332,29 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
303
332
  }
304
333
  }
305
334
 
335
+ function updateList() {
336
+ $(`#${opts.containerName}`)
337
+ .editableList('items')
338
+ .each(function (i) {
339
+ let item = $(this);
340
+ let secondField = item.find(`.${opts.containerSecondFieldName}`).val();
341
+ opts.list[i][Object.keys(opts.list[i])[1]] = secondField;
342
+ });
343
+ $(`#${opts.containerName}`).editableList('empty');
344
+ for (let i = 0; i < opts.list.length; i++) {
345
+ let item = opts.list[i];
346
+ $(`#${opts.containerName}`).editableList('addItem', item);
347
+ }
348
+ $(`#${opts.containerRowName}`).show();
349
+ }
350
+
306
351
  // Respond to clicks
307
352
  $('#node-lookup-instance').click(function () {
308
353
  //When search button is clicked
309
354
  $('#instance-search-sid').val('');
310
355
  $('#instance-search-pid').val('');
311
356
  $('#instance-search-ins').val('');
312
- if (level === 'rid') {
357
+ if (useRid) {
313
358
  $('#instance-search-rid').val('');
314
359
  }
315
360
  $('#node-lookup-instance').addClass('disabled');
@@ -324,7 +369,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
324
369
  $('#instance-search-ins').val('');
325
370
  searchObject.pid = '';
326
371
  searchObject.ins = '';
327
- if (level === 'rid') {
372
+ if (useRid) {
328
373
  searchObject.rid = '';
329
374
  }
330
375
  searchObject.objects = [];
@@ -336,7 +381,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
336
381
 
337
382
  searchObject.ins = '';
338
383
 
339
- if (level === 'rid') {
384
+ if (useRid) {
340
385
  $('#instance-search-rid').val('');
341
386
  searchObject.rid = '';
342
387
  }
@@ -346,7 +391,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
346
391
  });
347
392
  $('#instance-search-ins').click(function () {
348
393
  //INS field clicked
349
- if (level === 'rid') {
394
+ if (useRid) {
350
395
  $('#instance-search-rid').val('');
351
396
  searchObject.rid = '';
352
397
  }
@@ -355,7 +400,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
355
400
  }
356
401
  });
357
402
 
358
- if (level === 'rid') {
403
+ if (useRid) {
359
404
  $('#instance-search-rid').click(function () {
360
405
  //RID clicked
361
406
  if (
@@ -389,7 +434,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
389
434
  $('#instance-search-sid').val('');
390
435
  $('#instance-search-pid').val('');
391
436
  $('#instance-search-ins').val('');
392
- if (level === 'rid') {
437
+ if (useRid) {
393
438
  $('#instance-search-rid').val('');
394
439
  }
395
440
  });
@@ -405,7 +450,7 @@ function getMobsearch(mobiusSrvc, level, listed, fieldName, list, updateList, gl
405
450
  searchObject.ins = $('#instance-search-ins').val();
406
451
  acceptCheck();
407
452
  });
408
- if (level === 'rid') {
453
+ if (useRid) {
409
454
  $('#instance-search-rid').change(function () {
410
455
  searchObject.rid = $('#instance-search-rid').val();
411
456
  acceptCheck();
@@ -87,7 +87,6 @@ POSSIBILITY OF SUCH DAMAGE.
87
87
  }
88
88
 
89
89
  let mobiusSrvc = $("#node-input-connection").val();
90
- let globalIndex = 0;
91
90
 
92
91
  /** Create the subs container and populate it */
93
92
  $('#node-input-resources-container').css('min-height', '300px').css('min-width', '450px').editableList ({
@@ -121,23 +120,10 @@ POSSIBILITY OF SUCH DAMAGE.
121
120
  // resizeResource(container);
122
121
 
123
122
  // *** MOBSEARCH *** //
124
-
125
123
  if (!node.resources[i]) {
126
124
  node.resources[i] = {uri: '', comment: ''}
127
125
  }
128
-
129
- searchField.click(function () {
130
- globalIndex = i;
131
- $('#node-input-resources-container-row').hide();
132
- $("#instance-search-sid").val('');
133
- $("#instance-search-pid").val('');
134
- $("#instance-search-ins").val('');
135
- $("#instance-search-rid").val('');
136
- $("#node-search-return").removeClass('disabled');
137
- $("#node-search-accept").removeClass('disabled');
138
- $("#instance-search-row").show();
139
-
140
- });
126
+ addSearchButton(searchField, i)
141
127
  // *** END MOBSEARCH *** //
142
128
  },
143
129
  resizeItem: resizeResource
@@ -150,21 +136,13 @@ POSSIBILITY OF SUCH DAMAGE.
150
136
 
151
137
  // *** MOBSEARCH *** //
152
138
 
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)
139
+ opts = {
140
+ list: node.resources,
141
+ containerRowName: 'node-input-resources-container-row',
142
+ containerName: 'node-input-resources-container',
143
+ containerSecondFieldName: 'node-input-resources-comment',
144
+ };
145
+ initMobsearch.toRidListed(mobiusSrvc, opts);
168
146
 
169
147
  // *** END MOBSEARCH *** //
170
148
 
@@ -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.61",
4
4
  "description": "Node-RED base nodes for Mobius Flow",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",