Skip to content

Commit

Permalink
Fixed #11283 and Fixed #11296
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Mar 11, 2022
1 parent 179cfa7 commit 6e80d00
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/app/components/picklist/picklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ export class PickList implements AfterViewChecked,AfterContentInit {

@Input() stripedRows: boolean;

@Input() keepSelection: boolean = false;

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

@Output() onMoveAllToSource: EventEmitter<any> = new EventEmitter();
Expand Down Expand Up @@ -537,9 +539,15 @@ export class PickList implements AfterViewChecked,AfterContentInit {
this.visibleOptionsSource.splice(ObjectUtils.findIndexInList(selectedItem, this.visibleOptionsSource),1);
}
}

this.onMoveToTarget.emit({
items: this.selectedItemsSource
});

if (this.keepSelection) {
this.selectedItemsTarget = [...this.selectedItemsTarget, ...this.selectedItemsSource]
}

this.selectedItemsSource = [];

if (this.filterValueTarget) {
Expand All @@ -565,6 +573,10 @@ export class PickList implements AfterViewChecked,AfterContentInit {
items: movedItems
});

if (this.keepSelection) {
this.selectedItemsTarget = [...this.selectedItemsTarget, ...this.selectedItemsSource]
}

this.selectedItemsSource = [];

if (this.filterValueTarget) {
Expand All @@ -586,10 +598,15 @@ export class PickList implements AfterViewChecked,AfterContentInit {
this.visibleOptionsTarget.splice(ObjectUtils.findIndexInList(selectedItem, this.visibleOptionsTarget),1)[0]
}
}

this.onMoveToSource.emit({
items: this.selectedItemsTarget
});

if (this.keepSelection) {
this.selectedItemsSource = [...this.selectedItemsSource, ...this.selectedItemsTarget]
}

this.selectedItemsTarget = [];

if (this.filterValueSource) {
Expand All @@ -615,6 +632,10 @@ export class PickList implements AfterViewChecked,AfterContentInit {
items: movedItems
});

if (this.keepSelection) {
this.selectedItemsSource = [...this.selectedItemsSource, ...this.selectedItemsTarget]
}

this.selectedItemsTarget = [];

if (this.filterValueSource) {
Expand All @@ -640,6 +661,15 @@ export class PickList implements AfterViewChecked,AfterContentInit {
if (listType === this.SOURCE_LIST) {
if (isTransfer) {
transferArrayItem(event.previousContainer.data, event.container.data, dropIndexes.previousIndex, dropIndexes.currentIndex);
let selectedItemIndex = ObjectUtils.findIndexInList(event.item.data, this.selectedItemsTarget);

if (selectedItemIndex != -1) {
this.selectedItemsTarget.splice(selectedItemIndex,1);

if (this.keepSelection) {
this.selectedItemsTarget.push(event.item.data);
}
}

if (this.visibleOptionsTarget)
this.visibleOptionsTarget.splice(event.previousIndex, 1);
Expand All @@ -659,6 +689,16 @@ export class PickList implements AfterViewChecked,AfterContentInit {
if (isTransfer) {
transferArrayItem(event.previousContainer.data, event.container.data, dropIndexes.previousIndex, dropIndexes.currentIndex);

let selectedItemIndex = ObjectUtils.findIndexInList(event.item.data, this.selectedItemsSource);

if (selectedItemIndex != -1) {
this.selectedItemsSource.splice(selectedItemIndex,1);

if (this.keepSelection) {
this.selectedItemsTarget.push(event.item.data);
}
}

if (this.visibleOptionsSource)
this.visibleOptionsSource.splice(event.previousIndex, 1);

Expand Down

0 comments on commit 6e80d00

Please sign in to comment.