search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Issue when updating resources

Asked by Anonymous
2 months ago.

Hello, I am using the scheduler type calendar, and when I try to make an update with the resources, I get the following error:

TypeError: Cannot read properties of undefined (reading 'hidden')
    at DayPilot.Scheduler.wt (daypilot-vue.min.js?0d32:34:1)
    at DayPilot.Scheduler.zk (daypilot-vue.min.js?0d32:34:1)
    at j.Ij (daypilot-vue.min.js?0d32:31:1)
    at eval (daypilot-vue.min.js?0d32:31:1)
    at Array.forEach (<anonymous>)
    at j.qq (daypilot-vue.min.js?0d32:31:1)
    at U.clear (daypilot-vue.min.js?0d32:31:1)
    at updateSelection (_evaluationId.vue?c615:2349:1)
    at _callee3$ (_evaluationId.vue?c615:1868:1)
    at f (vue-ellipse-progress.umd.min.js?9949:1:1)

this is the line that gives me the error:

scheduler.value.control.update({
   events: configScheduler.value.events,
   resources: configScheduler.value.resources,
})

I am using daypilot-pro-vue version 2022.4.5475

Comment posted by Dan Letecky [DayPilot]
2 months ago.

I recommend checking the value of "configScheduler.value.resources". It may be a string (or something else) instead of the expected array.

Comment posted by Anonymous
2 months ago.

This is the value of configScheduler.value.resources

[
    {
        "name": "Compatibilidad",
        "id": "info",
        "cellsAutoUpdated": true,
        "cellsDisabled": true,
        "unselectable": true,
        "expanded": true,
        "children": [
            {
                "id": "SAME_PENSUM",
                "name": "Exámenes con mismo plan",
                "unselectable": true,
                "cellsAutoUpdated": true,
                "cellsDisabled": true
            },
            {
                "id": "SAME_PENSUM_LEVEL",
                "name": "Exámenes con mismo plan-nivel",
                "unselectable": true,
                "cellsAutoUpdated": true,
                "cellsDisabled": true
            }
        ]
    },
    {
        "name": "Recurso",
        "id": "CLASSROOM",
        "expanded": true,
        "children": [
            {
                "id": "927",
                "name": "Aulario I - Aula  106"
            },
            {
                "id": "1438",
                "name": "Estadio - Aula 001 004"
            }
        ]
    },
    {
        "name": "Supervisor",
        "id": "SUPERVISOR",
        "expanded": true,
        "children": [
            {
                "name": "ADRIÁN FONSECA JIMÉNEZ",
                "id": "49953"
            }
        ]
    }
]
Comment posted by Dan Letecky [DayPilot]
2 months ago.

Thanks for the update.

This error doesn't seem to come from the update() method (it's not anywhere in the stack trace).

It looks like the source of the problem is the rows.selection.clear() method which you call in your updateSelection() method.

Would you be able to create a sample project (you can use https://builder.daypilot.org to create a blank project) that reproduces the issue?

Comment posted by Anonymous
2 months ago.

I had to create the updateSelection function because sometimes when I delete a resource the calendar gets "dizzy" and leaves a different resource selected. This is the function:

const updateSelection = () => {
  if (scheduler.value && scheduler.value.control) {
    try {
      const rows = scheduler.value.control.rows.selection.get()

      scheduler.value.control.rows.selection.clear()

      rows.forEach((row) => {
        scheduler.value.control.rows.selection.add(row)
      })

      scheduler.value.control.update()
    } catch (e) {
      console.log('error updateSelection', e)
    }
  }
}
Comment posted by Dan Letecky [DayPilot]
2 months ago.

The Scheduler does essentially the same thing during every update. It saves a list selected row IDs to "selectedRows" property and restores the selection after update. So there is no need to do this and if it doesn't work properly there is a problem. The exception you see when calling rows.selection.clear() may be a different symptom of the same problem.

How do you add rows to the selection? The "row" object that you use as an argument of rows.selection.add() must be a fresh one - any "row" object that you got before an update() is invalid as this API relies on object equivalence. Also, if you make the "row" object reactive Vue will replace it with a proxy which makes it unusable with the row selection API.

Comment posted by Anonymous
2 months ago.

The strange thing is that the problem is only triggered in the following case:

I have an initial load of rooms of which, one comes selected. When I add more rooms to the list of rows, when I try to delete the one that is selected by default, it gives the error and the calendar remains blank until I move the scroll bar.

If I delete in any other order, either by deleting the initial room before adding more rooms to the list, or in any other way, the error is not triggered.

Comment posted by Dan Letecky [DayPilot]
2 months ago.

At this point, a sample project that reproduces the issue would be very helpful as there are too many factors involved. If you have a chance to create it (you can use https://themes.daypilot.org to generate a blank project) it would be great.

New Reply
This reply is
Attachments:
or drop files here
Your name (optional):