bryntum / support

An issues-only repository for the Bryntum project management component suite which includes powerful Grid, Scheduler, Calendar, Kanban Task Board and Gantt chart components all built in pure JS / CSS / TypeScript
https://www.bryntum.com
54 stars 6 forks source link

Assigning an event to multiple resources using `resourceIds` does not work #9187

Closed ghulamghousdev closed 5 months ago

ghulamghousdev commented 5 months ago

Forum post

I'm trying to setup my calendar to where events can belong to multiple calendars/resources. When I set the resourceIds field on the EventModel, the event(s) don't get assigned to any resources. https://bryntum.com/products/calendar/docs/api/Scheduler/model/EventModel#field-resourceIds

Use the following data in Calendar multi assign example:

{
  "success"   : true,
  "resources" : {
    "rows" : [
      {
        "id"         : "r1",
        "name"       : "Celia",
        "city"       : "Barcelona",
        "eventColor" : "red",
        "image"      : "celia.jpg"
      },
      {
        "id"         : "r2",
        "name"       : "Lee",
        "city"       : "London",
        "eventColor" : "purple",
        "image"      : "lee.jpg"
      },
      {
        "id"         : "r3",
        "name"       : "Macy",
        "city"       : "New York",
        "eventColor" : "blue",
        "image"      : "macy.jpg"
      },
      {
        "id"         : "r4",
        "name"       : "Madison",
        "city"       : "Barcelona",
        "eventColor" : "teal",
        "image"      : "madison.jpg"
      },
      {
        "id"         : "r5",
        "name"       : "Rob",
        "city"       : "Rome",
        "eventColor" : "green",
        "image"      : "rob.jpg"
      },
      {
        "id"         : "r6",
        "name"       : "Dave",
        "city"       : "Barcelona",
        "eventColor" : "magenta",
        "image"      : "dave.jpg"
      },
      {
        "id"         : "r7",
        "name"       : "Dan",
        "city"       : "London",
        "eventColor" : "deep-orange",
        "image"      : "dan.jpg"
      }
    ]
  },
  "events" : {
    "rows" : [
      {
        "id"        : 1,
        "startDate" : "2020-12-31T10:00",
        "endDate"   : "2020-12-31T12:00",
        "iconCls"   : "b-fa b-fa-utensils",
        "name"      : "Cook lunch",
        "resourceIds" : ["r1", "r2"]
      },
      {
        "id"        : 2,
        "startDate" : "2021-01-01T13:00",
        "endDate"   : "2021-01-01T15:00",
        "name"      : "Set up tent",
        "iconCls"   : "b-fa b-fa-campground",
        "resourceIds" : ["r3", "r4"]
      },
      {
        "id"        : 3,
        "startDate" : "2020-12-29T8:00",
        "endDate"   : "2020-12-29T11:00",
        "name"      : "Get firewood",
        "iconCls"   : "b-fa b-fa-tree",
        "resourceIds" : ["r5", "r6"]
      },
      {
        "id"        : 4,
        "startDate" : "2020-12-30T10:00",
        "endDate"   : "2020-12-30T13:00",
        "iconCls"   : "b-fa b-fa-tint",
        "name"      : "Boil water",
        "resourceIds" : ["r3", "r5"]
      },
      {
        "id"        : 5,
        "startDate" : "2021-01-02T13:00",
        "endDate"   : "2021-01-02T15:00",
        "name"      : "Make fire",
        "iconCls"   : "b-fa b-fa-fire-alt",
        "resourceIds" : ["r7", "r2"]
      }
    ]
  }
}
ghulamghousdev commented 5 months ago

This is actually not a bug. They were not declaring the resourceIds on eventModel. Adding this to eventModelClass is gonna solve their issue:

class CustomEventModel extends EventModel {
    static $name  = 'CustomEventModel';
    static fields = [
        { name : 'resourceIds', persist : true }
    ];
}

and then add the class to eventStore and all good to go.

ghulamghousdev commented 5 months ago

After discussion with Mats, we have decided to add a new multiassign demo using resourceIds.