AnsweredAssumed Answered

How can I make a custom dashlet class that is extendable?

Question asked by Steven Osborne on Oct 3, 2017
Latest reply on Jan 2, 2019 by Enes Saridogan

I have created a custom dashlet class that extends from tabbed dashlet view and implements some methods from the dashable list class to create a tabbed list view: 

(If there is a simple way to do this, then I would love to hear it)

The dashlet consists of three files: a javascript file, a php config file and a record.hbs file. Here is the javascript file:

    extendsFrom: 'TabbedDashletView',

    initialize: function (options) {
        options.meta = options.meta || {};
        options.meta.template = 'tabbed-dashlet';

        this._super('initialize', [options]);

    initDashlet: function() {
        this.metaFields = this._getColumnsForDisplay();

    _getColumnsForDisplay: function() {
        var columns = [];
        var fields = this.getFieldMetaForView(this._getListMeta(this.settings.get('module')));
        var moduleMeta = app.metadata.getModule(this.module);

        _.each(this.settings.get('display_columns'), function(name) {
            var field = _.find(fields, function(field) {
                return === name;
            }, this);

            field = field || app.metadata._patchFields(this.module, moduleMeta, [name]);

            //Set the sortable flag to false until sorting is implemented
            columns.push(_.extend({sortable: false}, field));
        }, this);
        return columns;

    getFieldMetaForView: function(meta) {
        meta = _.isObject(meta) ? meta : {};
        return !_.isUndefined(meta.panels) ? _.flatten(_.pluck(meta.panels, 'fields')) : [];

    _getListMeta: function(module) {
        return app.metadata.getView(module, 'list');

    _getCollectionFilters: function(index) {
        var tab = this.tabs[index];
        var filters = [];
        var today = new Date();

        _.each(tab.filters, function(condition, field) {
            var filter = {};
            filter[field] = condition;


        if (this.settings.get('overdue') === 'overdue') {
                date_due: {$lt: today}

        return filters;

We have two custom dashlets that we wish to create that would require the same javascript, but different php config files. I was wondering how I would go about making my javascript file extendable so that I am not duplicating a lot of code.


Thanks for any help.