@colijnit/corecomponents_v12 255.1.10 → 255.1.12

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.
@@ -5712,13 +5712,13 @@
5712
5712
  exports.FilterItemMode = void 0;
5713
5713
  (function (FilterItemMode) {
5714
5714
  //This mode makes the Filter display a multi select list
5715
- // Input will be passed along directly as a string with the following syntax: "?>='choice 1', ?<='choice2'"
5715
+ // Input will be passed along directly as a string with the following syntax: "?='choice 1', ?='choice2'"
5716
5716
  FilterItemMode["Filterlist"] = "filterlist";
5717
5717
  //This mode makes the Filter display a single select list
5718
5718
  // Input will be passed along directly as a simple string.
5719
5719
  FilterItemMode["SingleSelectList"] = "singleSelectList";
5720
5720
  //This mode makes the Filter display a multi select list
5721
- // Input will be passed along directly as a simple string.
5721
+ // Input will be passed along directly as a simple collection of strings.
5722
5722
  FilterItemMode["SelectListWithStringCollectionOutput"] = "selectListWithStringCollectionOutput";
5723
5723
  //This mode makes the Filter display a multi select list
5724
5724
  // Available choices will need to have their identifying value be a number. The summation of all these numbers will be passed along.
@@ -8007,7 +8007,7 @@
8007
8007
  InputNumberPickerComponent.decorators = [
8008
8008
  { type: i0.Component, args: [{
8009
8009
  selector: 'co-input-number-picker',
8010
- template: "\n <div class=\"icon-wrapper\" *ngIf=\"leftIconData\">\n <co-icon class=\"input-number-picker-icon\" [iconData]=\"leftIconData\" (click)=\"iconClick.emit($event)\"></co-icon>\n <div class=\"spacer\"></div>\n </div>\n <div class=\"button-wrapper\">\n <co-button *ngIf=\"showButtons\" class=\"minus-operator\" [class.select]=\"minSelected\" tabindex=\"-1\"\n [disabled]=\"readonly\"\n [iconData]=\"iconCacheService.getIcon(minusIcon)\"\n (mousedown)=\"onMinusMouseDown($event)\"\n (mouseup)=\"stopAutoCounting()\" (mouseleave)=\"stopAutoCounting()\"></co-button>\n </div>\n <input type=\"text\"\n [tabIndex]=\"readonly ? -1 : 0\"\n [ngModel]=\"model\"\n [readonly]=\"readonly\"\n [disabled]=\"disabled\"\n [required]=\"required\"\n (ngModelChange)=\"handleChangeModel($event)\"\n (keydown)=\"handleInputKeyDown($event)\"\n (blur)=\"handleBlur()\"/>\n <div class=\"button-wrapper\">\n <co-button *ngIf=\"showButtons\" class=\"plus-operator\" [class.select]=\"plusSelected\" tabindex=\"-1\"\n [disabled]=\"readonly\"\n [iconData]=\"iconCacheService.getIcon(plusIcon)\"\n (mousedown)=\"onPlusMouseDown($event)\"\n (mouseup)=\"stopAutoCounting()\" (mouseleave)=\"stopAutoCounting()\"></co-button>\n </div>\n ",
8010
+ template: "\n <div class=\"icon-wrapper\" *ngIf=\"leftIconData\">\n <co-icon class=\"input-number-picker-icon\" [iconData]=\"leftIconData\" (click)=\"iconClick.emit($event)\"></co-icon>\n <div class=\"spacer\"></div>\n </div>\n <div class=\"button-wrapper\">\n <co-button *ngIf=\"showButtons\" class=\"minus-operator\" [class.select]=\"minSelected\" tabindex=\"-1\"\n [disabled]=\"readonly\"\n [iconData]=\"iconCacheService.getIcon(minusIcon)\"\n (mousedown)=\"onMinusMouseDown($event)\"\n (mouseup)=\"stopAutoCounting()\" (mouseleave)=\"stopAutoCounting()\"></co-button>\n </div>\n <input type=\"text\"\n [tabIndex]=\"readonly ? -1 : 0\"\n [ngModel]=\"model\"\n [readonly]=\"readonly\"\n [disabled]=\"disabled\"\n [required]=\"required\"\n [placeholder]=\"label\"\n (ngModelChange)=\"handleChangeModel($event)\"\n (keydown)=\"handleInputKeyDown($event)\"\n (blur)=\"handleBlur()\"/>\n <div class=\"button-wrapper\">\n <co-button *ngIf=\"showButtons\" class=\"plus-operator\" [class.select]=\"plusSelected\" tabindex=\"-1\"\n [disabled]=\"readonly\"\n [iconData]=\"iconCacheService.getIcon(plusIcon)\"\n (mousedown)=\"onPlusMouseDown($event)\"\n (mouseup)=\"stopAutoCounting()\" (mouseleave)=\"stopAutoCounting()\"></co-button>\n </div>\n ",
8011
8011
  providers: [
8012
8012
  OverlayService, {
8013
8013
  provide: SCREEN_CONFIG_ADAPTER_COMPONENT_INTERFACE_NAME, useExisting: i0.forwardRef(function () { return InputNumberPickerComponent; })
@@ -14117,50 +14117,65 @@
14117
14117
  ];
14118
14118
 
14119
14119
  var HourSchedulingComponent = /** @class */ (function () {
14120
- function HourSchedulingComponent(cdRef, datePipe) {
14120
+ function HourSchedulingComponent(cdRef, datePipe, zone) {
14121
+ var _this = this;
14121
14122
  this.cdRef = cdRef;
14122
14123
  this.datePipe = datePipe;
14123
- this.showClass = true;
14124
- this.hours = [];
14124
+ this.zone = zone;
14125
+ this.hourLabels = [];
14125
14126
  this.scheduledObjects = {};
14127
+ this.activeHour = null;
14128
+ this.activeHalfHour = null;
14126
14129
  this.draggedObject = null;
14127
14130
  this.customTemplateUsed = false;
14128
14131
  this.timeChangeEvent = new i0.EventEmitter();
14132
+ this.newObjectPlanEvent = new i0.EventEmitter();
14133
+ this.showClass = true;
14134
+ document.addEventListener('click', function () { return _this.onDocumentClick; });
14129
14135
  }
14130
14136
  HourSchedulingComponent.prototype.ngOnInit = function () {
14131
- if (!this.childProp) {
14132
- this.startTime = parseInt(this.datePipe.transform(new Date(this.schedule[this.startTimeProp]).toISOString(), 'H:mm'));
14133
- this.endTime = parseInt(this.datePipe.transform(new Date(this.schedule[this.endTimeProp]).toISOString(), 'H:mm'));
14134
- }
14135
- else {
14136
- this.startTime = parseInt(this.datePipe.transform(new Date(this.schedule[this.childProp][this.startTimeProp]).toISOString(), 'H:mm'));
14137
- this.endTime = parseInt(this.datePipe.transform(new Date(this.schedule[this.childProp][this.endTimeProp]).toISOString(), 'H:mm'));
14138
- }
14139
14137
  this.generateTimeBlocks();
14138
+ this.generateScheduledObjects();
14139
+ };
14140
+ HourSchedulingComponent.prototype.ngOnDestroy = function () {
14141
+ var _this = this;
14142
+ document.removeEventListener('click', function () { return _this.onDocumentClick; });
14140
14143
  };
14141
14144
  HourSchedulingComponent.prototype.generateTimeBlocks = function () {
14145
+ var startUnix = !this.childProp ? this.dateToUnixEpoch(new Date(this.schedule[this.startTimeProp])) : this.dateToUnixEpoch(new Date(this.schedule[this.childProp][this.startTimeProp]));
14146
+ var endUnix = !this.childProp ? this.dateToUnixEpoch(new Date(this.schedule[this.endTimeProp])) : this.dateToUnixEpoch(new Date(this.schedule[this.childProp][this.endTimeProp]));
14147
+ var interval = 60 * 60;
14148
+ for (var hourCount = startUnix; hourCount <= endUnix; hourCount += interval) {
14149
+ var hour = new Date(hourCount * 1000);
14150
+ var hourString = hour.getHours() + ":" + (hour.getMinutes() === 0 ? '00' : hour.getMinutes());
14151
+ this.hourLabels.push(hourString);
14152
+ }
14153
+ };
14154
+ HourSchedulingComponent.prototype.generateScheduledObjects = function () {
14142
14155
  var objectsList = this.schedule[this.objectsProp];
14143
- for (var hour = this.startTime; hour <= this.endTime; hour++) {
14144
- this.hours.push(this.formatHour(hour));
14145
- this.scheduledObjects[this.formatHour(hour)] = this._getObjectsForHour(hour, objectsList);
14156
+ var startUnix = !this.childProp ? this.dateToUnixEpoch(new Date(this.schedule[this.startTimeProp])) : this.dateToUnixEpoch(new Date(this.schedule[this.childProp][this.startTimeProp]));
14157
+ var endUnix = !this.childProp ? this.dateToUnixEpoch(new Date(this.schedule[this.endTimeProp])) : this.dateToUnixEpoch(new Date(this.schedule[this.childProp][this.endTimeProp]));
14158
+ var interval = 30 * 60;
14159
+ for (var hourCount = startUnix; hourCount <= endUnix; hourCount += interval) {
14160
+ var hour = new Date(hourCount * 1000);
14161
+ var hourString = hour.getHours() + ":" + (hour.getMinutes() === 0 ? '00' : hour.getMinutes());
14162
+ this.scheduledObjects[hourString] = this._getObjectsForHourAndMinutes(hour.getHours(), hour.getMinutes(), objectsList);
14146
14163
  }
14147
14164
  };
14148
- HourSchedulingComponent.prototype._getObjectsForHour = function (hour, objectsList) {
14165
+ HourSchedulingComponent.prototype._getObjectsForHourAndMinutes = function (hour, minutes, objectsList) {
14149
14166
  var _this = this;
14150
14167
  var objectsForHour = [];
14151
14168
  objectsList.forEach(function (obj) {
14152
- if (_this.convertToHourNotation(obj[_this.startTimeProp]) === hour) {
14169
+ var split = _this.convertToHourNotation(obj[_this.startTimeProp]).split(':');
14170
+ if (parseInt(split[0]) === hour && parseInt(split[1]) === minutes) {
14153
14171
  objectsForHour.push(Object.assign({}, obj));
14154
14172
  }
14155
14173
  });
14156
14174
  return objectsForHour;
14157
14175
  };
14158
- HourSchedulingComponent.prototype.formatHour = function (hour) {
14159
- return hour + ":00";
14160
- };
14161
14176
  HourSchedulingComponent.prototype.onDragStart = function (event, obj) {
14162
14177
  var currentTarget = event.currentTarget;
14163
- var currentHourSpan = currentTarget.parentElement.parentElement.querySelector('.hour-label span');
14178
+ var currentHourSpan = currentTarget.parentElement.parentElement.querySelector('.hidden-hour-label');
14164
14179
  var currentHour = currentHourSpan.textContent;
14165
14180
  this.draggedObject = obj;
14166
14181
  event.dataTransfer.setData('text', JSON.stringify({ obj: this.draggedObject, currentHour: currentHour }));
@@ -14170,32 +14185,50 @@
14170
14185
  };
14171
14186
  HourSchedulingComponent.prototype.onDragOver = function (event) {
14172
14187
  event.preventDefault();
14188
+ event.stopPropagation();
14189
+ this.zone.runOutsideAngular(function () {
14190
+ var currentTarget = event.currentTarget;
14191
+ if (!currentTarget.classList.contains('drag-over')) {
14192
+ currentTarget.classList.add('drag-over');
14193
+ }
14194
+ });
14195
+ };
14196
+ HourSchedulingComponent.prototype.onDragLeave = function (event) {
14197
+ event.preventDefault();
14198
+ event.stopPropagation();
14199
+ this.zone.runOutsideAngular(function () {
14200
+ var currentTarget = event.currentTarget;
14201
+ currentTarget.classList.remove('drag-over');
14202
+ });
14173
14203
  };
14174
14204
  HourSchedulingComponent.prototype.onDrop = function (event, hour) {
14175
- var _a;
14205
+ var _c;
14176
14206
  var _this = this;
14177
14207
  event.preventDefault();
14178
14208
  event.stopPropagation();
14179
- var data = JSON.parse(event.dataTransfer.getData('text'));
14180
- if (!data || !data.obj) {
14209
+ var currentTarget = event.currentTarget;
14210
+ currentTarget.classList.remove('drag-over');
14211
+ var parsed = this.tryParseJSONObject(event.dataTransfer.getData("text"));
14212
+ if (!parsed) {
14213
+ this.newObjectPlanEvent.emit({ currentHour: hour, data: parsed.toString() });
14181
14214
  return;
14182
14215
  }
14183
- var newStartHour = parseInt(hour.split(':')[0], 10);
14184
- var newEndHour = newStartHour + 1;
14185
- var originalStartHour = this.convertToHourNotation(data.obj[this.startTimeProp]);
14216
+ var splitHour = hour.split(':');
14217
+ var newEndMinutes = splitHour[1] === "00" ? 30 : 0;
14218
+ var newEndHour = splitHour[1] === "30" ? (parseInt(splitHour[0]) + 1) : parseInt(splitHour[0]);
14219
+ var originalStartHour = this.convertToHourNotation(parsed.obj[this.startTimeProp]);
14186
14220
  // Get the unique identifier value from the object using the `idProp`
14187
- var objId = data.obj[this.idProp];
14221
+ var objId = parsed.obj[this.idProp];
14188
14222
  // Ensure we create a new object to avoid mutation issues
14189
- var updatedObject = Object.assign(Object.assign({}, data.obj), (_a = {}, _a[this.startTimeProp] = this.createDate(newStartHour), _a[this.endTimeProp] = this.createDate(newEndHour), _a));
14223
+ var updatedObject = Object.assign(Object.assign({}, parsed.obj), (_c = {}, _c[this.startTimeProp] = this.createDate(parseInt(splitHour[0]), parseInt(splitHour[1])), _c[this.endTimeProp] = this.createDate(newEndHour, newEndMinutes), _c));
14190
14224
  // Remove the object from its old hour block using its unique id
14191
- var originalHourBlock = this.formatHour(originalStartHour);
14225
+ var originalHourBlock = this.formatHour(parseInt(originalStartHour.split(':')[0]), parseInt(originalStartHour.split(':')[1]));
14192
14226
  this.scheduledObjects[originalHourBlock] = this.scheduledObjects[originalHourBlock].filter(function (o) { return o[_this.idProp] !== objId; });
14193
14227
  // Add the object to the new hour block
14194
- var newHourBlock = this.formatHour(newStartHour);
14195
- if (!this.scheduledObjects[newHourBlock]) {
14196
- this.scheduledObjects[newHourBlock] = [];
14228
+ if (!this.scheduledObjects[hour]) {
14229
+ this.scheduledObjects[hour] = [];
14197
14230
  }
14198
- this.scheduledObjects[newHourBlock].push(updatedObject);
14231
+ this.scheduledObjects[hour].push(updatedObject);
14199
14232
  // Clear the dragged object
14200
14233
  this.draggedObject = null;
14201
14234
  this.timeChangeEvent.emit(updatedObject);
@@ -14203,26 +14236,75 @@
14203
14236
  this.cdRef.detectChanges();
14204
14237
  };
14205
14238
  HourSchedulingComponent.prototype.convertToHourNotation = function (date) {
14206
- return parseInt(this.datePipe.transform(new Date(date).toISOString(), 'H:mm'));
14239
+ return this.datePipe.transform(new Date(date).toISOString(), 'HH:mm');
14207
14240
  };
14208
- HourSchedulingComponent.prototype.createDate = function (hours) {
14241
+ HourSchedulingComponent.prototype.createDate = function (hours, minutes) {
14209
14242
  var date = new Date();
14210
14243
  date.setHours(hours);
14211
- date.setMinutes(0, 0, 0);
14244
+ date.setMinutes(minutes ? minutes : 0);
14212
14245
  return date;
14213
14246
  };
14247
+ HourSchedulingComponent.prototype.dateToUnixEpoch = function (date) {
14248
+ return Math.floor(date.getTime()) / 1000;
14249
+ };
14250
+ HourSchedulingComponent.prototype.formatHour = function (hour, minutes) {
14251
+ return hour + ":" + (minutes ? minutes : '00');
14252
+ };
14253
+ HourSchedulingComponent.prototype.addMinutes = function (hour) {
14254
+ var split = hour.split(":");
14255
+ split[1] = "30";
14256
+ return split.join(':');
14257
+ };
14258
+ HourSchedulingComponent.prototype.onDocumentClick = function (event) {
14259
+ var targetElement = event.target;
14260
+ // Clear active state when clicking outside
14261
+ if (!targetElement.closest('.object-display')) {
14262
+ this.activeHalfHour = null;
14263
+ this.cdRef.detectChanges();
14264
+ }
14265
+ };
14266
+ HourSchedulingComponent.prototype.onObjectDisplayClick = function (hour, half) {
14267
+ var _a, _b;
14268
+ var halfHourIdentifier = hour + "-" + half;
14269
+ if (this.activeHalfHour === halfHourIdentifier) {
14270
+ // Deactivate if clicked again
14271
+ this.activeHalfHour = null;
14272
+ }
14273
+ else if (((_a = this.scheduledObjects[hour]) === null || _a === void 0 ? void 0 : _a.length) > 0 || ((_b = this.scheduledObjects[this.addMinutes(hour)]) === null || _b === void 0 ? void 0 : _b.length) > 0) {
14274
+ // Activate the half-hour if there are objects
14275
+ this.activeHalfHour = halfHourIdentifier;
14276
+ }
14277
+ };
14278
+ HourSchedulingComponent.prototype.tryParseJSONObject = function (jsonString) {
14279
+ try {
14280
+ var o = JSON.parse(jsonString);
14281
+ // Handle non-exception-throwing cases:
14282
+ // Neither JSON.parse(false) or JSON.parse(1234) throw errors, hence the type-checking,
14283
+ // but... JSON.parse(null) returns null, and typeof null === "object",
14284
+ // so we must check for that, too. Thankfully, null is falsey, so this suffices:
14285
+ if (o && typeof o === "object") {
14286
+ return o;
14287
+ }
14288
+ }
14289
+ catch (e) {
14290
+ }
14291
+ return false;
14292
+ };
14293
+ ;
14214
14294
  return HourSchedulingComponent;
14215
14295
  }());
14216
14296
  HourSchedulingComponent.decorators = [
14217
14297
  { type: i0.Component, args: [{
14218
14298
  selector: 'co-hour-scheduling',
14219
- template: "\n <div class=\"time-block\" *ngFor=\"let hour of hours\">\n <div class=\"hour-label\"><span [textContent]=\"hour\"></span></div>\n <div\n class=\"object-display\"\n (dragover)=\"onDragOver($event)\"\n (drop)=\"onDrop($event, hour)\"\n >\n <ng-container *ngIf=\"!customTemplateUsed\">\n <ng-container *ngIf=\"scheduledObjects[hour]\">\n <div\n *ngFor=\"let obj of scheduledObjects[hour]\"\n class=\"scheduled-object\"\n [draggable]=\"true\"\n (dragstart)=\"onDragStart($event, obj)\"\n >\n <span class=\"title\" [textContent]=\"obj.title\"></span>\n <span class=\"sub-title\" [textContent]=\"obj.subTitle\"></span>\n </div>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"customTemplateUsed\">\n <ng-template\n [ngTemplateOutlet]=\"customTemplate\"\n [ngTemplateOutletContext]=\"{\n hour: hour,\n objects: scheduledObjects[hour]\n }\"\n >\n </ng-template>\n </ng-container>\n </div>\n </div>\n ",
14299
+ template: "\n <div class=\"time-block\" *ngFor=\"let hour of hourLabels\">\n <div class=\"hour-label\"><span [textContent]=\"hour\"></span></div>\n <div class=\"object-display\">\n <div class=\"first-half-hour object-half\"\n [ngClass]=\"{'has-objects': scheduledObjects[hour]?.length > 0, 'active': activeHalfHour === hour + '-firstHalf'}\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (click)=\"onObjectDisplayClick(hour, 'firstHalf')\"\n (drop)=\"onDrop($event, hour)\">\n <ng-container *ngIf=\"!customTemplateUsed\">\n <ng-container *ngIf=\"scheduledObjects[hour]\">\n <span class=\"hidden-hour-label\" [hidden]=\"true\" [textContent]=\"hour\"></span>\n <div\n *ngFor=\"let obj of scheduledObjects[hour]\"\n class=\"scheduled-object\"\n [draggable]=\"true\"\n (dragstart)=\"onDragStart($event, obj)\"\n >\n <span class=\"hidden-hour-label\" [hidden]=\"true\" [textContent]=\"addMinutes(hour)\"></span>\n <span class=\"title\" [textContent]=\"obj.title\"></span>\n <span class=\"sub-title\" [textContent]=\"obj.subTitle\"></span>\n </div>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"customTemplateUsed\">\n <ng-template\n [ngTemplateOutlet]=\"customTemplate\"\n [ngTemplateOutletContext]=\"{\n hour: hour,\n hiddenHour: hour,\n objects: scheduledObjects[hour]\n }\"\n >\n </ng-template>\n </ng-container>\n </div>\n\n <div class=\"second-half-hour object-half\"\n [ngClass]=\"{'has-objects': scheduledObjects[addMinutes(hour)]?.length > 0, 'active': activeHalfHour === hour + '-secondHalf'}\"\n (dragover)=\"onDragOver($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (click)=\"onObjectDisplayClick(hour, 'secondHalf')\"\n (drop)=\"onDrop($event, addMinutes(hour))\">\n <ng-container *ngIf=\"!customTemplateUsed\">\n <ng-container *ngIf=\"scheduledObjects[addMinutes(hour)]\">\n <div\n *ngFor=\"let obj of scheduledObjects[addMinutes(hour)]\"\n class=\"scheduled-object\"\n [draggable]=\"true\"\n (dragstart)=\"onDragStart($event, obj)\"\n >\n <span class=\"title\" [textContent]=\"obj.title\"></span>\n <span class=\"sub-title\" [textContent]=\"obj.subTitle\"></span>\n <span class=\"hidden-hour-label\" [hidden]=\"true\" [textContent]=\"addMinutes(hour)\"></span>\n </div>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"customTemplateUsed\">\n <ng-template\n [ngTemplateOutlet]=\"customTemplate\"\n [ngTemplateOutletContext]=\"{\n hour: hour,\n hiddenHour: addMinutes(hour),\n objects: scheduledObjects[addMinutes(hour)]\n }\"\n >\n </ng-template>\n </ng-container>\n </div>\n\n\n </div>\n </div>\n ",
14300
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
14220
14301
  encapsulation: i0.ViewEncapsulation.None
14221
14302
  },] }
14222
14303
  ];
14223
14304
  HourSchedulingComponent.ctorParameters = function () { return [
14224
14305
  { type: i0.ChangeDetectorRef },
14225
- { type: common.DatePipe }
14306
+ { type: common.DatePipe },
14307
+ { type: i0.NgZone }
14226
14308
  ]; };
14227
14309
  HourSchedulingComponent.propDecorators = {
14228
14310
  schedule: [{ type: i0.Input }],
@@ -14234,7 +14316,8 @@
14234
14316
  customTemplateUsed: [{ type: i0.Input }],
14235
14317
  idProp: [{ type: i0.Input }],
14236
14318
  timeChangeEvent: [{ type: i0.Output }],
14237
- generateTimeBlocks: [{ type: i0.HostBinding, args: ['class.co-hour-scheduling',] }]
14319
+ newObjectPlanEvent: [{ type: i0.Output }],
14320
+ showClass: [{ type: i0.HostBinding, args: ['class.co-hour-scheduling',] }]
14238
14321
  };
14239
14322
 
14240
14323
  var HourSchedulingTestObjectComponent = /** @class */ (function () {