@eclipse-scout/core 11.0.39 → 11.0.41

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.
package/dist/file-list CHANGED
@@ -1,5 +1,5 @@
1
- eclipse-scout-core-f163f6353181b30b315f.min.js
2
- eclipse-scout-core-f163f6353181b30b315f.min.js.map
1
+ eclipse-scout-core-f05c37a693e6abaa57dc.min.js
2
+ eclipse-scout-core-f05c37a693e6abaa57dc.min.js.map
3
3
  eclipse-scout-core-theme-d1dee22d4f9b9233a432.min.css
4
4
  eclipse-scout-core-theme-dark-7ead007f849a9c1a6ec1.min.css
5
5
  eclipse-scout-core-theme-dark.css
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-scout/core",
3
- "version": "11.0.39",
3
+ "version": "11.0.41",
4
4
  "description": "Eclipse Scout runtime",
5
5
  "author": "BSI Business Systems Integration AG",
6
6
  "homepage": "https://www.eclipse.org/scout",
@@ -40,7 +40,7 @@
40
40
  "release-postdependency": "releng-scripts release-publish-dependency"
41
41
  },
42
42
  "devDependencies": {
43
- "@eclipse-scout/cli": "11.0.39",
43
+ "@eclipse-scout/cli": "11.0.41",
44
44
  "@eclipse-scout/releng": "^10.0.0",
45
45
  "jasmine-core": "3.6.0",
46
46
  "jasmine-ajax": "4.0.0",
@@ -8,9 +8,38 @@
8
8
  * Contributors:
9
9
  * BSI Business Systems Integration AG - initial API and implementation
10
10
  */
11
- import {arrays, LookupCall, scout} from '../index';
11
+ import {arrays, LookupCall, objects, scout} from '../index';
12
12
  import $ from 'jquery';
13
13
 
14
+ /**
15
+ * A lookup call that can load lookup rows from a REST service.
16
+ *
17
+ * API:
18
+ * ----
19
+ * By default, the REST service is expected to listen for POST requests at the URL defined by
20
+ * this.resourceUrl. It receives a restriction object and must return a list of matching lookup rows.
21
+ * The serialization format is JSON.
22
+ *
23
+ * Lookup rows:
24
+ * ------------
25
+ * The standard lookup row properties defined by Scout are usually sufficient (see AbstractLookupRowDo.java).
26
+ *
27
+ * Restriction:
28
+ * ------------
29
+ * The restriction object consists of a number of 'well-known' properties (e.g. 'text' in QueryBy.TEXT
30
+ * mode, see AbstractLookupRestrictionDo.java for details) and additional, service-dependent properties
31
+ * that can either be predefined in the model or added programmatically at runtime. Since all of those
32
+ * properties are sent in the same restriction object, some care must be taken to prevent accidental
33
+ * overwriting of properties.
34
+ *
35
+ * Order of precedence (lowest to highest):
36
+ * 1. Restrictions automatically applied to all clones after their creation in the respective cloneFor method.
37
+ * These are: 'active' (ALL, TEXT, REC) and 'maxRowCount' (ALL, TEXT, REC)
38
+ * 2. Restrictions predefined in the model property 'restriction', shared by all clones.
39
+ * 3. Restrictions applied to clones programmatically, e.g. during a 'prepareLookupCall' event.
40
+ * 4. Hard-coded properties that are fundamental to the respective queryBy mode (cannot be overridden).
41
+ * These are: 'ids' (KEY, KEYS) and 'text' (TEXT)
42
+ */
14
43
  export default class RestLookupCall extends LookupCall {
15
44
 
16
45
  constructor() {
@@ -42,6 +71,17 @@ export default class RestLookupCall extends LookupCall {
42
71
  this._restriction[key] = value;
43
72
  }
44
73
 
74
+ /**
75
+ * Adds the given key-value pair to 'this._restriction', but only if there is no predefined
76
+ * value for this key in 'this.restriction'. This prevents unintentional overriding of
77
+ * user-defined model restrictions.
78
+ */
79
+ _addRestrictionIfAbsent(key, value) {
80
+ if (!this.restriction || objects.isNullOrUndefined(this.restriction[key])) {
81
+ this.addRestriction(key, value);
82
+ }
83
+ }
84
+
45
85
  _getAll() {
46
86
  return this._call();
47
87
  }
@@ -63,22 +103,22 @@ export default class RestLookupCall extends LookupCall {
63
103
 
64
104
  cloneForAll() {
65
105
  let clone = super.cloneForAll();
66
- clone.addRestriction('active', true);
67
- clone.addRestriction('maxRowCount', this.maxRowCount);
106
+ clone._addRestrictionIfAbsent('active', true);
107
+ clone._addRestrictionIfAbsent('maxRowCount', this.maxRowCount);
68
108
  return clone;
69
109
  }
70
110
 
71
111
  cloneForText(text) {
72
112
  let clone = super.cloneForText(text);
73
- clone.addRestriction('active', true);
74
- clone.addRestriction('maxRowCount', this.maxRowCount);
113
+ clone._addRestrictionIfAbsent('active', true);
114
+ clone._addRestrictionIfAbsent('maxRowCount', this.maxRowCount);
75
115
  return clone;
76
116
  }
77
117
 
78
118
  cloneForRec(parentKey) {
79
119
  let clone = super.cloneForRec(parentKey);
80
- clone.addRestriction('active', true);
81
- clone.addRestriction('maxRowCount', this.maxRowCount);
120
+ clone._addRestrictionIfAbsent('active', true);
121
+ clone._addRestrictionIfAbsent('maxRowCount', this.maxRowCount);
82
122
  return clone;
83
123
  }
84
124
 
@@ -167,7 +207,7 @@ export default class RestLookupCall extends LookupCall {
167
207
  return value;
168
208
  };
169
209
 
170
- let newRestrictions = {};
210
+ let resolvedRestriction = {};
171
211
  let restriction = $.extend({}, this.restriction, this._restriction);
172
212
  Object.keys(restriction).forEach(key => {
173
213
  let value = restriction[key];
@@ -180,11 +220,11 @@ export default class RestLookupCall extends LookupCall {
180
220
  newValue = resolveValue(value);
181
221
  }
182
222
  // Only add non-null restrictions
183
- if (newValue) {
184
- newRestrictions[key] = newValue;
223
+ if (!objects.isNullOrUndefined(newValue)) {
224
+ resolvedRestriction[key] = newValue;
185
225
  }
186
226
  });
187
- return newRestrictions;
227
+ return resolvedRestriction;
188
228
  }
189
229
 
190
230
  _createAjaxCall() {