更新 widgets-types.js

This commit is contained in:
钟进 2020-07-10 06:09:07 +00:00
parent 4e46d89b97
commit d587ca08cf

View File

@ -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) {