diff --git a/lib/assets/javascripts/builder/components/modals/add-widgets/widgets-types.js b/lib/assets/javascripts/builder/components/modals/add-widgets/widgets-types.js index d9bba85..97de582 100755 --- a/lib/assets/javascripts/builder/components/modals/add-widgets/widgets-types.js +++ b/lib/assets/javascripts/builder/components/modals/add-widgets/widgets-types.js @@ -82,6 +82,48 @@ module.exports = [ }; } }, + { + type: 'formula_mini', + createOptionModels: function (tuplesItems) { + return _.reduce(tuplesItems, function (memo, tuples) { + var columnModel = tuples[0].columnModel; + var columnName = columnModel.get('name'); + var operation = 'avg'; + var title = columnName; + + if (columnModel.get('type') === 'number') { + if (columnName === CARTODB_ID) { + operation = 'count'; + title = _t('editor.data.stats.feature-count'); + } + + var m = new FormulaOptionModel({ + tuples: tuples, + title: title, + operation: operation, + name: columnModel.get('name') + }); + memo.push(m); + } + return memo; + }, []); + }, + createTabPaneItem: function (optionsCollection) { + return { + label: _t('components.modals.add-widgets.tab-pane.formula_mini-label'), + name: 'formula_mini', + createContentView: function () { + return new ScrollView({ + createContentView: function () { + return new FormulaOptionsView({ + collection: optionsCollection + }); + } + }); + } + }; + } + }, { type: 'formula', createOptionModels: function (tuplesItems) {