@eclipse-scout/core 22.0.34 → 22.0.39

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.
@@ -6613,7 +6613,7 @@ class DatePicker extends _index__WEBPACK_IMPORTED_MODULE_0__.Widget {
6613
6613
  this.selectedDate = null;
6614
6614
  this.dateFormat = null;
6615
6615
  this.viewDate = null;
6616
- this.allowedDates = null;
6616
+ this.allowedDates = [];
6617
6617
  this.currentMonth = null;
6618
6618
  this.$scrollable = null;
6619
6619
  // Contains the months to be rendered.
@@ -6901,7 +6901,7 @@ class DatePicker extends _index__WEBPACK_IMPORTED_MODULE_0__.Widget {
6901
6901
  shiftSelectedDate(years, months, days) {
6902
6902
  let date = this.preselectedDate;
6903
6903
  if (this.selectedDate) {
6904
- if (this.allowedDates) {
6904
+ if (this.allowedDates.length > 0) {
6905
6905
  date = this._findNextAllowedDate(years, months, days);
6906
6906
  } else {
6907
6907
  date = _index__WEBPACK_IMPORTED_MODULE_0__.dates.shift(this.selectedDate, years, months, days);
@@ -6948,16 +6948,12 @@ class DatePicker extends _index__WEBPACK_IMPORTED_MODULE_0__.Widget {
6948
6948
  }
6949
6949
  _isDateAllowed(date) {
6950
6950
  // when allowedDates is empty or not set, any date is allowed
6951
- if (!this.allowedDates || this.allowedDates.length === 0) {
6951
+ if (this.allowedDates.length === 0) {
6952
6952
  return true;
6953
6953
  }
6954
6954
  // when allowedDates is set, only dates contained in this array are allowed
6955
- let allowedDateAsTimestamp,
6956
- dateAsTimestamp = date.getTime();
6957
- return this.allowedDates.some(allowedDate => {
6958
- allowedDateAsTimestamp = allowedDate.getTime();
6959
- return allowedDateAsTimestamp === dateAsTimestamp;
6960
- });
6955
+ let dateAsTimestamp = _index__WEBPACK_IMPORTED_MODULE_0__.dates.trunc(date).getTime();
6956
+ return this.allowedDates.some(allowedDate => allowedDate.getTime() === dateAsTimestamp);
6961
6957
  }
6962
6958
  _build$DateBox(viewDate) {
6963
6959
  let cl,
@@ -28477,6 +28473,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
28477
28473
  class DateField extends _index__WEBPACK_IMPORTED_MODULE_0__.ValueField {
28478
28474
  constructor() {
28479
28475
  super();
28476
+ this.allowedDates = [];
28480
28477
  this.popup = null;
28481
28478
  this.autoDate = null;
28482
28479
  this.dateDisplayText = null;
@@ -28833,12 +28830,23 @@ class DateField extends _index__WEBPACK_IMPORTED_MODULE_0__.ValueField {
28833
28830
  if (!(value instanceof Date)) {
28834
28831
  throw this.session.text(this.invalidValueMessageKey);
28835
28832
  }
28833
+ if (!this.isDateAllowed(value)) {
28834
+ throw this.session.text('DateIsNotAllowed');
28835
+ }
28836
28836
  if (!this.hasDate && !this.value) {
28837
28837
  // truncate to 01.01.1970 if no date was entered before. Otherwise preserve date part (important for toggling hasDate on the fly)
28838
28838
  value = _index__WEBPACK_IMPORTED_MODULE_0__.dates.combineDateTime(null, value);
28839
28839
  }
28840
28840
  return value;
28841
28841
  }
28842
+ isDateAllowed(date) {
28843
+ if (!date || this.allowedDates.length === 0 || this.embedded) {
28844
+ // in embedded mode, main date field must take care of validation, otherwise error status won't be shown
28845
+ return true;
28846
+ }
28847
+ let dateAsTimestamp = _index__WEBPACK_IMPORTED_MODULE_0__.dates.trunc(date).getTime();
28848
+ return this.allowedDates.some(allowedDate => allowedDate.getTime() === dateAsTimestamp);
28849
+ }
28842
28850
  _valueEquals(valueA, valueB) {
28843
28851
  return _index__WEBPACK_IMPORTED_MODULE_0__.dates.equals(valueA, valueB);
28844
28852
  }
@@ -28849,15 +28857,18 @@ class DateField extends _index__WEBPACK_IMPORTED_MODULE_0__.ValueField {
28849
28857
  autoDate = _index__WEBPACK_IMPORTED_MODULE_0__.dates.ensure(autoDate);
28850
28858
  this._setProperty('autoDate', autoDate);
28851
28859
  }
28860
+ setAllowedDates(allowedDates) {
28861
+ this.setProperty('allowedDates', allowedDates);
28862
+ }
28852
28863
  _setAllowedDates(allowedDates) {
28853
- if (Array.isArray(allowedDates)) {
28854
- allowedDates = allowedDates.map(date => {
28855
- return _index__WEBPACK_IMPORTED_MODULE_0__.dates.ensure(date);
28856
- });
28857
- this._setProperty('allowedDates', allowedDates);
28858
- } else {
28859
- this._setProperty('allowedDates', null);
28860
- }
28864
+ let truncDates = [];
28865
+ _index__WEBPACK_IMPORTED_MODULE_0__.arrays.ensure(allowedDates).forEach(date => {
28866
+ if (date) {
28867
+ truncDates.push(_index__WEBPACK_IMPORTED_MODULE_0__.dates.trunc(_index__WEBPACK_IMPORTED_MODULE_0__.dates.ensure(date)));
28868
+ }
28869
+ });
28870
+ truncDates = truncDates.sort(_index__WEBPACK_IMPORTED_MODULE_0__.dates.compare);
28871
+ this._setProperty('allowedDates', truncDates);
28861
28872
  }
28862
28873
 
28863
28874
  /**
@@ -30171,13 +30182,6 @@ class DateFieldAdapter extends _index__WEBPACK_IMPORTED_MODULE_0__.ValueFieldAda
30171
30182
  constructor() {
30172
30183
  super();
30173
30184
  }
30174
- /**
30175
- * @override
30176
- */
30177
- _initProperties(model) {
30178
- super._initProperties(model);
30179
- }
30180
-
30181
30185
  /**
30182
30186
  * @override
30183
30187
  */
@@ -30215,8 +30219,22 @@ class DateFieldAdapter extends _index__WEBPACK_IMPORTED_MODULE_0__.ValueFieldAda
30215
30219
  _orderPropertyNamesOnSync(newProperties) {
30216
30220
  return Object.keys(newProperties).sort(this._createPropertySortFunc(DateFieldAdapter.PROPERTIES_ORDER));
30217
30221
  }
30222
+ static isDateAllowedRemote(date) {
30223
+ if (!this.modelAdapter) {
30224
+ return this.isDateAllowedOrig(date);
30225
+ }
30226
+ // Server will take care of it
30227
+ return true;
30228
+ }
30229
+ static modifyPrototype() {
30230
+ if (!_index__WEBPACK_IMPORTED_MODULE_0__.App.get().remote) {
30231
+ return;
30232
+ }
30233
+ _index__WEBPACK_IMPORTED_MODULE_0__.objects.replacePrototypeFunction(_index__WEBPACK_IMPORTED_MODULE_0__.DateField, 'isDateAllowed', DateFieldAdapter.isDateAllowedRemote, true);
30234
+ }
30218
30235
  }
30219
30236
  _defineProperty(DateFieldAdapter, "PROPERTIES_ORDER", ['hasTime', 'hasDate']);
30237
+ _index__WEBPACK_IMPORTED_MODULE_0__.App.addListener('bootstrap', DateFieldAdapter.modifyPrototype);
30220
30238
 
30221
30239
  /***/ }),
30222
30240
 
@@ -44681,6 +44699,7 @@ __webpack_require__.r(__webpack_exports__);
44681
44699
  * @property {object} parent
44682
44700
  * @property {object} owner
44683
44701
  * @property {object} displayParent
44702
+ * @property {string} displayHint
44684
44703
  * @property {object} inputData
44685
44704
  * @property {string} jsFormObjectType
44686
44705
  * @property {object} jsFormModel
@@ -44704,6 +44723,7 @@ class JsFormAdapter extends _index__WEBPACK_IMPORTED_MODULE_0__.FormAdapter {
44704
44723
  owner: model.owner,
44705
44724
  objectType: model.jsFormObjectType,
44706
44725
  displayParent: model.displayParent,
44726
+ displayHint: model.displayHint,
44707
44727
  data: model.inputData
44708
44728
  };
44709
44729
  if (model.jsFormModel) {
@@ -59190,11 +59210,32 @@ class StaticLookupCall extends _index__WEBPACK_IMPORTED_MODULE_0__.LookupCall {
59190
59210
  });
59191
59211
  }
59192
59212
  _lookupRowsByText(text) {
59193
- let datas = this.data.filter(data => {
59194
- return _index__WEBPACK_IMPORTED_MODULE_0__.strings.startsWith(data[1].toLowerCase(), text.toLowerCase());
59195
- });
59213
+ let regex = this._createSearchPattern(text);
59214
+ let datas = this.data.filter(data => regex.test(data[1].toLowerCase()));
59196
59215
  return datas.map(this._dataToLookupRow, this).filter(this._filterActiveLookupRow, this);
59197
59216
  }
59217
+ _createSearchPattern(text) {
59218
+ // Implementation copied from LocalLookupRow.java
59219
+
59220
+ const WILDCARD = '*';
59221
+ const WILDCARD_PLACEHOLDER = '@wildcard@';
59222
+ text = _index__WEBPACK_IMPORTED_MODULE_0__.strings.nvl(text);
59223
+ text = text.toLowerCase();
59224
+ text = text.replace(new RegExp(_index__WEBPACK_IMPORTED_MODULE_0__.strings.quote(WILDCARD), 'g'), WILDCARD_PLACEHOLDER);
59225
+ text = _index__WEBPACK_IMPORTED_MODULE_0__.strings.quote(text);
59226
+
59227
+ // replace repeating wildcards to prevent regex DoS
59228
+ let duplicateWildcards = WILDCARD_PLACEHOLDER + WILDCARD_PLACEHOLDER;
59229
+ while (_index__WEBPACK_IMPORTED_MODULE_0__.strings.contains(text, duplicateWildcards)) {
59230
+ text = text.replace(duplicateWildcards, WILDCARD_PLACEHOLDER);
59231
+ }
59232
+ if (!_index__WEBPACK_IMPORTED_MODULE_0__.strings.endsWith(WILDCARD_PLACEHOLDER)) {
59233
+ text += WILDCARD_PLACEHOLDER;
59234
+ }
59235
+ text = text.replace(new RegExp(_index__WEBPACK_IMPORTED_MODULE_0__.strings.quote(WILDCARD_PLACEHOLDER), 'g'), '.*');
59236
+ return new RegExp('^' + text + '$', 's'); // s = DOT_ALL
59237
+ }
59238
+
59198
59239
  _getByKey(key) {
59199
59240
  let deferred = jquery__WEBPACK_IMPORTED_MODULE_1___default().Deferred();
59200
59241
  setTimeout(this._queryByKey.bind(this, deferred, key), this.delay);
@@ -96663,6 +96704,7 @@ class TileGrid extends _index__WEBPACK_IMPORTED_MODULE_0__.Widget {
96663
96704
  this.virtual = false;
96664
96705
  this.virtualScrolling = null;
96665
96706
  this.withPlaceholders = false;
96707
+ this.placeholderProducer = null;
96666
96708
  this.$filterFieldContainer = null;
96667
96709
  this.textFilterEnabled = false;
96668
96710
  this.filterSupport = this._createFilterSupport();
@@ -97151,6 +97193,9 @@ class TileGrid extends _index__WEBPACK_IMPORTED_MODULE_0__.Widget {
97151
97193
  _renderWithPlaceholders() {
97152
97194
  this.invalidateLayoutTree();
97153
97195
  }
97196
+ setPlaceholderProducer(placeholderProducer) {
97197
+ this.setProperty('placeholderProducer', placeholderProducer);
97198
+ }
97154
97199
  fillUpWithPlaceholders() {
97155
97200
  if (!this.withPlaceholders) {
97156
97201
  this._deleteAllPlaceholders();
@@ -97163,9 +97208,7 @@ class TileGrid extends _index__WEBPACK_IMPORTED_MODULE_0__.Widget {
97163
97208
  if (!this.withPlaceholders) {
97164
97209
  return this.tiles;
97165
97210
  }
97166
- return this.tiles.filter(tile => {
97167
- return !(tile instanceof _index__WEBPACK_IMPORTED_MODULE_0__.PlaceholderTile);
97168
- });
97211
+ return this.tiles.filter(tile => !(tile instanceof _index__WEBPACK_IMPORTED_MODULE_0__.PlaceholderTile));
97169
97212
  }
97170
97213
  _createPlaceholders() {
97171
97214
  let numPlaceholders,
@@ -97193,9 +97236,17 @@ class TileGrid extends _index__WEBPACK_IMPORTED_MODULE_0__.Widget {
97193
97236
  return placeholders;
97194
97237
  }
97195
97238
  _createPlaceholder() {
97196
- return _index__WEBPACK_IMPORTED_MODULE_0__.scout.create('PlaceholderTile', {
97197
- parent: this
97198
- });
97239
+ let placeholder = this.placeholderProducer && this.placeholderProducer() || {};
97240
+ if (placeholder instanceof _index__WEBPACK_IMPORTED_MODULE_0__.PlaceholderTile) {
97241
+ return placeholder;
97242
+ }
97243
+ if (_index__WEBPACK_IMPORTED_MODULE_0__.objects.isPlainObject(placeholder)) {
97244
+ return _index__WEBPACK_IMPORTED_MODULE_0__.scout.create(jquery__WEBPACK_IMPORTED_MODULE_1___default().extend(true, {}, {
97245
+ objectType: 'PlaceholderTile',
97246
+ parent: this
97247
+ }, placeholder));
97248
+ }
97249
+ throw new Error('Placeholder producer returned unexpected result.');
97199
97250
  }
97200
97251
  _deleteObsoletePlaceholders() {
97201
97252
  let obsoletePlaceholders = [],
@@ -97503,7 +97554,7 @@ class TileGrid extends _index__WEBPACK_IMPORTED_MODULE_0__.Widget {
97503
97554
  this.filterSupport.filter();
97504
97555
  }
97505
97556
  _applyFilters(tiles, fullReset) {
97506
- return this.filterSupport.applyFilters(tiles, fullReset);
97557
+ return this.filterSupport.applyFilters(tiles.filter(tile => !(tile instanceof _index__WEBPACK_IMPORTED_MODULE_0__.PlaceholderTile)), fullReset);
97507
97558
  }
97508
97559
 
97509
97560
  /**
@@ -97513,7 +97564,7 @@ class TileGrid extends _index__WEBPACK_IMPORTED_MODULE_0__.Widget {
97513
97564
  return new _index__WEBPACK_IMPORTED_MODULE_0__.FilterSupport({
97514
97565
  widget: this,
97515
97566
  $container: () => this.$filterFieldContainer,
97516
- getElementsForFiltering: () => this.tiles,
97567
+ getElementsForFiltering: this.tilesWithoutPlaceholders.bind(this),
97517
97568
  createTextFilter: this._createTextFilter.bind(this),
97518
97569
  updateTextFilterText: this._updateTextFilterText.bind(this)
97519
97570
  });
@@ -101063,39 +101114,6 @@ class TimePicker extends _index__WEBPACK_IMPORTED_MODULE_0__.Widget {
101063
101114
  time.setMinutes(min);
101064
101115
  return time;
101065
101116
  }
101066
- _findNextAllowedDate(years, months, days) {
101067
- let i,
101068
- date,
101069
- sum = years + months + days,
101070
- dir = sum > 0 ? 1 : -1,
101071
- now = this.selectedDate || _index__WEBPACK_IMPORTED_MODULE_0__.dates.trunc(new Date());
101072
-
101073
- // if we shift by year or month, shift the 'now' date and then use that date as starting point
101074
- // to find the next allowed date.
101075
- if (years !== 0) {
101076
- now = _index__WEBPACK_IMPORTED_MODULE_0__.dates.shift(now, years, 0, 0);
101077
- } else if (months !== 0) {
101078
- now = _index__WEBPACK_IMPORTED_MODULE_0__.dates.shift(now, 0, months, 0);
101079
- }
101080
- if (dir === 1) {
101081
- // find next allowed date, starting from currently selected date
101082
- for (i = 0; i < this.allowedDates.length; i++) {
101083
- date = this.allowedDates[i];
101084
- if (_index__WEBPACK_IMPORTED_MODULE_0__.dates.compare(now, date) < 0) {
101085
- return date;
101086
- }
101087
- }
101088
- } else if (dir === -1) {
101089
- // find previous allowed date, starting from currently selected date
101090
- for (i = this.allowedDates.length - 1; i >= 0; i--) {
101091
- date = this.allowedDates[i];
101092
- if (_index__WEBPACK_IMPORTED_MODULE_0__.dates.compare(now, date) > 0) {
101093
- return date;
101094
- }
101095
- }
101096
- }
101097
- return null;
101098
- }
101099
101117
  _onNavigationMouseDown(event) {
101100
101118
  let $target = jquery__WEBPACK_IMPORTED_MODULE_1___default()(event.currentTarget);
101101
101119
  let diff = $target.data('shift');