Skip to content

Commit 3d4e5ec

Browse files
committed
Improved "formula" and "color" fields.
1 parent 1c65562 commit 3d4e5ec

6 files changed

Lines changed: 41 additions & 25 deletions

File tree

dist/evolutility.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ Evol.Dico = function(){
744744
formula:'formula', // soon to be a field attribute rather than a field type
745745
email: 'email',
746746
pix: 'image',
747-
doc:'document',
747+
//doc:'document',
748748
url: 'url',
749749
color: 'color',
750750
hidden: 'hidden'
@@ -862,7 +862,7 @@ return {
862862
break;
863863
case fts.color: // TODO is the color switch necessary?
864864
//h+=uiInput.colorBox(fid, fv)+fv;
865-
h+='<div id="'+fid+'" class="form-control">'+fv+'</div>';
865+
h+='<div id="'+fid+'" class="form-control">'+uiInput.colorBox(fid, fv)+'</div>';
866866
break;
867867
default:
868868
h+=this.fieldHTML_ReadOny(fld, fv, {}, iconsPath);
@@ -1728,9 +1728,11 @@ return Backbone.View.extend({
17281728
var that=this,
17291729
fv;
17301730
if(f.type==='formula'){
1731-
fv = '<div class="disabled evo-rdonly evol-ellipsis">' +
1732-
(this.model?f.formula(this.model):'') +
1733-
'</div>';
1731+
fv = '<div class="disabled evo-rdonly evol-ellipsis">';
1732+
if(f.formula && this.model){
1733+
fv+=f.formula(this.model);
1734+
}
1735+
fv+='</div>';
17341736
}else{
17351737
fv = eDico.fieldHTML_ReadOny(f, v, Evol.hashLov, this.iconsPath || '');
17361738
if (f.type === 'list') {
@@ -2733,7 +2735,7 @@ return Backbone.View.extend({
27332735
$f.html(eDico.fieldHTML_ReadOny(f, _.isUndefined(fv)?'':fv, Evol.hashLov, iconsPath) + ' ');
27342736
break;
27352737
case fts.formula:
2736-
$f.html(f.formula(model));
2738+
$f.html(f.formula?f.formula(model):'');
27372739
break;
27382740
case fts.color:
27392741
$f.html(uiInput.colorBox(f.id, fv, fv));
@@ -2763,7 +2765,7 @@ return Backbone.View.extend({
27632765
$f.select2('val', fv);
27642766
break;
27652767
case fts.formula:
2766-
$f.html(f.formula(model));
2768+
$f.html(f.formula?f.formula(model):'');
27672769
break;
27682770
default:
27692771
$f.val(fv);
@@ -3225,9 +3227,11 @@ return Backbone.View.extend({
32253227
}
32263228
if(f.type==='formula'){
32273229
h.push(Evol.Dico.HTMLFieldLabel(f, mode || 'edit')+
3228-
'<div id="'+this.fieldViewId(f.id)+'" class="disabled evo-rdonly evol-ellipsis">'+
3229-
(this.model?f.formula(this.model):'')+
3230-
'</div>');
3230+
'<div id="'+this.fieldViewId(f.id)+'" class="disabled evo-rdonly evol-ellipsis">');
3231+
if(f.formula && this.model){
3232+
h.push(f.formula(this.model));
3233+
}
3234+
h.push('</div>');
32313235
}else{
32323236
h.push(eDico.fieldHTML(f, this.fieldViewId(f.id), fv, mode, iconsPath, skipLabel));
32333237
}
@@ -3692,6 +3696,7 @@ Evol.ViewOne.Browse = Evol.ViewOne.extend({
36923696
setData: function (model) {
36933697
if(!_.isUndefined(model) && model!==null){
36943698
var that=this,
3699+
uii=Evol.UI.input,
36953700
fts = Evol.Dico.fieldTypes,
36963701
fieldHTML_ReadOny = Evol.Dico.fieldHTML_ReadOny,
36973702
$f, fv,
@@ -3715,11 +3720,14 @@ Evol.ViewOne.Browse = Evol.ViewOne.extend({
37153720
$f.html(fieldHTML_ReadOny(f, fv, Evol.hashLov, iconsPath));
37163721
break;
37173722
case fts.formula:
3718-
$f.html(f.formula(model));
3723+
$f.html(f.formula?f.formula(model):'');
37193724
break;
37203725
case fts.pix:
37213726
$f.html((fv)?('<img src="'+iconsPath+fv+'" class="img-thumbnail">'):('<p>'+Evol.i18n.nopix+'</p>'));
37223727
break;
3728+
case fts.color:
3729+
$f.html(uii.colorBox(f.id, fv, fv));
3730+
break;
37233731
case fts.textml:
37243732
if(fv){
37253733
$f.html(_.escape(fv).replace(/[\r\n]/g, '<br>'));

dist/evolutility.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dico.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Evol.Dico = function(){
3333
formula:'formula', // soon to be a field attribute rather than a field type
3434
email: 'email',
3535
pix: 'image',
36-
doc:'document',
36+
//doc:'document',
3737
url: 'url',
3838
color: 'color',
3939
hidden: 'hidden'
@@ -151,7 +151,7 @@ return {
151151
break;
152152
case fts.color: // TODO is the color switch necessary?
153153
//h+=uiInput.colorBox(fid, fv)+fv;
154-
h+='<div id="'+fid+'" class="form-control">'+fv+'</div>';
154+
h+='<div id="'+fid+'" class="form-control">'+uiInput.colorBox(fid, fv)+'</div>';
155155
break;
156156
default:
157157
h+=this.fieldHTML_ReadOny(fld, fv, {}, iconsPath);

js/many.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,11 @@ return Backbone.View.extend({
114114
var that=this,
115115
fv;
116116
if(f.type==='formula'){
117-
fv = '<div class="disabled evo-rdonly evol-ellipsis">' +
118-
(this.model?f.formula(this.model):'') +
119-
'</div>';
117+
fv = '<div class="disabled evo-rdonly evol-ellipsis">';
118+
if(f.formula && this.model){
119+
fv+=f.formula(this.model);
120+
}
121+
fv+='</div>';
120122
}else{
121123
fv = eDico.fieldHTML_ReadOny(f, v, Evol.hashLov, this.iconsPath || '');
122124
if (f.type === 'list') {

js/one-browse.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Evol.ViewOne.Browse = Evol.ViewOne.extend({
2323
setData: function (model) {
2424
if(!_.isUndefined(model) && model!==null){
2525
var that=this,
26+
uii=Evol.UI.input,
2627
fts = Evol.Dico.fieldTypes,
2728
fieldHTML_ReadOny = Evol.Dico.fieldHTML_ReadOny,
2829
$f, fv,
@@ -46,11 +47,14 @@ Evol.ViewOne.Browse = Evol.ViewOne.extend({
4647
$f.html(fieldHTML_ReadOny(f, fv, Evol.hashLov, iconsPath));
4748
break;
4849
case fts.formula:
49-
$f.html(f.formula(model));
50+
$f.html(f.formula?f.formula(model):'');
5051
break;
5152
case fts.pix:
5253
$f.html((fv)?('<img src="'+iconsPath+fv+'" class="img-thumbnail">'):('<p>'+Evol.i18n.nopix+'</p>'));
5354
break;
55+
case fts.color:
56+
$f.html(uii.colorBox(f.id, fv, fv));
57+
break;
5458
case fts.textml:
5559
if(fv){
5660
$f.html(_.escape(fv).replace(/[\r\n]/g, '<br>'));

js/one.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ return Backbone.View.extend({
227227
$f.html(eDico.fieldHTML_ReadOny(f, _.isUndefined(fv)?'':fv, Evol.hashLov, iconsPath) + ' ');
228228
break;
229229
case fts.formula:
230-
$f.html(f.formula(model));
230+
$f.html(f.formula?f.formula(model):'');
231231
break;
232232
case fts.color:
233233
$f.html(uiInput.colorBox(f.id, fv, fv));
@@ -257,7 +257,7 @@ return Backbone.View.extend({
257257
$f.select2('val', fv);
258258
break;
259259
case fts.formula:
260-
$f.html(f.formula(model));
260+
$f.html(f.formula?f.formula(model):'');
261261
break;
262262
default:
263263
$f.val(fv);
@@ -719,9 +719,11 @@ return Backbone.View.extend({
719719
}
720720
if(f.type==='formula'){
721721
h.push(Evol.Dico.HTMLFieldLabel(f, mode || 'edit')+
722-
'<div id="'+this.fieldViewId(f.id)+'" class="disabled evo-rdonly evol-ellipsis">'+
723-
(this.model?f.formula(this.model):'')+
724-
'</div>');
722+
'<div id="'+this.fieldViewId(f.id)+'" class="disabled evo-rdonly evol-ellipsis">');
723+
if(f.formula && this.model){
724+
h.push(f.formula(this.model));
725+
}
726+
h.push('</div>');
725727
}else{
726728
h.push(eDico.fieldHTML(f, this.fieldViewId(f.id), fv, mode, iconsPath, skipLabel));
727729
}

0 commit comments

Comments
 (0)