Createview for new fields?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • worldmiros
    Senior Member
    • Dec 2015
    • 120

    Createview for new fields?

    Trying to understand the client-side code although I'm not experienced with backbonejs. I'm trying to use the createview function for added fields such as, 'hourlyRate' in the matters entity, and 'tot-hours' in the task entity. Wondering if I'm in the ballpark as far my code below being correct and able to use in the setup function?
    Code:
    Espo.define('Advanced: Views.QuoteItem.Fields.HourlyRate', 'Views.Fields.Currency', function (Dep) {
     return Dep.extend({
            detailTemplated: 'fields.float.edit',
    
        fetch: function(){
            var value = this.$element.val();
            value = this.parse(value);
            var data = {};
            data[this.name] = value;
            return data;
    
            }
        });
    });
    Code:
    this.createView('hourlyRate','Advanced: QuoteItem.Fields.HourlyRate'){
    model: this.model,
    defs: {
        name: 'hourlyRate'
    },
    mode: this.mode,
    el: this.options.el + ' .field-hourlyrate',
    inlineEditDisabled: true
    }, function (view) {
            this.listenTo(view,'change',function () {
                setTimeout(function () {
                    this.trigger('change');
                }.bind(this),50);
            }, this);
        }.bind(this));
    
    }
    Code:
    Espo.define('Advanced:Views.QuoteItem.Fields.TotHours','Views.Fields.Float', function (Dep) {
     return Dep.extend({
        detailTemplated: 'fields.float.edit',
    
        fetch: function() {
        var value = this.$element.value();
        value = this.parse(value);
        var data = {};
        data[this.name] = value;
        return data;
     });
    });
    Code:
    Espo.define('Advanced:QuoteItem.Fields.TotHours',function (Dep) {
        this.createView('tot_hours','Advanced:QuoteItem.Fields.TotHours'){
        model: this.model,
        defs: {
            name:'tot_hours'
            },
        mode: this.mode,
        el: this.options.el + '.field-tot_hours',
        inlineEditDisabled: true
        }, function (view) {
            this.listenTo(view,'change',function() {
                setTimeout(function () {
                    this.trigger('change');
                }.bind(this),50);
            },this);
        }.bind(this));
    });
    Last edited by worldmiros; 01-22-2016, 04:15 PM.
  • yuri
    Member
    • Mar 2014
    • 8478

    #2
    Hi

    The last part is not correct. Should be

    PHP Code:
    Espo.define('advanced:views/quote-item/fields/tot-hours', 'views/fields/base', function (Dep) {  
       return Dep.extend({    
           setup: function () {      
    
               this.createView('someName', 'viewName', optionc, callback);       
           }  
      });  
    }); 
    
    createView method is intended to create nested view. Usually it is not needed in field views.
    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

    • worldmiros
      Senior Member
      • Dec 2015
      • 120

      #3
      My goal is to create nested views. I'm slowly trying to figure out how to modify certain files for quoteitem based on the response you gave to another question (http://forum.espocrm.com/developer-h...ze-a-quoteitem). My goal is set tot_hours (task entity) to quantity, and hourlyrate (matters entity) to listprice and unitprice. When changing the scope to Task, when data is selected, only data to autofill is the name. Trying to autofill quantity,listprice, and unitprice, change the input to readonly when selected.

      Comment

      Working...