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

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.
@@ -5,22 +5,47 @@ initMobsearch = {
5
5
  toIns: (mobiusSrvc, opts) => {
6
6
  getMobsearch(mobiusSrvc, false, false, opts);
7
7
  },
8
- toRidListed: (mobiusSrvc, opts) => {
8
+ toRid_listed: (mobiusSrvc, opts) => {
9
9
  getMobsearch(mobiusSrvc, true, true, opts);
10
10
  },
11
- toInsListed: (mobiusSrvc, opts) => {
11
+ toIns_listed: (mobiusSrvc, opts) => {
12
12
  getMobsearch(mobiusSrvc, false, true, opts);
13
13
  },
14
14
  };
15
15
 
16
16
  // RID ONLY
17
+ // opts.htmlElementId
17
18
  // opts.uriFieldName
18
19
  // opts.selectionIndex
19
20
  // opts.containerRowName
20
21
  // opts.containerName
21
22
  // opts.containerSecondFieldName
22
23
 
24
+ if (selectionIndex === undefined) {
25
+ let selectionIndex = 0;
26
+ }
27
+
28
+ function addMobsearchListButton(field, i) {
29
+ field.click(function () {
30
+ selectionIndex = i;
31
+ $('#node-input-resources-container-row').hide();
32
+ $('#instance-search-sid').val('');
33
+ $('#instance-search-pid').val('');
34
+ $('#instance-search-ins').val('');
35
+ $('#instance-search-rid').val('');
36
+ $('#node-search-return').removeClass('disabled');
37
+ $('#node-search-accept').removeClass('disabled');
38
+ $('#instance-search-row').show();
39
+ });
40
+ }
41
+
23
42
  function getMobsearch(mobiusSrvc, useRid, listed, opts) {
43
+ selectionIndex = 0;
44
+
45
+ if (useRid) {
46
+ $(`#${opts.uriFieldName}`).val($(`#${opts.uriFieldName}`).val());
47
+ }
48
+
24
49
  //level dependent html
25
50
  let rows =
26
51
  useRid === true
@@ -40,7 +65,7 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
40
65
  let alertMsg = useRid === true ? `and/or RID ` : ``;
41
66
 
42
67
  //Add new html
43
- document.getElementById('mobsearch').innerHTML += `
68
+ document.getElementById(opts.htmlElementId).innerHTML += `
44
69
  <div id="instance-search-row">
45
70
  <div class="form-row">
46
71
  <label for="instance-search-sid"><i class="fa fa-tasks"></i> URI</label>
@@ -248,7 +273,7 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
248
273
  uri = uri.substring(0, uri.indexOf('#') + 1);
249
274
  }
250
275
  if (listed) {
251
- opts.list[opts.selectionIndex].uri = uri;
276
+ opts.list[selectionIndex].uri = uri;
252
277
  updateList();
253
278
  } else {
254
279
  $(`#${opts.uriFieldName}`).val(uri);
@@ -314,14 +339,14 @@ function getMobsearch(mobiusSrvc, useRid, listed, opts) {
314
339
  $(`#${opts.containerName}`)
315
340
  .editableList('items')
316
341
  .each(function (i) {
317
- let resource = $(this);
318
- let comment = resource.find(`.${opts.containerSecondFieldName}`).val();
319
- node.resources[i].comment = comment;
342
+ let item = $(this);
343
+ let secondField = item.find(`.${opts.containerSecondFieldName}`).val();
344
+ opts.list[i][Object.keys(opts.list[i])[1]] = secondField;
320
345
  });
321
346
  $(`#${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);
347
+ for (let i = 0; i < opts.list.length; i++) {
348
+ let item = opts.list[i];
349
+ $(`#${opts.containerName}`).editableList('addItem', item);
325
350
  }
326
351
  $(`#${opts.containerRowName}`).show();
327
352
  }
@@ -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
+ addMobsearchListButton(searchField, i)
141
127
  // *** END MOBSEARCH *** //
142
128
  },
143
129
  resizeItem: resizeResource
@@ -151,12 +137,13 @@ POSSIBILITY OF SUCH DAMAGE.
151
137
  // *** MOBSEARCH *** //
152
138
 
153
139
  opts = {
154
- selectionIndex: globalIndex,
140
+ htmlElementId: 'mobsearch',
141
+ list: node.resources,
155
142
  containerRowName: 'node-input-resources-container-row',
156
143
  containerName: 'node-input-resources-container',
157
144
  containerSecondFieldName: 'node-input-resources-comment',
158
145
  };
159
- initMobsearch.toRidListed(mobiusSrvc, opts);
146
+ initMobsearch.toRid_listed(mobiusSrvc, opts);
160
147
 
161
148
  // *** END MOBSEARCH *** //
162
149
 
@@ -107,6 +107,7 @@ POSSIBILITY OF SUCH DAMAGE.
107
107
  let mobiusSrvc = $("#node-input-connection").val();
108
108
 
109
109
  opts = {
110
+ htmlElementId: 'mobsearch',
110
111
  uriFieldName: 'node-input-instance '
111
112
  };
112
113
  initMobsearch.toIns(mobiusSrvc, opts);
@@ -99,6 +99,7 @@ POSSIBILITY OF SUCH DAMAGE.
99
99
  var node = this;
100
100
  let mobiusSrvc = $("#node-input-connection").val();
101
101
  opts = {
102
+ htmlElementId: 'mobsearch',
102
103
  uriFieldName: 'node-input-resource'
103
104
  };
104
105
  initMobsearch.toRid(mobiusSrvc, opts);
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.59",
3
+ "version": "2.5.86-beta.62",
4
4
  "description": "Node-RED base nodes for Mobius Flow",
5
5
  "main": "index.js",
6
6
  "types": "dist/index.d.ts",