@@ -230,6 +230,7 @@ return Backbone.View.extend({
230230 this . newItem ( ) ;
231231 this . setIcons ( 'new' ) ;
232232 vw . mode = 'new' ;
233+ this . hideFilter ( ) ;
233234 } else {
234235 var ViewClass = Evol . viewClasses . getClass ( viewName ) ;
235236 if ( $v . length ) {
@@ -349,11 +350,12 @@ return Backbone.View.extend({
349350 this . updateStatus ( ) ;
350351 if ( vw . cardinality === 'n' ) {
351352 this . setRoute ( '' , false ) ;
352- if ( this . _filterOn ) { // TODO do not always change flag
353+ if ( ! this . _filterOn && this . _filterValue ) { // TODO do not always change flag
353354 this . showFilter ( false ) ;
354355 }
355356 this . updateNav ( ) ;
356357 } else {
358+ this . hideFilter ( ) ;
357359 //if(this.curView.viewName==='wizard'){
358360 // this.curView.stepIndex(0);
359361 //}
@@ -529,21 +531,21 @@ return Backbone.View.extend({
529531 return this ;
530532 } ,
531533
532- hideFilter : function ( evt ) {
534+ hideFilter : function ( ) {
533535 if ( this . _filters ) {
534536 this . _filters . $el . hide ( ) ; //.fadeOut(300);
535537 }
536538 this . _filterOn = false ;
537539 return this ;
538540 } ,
539541
540- _flagFilterIcon : function ( fOn ) {
541- dom . addRemClass ( this . $ ( 'a[data-id="filter"]' ) , fOn , 'evo-filter-on' ) ;
542+ toggleFilter : function ( v ) {
543+ this . _filterOn = _ . isBoolean ( v ) ? v : ! this . _filterOn ;
544+ return this . _filterOn ? this . showFilter ( true ) : this . hideFilter ( ) ;
542545 } ,
543546
544- toggleFilter : function ( ) {
545- this . _filterOn = ! this . _filterOn ;
546- return this . _filterOn ?this . showFilter ( true ) :this . hideFilter ( ) ;
547+ _flagFilterIcon : function ( fOn ) {
548+ dom . addRemClass ( this . $ ( 'a[data-id="filter"]' ) , fOn , 'evo-filter-on' ) ;
547549 } ,
548550
549551 setData : function ( data ) {
@@ -1042,23 +1044,19 @@ return Backbone.View.extend({
10421044 var fvs = this . _filters . val ( ) ,
10431045 collec ;
10441046 if ( fvs . length ) {
1045- var models ;
1046- if ( this . _searchString ) {
1047- models = this . _filteredCollection . models ;
1048- } else {
1049- models = this . model . collection . models ;
1050- }
1047+ var models = this . _searchString ? this . _filteredCollection . models : this . model . collection . models ;
10511048 models = Evol . Dico . filterModels ( models , fvs ) ;
10521049 if ( this . collectionClass ) {
10531050 collec = new this . collectionClass ( models ) ;
10541051 } else {
10551052 collec = new Backbone . Collection ( models ) ;
10561053 }
1057- this . _filteredCollection = collec ;
1058-
1054+ this . _filteredCollection = collec ;
1055+ this . _filterValue = fvs ;
10591056 } else {
10601057 collec = this . collection ;
1061- this . _filteredCollection = null ;
1058+ this . _filteredCollection = null ;
1059+ this . _filterValue = null ;
10621060 }
10631061 this . updateStatus ( ) ;
10641062 this . _flagFilterIcon ( fvs . length ) ;
0 commit comments