We should find a solution for the following use case. Our users only have access to different Resources, so we wrote a chanedFilter in the store part of the ResourceField item of the EventEditFeature, as show in the first picture.
Unforunately, Calendar reacted to this by adding a number 1 if someone does not have access to the first Resource. As the second picture shows.
Do you have any idea how to solve the problem? We tried to fill in the value, but unforunately it didn't work.
It seems that when we filter the store, it's not actually empty. All users can access at least one resource, so that's not an issue. However, we have a Resource List [R1, R2, R3, R4], and when we filter by R1, the resource appears, but only as the number "1" instead of its name. Filtering other resources like R3 works properly.
I attempted your solution, but it didn't resolve the issue. Here's what I understand:
store: new Store({
masterStore: resourceStore,
chainedFilterFn(record) {
if (user?.hasRole(Role.ADMIN)) {
return true;
}
const resourceRoles = record.getData('role').split(',');
const resourceGroup = record.getData('group');
for (const role of resourceRoles) {
if (user?.hasRole(role as Role)) {
if (!resourceGroup) {
return true;
}
if (user?.isInGroup(resourceGroup)) {
return true;
}
}
}
return false;
},
}),
I believe the main issue is that the ResourceField loads the default Store initially. If we define a new Store for it, the default store is overwritten, but the first element of the store is saved as the default value. Since this item isn't available in the new Store, it only displays the ID.
What does the config setup of that field look like?
Are you reconfiguring the existing resource field, or adding a new combo? Combo's need to know which field of the record to use as the filter match value when typing. See valueField in the combo docs
Cleaning up the indentation to make it quickly readable, I added it to the "Basic" example making the filtering function sipler. It just doesn't offer the "Michael Johnson" resource.
It works as expected:
Screenshot 2024-08-13 at 15.39.21.png (895.46 KiB) Viewed 211 times
I mentioned, the problem is comming when we need to filtering the first resource. So your example you need to filter the 'Bryntum Team' Resource, then you can see when you click to create a new Event, its showing the 'bryntum' word but its not a real Resource.
Please find the picture which representing the problem. In picture you can see, in EventEdit modal its Resource showing the 'bryntum' but this resource is filtered.