Skip to content

Commit 8660d22

Browse files
committed
Bubble view - different control depending on the number of options.
1 parent 597273c commit 8660d22

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

js/view-many/many-bubbles.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ Evol.ViewMany.Bubbles = Evol.ViewMany.extend({
1717
//'click .evol-buttons>button': 'click_button',
1818
//'click .evol-title-toggle': 'click_toggle',
1919
//'click .glyphicon-wrench': 'click_customize',
20-
'click .btn': 'changeGroup',
20+
'click .btn': 'clickGroup',
21+
'change .bubble-group': 'changeGroup',
2122
'change .bubble-color': 'changeColor',
2223
'change .bubble-size': 'changeSize',
2324
'click svg>circle': 'clickCircle'
@@ -68,24 +69,34 @@ Evol.ViewMany.Bubbles = Evol.ViewMany.extend({
6869
i18nTools = Evol.i18n.tools,
6970
hOpt = eUI.input.option,
7071
hOptNull = eUI.html.emptyOption,
72+
fo,
7173
fs2 = Evol.Dico.getFields(this.uiModel, Evol.Dico.fieldChartable),
7274
h = '<div class="evol-many-bubbles panel '+this.style+'"><div class="evol-bubbles-body">'+
7375
'<div class="d3-tooltip" style="opacity:0;"></div>';
7476
//h+=this._HTMLbody(this.getFields(), pSize, this.uiModel.icon, 0, this.selectable);
7577

7678
h+='<div class="bubbles-opts '+this.style+'">';
7779
// --- Group ---
78-
h+='<label>'+i18nTools.vizGroupBy+': </label>'+
79-
'<div class="btn-group" data-toggle="buttons">'+
80+
h+='<label>'+i18nTools.vizGroupBy+': </label>';
81+
if(fs2.length>5){
82+
fo=_.map(fs2, function(f, idx){
83+
return hOpt(f.id, f.label, idx===0);
84+
});
85+
h+='<select class="form-control bubble-group">'+hOptNull + fo.join('')+'</select>';
86+
}else{
87+
h+='<div class="btn-group" data-toggle="buttons">'+
8088
_.map(fs2, function(f, idx){
8189
if(_.isUndefined(f.groupable) || f.groupable){
8290
return '<label class="btn btn-default'+(idx===0?' active':'')+'" id="'+f.id+'">'+
8391
'<input type="radio" name="options"'+(idx===0?' checked':'')+'>'+f.label+'</label>';
8492
}
85-
}).join('')+
86-
'</div>';
93+
}).join('')+'</div>';
94+
}
95+
96+
97+
8798
// --- Color ---
88-
var fo=_.map(fs2, function(f, idx){
99+
fo=_.map(fs2, function(f, idx){
89100
return (_.isUndefined(f.colorable) || f.colorable) ? hOpt(f.id, f.label, idx===0) : '';
90101
});
91102
h+='<label>'+i18nTools.vizColorBy+': </label><select class="form-control bubble-color">'+hOptNull + fo.join('')+'</select>';
@@ -124,9 +135,12 @@ Evol.ViewMany.Bubbles = Evol.ViewMany.extend({
124135
return this;
125136
},
126137

127-
changeGroup: function(evt){
138+
clickGroup: function(evt){
128139
this.bubbles.changeBubblesGroup(evt.currentTarget.id);
129140
},
141+
changeGroup: function(evt){
142+
this.bubbles.changeBubblesGroup(evt.target.value);
143+
},
130144

131145
changeColor: function(evt){
132146
this.bubbles.changeBubblesColor(evt.target.value);

0 commit comments

Comments
 (0)