Как добавить дополнительные столбцы ресурсов fullCalendar-scheduler

Я хочу добавить столбцы ресурсов в приложение spfx fullCalendar.

Следуя документации, я попытался воспроизвести то, что показано в демо здесь:

https://fullcalendar.io/docs/resourceColumns

https://fullcalendar.io/docs/resourceColumns-demo.

Демонстрация, кажется, использует столбцы ресурсов, чтобы добавить дополнительное поле для «занятости».

resourceColumns: [
        {
          labelText: 'Room',
          field: 'title'
        },
        {
          labelText: 'Occupancy',
          field: 'occupancy'
        }
      ],
      resources: [
        { id: 'a', title: 'Auditorium A', occupancy: 40 },
        { id: 'b', title: 'Auditorium B', occupancy: 60 },
        { id: 'c', title: 'Auditorium C', occupancy: 40 },
        { id: 'd', title: 'Auditorium D', occupancy: 40 },
      ]

Я реализовал тот же фрагмент кода, но получаю сообщение об ошибке.

Type '{ id: string; title: string; occupancy: number; }[]' is not assignable to type 'ResourceSourceInput'.
  Type '{ id: string; title: string; occupancy: number; }[]' is not assignable to type 'ResourceInput[]'.
    Type '{ id: string; title: string; occupancy: number; }' is not assignable to type 'ResourceInput'.
      Object literal may only specify known properties, and 'occupancy' does not exist in type 'ResourceInput'.
declare module 'fullcalendar-scheduler/src/types/input-types' {
    /// <reference types="jquery" />
    import * as moment from 'moment';
    import { BusinessHoursInput, EventOptionsBase } from 'fullcalendar';
    export interface ResourceInput {
        id?: string;
        title?: string;
        eventColor?: string;
        eventBackgroundColor?: string;
        eventBorderColor?: string;
        eventTextColor?: string;
        eventClassName?: string | string[];
        businessHours?: BusinessHoursInput;
        children?: ResourceInput[];
        parentId?: string;
        parent?: ResourceInput;
    }
    export interface ResourceComplexInput extends EventOptionsBase, JQueryAjaxSettings {
    }
    export type ResourceFunctionCallback = (resources: ResourceInput[]) => void;
    export type ResourceFunction = (callback: ResourceFunctionCallback, start: moment.Moment, end: moment.Moment, timezone: string) => void;
    export type ResourceSourceInput = ResourceInput[] | ResourceFunction | ResourceComplexInput; module 'fullcalendar/src/types/input-types' {
        interface DropInfo {
            resourceId?: string;
        }
        interface OptionsInputBase {
            schedulerLicenseKey?: string;
            resourceAreaWidth?: number;
            resourceLabelText?: string;
            resourceColumns?: any;
            resources?: ResourceSourceInput;
            refetchResourcesOnNavigate?: boolean;
            groupByResource?: boolean;
            groupByDateAndResource?: boolean;
            resourceOrder?: string;
            resourceGroupField?: string;
            resourceGroupText?: (groupValue: string) => string;
            resourcesInitiallyExpanded?: boolean;
            filterResourcesWithEvents?: boolean;
            resourceText?: (resource: ResourceInput) => string;
            resourceRender?: (resource: ResourceInput, labelTds: JQuery, bodyTds: JQuery) => void;
            eventResourceEditable?: boolean;
        }
    }

Кажется, мне нужно добавить дополнительное свойство для занятости, хотя я не могу найти ничего в демо, которое показывает, как это делается.


person JMyner    schedule 31.01.2019    source источник
comment
Укажите ResourceInput тип, пожалуйста   -  person howHighUR    schedule 31.01.2019
comment
Просто добавил тип   -  person JMyner    schedule 31.01.2019


Ответы (1)


Добавьте дополнительный тип, расширяющий этот интерфейс:

type Extended = ResourceInput & {occupancy: number}
person howHighUR    schedule 31.01.2019
comment
Это будет прямое изменение файла, расположенного в папке node_modules. - person JMyner; 31.01.2019
comment
О, не делай этого - person howHighUR; 31.01.2019
comment
Да, конечно, это решает проблему, я думаю, мне нужно добавить свойство в свой собственный .tsx, может быть, путем расширения этого интерфейса? - person JMyner; 31.01.2019
comment
Обновлен мой ответ - person howHighUR; 31.01.2019