File tree Expand file tree Collapse file tree 3 files changed +30
-3
lines changed
Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 22 form: .input-group ( data-hook ='refine-input-group' )
33 input.form-control.input-sm ( type ='text' , data-hook ='refine-input' )
44 span.input-group-btn
5- button.btn.btn-default.btn-sm ( type ='button' , data-hook ='refine-button' ) Refine
5+ button.btn.btn-info.btn-sm ( type ='button' , data-hook ='refine-button' ) Apply
6+ button.btn.btn-default.btn-sm ( type ='button' , data-hook ='reset-button' ) Reset
Original file line number Diff line number Diff line change @@ -12,11 +12,28 @@ module.exports = AmpersandView.extend({
1212 default : true
1313 }
1414 } ,
15+ derived : {
16+ notEmpty : {
17+ deps : [ 'model.queryString' ] ,
18+ fn : function ( ) {
19+ return this . model . queryString !== '{}' ;
20+ }
21+ }
22+ } ,
1523 bindings : {
1624 'model.queryString' : {
1725 type : 'value' ,
1826 hook : 'refine-input'
1927 } ,
28+ notEmpty : [ {
29+ type : 'toggle' ,
30+ hook : 'reset-button'
31+ } , {
32+ type : 'booleanClass' ,
33+ hook : 'refine-button' ,
34+ yes : 'btn-info' ,
35+ no : 'btn-default'
36+ } ] ,
2037 valid : [
2138 // red input border while query is invalid
2239 {
@@ -35,7 +52,8 @@ module.exports = AmpersandView.extend({
3552 ]
3653 } ,
3754 events : {
38- 'click [data-hook=refine-button]' : 'buttonClicked' ,
55+ 'click [data-hook=refine-button]' : 'refineClicked' ,
56+ 'click [data-hook=reset-button]' : 'resetClicked' ,
3957 'input [data-hook=refine-input]' : 'inputChanged' ,
4058 'submit form' : 'submit'
4159 } ,
@@ -68,7 +86,11 @@ module.exports = AmpersandView.extend({
6886 }
6987 this . valid = true ;
7088 } ,
71- buttonClicked : function ( ) {
89+ resetClicked : function ( ) {
90+ this . model . query = new Query ( ) ;
91+ this . trigger ( 'submit' , this ) ;
92+ } ,
93+ refineClicked : function ( ) {
7294 var queryStr = this . _cleanupInput ( this . queryByHook ( 'refine-input' ) . value ) ;
7395 var queryObj = new Query ( EJSON . parse ( queryStr ) , { parse : true } ) ;
7496 this . model . query = queryObj ;
Original file line number Diff line number Diff line change 1010 height : 28px ;
1111 & + .input-group-btn {
1212 padding-left : 10px ;
13+
14+ & :last-child > .btn {
15+ margin-left : 2px ;
16+ }
1317 }
1418 }
1519}
You can’t perform that action at this time.
0 commit comments