-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpickerlist.ts
102 lines (88 loc) · 2.05 KB
/
pickerlist.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import { Component,OnInit, AfterViewInit,AfterContentInit,AfterViewChecked,HostListener} from '@angular/core';
import { Title } from '@angular/platform-browser';
import {GridOptions} from "ag-grid-community";
declare var $ :any;
@Component({
selector: "picker-list",
templateUrl: `./pickerlist.html`,
styles:[`.div-table {
display: table;
width: 100%;
border-spacing: 5px;
}
.tr {
display: table-row;
}
.tc {
display:table-cell;
vertical-align:top;
padding:5px 10px;
}
.tc1 {
width:240px;
}
.tc4, .tc5, .tc6 {
width: 80px;
}
`]
})
export class PickerListComponent {
private sourceList1 = [{
id:1,
type:'sr1',
added:false
},{
id:2,
type:'sr1',
added:false
}];
private sourceList2 = [
{
id:1,
type:'sr2',
added:false
},{
id:2,
type:'sr2',
added:false
}
];
private pickerList=[];
pickList(obj){
if(obj) {
this.pickerList.push(obj);
//update status of pick list
if(obj.type=="sr1") {
let ind= this.sourceList1.findIndex((a)=> {
return a.id==obj.id
});
this.sourceList1[ind].added=true;
}
else if(obj.type=="sr2") {
let ind= this.sourceList2.findIndex((a)=> {
return a.id==obj.id
});
this.sourceList1[ind].added=true;
}
}
console.log( this.sourceList1);
}
removePickList(obj){
let ind= this.pickerList.findIndex((a)=> {
return a.id==obj.id
});
if(obj.type=="sr1") {
let ind= this.sourceList1.findIndex((a)=> {
return a.id==obj.id
});
this.sourceList1[ind].added=false;
}
else if(obj.type=="sr2") {
let ind= this.sourceList2.findIndex((a)=> {
return a.id==obj.id
});
this.sourceList1[ind].added=false;
}
this.pickerList.splice(ind,1);
}
}