This is a migrated thread and some comments may be shown as answers.

Limit CRUD of event to specific user

8 Answers 168 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Roderick Prince
Top achievements
Rank 1
Roderick Prince asked on 09 May 2014, 10:53 PM
We have multiple contributors to a single calendar where each should only be able to manage events that they created. Is our only option to disable all Create/Edit/Delete functionality and manage the feature in another way (ie. separate page or popup)?

Desired UI behavior would be to only allow authenticated users to create an event, to allow any user to view the complete detail of an event but readonly fields and remove the Save / Delete buttons if they are not the owner.

Any suggestions are appreciated.

8 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 13 May 2014, 12:50 PM
Hello Roderick Prince,

There are several ways to accomplish your goal:
  1. Implement the Create/Update/Delete functionality manually. This will give you a full control over them and hence achieve your business requirements more easily. This approach is useful if the business logic is very complex and  specialized
  2. Customize current widget behavior:
    1. Wire edit event and hide the Save button if the user is not authorized.
    2. Wire save event and control whether to allow event modifications.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Roderick Prince
Top achievements
Rank 1
answered on 14 May 2014, 05:53 PM
Do you know of any samples that show these 2 techniques?
0
Georgi Krustev
Telerik team
answered on 15 May 2014, 08:08 AM
Hello again,

Currently, there is no specific examples showing how to use some of the suggested approaches. I would suggest you choose one of them and give it a try using the mentioned steps and API documentation. If you encounter any difficulties, let us know. We gladly will assist you accomplish your goal.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Roderick Prince
Top achievements
Rank 1
answered on 15 May 2014, 02:37 PM
In the Edit event is it possible to change the Template that will be displayed?

Something similar to...

​function scheduler_edit(e) {
   var scheduler = $("#scheduler").data("kendoScheduler");

        if (userIsEditor)  {
             scheduler.TemplateName = "EditEventTemplate";
        }
        else {
             $(".k-scheduler-update").remove();
             $(".k-scheduler-delete").remove();
             scheduler.TemplateName = "ViewEventTemplate";
        }
}

I look forward to your reply tomorrow...
0
Georgi Krustev
Telerik team
answered on 16 May 2014, 10:45 AM
Hello,

The edit event is raised after the edit form creation. Hence you cannot change the edit template on the fly. 
Probably the best way to handle your requirement is to use a custom editor template and control the state of each element part of the template based on the current credential information. In other words, define a custom editor template and allow or disable, hide or show some widgets based on the currently logged user. You can get the credential information on load and use it in directly in the editor template. Here is a demo, which shows the proposed approach in action.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Sam
Top achievements
Rank 1
answered on 14 May 2015, 07:05 PM

I stumbled on this post while looking for something else ...

I am able to swap out the custom editor by assigning a function to the editable.template property:

        ...
        ...
        ...
        editable: {

            //template: kendo.template($("#schedulerTemplate").html())
  
            template: kendo.template(function (event) {
              if (event.isAllDay) {
                  return $('#AllDayEditorTemplate').html();
              }
                  return $('#schedulerTemplate').html();
            })  
        },
        ...
        ...
        ...

Here is a demo based on Georgi's last demo: http://dojo.telerik.com/IFeNU.

(One caveat of this approach is that it doesn't handle escaped html in the template, as is present in the original demo.)

As I'm relying on this behavior for critical aspects of my application, I'm very eager to know if this is an acceptable approach or subject to breaking in the future.

Thanks.

Sam.

0
Georgi Krustev
Telerik team
answered on 18 May 2015, 09:01 AM
Hello Sam,

I believe that the used solution is acceptable and will work just fine.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Sam
Top achievements
Rank 1
answered on 18 May 2015, 05:42 PM
Thanks! 
Tags
Scheduler
Asked by
Roderick Prince
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Roderick Prince
Top achievements
Rank 1
Sam
Top achievements
Rank 1
Share this question
or