Skip to content

onResourceProblems

Hears what the resources given could not be read as: entries refused, fields dropped.

Type(problems: readonly Problem[]) => void
Defaultnot set
Live update (update())Yes
Declared inpackages/dom/src/settings.ts

Called with a list of problems — each { code, severity, path, detail } — only when there are some, after resources is given (at creation or by update()) or a new resourceOrder:

  • invalid-resource: not an object, or no id (refused); a field that cannot be read (dropped, a warning).
  • duplicate-id: a second resource with the same id (refused).
  • unknown-zone: a timeZone that is not a zone.
  • unknown-resource: an unknown parentId (the resource becomes a root).
  • resource-cycle: a cycle of parents (its first resource becomes a root).
  • invalid-resource at resourceOrder: a comparison that threw (the tree in the order given).

Bad input never throws: the resources that could be read are drawn.

import { createCalendar } from '@dzcalendar/dom';
createCalendar(element, {
timeZone: 'Europe/Paris',
initialView: 'resourceTimeGridDay',
resources: [{ id: 'benali', title: 'Dr Benali' }, { id: 'benali', title: 'Twice' }, { id: 'x', title: 'X', parentId: 'nobody' }],
// duplicate-id (the second refused), unknown-resource (X drawn as a root).
onResourceProblems: (problems) => console.warn(problems.map((p) => `${p.code} ${p.path}`)),
});

In the frameworks it is an output: Angular’s (resourceProblems), React’s onResourceProblems, Vue’s @resource-problems.