Newer
Older
resourceHash: (_a = {},
_a[resourceId] = internalResource,
});
};
ResourceApi.prototype.getParent = function () {
var context = this._context;
var parentId = this._resource.parentId;
if (parentId) {
return new ResourceApi(context, context.getCurrentData().resourceSource[parentId]);
}
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
};
ResourceApi.prototype.getChildren = function () {
var thisResourceId = this._resource.id;
var context = this._context;
var resourceStore = context.getCurrentData().resourceStore;
var childApis = [];
for (var resourceId in resourceStore) {
if (resourceStore[resourceId].parentId === thisResourceId) {
childApis.push(new ResourceApi(context, resourceStore[resourceId]));
}
}
return childApis;
};
/*
this is really inefficient!
TODO: make EventApi::resourceIds a hash or keep an index in the Calendar's state
*/
ResourceApi.prototype.getEvents = function () {
var thisResourceId = this._resource.id;
var context = this._context;
var _a = context.getCurrentData().eventStore, defs = _a.defs, instances = _a.instances;
var eventApis = [];
for (var instanceId in instances) {
var instance = instances[instanceId];
var def = defs[instance.defId];
if (def.resourceIds.indexOf(thisResourceId) !== -1) { // inefficient!!!
eventApis.push(new EventApi(context, def, instance));
}
}
return eventApis;
};
Object.defineProperty(ResourceApi.prototype, "id", {
get: function () { return getPublicId(this._resource.id); },
enumerable: false,
configurable: true
});
Object.defineProperty(ResourceApi.prototype, "title", {
get: function () { return this._resource.title; },
enumerable: false,
configurable: true
});
Object.defineProperty(ResourceApi.prototype, "eventConstraint", {
get: function () { return this._resource.ui.constraints[0] || null; },
enumerable: false,
configurable: true
});
Object.defineProperty(ResourceApi.prototype, "eventOverlap", {
get: function () { return this._resource.ui.overlap; },
enumerable: false,
configurable: true
});
Object.defineProperty(ResourceApi.prototype, "eventAllow", {
get: function () { return this._resource.ui.allows[0] || null; },
enumerable: false,
configurable: true
});
Object.defineProperty(ResourceApi.prototype, "eventBackgroundColor", {
get: function () { return this._resource.ui.backgroundColor; },
enumerable: false,
configurable: true
});
Object.defineProperty(ResourceApi.prototype, "eventBorderColor", {
get: function () { return this._resource.ui.borderColor; },
enumerable: false,
configurable: true
});
Object.defineProperty(ResourceApi.prototype, "eventTextColor", {
get: function () { return this._resource.ui.textColor; },
enumerable: false,
configurable: true
});
Object.defineProperty(ResourceApi.prototype, "eventClassNames", {
// NOTE: user can't modify these because Object.freeze was called in event-def parsing
get: function () { return this._resource.ui.classNames; },
enumerable: false,
configurable: true
});
Object.defineProperty(ResourceApi.prototype, "extendedProps", {
get: function () { return this._resource.extendedProps; },
enumerable: false,
configurable: true
});
ResourceApi.prototype.toPlainObject = function (settings) {
if (settings === void 0) { settings = {}; }
var internal = this._resource;
var ui = internal.ui;
var publicId = this.id;
var res = {};
if (publicId) {
res.id = publicId;
}
if (internal.title) {
res.title = internal.title;
}
if (settings.collapseEventColor && ui.backgroundColor && ui.backgroundColor === ui.borderColor) {
res.eventColor = ui.backgroundColor;
}
else {
if (ui.backgroundColor) {
res.eventBackgroundColor = ui.backgroundColor;
}
if (ui.borderColor) {
res.eventBorderColor = ui.borderColor;
}
}
if (ui.textColor) {
res.eventTextColor = ui.textColor;
}
if (ui.classNames.length) {
res.eventClassNames = ui.classNames;
}
if (Object.keys(internal.extendedProps).length) {
if (settings.collapseExtendedProps) {
__assign(res, internal.extendedProps);
}
else {
res.extendedProps = internal.extendedProps;
}
}
return res;
};
ResourceApi.prototype.toJSON = function () {
return this.toPlainObject();
};
return ResourceApi;
}());
function buildResourceApis(resourceStore, context) {
var resourceApis = [];
for (var resourceId in resourceStore) {
resourceApis.push(new ResourceApi(context, resourceStore[resourceId]));
}
return resourceApis;
}
CalendarApi.prototype.addResource = function (input, scrollTo) {
var _a;
var _this = this;
if (scrollTo === void 0) { scrollTo = true; }
var currentState = this.getCurrentData();
var resourceHash;
var resource;
if (input instanceof ResourceApi) {
resource = input._resource;
resourceHash = (_a = {}, _a[resource.id] = resource, _a);
}
else {
resourceHash = {};
resource = parseResource(input, '', resourceHash, currentState);
}
this.dispatch({
type: 'ADD_RESOURCE',
});
if (scrollTo) {
// TODO: wait til dispatch completes somehow
this.trigger('_scrollRequest', { resourceId: resource.id });
}
var resourceApi = new ResourceApi(currentState, resource);
currentState.emitter.trigger('resourceAdd', {
resource: resourceApi,
revert: function () {
_this.dispatch({
type: 'REMOVE_RESOURCE',
});
return resourceApi;
};
CalendarApi.prototype.getResourceById = function (id) {
id = String(id);
var currentState = this.getCurrentData(); // eslint-disable-line react/no-this-in-sfc
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
if (currentState.resourceStore) { // guard against calendar with no resource functionality
var rawResource = currentState.resourceStore[id];
if (rawResource) {
return new ResourceApi(currentState, rawResource);
}
}
return null;
};
CalendarApi.prototype.getResources = function () {
var currentState = this.getCurrentData();
var resourceStore = currentState.resourceStore;
var resourceApis = [];
if (resourceStore) { // guard against calendar with no resource functionality
for (var resourceId in resourceStore) {
resourceApis.push(new ResourceApi(currentState, resourceStore[resourceId]));
}
}
return resourceApis;
};
CalendarApi.prototype.getTopLevelResources = function () {
var currentState = this.getCurrentData();
var resourceStore = currentState.resourceStore;
var resourceApis = [];
if (resourceStore) { // guard against calendar with no resource functionality
for (var resourceId in resourceStore) {
if (!resourceStore[resourceId].parentId) {
resourceApis.push(new ResourceApi(currentState, resourceStore[resourceId]));
}
}
}
return resourceApis;
};
CalendarApi.prototype.refetchResources = function () {
this.dispatch({
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
});
};
function transformDatePoint(dateSpan, context) {
return dateSpan.resourceId ?
{ resource: context.calendarApi.getResourceById(dateSpan.resourceId) } :
{};
}
function transformDateSpan(dateSpan, context) {
return dateSpan.resourceId ?
{ resource: context.calendarApi.getResourceById(dateSpan.resourceId) } :
{};
}
/*
splits things BASED OFF OF which resources they are associated with.
creates a '' entry which is when something has NO resource.
*/
var ResourceSplitter = /** @class */ (function (_super) {
__extends(ResourceSplitter, _super);
function ResourceSplitter() {
return _super !== null && _super.apply(this, arguments) || this;
}
ResourceSplitter.prototype.getKeyInfo = function (props) {
return __assign({ '': {} }, props.resourceStore);
};
ResourceSplitter.prototype.getKeysForDateSpan = function (dateSpan) {
return [dateSpan.resourceId || ''];
};
ResourceSplitter.prototype.getKeysForEventDef = function (eventDef) {
var resourceIds = eventDef.resourceIds;
if (!resourceIds.length) {
return [''];
}
return resourceIds;
};
return ResourceSplitter;
}(Splitter));
function isPropsValidWithResources(combinedProps, context) {
var splitter = new ResourceSplitter();
var sets = splitter.splitProps(__assign(__assign({}, combinedProps), { resourceStore: context.getCurrentData().resourceStore }));
for (var resourceId in sets) {
// merge in event data from the non-resource segment
if (resourceId && sets['']) { // current segment is not the non-resource one, and there IS a non-resource one
props = __assign(__assign({}, props), { eventStore: mergeEventStores(sets[''].eventStore, props.eventStore), eventUiBases: __assign(__assign({}, sets[''].eventUiBases), props.eventUiBases) });
if (!isPropsValid(props, context, { resourceId: resourceId }, filterConfig.bind(null, resourceId))) {
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
return false;
}
}
return true;
}
function filterConfig(resourceId, config) {
return __assign(__assign({}, config), { constraints: filterConstraints(resourceId, config.constraints) });
}
function filterConstraints(resourceId, constraints) {
return constraints.map(function (constraint) {
var defs = constraint.defs;
if (defs) { // we are dealing with an EventStore
// if any of the events define constraints to resources that are NOT this resource,
// then this resource is unconditionally prohibited, which is what a `false` value does.
for (var defId in defs) {
var resourceIds = defs[defId].resourceIds;
if (resourceIds.length && resourceIds.indexOf(resourceId) === -1) { // TODO: use a hash?!!! (for other reasons too)
return false;
}
}
}
return constraint;
});
}
function transformExternalDef(dateSpan) {
return dateSpan.resourceId ?
{ resourceId: dateSpan.resourceId } :
{};
}
function transformEventResizeJoin(hit0, hit1) {
var component = hit0.component;
if (component.allowAcrossResources === false &&
hit0.dateSpan.resourceId !== hit1.dateSpan.resourceId) {
return false;
}
}
EventApi.prototype.getResources = function () {
var calendarApi = this._context.calendarApi;
return this._def.resourceIds.map(function (resourceId) { return calendarApi.getResourceById(resourceId); });
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
};
EventApi.prototype.setResources = function (resources) {
var resourceIds = [];
// massage resources -> resourceIds
for (var _i = 0, resources_1 = resources; _i < resources_1.length; _i++) {
var resource = resources_1[_i];
var resourceId = null;
if (typeof resource === 'string') {
resourceId = resource;
}
else if (typeof resource === 'number') {
resourceId = String(resource);
}
else if (resource instanceof ResourceApi) {
resourceId = resource.id; // guaranteed to always have an ID. hmmm
}
else {
console.warn('unknown resource type: ' + resource);
}
if (resourceId) {
resourceIds.push(resourceId);
}
}
this.mutate({
standardProps: {
});
};
var optionChangeHandlers = {
};
function handleResources(newSourceInput, context) {
var oldSourceInput = context.getCurrentData().resourceSource._raw;
if (oldSourceInput !== newSourceInput) {
context.dispatch({
type: 'RESET_RESOURCE_SOURCE',
});
}
}
var DEFAULT_RESOURCE_ORDER = parseFieldSpecs('id,title');
function handleResourceStore(resourceStore, calendarData) {
var emitter = calendarData.emitter;
if (emitter.hasHandlers('resourcesSet')) {
emitter.trigger('resourcesSet', buildResourceApis(resourceStore, calendarData));
}
}
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
initialResources: identity,
resources: identity,
eventResourceEditable: Boolean,
refetchResourcesOnNavigate: Boolean,
resourceOrder: parseFieldSpecs,
filterResourcesWithEvents: Boolean,
resourceGroupField: String,
resourceAreaWidth: identity,
resourceAreaColumns: identity,
resourcesInitiallyExpanded: Boolean,
datesAboveResources: Boolean,
needsResourceData: Boolean,
resourceAreaHeaderClassNames: identity,
resourceAreaHeaderContent: identity,
resourceAreaHeaderDidMount: identity,
resourceAreaHeaderWillUnmount: identity,
resourceGroupLabelClassNames: identity,
resourceGroupLabelContent: identity,
resourceGroupLabelDidMount: identity,
resourceGroupLabelWillUnmount: identity,
resourceLabelClassNames: identity,
resourceLabelContent: identity,
resourceLabelDidMount: identity,
resourceLabelWillUnmount: identity,
resourceLaneClassNames: identity,
resourceLaneContent: identity,
resourceLaneDidMount: identity,
resourceLaneWillUnmount: identity,
resourceGroupLaneClassNames: identity,
resourceGroupLaneContent: identity,
resourceGroupLaneDidMount: identity,
resourceGroupLaneWillUnmount: identity,
};
var LISTENER_REFINERS$1 = {
resourcesSet: identity,
resourceAdd: identity,
resourceChange: identity,
};
registerResourceSourceDef({
ignoreRange: true,
parseMeta: function (refined) {
if (Array.isArray(refined.resources)) {
return refined.resources;
}
return null;
},
fetch: function (arg, successCallback) {
successCallback({
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
});
registerResourceSourceDef({
parseMeta: function (refined) {
if (typeof refined.resources === 'function') {
return refined.resources;
}
return null;
},
fetch: function (arg, success, failure) {
var dateEnv = arg.context.dateEnv;
var func = arg.resourceSource.meta;
var publicArg = arg.range ? {
start: dateEnv.toDate(arg.range.start),
end: dateEnv.toDate(arg.range.end),
startStr: dateEnv.formatIso(arg.range.start),
endStr: dateEnv.formatIso(arg.range.end),
} : {};
// TODO: make more dry with EventSourceFunc
// TODO: accept a response?
unpromisify(func.bind(null, publicArg), function (rawResources) {
success({ rawResources: rawResources }); // needs an object response
});
registerResourceSourceDef({
parseMeta: function (refined) {
if (refined.url) {
return {
url: refined.url,
method: (refined.method || 'GET').toUpperCase(),
};
}
return null;
},
fetch: function (arg, successCallback, failureCallback) {
var meta = arg.resourceSource.meta;
var requestParams = buildRequestParams$2(meta, arg.range, arg.context);
requestJson(meta.method, meta.url, requestParams, function (rawResources, xhr) {
successCallback({ rawResources: rawResources, xhr: xhr });
}, function (message, xhr) {
failureCallback({ message: message, xhr: xhr });
});
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
});
// TODO: somehow consolidate with event json feed
function buildRequestParams$2(meta, range, context) {
var dateEnv = context.dateEnv, options = context.options;
var startParam;
var endParam;
var timeZoneParam;
var customRequestParams;
var params = {};
if (range) {
startParam = meta.startParam;
if (startParam == null) {
startParam = options.startParam;
}
endParam = meta.endParam;
if (endParam == null) {
endParam = options.endParam;
}
timeZoneParam = meta.timeZoneParam;
if (timeZoneParam == null) {
timeZoneParam = options.timeZoneParam;
}
params[startParam] = dateEnv.formatIso(range.start);
params[endParam] = dateEnv.formatIso(range.end);
if (dateEnv.timeZone !== 'local') {
params[timeZoneParam] = dateEnv.timeZone;
}
}
// retrieve any outbound GET/POST data from the options
if (typeof meta.extraParams === 'function') {
// supplied as a function that returns a key/value object
customRequestParams = meta.extraParams();
}
else {
// probably supplied as a straight key/value object
customRequestParams = meta.extraParams || {};
}
__assign(params, customRequestParams);
return params;
}
// TODO: not used for Spreadsheet. START USING. difficult because of col-specific rendering props
function ResourceLabelRoot(props) {
return (createElement(ViewContextType.Consumer, null, function (context) {
var options = context.options;
var hookProps = {
resource: new ResourceApi(context, props.resource),
date: props.date ? context.dateEnv.toDate(props.date) : null,
};
var dataAttrs = {
'data-resource-id': props.resource.id,
'data-date': props.date ? formatDayString(props.date) : undefined,
};
return (createElement(RenderHook, { hookProps: hookProps, classNames: options.resourceLabelClassNames, content: options.resourceLabelContent, defaultContent: renderInnerContent$6, didMount: options.resourceLabelDidMount, willUnmount: options.resourceLabelWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return props.children(rootElRef, classNames, // TODO: pass in 'fc-resource' ?
dataAttrs, innerElRef, innerContent); }));
}));
}
function renderInnerContent$6(props) {
return props.resource.title || props.resource.id;
}
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
var ResourceCell = /** @class */ (function (_super) {
__extends(ResourceCell, _super);
function ResourceCell() {
return _super !== null && _super.apply(this, arguments) || this;
}
ResourceCell.prototype.render = function () {
var props = this.props;
return (createElement(ResourceLabelRoot, { resource: props.resource, date: props.date }, function (elRef, customClassNames, dataAttrs, innerElRef, innerContent) { return (createElement("th", __assign({ ref: elRef, className: ['fc-col-header-cell', 'fc-resource'].concat(customClassNames).join(' '), colSpan: props.colSpan }, dataAttrs),
createElement("div", { className: "fc-scrollgrid-sync-inner" },
createElement("span", { className: [
'fc-col-header-cell-cushion',
props.isSticky ? 'fc-sticky' : '',
].join(' '), ref: innerElRef }, innerContent)))); }));
};
return ResourceCell;
}(BaseComponent));
var ResourceDayHeader = /** @class */ (function (_super) {
__extends(ResourceDayHeader, _super);
function ResourceDayHeader() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.buildDateFormat = memoize(buildDateFormat);
return _this;
}
ResourceDayHeader.prototype.render = function () {
var _this = this;
var _a = this, props = _a.props, context = _a.context;
var dateFormat = this.buildDateFormat(context.options.dayHeaderFormat, props.datesRepDistinctDays, props.dates.length);
return (createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) {
if (props.dates.length === 1) {
return _this.renderResourceRow(props.resources, props.dates[0]);
}
if (context.options.datesAboveResources) {
return _this.renderDayAndResourceRows(props.dates, dateFormat, todayRange, props.resources);
return _this.renderResourceAndDayRows(props.resources, props.dates, dateFormat, todayRange);
}));
};
ResourceDayHeader.prototype.renderResourceRow = function (resources, date) {
var resourceCells = resources.map(function (resource) { return (createElement(ResourceCell, { key: resource.id, resource: resource, colSpan: 1, date: date })); });
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
return this.buildTr(resourceCells, 'resources');
};
ResourceDayHeader.prototype.renderDayAndResourceRows = function (dates, dateFormat, todayRange, resources) {
var dateCells = [];
var resourceCells = [];
for (var _i = 0, dates_1 = dates; _i < dates_1.length; _i++) {
var date = dates_1[_i];
dateCells.push(this.renderDateCell(date, dateFormat, todayRange, resources.length, null, true));
for (var _a = 0, resources_1 = resources; _a < resources_1.length; _a++) {
var resource = resources_1[_a];
resourceCells.push(createElement(ResourceCell, { key: resource.id + ':' + date.toISOString(), resource: resource, colSpan: 1, date: date }));
}
}
return (createElement(Fragment, null,
this.buildTr(dateCells, 'day'),
this.buildTr(resourceCells, 'resources')));
};
ResourceDayHeader.prototype.renderResourceAndDayRows = function (resources, dates, dateFormat, todayRange) {
var resourceCells = [];
var dateCells = [];
for (var _i = 0, resources_2 = resources; _i < resources_2.length; _i++) {
var resource = resources_2[_i];
resourceCells.push(createElement(ResourceCell, { key: resource.id, resource: resource, colSpan: dates.length, isSticky: true }));
for (var _a = 0, dates_2 = dates; _a < dates_2.length; _a++) {
var date = dates_2[_a];
dateCells.push(this.renderDateCell(date, dateFormat, todayRange, 1, resource));
}
}
return (createElement(Fragment, null,
this.buildTr(resourceCells, 'resources'),
this.buildTr(dateCells, 'day')));
};
// a cell with date text. might have a resource associated with it
ResourceDayHeader.prototype.renderDateCell = function (date, dateFormat, todayRange, colSpan, resource, isSticky) {
var props = this.props;
var keyPostfix = resource ? ":" + resource.id : '';
var extraHookProps = resource ? { resource: new ResourceApi(this.context, resource) } : {};
var extraDataAttrs = resource ? { 'data-resource-id': resource.id } : {};
return props.datesRepDistinctDays ? (createElement(TableDateCell, { key: date.toISOString() + keyPostfix, date: date, dateProfile: props.dateProfile, todayRange: todayRange, colCnt: props.dates.length * props.resources.length, dayHeaderFormat: dateFormat, colSpan: colSpan, isSticky: isSticky, extraHookProps: extraHookProps, extraDataAttrs: extraDataAttrs })) : (createElement(TableDowCell // we can't leverage the pure-componentness becausae the extra* props are new every time :(
, { key: date.getUTCDay() + keyPostfix, dow: date.getUTCDay(), dayHeaderFormat: dateFormat, colSpan: colSpan, isSticky: isSticky, extraHookProps: extraHookProps, extraDataAttrs: extraDataAttrs }));
};
ResourceDayHeader.prototype.buildTr = function (cells, key) {
var renderIntro = this.props.renderIntro;
if (!cells.length) {
cells = [createElement("td", { key: 0 }, "\u00A0")];
}
return (createElement("tr", { key: key },
cells));
};
return ResourceDayHeader;
}(BaseComponent));
function buildDateFormat(dayHeaderFormat, datesRepDistinctDays, dayCnt) {
return dayHeaderFormat || computeFallbackHeaderFormat(datesRepDistinctDays, dayCnt);
}
var ResourceIndex = /** @class */ (function () {
function ResourceIndex(resources) {
var indicesById = {};
var ids = [];
for (var i = 0; i < resources.length; i += 1) {
var id = resources[i].id;
ids.push(id);
indicesById[id] = i;
}
this.ids = ids;
this.indicesById = indicesById;
this.length = resources.length;
var AbstractResourceDayTableModel = /** @class */ (function () {
function AbstractResourceDayTableModel(dayTableModel, resources, context) {
this.dayTableModel = dayTableModel;
this.resources = resources;
this.context = context;
this.resourceIndex = new ResourceIndex(resources);
this.rowCnt = dayTableModel.rowCnt;
this.colCnt = dayTableModel.colCnt * resources.length;
this.cells = this.buildCells();
}
AbstractResourceDayTableModel.prototype.buildCells = function () {
var _a = this, rowCnt = _a.rowCnt, dayTableModel = _a.dayTableModel, resources = _a.resources;
var rows = [];
for (var row = 0; row < rowCnt; row += 1) {
for (var dateCol = 0; dateCol < dayTableModel.colCnt; dateCol += 1) {
for (var resourceCol = 0; resourceCol < resources.length; resourceCol += 1) {
var resource = resources[resourceCol];
var extraHookProps = { resource: new ResourceApi(this.context, resource) };
var extraDataAttrs = { 'data-resource-id': resource.id };
var extraClassNames = ['fc-resource'];
var date = dayTableModel.cells[row][dateCol].date;
rowCells[this.computeCol(dateCol, resourceCol)] = {
key: resource.id + ':' + date.toISOString(),
date: date,
resource: resource,
extraHookProps: extraHookProps,
extraDataAttrs: extraDataAttrs,
};
}
}
rows.push(rowCells);
}
return rows;
};
return AbstractResourceDayTableModel;
}());
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
/*
resources over dates
*/
var ResourceDayTableModel = /** @class */ (function (_super) {
__extends(ResourceDayTableModel, _super);
function ResourceDayTableModel() {
return _super !== null && _super.apply(this, arguments) || this;
}
ResourceDayTableModel.prototype.computeCol = function (dateI, resourceI) {
return resourceI * this.dayTableModel.colCnt + dateI;
};
/*
all date ranges are intact
*/
ResourceDayTableModel.prototype.computeColRanges = function (dateStartI, dateEndI, resourceI) {
return [
{
firstCol: this.computeCol(dateStartI, resourceI),
lastCol: this.computeCol(dateEndI, resourceI),
isStart: true,
];
};
return ResourceDayTableModel;
}(AbstractResourceDayTableModel));
/*
dates over resources
*/
var DayResourceTableModel = /** @class */ (function (_super) {
__extends(DayResourceTableModel, _super);
function DayResourceTableModel() {
return _super !== null && _super.apply(this, arguments) || this;
}
DayResourceTableModel.prototype.computeCol = function (dateI, resourceI) {
return dateI * this.resources.length + resourceI;
};
/*
every single day is broken up
*/
DayResourceTableModel.prototype.computeColRanges = function (dateStartI, dateEndI, resourceI) {
var segs = [];
for (var i = dateStartI; i <= dateEndI; i += 1) {
var col = this.computeCol(i, resourceI);
segs.push({
firstCol: col,
lastCol: col,
isStart: i === dateStartI,
isEnd: i === dateEndI,
});
return DayResourceTableModel;
}(AbstractResourceDayTableModel));
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
var NO_SEGS = []; // for memoizing
var VResourceJoiner = /** @class */ (function () {
function VResourceJoiner() {
this.joinDateSelection = memoize(this.joinSegs);
this.joinBusinessHours = memoize(this.joinSegs);
this.joinFgEvents = memoize(this.joinSegs);
this.joinBgEvents = memoize(this.joinSegs);
this.joinEventDrags = memoize(this.joinInteractions);
this.joinEventResizes = memoize(this.joinInteractions);
}
/*
propSets also has a '' key for things with no resource
*/
VResourceJoiner.prototype.joinProps = function (propSets, resourceDayTable) {
var dateSelectionSets = [];
var businessHoursSets = [];
var fgEventSets = [];
var bgEventSets = [];
var eventDrags = [];
var eventResizes = [];
var eventSelection = '';
var keys = resourceDayTable.resourceIndex.ids.concat(['']); // add in the all-resource key
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
var key = keys_1[_i];
var props = propSets[key];
dateSelectionSets.push(props.dateSelectionSegs);
businessHoursSets.push(key ? props.businessHourSegs : NO_SEGS); // don't include redundant all-resource businesshours
fgEventSets.push(key ? props.fgEventSegs : NO_SEGS); // don't include fg all-resource segs
bgEventSets.push(props.bgEventSegs);
eventDrags.push(props.eventDrag);
eventResizes.push(props.eventResize);
eventSelection = eventSelection || props.eventSelection;
}
return {
dateSelectionSegs: this.joinDateSelection.apply(this, __spreadArrays([resourceDayTable], dateSelectionSets)),
businessHourSegs: this.joinBusinessHours.apply(this, __spreadArrays([resourceDayTable], businessHoursSets)),
fgEventSegs: this.joinFgEvents.apply(this, __spreadArrays([resourceDayTable], fgEventSets)),
bgEventSegs: this.joinBgEvents.apply(this, __spreadArrays([resourceDayTable], bgEventSets)),
eventDrag: this.joinEventDrags.apply(this, __spreadArrays([resourceDayTable], eventDrags)),
eventResize: this.joinEventResizes.apply(this, __spreadArrays([resourceDayTable], eventResizes)),
};
};
VResourceJoiner.prototype.joinSegs = function (resourceDayTable) {
var segGroups = [];
for (var _i = 1; _i < arguments.length; _i++) {
segGroups[_i - 1] = arguments[_i];
}
var resourceCnt = resourceDayTable.resources.length;
var transformedSegs = [];
for (var i = 0; i < resourceCnt; i += 1) {
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
for (var _a = 0, _b = segGroups[i]; _a < _b.length; _a++) {
var seg = _b[_a];
transformedSegs.push.apply(transformedSegs, this.transformSeg(seg, resourceDayTable, i));
}
for (var _c = 0, _d = segGroups[resourceCnt]; _c < _d.length; _c++) { // one beyond. the all-resource
var seg = _d[_c];
transformedSegs.push.apply(// one beyond. the all-resource
transformedSegs, this.transformSeg(seg, resourceDayTable, i));
}
}
return transformedSegs;
};
/*
for expanding non-resource segs to all resources.
only for public use.
no memoizing.
*/
VResourceJoiner.prototype.expandSegs = function (resourceDayTable, segs) {
var resourceCnt = resourceDayTable.resources.length;
var transformedSegs = [];
for (var i = 0; i < resourceCnt; i += 1) {
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
var seg = segs_1[_i];
transformedSegs.push.apply(transformedSegs, this.transformSeg(seg, resourceDayTable, i));
}
}
return transformedSegs;
};
VResourceJoiner.prototype.joinInteractions = function (resourceDayTable) {
var interactions = [];
for (var _i = 1; _i < arguments.length; _i++) {
interactions[_i - 1] = arguments[_i];
}
var resourceCnt = resourceDayTable.resources.length;
var affectedInstances = {};
var transformedSegs = [];
var anyInteractions = false;
var isEvent = false;
for (var i = 0; i < resourceCnt; i += 1) {
var interaction = interactions[i];
if (interaction) {
anyInteractions = true;
for (var _a = 0, _b = interaction.segs; _a < _b.length; _a++) {
var seg = _b[_a];
transformedSegs.push.apply(transformedSegs, this.transformSeg(seg, resourceDayTable, i));
}
__assign(affectedInstances, interaction.affectedInstances);
isEvent = isEvent || interaction.isEvent;
}
if (interactions[resourceCnt]) { // one beyond. the all-resource
for (var _c = 0, _d = interactions[resourceCnt].segs; _c < _d.length; _c++) {
var seg = _d[_c];
transformedSegs.push.apply(transformedSegs, this.transformSeg(seg, resourceDayTable, i));
}
}
}
if (anyInteractions) {
return {
affectedInstances: affectedInstances,
segs: transformedSegs,
};
return VResourceJoiner;
}());
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
/*
TODO: just use ResourceHash somehow? could then use the generic ResourceSplitter
*/
var VResourceSplitter = /** @class */ (function (_super) {
__extends(VResourceSplitter, _super);
function VResourceSplitter() {
return _super !== null && _super.apply(this, arguments) || this;
}
VResourceSplitter.prototype.getKeyInfo = function (props) {
var resourceDayTableModel = props.resourceDayTableModel;
var hash = mapHash(resourceDayTableModel.resourceIndex.indicesById, function (i) { return resourceDayTableModel.resources[i]; }); // :(
hash[''] = {};
return hash;
};
VResourceSplitter.prototype.getKeysForDateSpan = function (dateSpan) {
return [dateSpan.resourceId || ''];
};
VResourceSplitter.prototype.getKeysForEventDef = function (eventDef) {
var resourceIds = eventDef.resourceIds;
if (!resourceIds.length) {
return [''];
}
return resourceIds;
};
return VResourceSplitter;
}(Splitter));
/*
doesn't accept grouping
*/
function flattenResources(resourceStore, orderSpecs) {
return buildRowNodes(resourceStore, [], orderSpecs, false, {}, true)
.map(function (node) { return node.resource; });
}
function buildRowNodes(resourceStore, groupSpecs, orderSpecs, isVGrouping, expansions, expansionDefault) {
var complexNodes = buildHierarchy(resourceStore, isVGrouping ? -1 : 1, groupSpecs, orderSpecs);
var flatNodes = [];
flattenNodes(complexNodes, flatNodes, isVGrouping, [], 0, expansions, expansionDefault);
return flatNodes;
}
function flattenNodes(complexNodes, res, isVGrouping, rowSpans, depth, expansions, expansionDefault) {
for (var i = 0; i < complexNodes.length; i += 1) {
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
var complexNode = complexNodes[i];
var group = complexNode.group;
if (group) {
if (isVGrouping) {
var firstRowIndex = res.length;
var rowSpanIndex = rowSpans.length;
flattenNodes(complexNode.children, res, isVGrouping, rowSpans.concat(0), depth, expansions, expansionDefault);
if (firstRowIndex < res.length) {
var firstRow = res[firstRowIndex];
var firstRowSpans = firstRow.rowSpans = firstRow.rowSpans.slice();
firstRowSpans[rowSpanIndex] = res.length - firstRowIndex;
}
}
else {
var id = group.spec.field + ':' + group.value;
var isExpanded = expansions[id] != null ? expansions[id] : expansionDefault;
res.push({ id: id, group: group, isExpanded: isExpanded });
if (isExpanded) {
flattenNodes(complexNode.children, res, isVGrouping, rowSpans, depth + 1, expansions, expansionDefault);
}
}
}
else if (complexNode.resource) {
var id = complexNode.resource.id;
var isExpanded = expansions[id] != null ? expansions[id] : expansionDefault;
res.push({
id: id,
rowSpans: rowSpans,
depth: depth,
isExpanded: isExpanded,
hasChildren: Boolean(complexNode.children.length),
resource: complexNode.resource,
resourceFields: complexNode.resourceFields,
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
});
if (isExpanded) {
flattenNodes(complexNode.children, res, isVGrouping, rowSpans, depth + 1, expansions, expansionDefault);
}
}
}
}
function buildHierarchy(resourceStore, maxDepth, groupSpecs, orderSpecs) {
var resourceNodes = buildResourceNodes(resourceStore, orderSpecs);
var builtNodes = [];
for (var resourceId in resourceNodes) {
var resourceNode = resourceNodes[resourceId];
if (!resourceNode.resource.parentId) {
insertResourceNode(resourceNode, builtNodes, groupSpecs, 0, maxDepth, orderSpecs);
}
}
return builtNodes;
}
function buildResourceNodes(resourceStore, orderSpecs) {
var nodeHash = {};
for (var resourceId in resourceStore) {
var resource = resourceStore[resourceId];
nodeHash[resourceId] = {
resource: resource,
resourceFields: buildResourceFields(resource),
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
};
}
for (var resourceId in resourceStore) {
var resource = resourceStore[resourceId];
if (resource.parentId) {
var parentNode = nodeHash[resource.parentId];
if (parentNode) {
insertResourceNodeInSiblings(nodeHash[resourceId], parentNode.children, orderSpecs);
}
}
}
return nodeHash;
}
function insertResourceNode(resourceNode, nodes, groupSpecs, depth, maxDepth, orderSpecs) {
if (groupSpecs.length && (maxDepth === -1 || depth <= maxDepth)) {
var groupNode = ensureGroupNodes(resourceNode, nodes, groupSpecs[0]);
insertResourceNode(resourceNode, groupNode.children, groupSpecs.slice(1), depth + 1, maxDepth, orderSpecs);
}
else {
insertResourceNodeInSiblings(resourceNode, nodes, orderSpecs);
}
}
function ensureGroupNodes(resourceNode, nodes, groupSpec) {
var groupValue = resourceNode.resourceFields[groupSpec.field];
var groupNode;
var newGroupIndex;
// find an existing group that matches, or determine the position for a new group
if (groupSpec.order) {
for (newGroupIndex = 0; newGroupIndex < nodes.length; newGroupIndex += 1) {
var node = nodes[newGroupIndex];
if (node.group) {
var cmp = flexibleCompare(groupValue, node.group.value) * groupSpec.order;
if (cmp === 0) {
groupNode = node;
break;
}
else if (cmp < 0) {
break;
}
}
}
}
else { // the groups are unordered
for (newGroupIndex = 0; newGroupIndex < nodes.length; newGroupIndex += 1) {
var node = nodes[newGroupIndex];
if (node.group && groupValue === node.group.value) {