@@ -35,36 +35,46 @@ export class ComboBoxListItemPicker extends React.Component<IComboBoxListItemPic
35
35
}
36
36
37
37
protected async loadOptions ( ) : Promise < void > {
38
- let query = "" ;
39
- query += this . props . filter || "Id gt 0" ;
40
- let keyColumnName = this . props . keyColumnInternalName || "Id" ;
38
+ const {
39
+ filter,
40
+ keyColumnInternalName,
41
+ listId,
42
+ columnInternalName,
43
+ webUrl,
44
+ itemLimit,
45
+ defaultSelectedItems,
46
+ onInitialized
47
+ } = this . props ;
48
+ let query = filter || "" ;
49
+ //query += filter;
50
+ let keyColumnName = keyColumnInternalName || "Id" ;
41
51
let listItems = await this . _listItemRepo . getListItemsByFilterClause ( query ,
42
- this . props . listId ,
43
- this . props . columnInternalName ,
44
- this . props . keyColumnInternalName ,
45
- this . props . webUrl ,
46
- /*this.props. itemLimit ||*/ 100 ) ;
52
+ listId ,
53
+ columnInternalName ,
54
+ keyColumnInternalName ,
55
+ webUrl ,
56
+ itemLimit || 100 ) ;
47
57
48
58
let options = listItems . map ( option => {
49
59
return {
50
60
key : option [ keyColumnName ] ,
51
- text : option [ this . props . columnInternalName || "Id" ]
61
+ text : option [ columnInternalName || "Id" ]
52
62
} ;
53
63
} ) ;
54
- if ( this . props . defaultSelectedItems ) {
64
+ if ( defaultSelectedItems ) {
55
65
//if passed only ids
56
- if ( ! isNaN ( this . props . defaultSelectedItems [ 0 ] ) ) {
57
- this . selectedItems = options . filter ( opt => this . props . defaultSelectedItems . indexOf ( opt . key ) >= 0 ) ;
66
+ if ( ! isNaN ( defaultSelectedItems [ 0 ] ) ) {
67
+ this . selectedItems = options . filter ( opt => defaultSelectedItems . indexOf ( opt . key ) >= 0 ) ;
58
68
}
59
69
else {
60
- this . selectedItems = options . filter ( opt => this . props . defaultSelectedItems . map ( selected => selected [ keyColumnName ] ) . indexOf ( opt . key ) >= 0 ) ;
70
+ this . selectedItems = options . filter ( opt => defaultSelectedItems . map ( selected => selected [ keyColumnName ] ) . indexOf ( opt . key ) >= 0 ) ;
61
71
}
62
72
}
63
73
this . setState ( {
64
74
availableOptions : options
65
75
} ) ;
66
- if ( this . props . onInitialized ) {
67
- this . props . onInitialized ( ) ;
76
+ if ( onInitialized ) {
77
+ onInitialized ( ) ;
68
78
}
69
79
}
70
80
@@ -105,7 +115,7 @@ export class ComboBoxListItemPicker extends React.Component<IComboBoxListItemPic
105
115
/**
106
116
* On Selected Item
107
117
*/
108
- private onChanged = ( option ?: IComboBoxOption , index ?: number , value ?: string , submitPendingValueEvent ?: any ) : void => {
118
+ private onChanged = ( option ?: IComboBoxOption , index ?: number , value ?: string , submitPendingValueEvent ?: any ) : void => {
109
119
if ( this . props . multiSelect ) {
110
120
if ( option && option . selected ) {
111
121
this . selectedItems . push ( {
@@ -119,12 +129,12 @@ export class ComboBoxListItemPicker extends React.Component<IComboBoxListItemPic
119
129
} else {
120
130
this . selectedItems . push ( {
121
131
[ this . props . keyColumnInternalName || "Id" ] : option . key ,
122
- [ this . props . columnInternalName ] : option . text
132
+ [ this . props . columnInternalName ] : option . text
123
133
} ) ;
124
-
134
+
125
135
this . selectedItems = this . selectedItems . filter ( o => o [ this . props . keyColumnInternalName || "Id" ] === option . key ) ;
126
136
}
127
-
137
+
128
138
this . props . onSelectedItem ( this . selectedItems ) ;
129
139
}
130
140
}
0 commit comments