Skip to content

Commit 87a716d

Browse files
author
Olivier Giulieri
committed
Title update.
1 parent 7b0eea1 commit 87a716d

File tree

8 files changed

+98
-53
lines changed

8 files changed

+98
-53
lines changed

dist/evolutility.js

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ Evol.i18n = {
578578
var ns=label.split('.');
579579
l=this[ns[0]][ns[1]];
580580
}else{
581-
l=label;
581+
l=this[label];
582582
}
583583
if(string1){
584584
l= l.replace('{0}',string1);
@@ -594,11 +594,11 @@ Evol.i18n = {
594594
Edit:'Edit',
595595
// Login:'Login',
596596
New:'New',
597-
NewItem:'New {0}', //'New Item',
597+
NewEntity:'New {0}', //'New Item',
598598
NewUpload:'New Upload',
599599
//Search:'Search',
600600
//AdvSearch:'Advanced Search',
601-
NewSearch:'New Search',
601+
//NewSearch:'New Search',
602602
Selections:'Selections',
603603
Selection:'Selection',
604604
Export:'Export',
@@ -615,6 +615,13 @@ Evol.i18n = {
615615
nochart:'No charts available.',
616616
badchart:'The data structure doesn\'t allow for auto-generated charts.',
617617

618+
// --- buttons ---
619+
Save:'Save',
620+
SaveAdd:'Save and Add Another',
621+
Cancel:'Cancel',
622+
NoChange:'No Change',
623+
NoX:'No {0}',
624+
618625
// --- status ---
619626
status:{
620627
added:'New {0} "{1}" added.',
@@ -646,7 +653,8 @@ Evol.i18n = {
646653

647654
// --- export ---
648655
export:{
649-
ExportEntity: 'Export this {0}', // {0}=entity
656+
ExportEntity: 'Export {0}', // {0}=entity
657+
ExportEntities: 'Export {0}', // {0}=entities
650658
ExportHeader: 'Header',
651659
ExportSeparator: 'Separator',
652660
ExportFirstLine:'First line for field names',
@@ -667,13 +675,6 @@ Evol.i18n = {
667675
DownloadEntity:'Download {0}'
668676
},
669677

670-
// --- buttons ---
671-
Save:'Save',
672-
SaveAdd:'Save and Add Another',
673-
Cancel:'Cancel',
674-
NoChange:'No Change',
675-
NoX:'No {0}',
676-
677678
// --- filters ---
678679
filters:{
679680
sEqual:'equals',
@@ -890,7 +891,7 @@ Evol.ViewMany = Backbone.View.extend({
890891
options: {
891892
style: 'panel-info',
892893
pageSize: 20,
893-
title: '#title', // TODO FIX
894+
titleSelector: '#title',
894895
selectable: true
895896
},
896897

@@ -903,7 +904,7 @@ Evol.ViewMany = Backbone.View.extend({
903904

904905
initialize: function (opts) {
905906
var that=this;
906-
_.extend(this.options, opts);
907+
this.options=_.extend(this.options, opts);
907908
this._filter=[];
908909
if(this.collection){
909910
this.collection.on('change', function(model){
@@ -959,6 +960,7 @@ Evol.ViewMany = Backbone.View.extend({
959960
case 0:
960961
want=!fv;
961962
break;
963+
962964
}
963965
}
964966
return want;
@@ -1011,7 +1013,11 @@ Evol.ViewMany = Backbone.View.extend({
10111013
//},
10121014

10131015
_updateTitle: function (){
1014-
//$(this.options.title).html(this.model.get('title'));
1016+
$(this.options.titleSelector).html(this.getTitle());
1017+
},
1018+
1019+
getTitle: function (){
1020+
return Evol.UI.capFirstLetter(this.options.uiModel.entities);
10151021
},
10161022

10171023
getFields: function (){
@@ -1149,6 +1155,7 @@ Evol.ViewMany = Backbone.View.extend({
11491155
var $e=$(evt.currentTarget),
11501156
id=$e.data('id'),
11511157
eType=$e.data('type');
1158+
11521159
Evol.Dico.showDesigner(id, eType, $e);
11531160
this.$el.trigger(eType+'.customize', {id: id, type:eType});
11541161
}
@@ -1521,7 +1528,7 @@ Evol.ViewOne = Backbone.View.extend({
15211528
});
15221529
},
15231530

1524-
getSummary: function(){
1531+
getTitle: function(){
15251532
if(this.model){
15261533
var lf=this.options.uiModel.leadfield;
15271534
return _.isFunction(lf)?lf(this.model):this.model.get(lf);
@@ -1929,7 +1936,7 @@ Evol.ViewOne = Backbone.View.extend({
19291936
if(title){
19301937
t=title;
19311938
}else if(lf!==undefined && lf!==''){
1932-
t=this.getSummary();
1939+
t=this.getTitle();
19331940
}else{
19341941
t=Evol.UI.capFirstLetter(opts.uiModel.entities);
19351942
}
@@ -2277,6 +2284,7 @@ Evol.ViewToolbar = Backbone.View.extend({
22772284
defaultView: 'list',
22782285
style: 'panel-info',
22792286
display: 'tooltip', // tooltip, text, icon, none
2287+
titleSelector: '#title',
22802288
buttons: {
22812289
// --- views for one ---
22822290
edit: true,
@@ -2469,7 +2477,8 @@ Evol.ViewToolbar = Backbone.View.extend({
24692477
model: this.model,
24702478
collection: this.collection,
24712479
uiModel: opts.uiModel,
2472-
style: opts.style
2480+
style: opts.style,
2481+
titleSelector: opts.titleSelector
24732482
};
24742483
this.$('[data-id="new"]').show();
24752484
this.$('[data-id="views"] > li').removeClass('evo-sel') // TODO optimize
@@ -2499,9 +2508,15 @@ Evol.ViewToolbar = Backbone.View.extend({
24992508
this.curView=vw;
25002509
this.curViewName=viewName;
25012510
this.viewsHash[viewName]=vw;
2511+
if(this.curView._updateTitle){
2512+
this.curView._updateTitle(); // TODO fix: make public?
2513+
}else{
2514+
//TODO better way
2515+
$(this.options.titleSelector).html(this.curView.getTitle());
2516+
}
25022517
}
25032518
}
2504-
this.setButtons(viewName);
2519+
this.setMode(viewName);
25052520
return this;
25062521
},
25072522

@@ -2519,7 +2534,7 @@ Evol.ViewToolbar = Backbone.View.extend({
25192534
return this._toolbarButtons;
25202535
},
25212536

2522-
setButtons: function(mode){
2537+
setMode: function(mode){
25232538
function oneMany(showOne, showMany){
25242539
Evol.UI.setVisible(tbBs.ones, showOne);
25252540
Evol.UI.setVisible(tbBs.manys, showMany);
@@ -2628,7 +2643,7 @@ Evol.ViewToolbar = Backbone.View.extend({
26282643
}else{
26292644
that.model=m;
26302645
that._isNew=false;
2631-
that.setButtons('edit');
2646+
that.setMode('edit');
26322647
vw.setModel(m);
26332648
}
26342649
vw._updateTitle();
@@ -2642,7 +2657,7 @@ Evol.ViewToolbar = Backbone.View.extend({
26422657
collec.create(this.getData(), {
26432658
success: function(m){
26442659
fnSuccess(m);
2645-
that.setMessage('Record saved.', Evol.i18n.getLabel('status.added',entityName,vw.getSummary()), 'success');
2660+
that.setMessage('Record saved.', Evol.i18n.getLabel('status.added',entityName,vw.getTitle()), 'success');
26462661
},
26472662
error:function(err){
26482663
alert('error');
@@ -2657,7 +2672,7 @@ Evol.ViewToolbar = Backbone.View.extend({
26572672
this.model.save('','',{
26582673
success: function(m){
26592674
fnSuccess(m);
2660-
that.setMessage('Record saved.', Evol.i18n.getLabel('status.updated',entityName,vw.getSummary()), 'success');
2675+
that.setMessage('Record saved.', Evol.i18n.getLabel('status.updated',entityName,vw.getTitle()), 'success');
26612676
},
26622677
error:function(err){
26632678
alert('error');
@@ -2677,12 +2692,12 @@ Evol.ViewToolbar = Backbone.View.extend({
26772692
newItem: function(){
26782693
var vw=this.curView;
26792694
return vw.clear()
2680-
._updateTitle(Evol.i18n.getLabel('NewItem', this.options.uiModel.entity, vw.getSummary()));
2695+
._updateTitle(Evol.i18n.getLabel('NewEntity', this.options.uiModel.entity, vw.getTitle()));
26812696
},
26822697

26832698
deleteItem: function(){
26842699
var entityName=this.options.uiModel.entity,
2685-
entityValue=this.curView.getSummary(),
2700+
entityValue=this.curView.getTitle(),
26862701
delModel=this.curView.model;
26872702
// TODO good looking msgbox
26882703
if (delModel && confirm(Evol.i18n.getLabel('DeleteEntity', entityName, entityValue))) {
@@ -2827,11 +2842,11 @@ Evol.ViewExport = Backbone.View.extend({
28272842
toolbar: true,
28282843
model: null,
28292844
uiModel: null,
2845+
many: true,
28302846
style: 'normal',
28312847
prefix: 'tbr'
28322848
},
28332849

2834-
many: true,
28352850
viewName: "export",
28362851

28372852
initialize: function (opts) {
@@ -2973,6 +2988,14 @@ Evol.ViewExport = Backbone.View.extend({
29732988
return this.fields;
29742989
},
29752990

2991+
getTitle: function(){
2992+
if(this.options.many){
2993+
return Evol.i18n.getLabel('export.ExportEntities', this.options.uiModel.entities);
2994+
}else{
2995+
return Evol.i18n.getLabel('export.ExportEntity', this.options.uiModel.entity);
2996+
}
2997+
},
2998+
29762999
_preview: function (format) {
29773000
var h=[];
29783001
if(this.model && this.model.collection){

dist/evolutility.min.js

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

js/demo.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ function setDemo(uiModel, localStorage, data, style){
5151
modelClass: M,
5252
collection: ms,
5353
collectionClass: Ms,
54-
uiModel: uiModel
54+
uiModel: uiModel,
55+
titleSelector: '#title'
5556
});
5657

5758
$('#recs > a').on('click', function(evt){

js/export.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ Evol.ViewExport = Backbone.View.extend({
2626
toolbar: true,
2727
model: null,
2828
uiModel: null,
29+
many: true,
2930
style: 'normal',
3031
prefix: 'tbr'
3132
},
3233

33-
many: true,
3434
viewName: "export",
3535

3636
initialize: function (opts) {
@@ -172,6 +172,14 @@ Evol.ViewExport = Backbone.View.extend({
172172
return this.fields;
173173
},
174174

175+
getTitle: function(){
176+
if(this.options.many){
177+
return Evol.i18n.getLabel('export.ExportEntities', this.options.uiModel.entities);
178+
}else{
179+
return Evol.i18n.getLabel('export.ExportEntity', this.options.uiModel.entity);
180+
}
181+
},
182+
175183
_preview: function (format) {
176184
var h=[];
177185
if(this.model && this.model.collection){

js/i18n/EN.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Evol.i18n = {
1414
var ns=label.split('.');
1515
l=this[ns[0]][ns[1]];
1616
}else{
17-
l=label;
17+
l=this[label];
1818
}
1919
if(string1){
2020
l= l.replace('{0}',string1);
@@ -30,11 +30,11 @@ Evol.i18n = {
3030
Edit:'Edit',
3131
// Login:'Login',
3232
New:'New',
33-
NewItem:'New {0}', //'New Item',
33+
NewEntity:'New {0}', //'New Item',
3434
NewUpload:'New Upload',
3535
//Search:'Search',
3636
//AdvSearch:'Advanced Search',
37-
NewSearch:'New Search',
37+
//NewSearch:'New Search',
3838
Selections:'Selections',
3939
Selection:'Selection',
4040
Export:'Export',
@@ -51,6 +51,13 @@ Evol.i18n = {
5151
nochart:'No charts available.',
5252
badchart:'The data structure doesn\'t allow for auto-generated charts.',
5353

54+
// --- buttons ---
55+
Save:'Save',
56+
SaveAdd:'Save and Add Another',
57+
Cancel:'Cancel',
58+
NoChange:'No Change',
59+
NoX:'No {0}',
60+
5461
// --- status ---
5562
status:{
5663
added:'New {0} "{1}" added.',
@@ -82,7 +89,8 @@ Evol.i18n = {
8289

8390
// --- export ---
8491
export:{
85-
ExportEntity: 'Export this {0}', // {0}=entity
92+
ExportEntity: 'Export {0}', // {0}=entity
93+
ExportEntities: 'Export {0}', // {0}=entities
8694
ExportHeader: 'Header',
8795
ExportSeparator: 'Separator',
8896
ExportFirstLine:'First line for field names',
@@ -103,13 +111,6 @@ Evol.i18n = {
103111
DownloadEntity:'Download {0}'
104112
},
105113

106-
// --- buttons ---
107-
Save:'Save',
108-
SaveAdd:'Save and Add Another',
109-
Cancel:'Cancel',
110-
NoChange:'No Change',
111-
NoX:'No {0}',
112-
113114
// --- filters ---
114115
filters:{
115116
sEqual:'equals',

js/many.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Evol.ViewMany = Backbone.View.extend({
1919
options: {
2020
style: 'panel-info',
2121
pageSize: 20,
22-
title: '#title', // TODO FIX
22+
titleSelector: '#title',
2323
selectable: true
2424
},
2525

@@ -32,7 +32,7 @@ Evol.ViewMany = Backbone.View.extend({
3232

3333
initialize: function (opts) {
3434
var that=this;
35-
_.extend(this.options, opts);
35+
this.options=_.extend(this.options, opts);
3636
this._filter=[];
3737
if(this.collection){
3838
this.collection.on('change', function(model){
@@ -141,7 +141,11 @@ Evol.ViewMany = Backbone.View.extend({
141141
//},
142142

143143
_updateTitle: function (){
144-
//$(this.options.title).html(this.model.get('title'));
144+
$(this.options.titleSelector).html(this.getTitle());
145+
},
146+
147+
getTitle: function (){
148+
return Evol.UI.capFirstLetter(this.options.uiModel.entities);
145149
},
146150

147151
getFields: function (){

js/one.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Evol.ViewOne = Backbone.View.extend({
9393
});
9494
},
9595

96-
getSummary: function(){
96+
getTitle: function(){
9797
if(this.model){
9898
var lf=this.options.uiModel.leadfield;
9999
return _.isFunction(lf)?lf(this.model):this.model.get(lf);
@@ -501,7 +501,7 @@ Evol.ViewOne = Backbone.View.extend({
501501
if(title){
502502
t=title;
503503
}else if(lf!==undefined && lf!==''){
504-
t=this.getSummary();
504+
t=this.getTitle();
505505
}else{
506506
t=Evol.UI.capFirstLetter(opts.uiModel.entities);
507507
}

0 commit comments

Comments
 (0)