Skip to content

Commit

Permalink
Fixed #1053
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Oct 11, 2016
1 parent 88c5028 commit afa673b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
22 changes: 19 additions & 3 deletions components/picklist/picklist.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NgModule,Component,ElementRef,OnDestroy,AfterViewInit,AfterViewChecked,DoCheck,Input,Output,ContentChild,TemplateRef} from '@angular/core';
import {NgModule,Component,ElementRef,OnDestroy,AfterViewInit,AfterViewChecked,DoCheck,Input,Output,ContentChild,TemplateRef,EventEmitter} from '@angular/core';
import {CommonModule} from '@angular/common';
import {ButtonModule} from '../button/button';
import {SharedModule} from '../common/shared';
Expand Down Expand Up @@ -73,6 +73,10 @@ export class PickList implements OnDestroy,AfterViewChecked {
@Input() sourceStyle: any;

@Input() targetStyle: any;

@Output() onMovetoSource: EventEmitter<any> = new EventEmitter();

@Output() onMoveToTarget: EventEmitter<any> = new EventEmitter();

@ContentChild(TemplateRef) itemTemplate: TemplateRef<any>;

Expand Down Expand Up @@ -209,15 +213,21 @@ export class PickList implements OnDestroy,AfterViewChecked {
this.target.push(this.source.splice(this.findIndexInList(selectedItem, this.source),1)[0]);
}
}
this.onMoveToTarget.emit({
items: this.selectedItems
});
this.selectedItems = [];
}
}

moveAllRight() {
if(this.selectedItems) {
if(this.source) {
for(let i = 0; i < this.source.length; i++) {
this.target.push(this.source[i]);
}
this.onMoveToTarget.emit({
items: this.source
});
this.source.splice(0, this.source.length);
this.selectedItems = [];
}
Expand All @@ -231,15 +241,21 @@ export class PickList implements OnDestroy,AfterViewChecked {
this.source.push(this.target.splice(this.findIndexInList(selectedItem, this.target),1)[0]);
}
}
this.onMovetoSource.emit({
items: this.selectedItems
});
this.selectedItems = [];
}
}

moveAllLeft() {
if(this.selectedItems) {
if(this.target) {
for(let i = 0; i < this.target.length; i++) {
this.source.push(this.target[i]);
}
this.onMovetoSource.emit({
items: this.target
});
this.target.splice(0, this.target.length);
this.selectedItems = [];
}
Expand Down
25 changes: 25 additions & 0 deletions showcase/demo/picklist/picklistdemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,31 @@ <h3>Attributes</h3>
</tbody>
</table>
</div>

<h3>Events</h3>
<div class="doc-tablewrapper">
<table class="doc-table">
<thead>
<tr>
<th>Name</th>
<th>Parameters</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>onMoveToTarget</td>
<td>event.items: Moved items array</td>
<td>Callback to invoke when items are moved from source to target.</td>
</tr>
<tr>
<td>onMoveToSource</td>
<td>event.items: Moved items array</td>
<td>Callback to invoke when items are moved from target to source.</td>
</tr>
</tbody>
</table>
</div>

<h3>Styling</h3>
<p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
Expand Down

0 comments on commit afa673b

Please sign in to comment.