Skip to content

Commit e556d67

Browse files
author
Olivier Giulieri
committed
Work on fields of type "color".
1 parent bd9b62b commit e556d67

File tree

6 files changed

+32
-19
lines changed

6 files changed

+32
-19
lines changed

dist/css/evolutility.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ label {
189189
width: 20px;
190190
border: solid 1px silver;
191191
}
192+
.evo-color-box span {
193+
margin-left: 24px;
194+
}
192195
/* --- mini --- */
193196
.evol-mini-label {
194197
float: left;

dist/css/evolutility.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dico.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,8 @@ Evol.Dico = {
346346
return Evol.UI.linkEmail(f.id, v);
347347
case fTypes.url:
348348
return Evol.UI.link(f.id, v, v, f.id);
349+
//case fTypes.color:
350+
// return Evol.UI.input.colorBox(f.id, v, v);
349351
default:
350352
return v;
351353
}
@@ -355,6 +357,7 @@ Evol.Dico = {
355357
HTMLField4One: function(fld, fid, fv, mode, iconsPath, skipLabel){
356358
var h=[],
357359
EvoUI=Evol.UI,
360+
uiInput=EvoUI.input,
358361
fTypes=Evol.Dico.fieldTypes;
359362
// --- field label ---
360363
if(mode==='mini'){
@@ -373,7 +376,7 @@ Evol.Dico = {
373376
}
374377
h.push('">');
375378
switch (fld.type) {
376-
case fTypes.color:
379+
case fTypes.color: // TODO is the color switch necessary?
377380
//h.push(Evol.UI.input.colorBox(fid, fv), fv);
378381
h.push('<div id="',fid, '" class="form-control">',fv,'</div>');
379382
break;
@@ -390,19 +393,19 @@ Evol.Dico = {
390393
}else{
391394
switch (fld.type) {
392395
case fTypes.text:
393-
h.push(EvoUI.input.text(fid, fv, fld, null));
396+
h.push(uiInput.text(fid, fv, fld, null));
394397
break;
395398
case fTypes.int:
396399
case fTypes.dec:
397-
h.push(EvoUI.input.textInt(fid, fv, fld.max, fld.min));
400+
h.push(uiInput.textInt(fid, fv, fld.max, fld.min));
398401
break;
399402
case fTypes.money:
400403
h.push('<div class="input-group">', EvoUI.input.typeFlag('$'),
401-
EvoUI.input.textInt(fid, fv),
404+
uiInput.textInt(fid, fv),
402405
'</div>');
403406
break;
404407
case fTypes.bool:
405-
h.push(EvoUI.input.checkbox(fid, fv));
408+
h.push(uiInput.checkbox(fid, fv));
406409
break;
407410
case fTypes.textml:
408411
case fTypes.html:
@@ -415,30 +418,30 @@ Evol.Dico = {
415418
fld.height = 5;
416419
}
417420
}
418-
h.push(EvoUI.input.textM(fid, fv, fld.maxlength, fld.height));
421+
h.push(uiInput.textM(fid, fv, fld.maxlength, fld.height));
419422
break;
420423
case fTypes.date:
421-
h.push(EvoUI.input.date(fid, fv));
424+
h.push(uiInput.date(fid, fv));
422425
break;
423426
case fTypes.datetime:
424-
h.push(EvoUI.input.dateTime(fid, fv));
427+
h.push(uiInput.dateTime(fid, fv));
425428
break;
426429
case fTypes.time:
427-
h.push(EvoUI.input.time(fid, fv));
430+
h.push(uiInput.time(fid, fv));
428431
break;
429432
case fTypes.lov:
430-
h.push(EvoUI.input.select(fid, fv, '', true, fld.list));
433+
h.push(uiInput.select(fid, fv, '', true, fld.list));
431434
break;
432435
case fTypes.list: // fv is an array. will use select2
433436
h.push('<div id="',fid, '" class="w-100 form-control"></div>');
434437
break;
435438
case fTypes.email:
436-
h.push('<div class="input-group">', EvoUI.input.typeFlag(Evol.i18n.sgn_email),
437-
EvoUI.input.text(fid, fv, fld),
439+
h.push('<div class="input-group">', uiInput.typeFlag(Evol.i18n.sgn_email),
440+
uiInput.text(fid, fv, fld),
438441
'</div>');
439442
break;
440443
case fTypes.url:
441-
h.push(EvoUI.input.text(fid, fv, fld));
444+
h.push(uiInput.text(fid, fv, fld));
442445
break;
443446
//case fTypes.doc:
444447
case fTypes.pix:
@@ -447,14 +450,14 @@ Evol.Dico = {
447450
}else{
448451
h.push('<p class="">',Evol.i18n.nopix,'</p>');
449452
}
450-
h.push(EvoUI.input.text(fid, fv, fld, null));
453+
h.push(uiInput.text(fid, fv, fld, null));
451454
break;
452455
case fTypes.color:
453456
//h.push('<div id="',fid, '" class="form-control">',fv,'</div>');
454-
h.push(EvoUI.input.color(fid, fv));
457+
h.push(uiInput.color(fid, fv));
455458
break;
456459
case fTypes.hidden:
457-
h.push(EvoUI.input.hidden(fid, fv));
460+
h.push(uiInput.hidden(fid, fv));
458461
break;
459462
}
460463
}

js/many-badges.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ Evol.ViewMany.Badges = Evol.ViewMany.extend({
3636
HTMLItem: function(h, fields, model, icon, selectable, route){
3737
var that = this,
3838
v,
39+
ft=Evol.Dico.fieldTypes,
3940
opts = this.options,
4041
link = (opts.links!==false);
4142

4243
h.push('<div class="panel ',this.options.style,'">');
4344
_.each(fields, function(f, idx){
4445
if(f.value){
4546
v = f.value(model);
47+
}else if(f.type===ft.color) {
48+
v = model.escape(f.attribute || f.id);
49+
v = Evol.UI.input.colorBox(f.id, v, v);
4650
}else{
4751
v = that._HTMLField(f, model.escape(f.attribute || f.id));
4852
}

js/ui.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ Evol.UI = {
119119
'<input type="color" id="', id, '" value="', value, '" size="15">'
120120
].join('');
121121
},
122-
colorBox: function (id, value) {
122+
colorBox: function (id, value, text) {
123123
return [
124124
'<div class="evo-color-box" id="', id,
125125
'" style="background-color:', value,
126-
'" title="', value, '"></div>'
126+
'" title="', value, '">', text?'<span>'+text+'</span>':'', '</div>'
127127
].join('');
128128
},
129129

less/one.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,7 @@ label{
167167
height:20px;
168168
width:20px;
169169
border: solid 1px silver;
170+
span{
171+
margin-left:24px;
172+
}
170173
}

0 commit comments

Comments
 (0)