Skip to content

Commit 9dba74c

Browse files
author
Olivier Giulieri
committed
Cleanups + bug fixes.
1 parent 292febf commit 9dba74c

12 files changed

Lines changed: 64 additions & 55 deletions

File tree

js/action-export.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,13 @@ Evol.ViewAction.Export = Backbone.View.extend({
209209
//data
210210
_.every(data, function(m, idx){
211211
_.each(flds, function(f, idx){
212-
var mj = m.get(f.id);
213-
if (mj) {
214-
h.push(mj);
212+
var mv = m.get(f.id);
213+
if (mv) {
214+
if((_.isArray(mv) && mv.length>1)|| (mv.indexOf(',')>-1)){
215+
h.push('"', mv, '"');
216+
}else{
217+
h.push(mv);
218+
}
215219
}
216220
if(idx<fMax){
217221
h.push(sep);
@@ -305,6 +309,13 @@ Evol.ViewAction.Export = Backbone.View.extend({
305309
h.push('"', fValue.replace(/"/g, '""'), '"');
306310
}
307311
break;
312+
case fTypes.list:
313+
if(_.isUndefined(fValue)||fValue===''){
314+
h.push('NULL');
315+
}else {
316+
h.push('"', Evol.Dico.HTMLField4Many(f, fValue, Evol.hashLov, '').replace(/"/g, '""'), '"');
317+
}
318+
break;
308319
default:
309320
if(_.isUndefined(fValue)){
310321
h.push('""');

js/action-filter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Evol.ViewAction.Filter = Backbone.View.extend({
5656
if(f.type!==Evol.Dico.fieldTypes.list){
5757
return f;
5858
}else{
59-
return _.extend(f, {
59+
return _.extend({}, f, {
6060
type: Evol.Dico.fieldTypes.lov,
6161
trueType: Evol.Dico.fieldTypes.list
6262
});
@@ -564,15 +564,15 @@ Evol.ViewAction.Filter = Backbone.View.extend({
564564
},
565565

566566
val: function(value){
567+
// --- get value
567568
if (_.isUndefined(value)){
568-
// --- get value
569569
var v=[];
570570
this._filters.find('a').each(function(){
571571
v.push($(this).data('filter'));
572572
});
573573
return v;
574+
// --- set value
574575
}else{
575-
// --- set value
576576
this._filters.empty();
577577
for(var i=0,iMax=value.length;i<iMax;i++){
578578
this.addFilter(value[i]);

js/dico.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ Evol.Dico = {
200200
var filter=filters[i],
201201
vf=filter.value.value,
202202
vm=model.get(filter.field.value);
203+
// TODO use field.value(m) || field.id
204+
203205
if(_.isUndefined(vm)){
204206
vm='';
205207
}

js/i18n/EN.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Evol.i18n = {
9191
// --- validation ---
9292
validation:{
9393
incomplete: 'Incomplete information',
94+
invalid: 'Invalid format.',
9495
intro:'You are not finished yet:',
9596
empty:'"{0}" must have a value.',
9697
email:'"{0}" must be a valid email like "abc@company.com".',

js/many-badges.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Evol.ViewMany.Badges = Evol.ViewMany.extend({
4444
if(f.value){
4545
v = f.value(model);
4646
}else{
47-
v = that._HTMLField(f, model.escape(f.id));
47+
v = that._HTMLField(f, model.escape(f.attribute || f.id));
4848
}
4949
if (idx === 0) {
5050
h.push('<div data-mid="', model.id, '"><h4>',

js/many-charts.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
*
1010
*************************************************************************** */
1111

12+
// Quick and easy implementation w/ the old version of google charts
13+
// must be re-written to use D3.js or other cool stuff
1214
Evol.ViewMany.Charts = Evol.ViewMany.extend({
1315

1416
viewName: 'charts',

js/many-list.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ Evol.ViewMany.List = Evol.ViewMany.extend({
5555
}
5656
_.each(fields, function(f, idx){
5757
if(f.type===Evol.Dico.fieldTypes.color){
58-
v = Evol.UI.input.colorBox(f.id, model.escape(f.id));
58+
v = Evol.UI.input.colorBox(f.id, model.escape(f.attribute || f.id));
5959
}else if(f.value){
6060
v = f.value(model);
6161
}else{
62-
v = that._HTMLField(f, model.escape(f.id));
62+
v = that._HTMLField(f, model.escape(f.attribute || f.id));
6363
}
6464
if(idx===0){
6565
v = Evol.Dico.HTMLFieldLink('fv-'+f.id, f, v, icon, !link, route?route+model.id:null);

js/many.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ Evol.ViewMany = Backbone.View.extend({
8585
var models = this.collection.models,
8686
model,
8787
r,
88-
rMin=0,
88+
rMin = 0,
8989
rMax = _.min([models.length, rMin+pSize]),
9090
ico = icon?(this.options.iconsPath || '')+icon:null,
9191
route=this.getItemRoute();
9292

93-
if(pageIdx>0){
93+
if(pageIdx > 0){
9494
rMin = pageIdx*pSize;
9595
rMax = _.min([models.length, rMin+pSize]);
9696
}
@@ -106,6 +106,14 @@ Evol.ViewMany = Backbone.View.extend({
106106
alert('_render must be overwritten');
107107
},
108108

109+
_HTMLField: function(f, v){
110+
var fv=Evol.Dico.HTMLField4Many(f, v, Evol.hashLov, this.options.iconsPath || '');
111+
if(f.type==='list'){
112+
fv= _.escape(fv);
113+
}
114+
return fv;
115+
},
116+
109117
_HTMLCheckbox: function(cid){
110118
return Evol.UI.input.checkbox2(cid, false, 'list-sel');
111119
},
@@ -192,10 +200,6 @@ Evol.ViewMany = Backbone.View.extend({
192200
return this.pageIndex;
193201
},
194202

195-
_HTMLField: function(f, v){
196-
return Evol.Dico.HTMLField4Many(f, v, Evol.hashLov, this.options.iconsPath || '');
197-
},
198-
199203
_$Selection:function(){
200204
return this.$('.list-sel:checked').not('[data-id="cbxAll"]');
201205
},

js/one-view.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ Evol.ViewOne.View = Evol.ViewOne.extend({
2222

2323
setData: function (model) {
2424
if(!_.isUndefined(model) && model!==null){
25-
var fs = this.getFields(),
26-
that=this,
25+
var that=this,
2726
fTypes = Evol.Dico.fieldTypes,
2827
$f, fv,
2928
prefix='#'+ that.prefix + '-',
3029
subCollecs=this.getSubCollecs(),
3130
iconsPath=this.options.iconsPath||'';
32-
_.each(fs, function (f) {
31+
_.each(this.getFields(), function (f) {
3332
$f=that.$(prefix + f.id);
3433
if(f.value){
3534
fv=f.value(model);
@@ -73,15 +72,14 @@ Evol.ViewOne.View = Evol.ViewOne.extend({
7372
},
7473

7574
clear: function () {
76-
var fs = this.getFields(),
77-
that=this,
75+
var that=this,
7876
$f,
7977
fTypes = Evol.Dico.fieldTypes,
8078
prefix='#'+ that.prefix + '-',
8179
subCollecs=this.getSubCollecs();
8280

8381
this.clearMessages();
84-
_.each(fs, function (f) {
82+
_.each(this.getFields(), function (f) {
8583
$f=that.$(prefix + f.id);
8684
switch(f.type) {
8785
case fTypes.bool:

js/one.js

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Evol.ViewOne = Backbone.View.extend({
151151
});
152152
}
153153
if(skipReadOnlyFields){
154-
_.each(this.getFields(),function(f){
154+
_.each(fs, function(f){
155155
if(f.readonly){
156156
delete vs[f.id];
157157
}
@@ -162,16 +162,15 @@ Evol.ViewOne = Backbone.View.extend({
162162

163163
setData: function (model, isModel) {
164164
if(!_.isUndefined(model) && model!==null){
165-
var fs = this.getFields(),
166-
that=this,
165+
var that=this,
167166
fTypes = Evol.Dico.fieldTypes,
168167
$f, fv,
169168
prefix='#'+ this.prefix + '-',
170169
subCollecs=this.getSubCollecs(),
171170
iconsPath=this.options.iconsPath||'',
172171
newPix;
173172

174-
_.each(fs, function (f) {
173+
_.each(this.getFields(), function (f) {
175174
$f=that.$(prefix + f.id);
176175
if(isModel){
177176
if(f.value){
@@ -183,28 +182,19 @@ Evol.ViewOne = Backbone.View.extend({
183182
fv=model[f.attribute || f.id];
184183
}
185184
if(f.readonly){
186-
if(f.type===fTypes.pix){
187-
newPix=(fv)?('<img src="'+iconsPath+fv+'" class="img-thumbnail">'):('<p class="">'+Evol.i18n.nopix+'</p>');
188-
$f.val(fv)
189-
.prev().remove();
190-
$f.before(newPix);
191-
}else{
192-
switch(f.type){
193-
case fTypes.lov:
194-
case fTypes.bool:
195-
case fTypes.email:
196-
case fTypes.url:
197-
$f.html(Evol.Dico.HTMLField4Many(f, fv, Evol.hashLov, iconsPath));
198-
break;
199-
case fTypes.pix:
200-
$f.html((fv)?('<img src="'+iconsPath+fv+'" class="img-thumbnail">'):('<p>'+Evol.i18n.nopix+'</p>'));
201-
break;
202-
case fTypes.textml:
203-
$f.html(Evol.UI.cr2br(fv));
204-
break;
205-
default:
206-
$f.text(Evol.Dico.HTMLField4Many(f, fv, Evol.hashLov, iconsPath) || ' ');
207-
}
185+
switch(f.type){
186+
case fTypes.pix:
187+
newPix=(fv)?('<img src="'+iconsPath+fv+'" class="img-thumbnail">'):('<p class="">'+Evol.i18n.nopix+'</p>');
188+
$f.val(fv)
189+
.prev().remove();
190+
$f.before(newPix);
191+
//$f.html((fv)?('<img src="'+iconsPath+fv+'" class="img-thumbnail">'):('<p>'+Evol.i18n.nopix+'</p>'));
192+
break;
193+
case fTypes.textml:
194+
$f.html(Evol.UI.cr2br(fv));
195+
break;
196+
default:
197+
$f.text(Evol.Dico.HTMLField4Many(f, _.isUndefined(fv)?'':fv, Evol.hashLov, iconsPath) + ' ');
208198
}
209199
}else{
210200
switch(f.type) {
@@ -262,16 +252,15 @@ Evol.ViewOne = Backbone.View.extend({
262252
},
263253

264254
clear: function () {
265-
var ft =Evol.Dico.fieldTypes,
266-
fs = this.getFields(),
267-
that=this,
255+
var that=this,
256+
ft =Evol.Dico.fieldTypes,
268257
$f,
269258
prefix='#'+ that.prefix + '-',
270259
subCollecs=this.getSubCollecs(),
271260
defaultVal;
272261

273262
this.clearMessages();
274-
_.each(fs, function (f) {
263+
_.each(this.getFields(), function (f) {
275264
$f = that.$(prefix + f.id);
276265
defaultVal = f.defaultvalue || '';
277266
switch(f.type) {
@@ -425,7 +414,7 @@ Evol.ViewOne = Backbone.View.extend({
425414
iTab = -1,
426415
iPanel = -1,
427416
elems = this.uiModel.elements,
428-
iMax = elems.length;
417+
iMax1 = elems.length - 1;
429418

430419
h.push('<div class="evo-one-',mode,'">');
431420
_.each(elems, function(p, idx){
@@ -442,7 +431,7 @@ Evol.ViewOne = Backbone.View.extend({
442431
iTab++;
443432
h.push('<div id="evol-tab-', idx, '" class="tab-pane', (idx === 1 ? ' active">' : '">'));
444433
that.renderTab(h, p, mode);
445-
if (iTab == iMax - 1) {
434+
if (iTab == iMax1) {
446435
h.push('</div>');
447436
}
448437
}else{

0 commit comments

Comments
 (0)