@colijnit/corecomponents_v12 258.1.4 → 258.1.5

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.
@@ -14987,8 +14987,19 @@
14987
14987
 
14988
14988
  var HourSchedulingExpandableTemplateComponent = /** @class */ (function () {
14989
14989
  function HourSchedulingExpandableTemplateComponent() {
14990
- this.objects = [];
14990
+ this.layouts = [];
14991
14991
  }
14992
+ Object.defineProperty(HourSchedulingExpandableTemplateComponent.prototype, "objects", {
14993
+ get: function () {
14994
+ return this._objects;
14995
+ },
14996
+ set: function (objects) {
14997
+ this._objects = objects;
14998
+ this.layouts = this.calculateLeftAndWidthOfObjects();
14999
+ },
15000
+ enumerable: false,
15001
+ configurable: true
15002
+ });
14992
15003
  HourSchedulingExpandableTemplateComponent.prototype.showClass = function () {
14993
15004
  return true;
14994
15005
  };
@@ -14996,28 +15007,53 @@
14996
15007
  onDragStartCustom === null || onDragStartCustom === void 0 ? void 0 : onDragStartCustom.call(obj);
14997
15008
  event.dataTransfer.setData("text", JSON.stringify({ obj: obj }));
14998
15009
  };
14999
- HourSchedulingExpandableTemplateComponent.prototype.leftForObject = function (index, objects) {
15000
- if (index === 0) {
15001
- return 0;
15002
- }
15003
- else {
15004
- return index * this.widthForObject(index, objects);
15005
- }
15006
- };
15007
- HourSchedulingExpandableTemplateComponent.prototype.widthForObject = function (index, objects) {
15008
- if (objects.length > 1) {
15009
- return 100 / objects.length;
15010
- }
15011
- if (objects.length === 1) {
15012
- return 100;
15013
- }
15010
+ HourSchedulingExpandableTemplateComponent.prototype.calculateLeftAndWidthOfObjects = function () {
15011
+ var layoutData = new Array(this._objects.length);
15012
+ // Helper: check if two time ranges overlap
15013
+ var isOverlapping = function (startA, endA, startB, endB) {
15014
+ return startA < endB && startB < endA;
15015
+ };
15016
+ // Step 1: build overlap groups
15017
+ var overlapGroups = [];
15018
+ var processed = new Set();
15019
+ for (var i = 0; i < this._objects.length; i++) {
15020
+ if (processed.has(i))
15021
+ continue;
15022
+ var group = [i];
15023
+ var objA = this._objects[i];
15024
+ var startA = new Date(objA.start);
15025
+ var endA = new Date(objA.end);
15026
+ for (var j = i + 1; j < this._objects.length; j++) {
15027
+ var objB = this._objects[j];
15028
+ var startB = new Date(objB.start);
15029
+ var endB = new Date(objB.end);
15030
+ if (isOverlapping(startA, endA, startB, endB)) {
15031
+ group.push(j);
15032
+ processed.add(j);
15033
+ }
15034
+ }
15035
+ group.forEach(function (index) { return processed.add(index); });
15036
+ overlapGroups.push(group);
15037
+ }
15038
+ // Step 2: assign layout per group
15039
+ overlapGroups.forEach(function (group) {
15040
+ var total = group.length;
15041
+ var width = 100 / total;
15042
+ group.forEach(function (objectIndex, i) {
15043
+ layoutData[objectIndex] = {
15044
+ leftPercent: i * width,
15045
+ widthPercent: width
15046
+ };
15047
+ });
15048
+ });
15049
+ return layoutData;
15014
15050
  };
15015
15051
  return HourSchedulingExpandableTemplateComponent;
15016
15052
  }());
15017
15053
  HourSchedulingExpandableTemplateComponent.decorators = [
15018
15054
  { type: i0.Component, args: [{
15019
15055
  selector: "co-hour-scheduling-expandable-template",
15020
- template: "\n <div class=\"row\">\n <div\n *ngFor=\"let obj of objects\"\n [class]=\"'custom-scheduled-object'\"\n [class.selected]=\"obj['selected']\"\n [draggable]=\"!obj['selected']\"\n [style.--height]=\"obj['height'] + 'px'\"\n [style.--top]=\"obj['top'] + 'px'\"\n [style.--left]=\"leftForObject(objects.indexOf(obj), objects) + '%'\"\n [style.--width]=\"widthForObject(objects.indexOf(obj), objects) + '%'\"\n (click)=\"onSelectBlock(obj)\"\n (dragstart)=\"onExpandableDragStart($event, obj, onDragStartCustom(obj) )\">\n\n <div\n *ngIf=\"obj['selected']\"\n class=\"top-resizer\"\n (mousedown)=\"onResizeStart($event, obj, 'top')\"></div>\n <ng-template\n [ngTemplateOutlet]=\"objectTemplate\"\n [ngTemplateOutletContext]=\"{\n object: obj\n }\"\n >\n </ng-template>\n <div *ngIf=\"obj['selected']\"\n class=\"bottom-resizer\"\n (mousedown)=\"onResizeStart($event, obj, 'bottom')\"></div>\n </div>\n </div>\n ",
15056
+ template: "\n \n <div\n *ngFor=\"let obj of objects\"\n [class]=\"'custom-scheduled-object'\"\n [class.selected]=\"obj.selected\"\n [draggable]=\"!obj.selected\"\n [style.--height]=\"obj.height + 'px'\"\n [style.--top]=\"obj.top + 'px'\"\n [style.--left]=\"layouts[objects.indexOf(obj)].leftPercent + '%'\"\n [style.--width]=\"layouts[objects.indexOf(obj)].widthPercent + '%'\"\n (click)=\"onSelectBlock(obj)\"\n (dragstart)=\"onExpandableDragStart($event, obj, onDragStartCustom(obj) )\">\n\n <div\n *ngIf=\"obj.selected\"\n class=\"top-resizer\"\n (mousedown)=\"onResizeStart($event, obj, 'top')\"></div>\n <ng-template\n [ngTemplateOutlet]=\"objectTemplate\"\n [ngTemplateOutletContext]=\"{\n object: obj\n }\"\n >\n </ng-template>\n <div *ngIf=\"obj.selected\"\n class=\"bottom-resizer\"\n (mousedown)=\"onResizeStart($event, obj, 'bottom')\"></div>\n </div>\n ",
15021
15057
  encapsulation: i0.ViewEncapsulation.None
15022
15058
  },] }
15023
15059
  ];
@@ -15027,6 +15063,8 @@
15027
15063
  onDragStartCustom: [{ type: i0.Input }],
15028
15064
  onResizeStart: [{ type: i0.Input }],
15029
15065
  onSelectBlock: [{ type: i0.Input }],
15066
+ startTimeProp: [{ type: i0.Input }],
15067
+ endTimeProp: [{ type: i0.Input }],
15030
15068
  showClass: [{ type: i0.HostBinding, args: ["class.co-hour-scheduling-expandable-template",] }]
15031
15069
  };
15032
15070