@colijnit/corecomponents_v12 255.1.6 → 255.1.7
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/bundles/colijnit-corecomponents_v12.umd.js +55 -18
- package/bundles/colijnit-corecomponents_v12.umd.js.map +1 -1
- package/colijnit-corecomponents_v12.metadata.json +1 -1
- package/esm2015/lib/components/hour-scheduling/hour-scheduling.component.js +76 -29
- package/esm2015/lib/components/hour-scheduling/hour-scheduling.module.js +4 -3
- package/fesm2015/colijnit-corecomponents_v12.js +76 -29
- package/fesm2015/colijnit-corecomponents_v12.js.map +1 -1
- package/lib/components/hour-scheduling/hour-scheduling.component.d.ts +14 -4
- package/package.json +1 -1
|
@@ -14115,8 +14115,9 @@
|
|
|
14115
14115
|
];
|
|
14116
14116
|
|
|
14117
14117
|
var HourSchedulingComponent = /** @class */ (function () {
|
|
14118
|
-
function HourSchedulingComponent(cdRef) {
|
|
14118
|
+
function HourSchedulingComponent(cdRef, _datepipe) {
|
|
14119
14119
|
this.cdRef = cdRef;
|
|
14120
|
+
this._datepipe = _datepipe;
|
|
14120
14121
|
this.showClass = true;
|
|
14121
14122
|
this.customTemplateUsed = false;
|
|
14122
14123
|
this.hours = [];
|
|
@@ -14124,21 +14125,28 @@
|
|
|
14124
14125
|
this.draggedObject = null;
|
|
14125
14126
|
}
|
|
14126
14127
|
HourSchedulingComponent.prototype.ngOnInit = function () {
|
|
14128
|
+
if (!this.childProp) {
|
|
14129
|
+
this.startTime = parseInt(this._datepipe.transform(new Date(this.schedule[this.startTimeProp]).toISOString(), 'H:mm'));
|
|
14130
|
+
this.endTime = parseInt(this._datepipe.transform(new Date(this.schedule[this.endTimeProp]).toISOString(), 'H:mm'));
|
|
14131
|
+
}
|
|
14132
|
+
else {
|
|
14133
|
+
this.startTime = parseInt(this._datepipe.transform(new Date(this.schedule[this.childProp][this.startTimeProp]).toISOString(), 'H:mm'));
|
|
14134
|
+
this.endTime = parseInt(this._datepipe.transform(new Date(this.schedule[this.childProp][this.endTimeProp]).toISOString(), 'H:mm'));
|
|
14135
|
+
}
|
|
14127
14136
|
this.generateTimeBlocks();
|
|
14128
14137
|
};
|
|
14129
14138
|
HourSchedulingComponent.prototype.generateTimeBlocks = function () {
|
|
14130
|
-
var startTime = this.schedule[this.startTimeProp];
|
|
14131
|
-
var endTime = this.schedule[this.endTimeProp];
|
|
14132
14139
|
var objectsList = this.schedule[this.objectsProp];
|
|
14133
|
-
for (var hour = startTime; hour <= endTime; hour++) {
|
|
14140
|
+
for (var hour = this.startTime; hour <= this.endTime; hour++) {
|
|
14134
14141
|
this.hours.push(this.formatHour(hour));
|
|
14135
|
-
this.scheduledObjects[this.formatHour(hour)] = this.
|
|
14142
|
+
this.scheduledObjects[this.formatHour(hour)] = this._getObjectsForHour(hour, objectsList);
|
|
14136
14143
|
}
|
|
14137
14144
|
};
|
|
14138
|
-
HourSchedulingComponent.prototype.
|
|
14145
|
+
HourSchedulingComponent.prototype._getObjectsForHour = function (hour, objectsList) {
|
|
14146
|
+
var _this = this;
|
|
14139
14147
|
var objectsForHour = [];
|
|
14140
14148
|
objectsList.forEach(function (obj) {
|
|
14141
|
-
if (obj.
|
|
14149
|
+
if (_this.convertToHourNotation(obj[_this.startTimeProp]) === hour) {
|
|
14142
14150
|
objectsForHour.push(Object.assign({}, obj));
|
|
14143
14151
|
}
|
|
14144
14152
|
});
|
|
@@ -14152,49 +14160,77 @@
|
|
|
14152
14160
|
var currentHourSpan = currentTarget.parentElement.parentElement.querySelector('.hour-label span');
|
|
14153
14161
|
var currentHour = currentHourSpan.textContent;
|
|
14154
14162
|
this.draggedObject = obj;
|
|
14155
|
-
event.dataTransfer.setData('text', JSON.stringify({ obj:
|
|
14163
|
+
event.dataTransfer.setData('text', JSON.stringify({ obj: this.draggedObject, currentHour: currentHour }));
|
|
14164
|
+
};
|
|
14165
|
+
HourSchedulingComponent.prototype.onCustomDragStart = function (event, obj) {
|
|
14166
|
+
this.onDragStart(event, obj);
|
|
14156
14167
|
};
|
|
14157
14168
|
HourSchedulingComponent.prototype.onDragOver = function (event) {
|
|
14158
14169
|
event.preventDefault();
|
|
14159
14170
|
};
|
|
14160
14171
|
HourSchedulingComponent.prototype.onDrop = function (event, hour) {
|
|
14172
|
+
var _a;
|
|
14161
14173
|
var _this = this;
|
|
14162
14174
|
event.preventDefault();
|
|
14175
|
+
event.stopPropagation();
|
|
14163
14176
|
var data = JSON.parse(event.dataTransfer.getData('text'));
|
|
14177
|
+
if (!data || !data.obj) {
|
|
14178
|
+
return;
|
|
14179
|
+
}
|
|
14164
14180
|
var newStartHour = parseInt(hour.split(':')[0], 10);
|
|
14165
14181
|
var newEndHour = newStartHour + 1;
|
|
14166
|
-
data.obj.
|
|
14167
|
-
|
|
14168
|
-
var
|
|
14169
|
-
|
|
14182
|
+
var originalStartHour = this.convertToHourNotation(data.obj[this.startTimeProp]);
|
|
14183
|
+
// Get the unique identifier value from the object using the `idProp`
|
|
14184
|
+
var objId = data.obj[this.idProp];
|
|
14185
|
+
// Ensure we create a new object to avoid mutation issues
|
|
14186
|
+
var updatedObject = Object.assign(Object.assign({}, data.obj), { start: newStartHour, end: newEndHour });
|
|
14187
|
+
var updatedObject2 = Object.assign(Object.assign({}, data.obj), (_a = {}, _a[this.startTimeProp] = this.createDate(newStartHour), _a[this.endTimeProp] = this.createDate(newEndHour), _a));
|
|
14188
|
+
// Remove the object from its old hour block using its unique id
|
|
14189
|
+
var originalHourBlock = this.formatHour(originalStartHour);
|
|
14190
|
+
this.scheduledObjects[originalHourBlock] = this.scheduledObjects[originalHourBlock].filter(function (o) { return o[_this.idProp] !== objId; });
|
|
14191
|
+
// Add the object to the new hour block
|
|
14170
14192
|
var newHourBlock = this.formatHour(newStartHour);
|
|
14171
14193
|
if (!this.scheduledObjects[newHourBlock]) {
|
|
14172
14194
|
this.scheduledObjects[newHourBlock] = [];
|
|
14173
14195
|
}
|
|
14174
|
-
this.scheduledObjects[newHourBlock].push(
|
|
14196
|
+
this.scheduledObjects[newHourBlock].push(updatedObject2);
|
|
14197
|
+
// Clear the dragged object
|
|
14175
14198
|
this.draggedObject = null;
|
|
14199
|
+
// Trigger change detection to update the view
|
|
14176
14200
|
this.cdRef.detectChanges();
|
|
14177
14201
|
};
|
|
14202
|
+
HourSchedulingComponent.prototype.convertToHourNotation = function (date) {
|
|
14203
|
+
return parseInt(this._datepipe.transform(new Date(date).toISOString(), 'H:mm'));
|
|
14204
|
+
};
|
|
14205
|
+
HourSchedulingComponent.prototype.createDate = function (hours) {
|
|
14206
|
+
var date = new Date();
|
|
14207
|
+
date.setHours(hours);
|
|
14208
|
+
date.setMinutes(0, 0, 0);
|
|
14209
|
+
return date;
|
|
14210
|
+
};
|
|
14178
14211
|
return HourSchedulingComponent;
|
|
14179
14212
|
}());
|
|
14180
14213
|
HourSchedulingComponent.decorators = [
|
|
14181
14214
|
{ type: i0.Component, args: [{
|
|
14182
14215
|
selector: 'co-hour-scheduling',
|
|
14183
|
-
template: "\n <div class=\"time-block\" *ngFor=\"let hour of hours\">\n <div class=\"hour-label\"><span [textContent]=\"hour\"></span></div>\n <div
|
|
14216
|
+
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 ",
|
|
14184
14217
|
encapsulation: i0.ViewEncapsulation.None
|
|
14185
14218
|
},] }
|
|
14186
14219
|
];
|
|
14187
14220
|
HourSchedulingComponent.ctorParameters = function () { return [
|
|
14188
|
-
{ type: i0.ChangeDetectorRef }
|
|
14221
|
+
{ type: i0.ChangeDetectorRef },
|
|
14222
|
+
{ type: common.DatePipe }
|
|
14189
14223
|
]; };
|
|
14190
14224
|
HourSchedulingComponent.propDecorators = {
|
|
14191
|
-
showClass: [{ type: i0.HostBinding, args: ['class.co-hour-scheduling',] }],
|
|
14192
14225
|
schedule: [{ type: i0.Input }],
|
|
14193
14226
|
startTimeProp: [{ type: i0.Input }],
|
|
14194
14227
|
endTimeProp: [{ type: i0.Input }],
|
|
14195
14228
|
objectsProp: [{ type: i0.Input }],
|
|
14229
|
+
childProp: [{ type: i0.Input }],
|
|
14196
14230
|
customTemplate: [{ type: i0.Input }],
|
|
14197
|
-
customTemplateUsed: [{ type: i0.Input }]
|
|
14231
|
+
customTemplateUsed: [{ type: i0.Input }],
|
|
14232
|
+
idProp: [{ type: i0.Input }],
|
|
14233
|
+
generateTimeBlocks: [{ type: i0.HostBinding, args: ['class.co-hour-scheduling',] }]
|
|
14198
14234
|
};
|
|
14199
14235
|
|
|
14200
14236
|
var HourSchedulingTestObjectComponent = /** @class */ (function () {
|
|
@@ -14235,7 +14271,8 @@
|
|
|
14235
14271
|
exports: [
|
|
14236
14272
|
HourSchedulingComponent,
|
|
14237
14273
|
HourSchedulingTestObjectComponent
|
|
14238
|
-
]
|
|
14274
|
+
],
|
|
14275
|
+
providers: [common.DatePipe]
|
|
14239
14276
|
},] }
|
|
14240
14277
|
];
|
|
14241
14278
|
|