Limit CRUD of event to specific user

9 posts, 0 answers
  1. Roderick Prince
    Roderick Prince avatar
    29 posts
    Member since:
    May 2004

    Posted 09 May 2014 Link to this post

    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.
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3747 posts

    Posted 13 May 2014 Link to this post

    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!
     
  3. Roderick Prince
    Roderick Prince avatar
    29 posts
    Member since:
    May 2004

    Posted 14 May 2014 in reply to Georgi Krustev Link to this post

    Do you know of any samples that show these 2 techniques?
  4. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3747 posts

    Posted 15 May 2014 Link to this post

    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!
     
  5. Roderick Prince
    Roderick Prince avatar
    29 posts
    Member since:
    May 2004

    Posted 15 May 2014 in reply to Georgi Krustev Link to this post

    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...
  6. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3747 posts

    Posted 16 May 2014 Link to this post

    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!
     
  7. Sam
    Sam avatar
    13 posts
    Member since:
    Dec 2014

    Posted 14 May 2015 in reply to Georgi Krustev Link to this post

    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.

  8. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3747 posts

    Posted 18 May 2015 Link to this post

    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!
     
  9. Sam
    Sam avatar
    13 posts
    Member since:
    Dec 2014

    Posted 18 May 2015 in reply to Georgi Krustev Link to this post

    Thanks! 
Back to Top