@progress/kendo-angular-gantt
Version:
Kendo UI Angular Gantt
63 lines (62 loc) • 2.67 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { Injectable } from '@angular/core';
import { getter } from '@progress/kendo-common';
import { DEFAULT_DEPENDENCY_MODEL_FIELDS } from '../models/gantt-dependency-model-fields.interface';
import { DEFAULT_TASK_MODEL_FIELDS } from '../models/gantt-task-model-fields.interface';
import { isPresent } from '../utils';
import * as i0 from "@angular/core";
/**
* @hidden
*/
export class MappingService {
/**
* Gets or sets the model fields for the task data items.
* Uses the default values for fields which are not specified.
*/
set taskFields(fields) {
this._taskFields = { ...DEFAULT_TASK_MODEL_FIELDS, ...fields };
}
get taskFields() {
return this._taskFields;
}
/**
* Gets or sets the model fields for the depenency data items.
* Uses the default values for fields which are not specified.
*/
set dependencyFields(fields) {
this._dependencyFields = { ...DEFAULT_DEPENDENCY_MODEL_FIELDS, ...fields };
}
get dependencyFields() {
return this._dependencyFields;
}
_taskFields = { ...DEFAULT_TASK_MODEL_FIELDS };
_dependencyFields = { ...DEFAULT_DEPENDENCY_MODEL_FIELDS };
/**
* Retrieves the value for the specified task field.
* Supports nested fields as well (e.g. 'manager.id').
*/
extractFromTask(dataItem, field) {
if (!isPresent(this.taskFields)) {
return null;
}
return getter(this.taskFields[field])(dataItem);
}
/**
* Retrieves the value for the specified dependency field.
* Supports nested fields as well (e.g. 'manager.id').
*/
extractFromDependency(dataItem, field) {
if (!isPresent(this.dependencyFields)) {
return null;
}
return getter(this.dependencyFields[field])(dataItem);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: MappingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: MappingService });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: MappingService, decorators: [{
type: Injectable
}] });