devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
48 lines (47 loc) • 1.54 kB
JavaScript
/**
* DevExtreme (cjs/__internal/scheduler/view_model/generate_view_model/steps/maybe_split.js)
* Version: 25.2.3
* Build date: Fri Dec 12 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.maybeSplit = void 0;
var _split_by_condition = require("./add_collector/split_by_condition");
const mergeByStartDate = (a, b) => {
const result = [];
let i = 0;
let j = 0;
while (i < a.length && j < b.length) {
if (a[i].startDateUTC <= b[j].startDateUTC) {
result.push(a[i]);
i += 1
} else {
result.push(b[j]);
j += 1
}
}
while (i < a.length) {
result.push(a[i]);
i += 1
}
while (j < b.length) {
result.push(b[j]);
j += 1
}
return result
};
const maybeSplit = (entities, shouldSplit, callback) => {
if (shouldSplit) {
const [allDayEntities, regularEntities] = (0, _split_by_condition.splitByCondition)(entities, (entity => entity.isAllDayPanelOccupied));
const allDayPanel = callback(allDayEntities, "allDayPanel");
const regularPanel = callback(regularEntities, "regularPanel");
return mergeByStartDate(allDayPanel, regularPanel)
}
return callback(entities, "regularPanel")
};
exports.maybeSplit = maybeSplit;