This.model.save not for only one entity?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kirill
    Junior Member
    • Oct 2018
    • 20

    This.model.save not for only one entity?

    Hello!!! I created buttons that change the status of the Case entity. Most of the code is in the detail.js file in the directory ..... / client / modules / casebuttons / src / views / case. Changing the status produces the following code:
    PHP Code:
    this.model.save({
          status: param
    }).success(function () {
          this.notify(false);
          this.model.trigger('after:save');
    }.bind(this)); 
    
    Everything works well, but sometimes even too (very rarely): I change the status in one “Case” - the status changes to identical in a few more “Case”, which have nothing to do with the first. How to get rid of this error? There is a suspicion that this is somehow connected with this.model.collection.
  • Kirill
    Junior Member
    • Oct 2018
    • 20

    #2
    Found a mistake: during a quick transition between entities, ajax worked asynchronously, which led to incorrect button generation. Set the async parameter: "false", and everything works as it should.

    Comment

    • rodrigocoelho
      Active Community Member
      • Jun 2016
      • 296

      #3
      yuri , please take a look on this. A button that doesn't need to click on EDIT first, to be clicked, would be a great feature.

      Thanks.

      Comment

      • yuri
        Member
        • Mar 2014
        • 8453

        #4
        async: false is not recommended and I wonder if it's still available in browsers. Was deprecated long ago.

        You need to review your logic. This behavior definitely should not't be happening.
        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

        Comment

        • Kirill
          Junior Member
          • Oct 2018
          • 20

          #5
          In another way, the problem returns. The buttons are located in clienDefs, actions for them are specified in view / detail.js (JS code from the first message). If you quickly and heavily press the transition buttons (see picture), or use the browser buttons forward, backward, then after clicking the created buttons, more than 1 entity is edited. How to prevent this?Click image for larger version

Name:	111.png
Views:	589
Size:	52.3 KB
ID:	52016

          Comment

          • yuri
            Member
            • Mar 2014
            • 8453

            #6
            Can you provide whole js file contents?
            If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

            Comment

            • yuri
              Member
              • Mar 2014
              • 8453

              #7
              If you listen to 'change:status' and then save a model -- it's a wrong way.
              If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

              Comment

              • Kirill
                Junior Member
                • Oct 2018
                • 20

                #8

                After quickly switching between entities, the code is: console.log (this.model); displays 2-4 entities. That is how it should be? How to avoid this error?
                I added the following code to "action follow": console.log (this.model.id); then i repeated the above steps and after pressing the "follow" button received:Click image for larger version

Name:	1.png
Views:	561
Size:	36.9 KB
ID:	52156
                A rare mistake, but our managers are faced with this, maybe there are still some conditions for receiving this error.

                Last edited by Kirill; 10-03-2019, 06:18 AM.

                Comment

                • Kirill
                  Junior Member
                  • Oct 2018
                  • 20

                  #9
                  I'm still waiting your answer or reaction....

                  Comment

                  • yuri
                    Member
                    • Mar 2014
                    • 8453

                    #10
                    I will look into. I need to reproduce first.
                    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                    Comment

                    • yuri
                      Member
                      • Mar 2014
                      • 8453

                      #11
                      This fix may solve the problem: https://github.com/espocrm/espocrm/c...09bfa8bd8b6fdf
                      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                      Comment

                      • Kirill
                        Junior Member
                        • Oct 2018
                        • 20

                        #12
                        Thank you, this fix partially solved my problem. There are new problems. How to call actionEdit using code without using: $ ('[data-action = "edit"]').сlick (); ? this.setEditMode(); not working now. How to get the mode of the current model in detail?
                        Last edited by Kirill; 10-09-2019, 10:11 AM.

                        Comment

                        Working...