Skip to content

Commit 06e80e0

Browse files
author
Çağatay Çivici
committed
Dump enum
1 parent da227b0 commit 06e80e0

File tree

2 files changed

+41
-48
lines changed

2 files changed

+41
-48
lines changed

Diff for: src/app/components/picklist/picklist.ts

+40-47
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ import {SharedModule,PrimeTemplate} from '../common/shared';
55
import {DomHandler} from '../dom/domhandler';
66
import {ObjectUtils} from '../utils/objectutils';
77

8-
enum ListType {
9-
SOURCE = 0,
10-
TARGET = 1
11-
}
12-
138
@Component({
149
selector: 'p-pickList',
1510
template: `
@@ -25,22 +20,22 @@ enum ListType {
2520
<div class="ui-picklist-listwrapper ui-picklist-source-wrapper" [ngClass]="{'ui-picklist-listwrapper-nocontrols':!showSourceControls}">
2621
<div class="ui-picklist-caption ui-widget-header ui-corner-tl ui-corner-tr" *ngIf="sourceHeader">{{sourceHeader}}</div>
2722
<div class="ui-picklist-filter-container ui-widget-content" *ngIf="filterBy">
28-
<input type="text" role="textbox" (keyup)="onFilter($event,source,listType.SOURCE)" class="ui-picklist-filter ui-inputtext ui-widget ui-state-default ui-corner-all" [disabled]="disabled" [attr.placeholder]="sourceFilterPlaceholder">
23+
<input type="text" role="textbox" (keyup)="onFilter($event,source,-1)" class="ui-picklist-filter ui-inputtext ui-widget ui-state-default ui-corner-all" [disabled]="disabled" [attr.placeholder]="sourceFilterPlaceholder">
2924
<span class="fa fa-search"></span>
3025
</div>
31-
<ul #sourcelist class="ui-widget-content ui-picklist-list ui-picklist-source ui-corner-bottom" [ngStyle]="sourceStyle" (dragover)="onListMouseMove($event,listType.SOURCE)">
26+
<ul #sourcelist class="ui-widget-content ui-picklist-list ui-picklist-source ui-corner-bottom" [ngStyle]="sourceStyle" (dragover)="onListMouseMove($event,-1)">
3227
<li class="ui-picklist-droppoint-empty" *ngIf="dragdrop && source && source.length == 0"
33-
(dragover)="onEmptyListDragOver($event, listType.SOURCE)" (drop)="onEmptyListDrop($event, listType.SOURCE)"></li>
28+
(dragover)="onEmptyListDragOver($event, -1)" (drop)="onEmptyListDrop($event, -1)"></li>
3429
<ng-template ngFor let-item [ngForOf]="source" let-i="index" let-l="last">
35-
<li class="ui-picklist-droppoint" *ngIf="dragdrop" (dragover)="onDragOver($event, i, listType.SOURCE)" (drop)="onDrop($event, i, listType.SOURCE)" (dragleave)="onDragLeave($event, listType.SOURCE)"
36-
[ngClass]="{'ui-state-highlight': (i === dragOverItemIndexSource)}" [style.display]="isItemVisible(item, listType.SOURCE) ? 'block' : 'none'"></li>
30+
<li class="ui-picklist-droppoint" *ngIf="dragdrop" (dragover)="onDragOver($event, i, -1)" (drop)="onDrop($event, i, -1)" (dragleave)="onDragLeave($event, -1)"
31+
[ngClass]="{'ui-state-highlight': (i === dragOverItemIndexSource)}" [style.display]="isItemVisible(item, -1) ? 'block' : 'none'"></li>
3732
<li [ngClass]="{'ui-picklist-item':true,'ui-state-highlight':isSelected(item,selectedItemsSource)}"
3833
(click)="onItemClick($event,item,selectedItemsSource)" (touchend)="onItemTouchEnd($event)"
39-
[style.display]="isItemVisible(item, listType.SOURCE) ? 'block' : 'none'"
40-
[draggable]="dragdrop" (dragstart)="onDragStart($event, i, listType.SOURCE)" (dragend)="onDragEnd($event)">
34+
[style.display]="isItemVisible(item, -1) ? 'block' : 'none'"
35+
[draggable]="dragdrop" (dragstart)="onDragStart($event, i, -1)" (dragend)="onDragEnd($event)">
4136
<ng-template [pTemplateWrapper]="itemTemplate" [item]="item"></ng-template>
4237
</li>
43-
<li class="ui-picklist-droppoint" *ngIf="dragdrop&&l" (dragover)="onDragOver($event, i + 1, listType.SOURCE)" (drop)="onDrop($event, i + 1, listType.SOURCE)" (dragleave)="onDragLeave($event, listType.SOURCE)"
38+
<li class="ui-picklist-droppoint" *ngIf="dragdrop&&l" (dragover)="onDragOver($event, i + 1, -1)" (drop)="onDrop($event, i + 1, -1)" (dragleave)="onDragLeave($event, -1)"
4439
[ngClass]="{'ui-state-highlight': (i + 1 === dragOverItemIndexSource)}"></li>
4540
</ng-template>
4641
</ul>
@@ -56,22 +51,22 @@ enum ListType {
5651
<div class="ui-picklist-listwrapper ui-picklist-target-wrapper" [ngClass]="{'ui-picklist-listwrapper-nocontrols':!showTargetControls}">
5752
<div class="ui-picklist-caption ui-widget-header ui-corner-tl ui-corner-tr" *ngIf="targetHeader">{{targetHeader}}</div>
5853
<div class="ui-picklist-filter-container ui-widget-content" *ngIf="filterBy">
59-
<input type="text" role="textbox" (keyup)="onFilter($event,target,listType.TARGET)" class="ui-picklist-filter ui-inputtext ui-widget ui-state-default ui-corner-all" [disabled]="disabled" [attr.placeholder]="targetFilterPlaceholder">
54+
<input type="text" role="textbox" (keyup)="onFilter($event,target,1)" class="ui-picklist-filter ui-inputtext ui-widget ui-state-default ui-corner-all" [disabled]="disabled" [attr.placeholder]="targetFilterPlaceholder">
6055
<span class="fa fa-search"></span>
6156
</div>
62-
<ul #targetlist class="ui-widget-content ui-picklist-list ui-picklist-target ui-corner-bottom" [ngStyle]="targetStyle" (dragover)="onListMouseMove($event,listType.TARGET)">
57+
<ul #targetlist class="ui-widget-content ui-picklist-list ui-picklist-target ui-corner-bottom" [ngStyle]="targetStyle" (dragover)="onListMouseMove($event,1)">
6358
<li class="ui-picklist-droppoint-empty" *ngIf="dragdrop && target && target.length == 0"
64-
(dragover)="onEmptyListDragOver($event, listType.TARGET)" (drop)="onEmptyListDrop($event, listType.TARGET)"></li>
59+
(dragover)="onEmptyListDragOver($event, 1)" (drop)="onEmptyListDrop($event, 1)"></li>
6560
<ng-template ngFor let-item [ngForOf]="target" let-i="index" let-l="last">
66-
<li class="ui-picklist-droppoint" *ngIf="dragdrop" (dragover)="onDragOver($event, i, listType.TARGET)" (drop)="onDrop($event, i, listType.TARGET)" (dragleave)="onDragLeave($event, listType.TARGET)"
67-
[ngClass]="{'ui-state-highlight': (i === dragOverItemIndexTarget)}" [style.display]="isItemVisible(item, listType.TARGET) ? 'block' : 'none'"></li>
61+
<li class="ui-picklist-droppoint" *ngIf="dragdrop" (dragover)="onDragOver($event, i, 1)" (drop)="onDrop($event, i, 1)" (dragleave)="onDragLeave($event, 1)"
62+
[ngClass]="{'ui-state-highlight': (i === dragOverItemIndexTarget)}" [style.display]="isItemVisible(item, 1) ? 'block' : 'none'"></li>
6863
<li [ngClass]="{'ui-picklist-item':true,'ui-state-highlight':isSelected(item,selectedItemsTarget)}"
6964
(click)="onItemClick($event,item,selectedItemsTarget)" (touchend)="onItemTouchEnd($event)"
70-
[style.display]="isItemVisible(item, listType.TARGET) ? 'block' : 'none'"
71-
[draggable]="dragdrop" (dragstart)="onDragStart($event, i, listType.TARGET)" (dragend)="onDragEnd($event)">
65+
[style.display]="isItemVisible(item, 1) ? 'block' : 'none'"
66+
[draggable]="dragdrop" (dragstart)="onDragStart($event, i, 1)" (dragend)="onDragEnd($event)">
7267
<ng-template [pTemplateWrapper]="itemTemplate" [item]="item"></ng-template>
7368
</li>
74-
<li class="ui-picklist-droppoint" *ngIf="dragdrop&&l" (dragover)="onDragOver($event, i + 1, listType.TARGET)" (drop)="onDrop($event, i + 1, listType.TARGET)" (dragleave)="onDragLeave($event, listType.TARGET)"
69+
<li class="ui-picklist-droppoint" *ngIf="dragdrop&&l" (dragover)="onDragOver($event, i + 1, 1)" (drop)="onDrop($event, i + 1, 1)" (dragleave)="onDragLeave($event, 1)"
7570
[ngClass]="{'ui-state-highlight': (i + 1 === dragOverItemIndexTarget)}"></li>
7671
</ng-template>
7772
</ul>
@@ -147,9 +142,7 @@ export class PickList implements AfterViewChecked,AfterContentInit {
147142
public visibleOptionsSource: any[];
148143

149144
public visibleOptionsTarget: any[];
150-
151-
public listType = ListType;
152-
145+
153146
selectedItemsSource: any[] = [];
154147

155148
selectedItemsTarget: any[] = [];
@@ -176,9 +169,9 @@ export class PickList implements AfterViewChecked,AfterContentInit {
176169

177170
filterValueTarget: string;
178171

179-
fromListType: ListType;
172+
fromListType: number;
180173

181-
toListType: ListType;
174+
toListType: number;
182175

183176
constructor(public el: ElementRef, public domHandler: DomHandler, public objectUtils: ObjectUtils) {}
184177

@@ -242,28 +235,28 @@ export class PickList implements AfterViewChecked,AfterContentInit {
242235
this.itemTouched = false;
243236
}
244237

245-
onFilter(event: KeyboardEvent, data: any[], listType: ListType) {
238+
onFilter(event: KeyboardEvent, data: any[], listType: number) {
246239
let query = (<HTMLInputElement> event.target).value.trim().toLowerCase();
247240

248-
if(listType === ListType.SOURCE)
241+
if(listType === -1)
249242
this.filterValueSource = query;
250243
else
251244
this.filterValueTarget = query;
252245

253246
this.activateFilter(data, listType);
254247
}
255248

256-
activateFilter(data: any[], listType: ListType) {
249+
activateFilter(data: any[], listType: number) {
257250
let searchFields = this.filterBy.split(',');
258251

259-
if(listType === ListType.SOURCE)
252+
if(listType === -1)
260253
this.visibleOptionsSource = this.objectUtils.filter(data, searchFields, this.filterValueSource);
261254
else
262255
this.visibleOptionsTarget = this.objectUtils.filter(data, searchFields, this.filterValueTarget);
263256
}
264257

265-
isItemVisible(item: any, listType: ListType): boolean {
266-
if(listType == ListType.SOURCE)
258+
isItemVisible(item: any, listType: number): boolean {
259+
if(listType == -1)
267260
return this.isVisibleInList(this.visibleOptionsSource, item, this.filterValueSource);
268261
else
269262
return this.isVisibleInList(this.visibleOptionsTarget, item, this.filterValueTarget);
@@ -466,10 +459,10 @@ export class PickList implements AfterViewChecked,AfterContentInit {
466459
return index;
467460
}
468461

469-
onDragStart(event: DragEvent, index: number, listType: ListType) {
462+
onDragStart(event: DragEvent, index: number, listType: number) {
470463
this.dragging = true;
471464
this.fromListType = listType;
472-
if(listType === ListType.SOURCE)
465+
if(listType === -1)
473466
this.draggedItemIndexSource = index;
474467
else
475468
this.draggedItemIndexTarget = index;
@@ -480,37 +473,37 @@ export class PickList implements AfterViewChecked,AfterContentInit {
480473
}
481474
}
482475

483-
onDragOver(event: DragEvent, index: number, listType: ListType) {
484-
if(listType == ListType.SOURCE) {
485-
if(this.draggedItemIndexSource !== index && this.draggedItemIndexSource + 1 !== index || (this.fromListType === ListType.TARGET)) {
476+
onDragOver(event: DragEvent, index: number, listType: number) {
477+
if(listType == -1) {
478+
if(this.draggedItemIndexSource !== index && this.draggedItemIndexSource + 1 !== index || (this.fromListType === 1)) {
486479
this.dragOverItemIndexSource = index;
487480
event.preventDefault();
488481
}
489482
}
490483
else {
491-
if(this.draggedItemIndexTarget !== index && this.draggedItemIndexTarget + 1 !== index || (this.fromListType === ListType.SOURCE)) {
484+
if(this.draggedItemIndexTarget !== index && this.draggedItemIndexTarget + 1 !== index || (this.fromListType === -1)) {
492485
this.dragOverItemIndexTarget = index;
493486
event.preventDefault();
494487
}
495488
}
496489
}
497490

498-
onDragLeave(event: DragEvent, listType: ListType) {
491+
onDragLeave(event: DragEvent, listType: number) {
499492
this.dragOverItemIndexSource = null;
500493
this.dragOverItemIndexTarget = null;
501494
}
502495

503-
onDrop(event: DragEvent, index: number, listType: ListType) {
504-
if(listType === ListType.SOURCE) {
505-
if(this.fromListType === ListType.TARGET)
496+
onDrop(event: DragEvent, index: number, listType: number) {
497+
if(listType === -1) {
498+
if(this.fromListType === 1)
506499
this.insert(this.draggedItemIndexTarget, this.target, index, this.source);
507500
else
508501
this.objectUtils.reorderArray(this.source, this.draggedItemIndexSource, (this.draggedItemIndexSource > index) ? index : (index === 0) ? 0 : index - 1);
509502

510503
this.dragOverItemIndexSource = null;
511504
}
512505
else {
513-
if(this.fromListType === ListType.SOURCE)
506+
if(this.fromListType === -1)
514507
this.insert(this.draggedItemIndexSource, this.source, index, this.target);
515508
else
516509
this.objectUtils.reorderArray(this.target, this.draggedItemIndexTarget, (this.draggedItemIndexTarget > index) ? index : (index === 0) ? 0 : index - 1);
@@ -525,16 +518,16 @@ export class PickList implements AfterViewChecked,AfterContentInit {
525518
this.dragging = false;
526519
}
527520

528-
onEmptyListDrop(event: DragEvent, listType: ListType) {
529-
if(listType === ListType.SOURCE)
521+
onEmptyListDrop(event: DragEvent, listType: number) {
522+
if(listType === -1)
530523
this.insert(this.draggedItemIndexTarget, this.target, null, this.source);
531524
else
532525
this.insert(this.draggedItemIndexSource, this.source, null, this.target);
533526

534527
event.preventDefault();
535528
}
536529

537-
onEmptyListDragOver(event: DragEvent, listType: ListType) {
530+
onEmptyListDragOver(event: DragEvent, listType: number) {
538531
event.preventDefault();
539532
}
540533

@@ -545,7 +538,7 @@ export class PickList implements AfterViewChecked,AfterContentInit {
545538
toList.splice(toIndex, 0, fromList.splice(fromIndex, 1)[0]);
546539
}
547540

548-
onListMouseMove(event: MouseEvent, listType: ListType) {
541+
onListMouseMove(event: MouseEvent, listType: number) {
549542
if(this.dragging) {
550543
let moveListType = (listType == 0 ? this.listViewSourceChild : this.listViewTargetChild);
551544
let offsetY = moveListType.nativeElement.getBoundingClientRect().top + document.body.scrollTop;

Diff for: tsconfig-release.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"baseUrl": "src",
66
"rootDir": "src/app/components",
77
"sourceMap": true,
8-
"declaration": false,
8+
"declaration": true,
99
"moduleResolution": "node",
1010
"emitDecoratorMetadata": true,
1111
"experimentalDecorators": true,

0 commit comments

Comments
 (0)