Announcement

Collapse
No announcement yet.

after:save and after:destroy events

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • after:save and after:destroy events

    Hi Team,

    May I know where can I locate the events after:save and after:destroy?

    Thanks!

  • #2
    Hello
    More details, please. What do you want to do? On the backend or on the frontend?

    Comment


    • #3
      I was trying to dissect the calendar.js select and eventClick callbacks. I guess both backend and front-end would do.

      Comment


      • brianpunzalan
        brianpunzalan commented
        Editing a comment
        /client/src/views/calendar/calendar.js

    • #4
      For backend you can use hooks https://www.espocrm.com/documentatio...lopment/hooks/
      About frontend - espocrm frontend is based on backbone http://backbonejs.org

      Comment


      • #5
        The frontend has now been detecting that there is a conflict and halting it from saving the UI model. But, on the backend, my conflicted schedule has still been saved. So therefore, after refreshing the page, it refetch all of the events from the backend and update again the UI model which makes it an issue.

        Should I just use hooks for this scenario? Also, I cannot fully understand the documentation about making my own hook type and how could I triggered it for my specific case.

        Below is a snippet code from calendar.js where I make some modifications to prevent the conflict selection.

        Thanks!

        Code:
        select: function (start, end, allDay) {
                            var dateStart = this.convertTime(start);
                            var dateEnd = this.convertTime(end);
        
                            var attributes = {
                                dateStart: dateStart,
                                dateEnd: dateEnd
                            };
                            if (this.options.userId) {
                                attributes.assignedUserId = this.options.userId;
                                attributes.assignedUserName = this.options.userName || this.options.userId;
                            }
        
                            this.notify('Loading...');
                            this.createView('quickEdit', 'crm:views/calendar/modals/edit', {
                                attributes: attributes,
                                enabledScopeList: this.enabledScopeList,
                                scopeList: this.scopeList
                            }, function (view) {
                                view.render();
                                view.notify(false);
                                this.listenToOnce(view, 'after:save', function (model) {
                                    // custom
                                    if(!this.checkOverlap(start, end)){
                                        this.addModel(model);
                                    }
                                    else{
                                        this.notify("Conflicting schedule. Event has not been created.");
                                        this.removeModel(model);
                                    }
                                    // end custom
        
                                }, this);
                            }, this);

        Comment


        • #6
          If you want to stop saving on backend, you could create beforeSave hook and throw an error http://forum.espocrm.com/forum/devel...-in-beforesave
          I don't know everything you want to implement

          Comment

          Working...
          X