@@ -5,11 +5,12 @@ import { DualListComponent } from 'angular-dual-listbox';
55
66@Component ( {
77 selector : 'demo-app' ,
8+ styles : [ '.form-group { margin-bottom: 16px; }' , '.checkbox { margin-top: inherit }' ] ,
89 template : `
910<div class="container-fluid">
1011 <p></p>
1112 <dual-list [sort]="keepSorted" [source]="source" [key]="key" [display]="display" [filter]="filter"
12- [(destination)]="confirmed" height="265px" [format]="format"></dual-list>
13+ [(destination)]="confirmed" height="265px" [format]="format" [disabled]="disabled" ></dual-list>
1314
1415 <ul class="nav nav-tabs" style="margin-top:50px;">
1516 <li [class.active]="tab===1"><a (click)="tab=1">Arrays</a><li>
@@ -52,6 +53,12 @@ import { DualListComponent } from 'angular-dual-listbox';
5253 <label>None button</label>
5354 <input class="form-control col-sm-2" [(ngModel)]="format.none" name="noneBtn">
5455 </div>
56+ <div class="form-group">
57+ <label>Enable drag-and-drop</label>
58+ <div class="checkbox">
59+ <label><input type="checkbox" [(ngModel)]="format.draggable" name="drag">draggable</label>
60+ </div>
61+ </div>
5562 </form>
5663 </div>
5764
@@ -92,6 +99,7 @@ import { DualListComponent } from 'angular-dual-listbox';
9299 <label>General</label><br/>
93100 <form class="form-inline well">
94101 <button class="btn btn-default" (click)="doFilter()">{{filterBtn()}}</button>
102+ <button class="btn btn-default" (click)="doDisable()">{{disableBtn()}}</button>
95103 <button class="btn btn-primary" (click)="doReset()">Reset</button>
96104 </form>
97105 </div>
@@ -111,6 +119,7 @@ export class DemoAppComponent implements OnInit {
111119 source :Array < any > ;
112120 confirmed :Array < any > ;
113121 userAdd = '' ;
122+ disabled = false ;
114123
115124 sourceLeft = true ;
116125 format :any = DualListComponent . DEFAULT_FORMAT ;
@@ -209,7 +218,7 @@ export class DemoAppComponent implements OnInit {
209218
210219 private useStations ( ) {
211220 this . key = 'key' ;
212- this . display = 'station' ; //[ 'station', 'state' ];
221+ this . display = 'station' ; // [ 'station', 'state' ];
213222 this . keepSorted = true ;
214223 this . source = this . sourceStations ;
215224 this . confirmed = this . confirmedStations ;
@@ -241,7 +250,7 @@ export class DemoAppComponent implements OnInit {
241250 break ;
242251 case this . arrayType [ 2 ] . value :
243252 this . useTube ( ) ;
244- break
253+ break ;
245254 }
246255 }
247256
@@ -279,7 +288,7 @@ export class DemoAppComponent implements OnInit {
279288
280289 doCreate ( ) {
281290 if ( typeof this . source [ 0 ] === 'object' ) {
282- let o : any = { } ;
291+ const o = { } ;
283292 o [ this . key ] = this . source . length + 1 ;
284293 o [ this . display ] = this . userAdd ;
285294 this . source . push ( o ) ;
@@ -291,8 +300,8 @@ export class DemoAppComponent implements OnInit {
291300
292301 doAdd ( ) {
293302 for ( let i = 0 , len = this . source . length ; i < len ; i += 1 ) {
294- let o = this . source [ i ] ;
295- let found = this . confirmed . find ( ( e :any ) => e === o ) ;
303+ const o = this . source [ i ] ;
304+ const found = this . confirmed . find ( ( e :any ) => e === o ) ;
296305 if ( ! found ) {
297306 this . confirmed . push ( o ) ;
298307 break ;
@@ -314,6 +323,14 @@ export class DemoAppComponent implements OnInit {
314323 return ( this . filter ? 'Hide Filter' : 'Show Filter' ) ;
315324 }
316325
326+ doDisable ( ) {
327+ this . disabled = ! this . disabled ;
328+ }
329+
330+ disableBtn ( ) {
331+ return ( this . disabled ? 'Enable' : 'Disabled' ) ;
332+ }
333+
317334 swapDirection ( ) {
318335 this . sourceLeft = ! this . sourceLeft ;
319336 this . format . direction = this . sourceLeft ? DualListComponent . LTR : DualListComponent . RTL ;
0 commit comments