Announcement

Collapse
No announcement yet.

Notification on subpanel changes ( FROM THE UI, IN THE UI )

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

  • Notification on subpanel changes ( FROM THE UI, IN THE UI )

    Guys, you are VERY smart !!!

    What I'm looking for is SO simple in JQuery .. but .. I'm trying not to do things "my way", and share what I'm doing because I can't find it in the documentation, and I believe have to be something SUPER simple ...

    LETs imagine I'm doing something similar to .. a quote system .. for example .. .. I will create an entity named "Quote", another one named "Items", and a last one named "Quote-Items" (to hold the many-to-many) ... then .. in the bottom of the Quote detail I will present a "quote-items" subpanel .. where the user can ADD/Update/Delete items (related to the quote) .. along with prices and so ..

    if that's the case .. I will do something as simple as creating a file "detail.js"

    /home/espocrm/client/custom/src/views/quote/detail.js
    Code:
    define('custom:views/quote/detail', 'views/detail', function (Dep) {
    
        return Dep.extend({
    
            setup: function() {
                ......
    a-->        this.listenTo( "... changes on the bottom-panel ... ??? ", function() {
    
                    var total = 0;
    b-->            this." get quote-items list from subpanel bellow ??? "
                        .each( function( index, value ) { total += value.attribute.price * value.attribute.qty; });
    
                    this.model.set('total', total);
                    this.model.save()
                              .then(function() {
                                  //Cool beans .. Total updated !.
                              });
                });
            }
        })
    });​​
    I'm just looking for something .. as SIMPLE as that (getting "a" and "b" addressed) .. can anyone please, tell me .. if that SIMPLE thing can be done .. and HOW !???

    thanks in advance ..

    I will LOVE to be as smart as you guys are .. but .. I'm NOT .. I know how to "get around" using jquery .. but .. that solution is NOT the best, that's why I'm asking for help.

  • #2
    There are events fired on this.model: 'after:relate', 'after:relate:yourLinkName', 'after:unrelate', 'after:unrelate:yourLinkName'. You can listen to all them by using space as a separator.

    Comment


    • #3
      Hi ..

      That worked ! .. BUT ... first, the notification happens "after relate" . but before displaying. .. so, if I can know HOW to read the collection on the sub-panel (if it already exists "after" the "after:relate") .. that will be great.

      Anyway, the "after:relate" and "after:unrelate" work .. but if a record in the sub-panel gets modified .. you DO NOT get notified .. I guess because "relate" and "unrelate" are only for .. "add, delete, unlink" .. but for .. " after: .. edit ? " ..

      Any clues, what I can do for "after .. update" ... and if I'm able to read the sub-panel collection somehow .. ?

      Comment


      • #4
        To find out what events are fired.

        Code:
        this.listenTo(this.collection, 'all', event => console.log(event));

        Comment


        • #5
          I think you need to do it from the panel view.

          Comment

          Working...
          X