New column in case list page

To add a new column in case list page the heading for column need to add in theme template. and extend the Case.List.Items view. Case.List.Items is a child child view we need to extend.It includes in the getChildViews.

CaseListView = CaseListView.CaseListView;
_.extend(CaseListView.prototype, {
  getChildViews: _.wrap(CaseListView.prototype.getChildViews, function(fn) {
    var original_Ret = fn.apply(this, _.toArray(arguments).slice(1));
    original_Ret["Case.List.Items"] = function() {
      var records_collection = new Backbone.Collection(this.collection.map(function(current_case) {
        console.log("current_case", current_case);
        return new Backbone.Model({
          touchpoint: 'customercenter',
          title: _('Case #$(0)').translate(current_case.get('caseNumber')),
          detailsURL: '#/cases/' + current_case.get('internalid'),
          internalid: current_case.get('internalid'),
          columns: [{
            label: _('Subject:').translate(),
            type: 'subject',
            name: 'subject',
            value: current_case.get('title')
          }, {
            label: _('Creation Date:').translate(),
            type: 'creation-date',
            name: 'creation-date',
            value: current_case.get('createdDate').split(' ')[0]
          }, {
            label: _('Last Message:').translate(),
            type: 'date',
            name: 'last-message',
            value: current_case.get('lastMessageDate').split(' ')[0]
          }, {
            label: _('Status:').translate(),
            type: 'status',
            name: 'status',
            value: _.isObject(current_case.get('status')) ? current_case.get('status').name : current_case.get('status').name
          }, {
            label: _('Type of Inquiry:').translate(),
            type: 'inquiry',
            name: 'inquiry',
            value: _.isObject(current_case.get('category')) ? current_case.get('category').name : current_case.get('category').name
          }]
        });
      }));
      return new BackboneCollectionView({
        childView: RecordViewsView,
        collection: records_collection,
        viewsPerRow: 1
      });
    }
    return original_Ret;
  }),
});

Leave a comment

Your email address will not be published. Required fields are marked *