Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @action.bound
- setIsDefaultOptions(ref){
- if(ref !== null){
- featureServices.getDistinctOptionName().then(json => {
- ref.setState(Object.assign(ref.state, {loadedOptions : json, defaultOptions: true}));})
- ref.loadOptions("",function (options) {
- ref.setState({ defaultOptions : options||[],inputValue: ref.state.inputValue});
- let selectValuesHasChanged = false;
- let newValues = ref.state.loadedOptions;
- ref.state.loadedOptions.forEach((el, currIndex) => {
- let found = options.find(option => option.id === el.id);
- if(found === undefined) {
- newValues.splice(currIndex, 1);
- selectValuesHasChanged = true;
- }
- }) ;
- selectValuesHasChanged = true;
- if(selectValuesHasChanged) {
- // Set 'all' by default
- if(newValues.length === 0) {
- newValues.push({id: 'all', value: 'All'});
- }
- ref.select.select.select.setValue(newValues);
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement