Skip to content

Commit 7de1e8f

Browse files
authored
Merge pull request #21 from edcarroll/develop
v0.4.6 into master
2 parents 20f26e4 + 0554f6c commit 7de1e8f

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

components/message/message.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Component, Input, Output, EventEmitter, ElementRef, Renderer, AfterViewInit} from '@angular/core';
22
import {SuiTransition} from "../transition/transition";
3-
import {ViewChild} from "@angular/core/src/metadata/di";
3+
import {ViewChild} from "@angular/core";
44

55
@Component({
66
selector: 'sui-message',

components/select/multi-select.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {SuiSelectOption} from "./select-option";
1010
import {KeyCode} from '../../components/dropdown/dropdown.service';
1111
import {Subscription} from "rxjs";
1212
import {SuiDropdownService} from "../dropdown/dropdown.service";
13-
import {Input, Output} from "@angular/core/src/metadata/directives";
13+
import {Input, Output} from "@angular/core";
1414
import {SuiSearchService} from "../search/search.service";
1515
import {SuiSelectMultiLabel} from "./multi-select-label";
1616

@@ -78,12 +78,20 @@ export class SuiMultiSelect implements AfterContentInit, AfterViewInit {
7878
public placeholder:string = "Select...";
7979

8080
@Input()
81-
public get options():any {
81+
public get options():any[] {
8282
return this._searchService.options;
8383
}
8484

85-
public set options(value:any) {
85+
public set options(value:any[]) {
8686
this._searchService.options = value;
87+
if (this.options.length > 0 && this.selectedOptions) {
88+
this.selectedOptions = this.selectedOptions.map(so => {
89+
if (!this.options.find(o => o == so)) {
90+
return this.options.find(o => so == this._searchService.deepValue(o, this.keyField));
91+
}
92+
return so;
93+
});
94+
}
8795
}
8896

8997
@Input()
@@ -257,8 +265,7 @@ export class SuiMultiSelect implements AfterContentInit, AfterViewInit {
257265
this.selectedOptions = value;
258266
if (this.options.length > 0) {
259267
this.selectedOptions = this.selectedOptions.map(so => {
260-
let compareValue = this._searchService.deepValue(so, this.keyField);
261-
return this.options.find( (o:any) => compareValue == o);
268+
return this.options.find(o => so == this._searchService.deepValue(o, this.keyField));
262269
});
263270
}
264271
}

components/select/select.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {SuiSelectOption} from "./select-option";
1010
import {KeyCode} from '../../components/dropdown/dropdown.service';
1111
import {Subscription} from "rxjs";
1212
import {SuiDropdownService} from "../dropdown/dropdown.service";
13-
import {Input, Output} from "@angular/core/src/metadata/directives";
13+
import {Input, Output} from "@angular/core";
1414
import {SuiSearchService} from "../search/search.service";
1515
import {SuiMultiSelect, SuiMultiSelectValueAccessor} from "./multi-select";
1616
import {SuiSelectMultiLabel} from "./multi-select-label";
@@ -73,12 +73,15 @@ export class SuiSelect implements AfterContentInit, AfterViewInit {
7373
public placeholder:string = "Select one";
7474

7575
@Input()
76-
public get options():any {
76+
public get options():any[] {
7777
return this._searchService.options;
7878
}
7979

80-
public set options(value:any) {
80+
public set options(value:any[]) {
8181
this._searchService.options = value;
82+
if (this.options.length > 0 && !this.options.find(o => o == this.selectedOption)) {
83+
this.selectedOption = this.options.find(o => this.selectedOption == this._searchService.deepValue(o, this.keyField));
84+
}
8285
}
8386

8487
@Input()

demo/app/pages/select/select.page.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class SelectPage {
106106
description: "Fires whenever the select's selected item is changed. <code>[(ngModel)]</code> syntax is supported."
107107
},
108108
{
109-
name: "selectedOptionChange",
109+
name: "selectedOptionsChange",
110110
description: "Fires whenever the select's selected item is changed. The selected value is passed as <code>$event</code>."
111111
}
112112
]
@@ -141,7 +141,7 @@ export class SelectPage {
141141
`;
142142
public exampleSearchTemplate:string = `
143143
<p>You can also use the keyboard to navigate.</p>
144-
<sui-select [(ngModel)]="selectedOption" [options]="options" displayField="name" [isSearchable]="true" #searchSelect>
144+
<sui-select [(ngModel)]="selectedOption" [options]="options" displayField="name" keyField="id" [isSearchable]="true" #searchSelect>
145145
<sui-select-option *ngFor="let option of searchSelect.availableOptions" [value]="option"></sui-select-option>
146146
</sui-select>
147147
<div class="ui segment">
@@ -217,7 +217,7 @@ export class SelectExampleOptions {
217217
template: new SelectPage().exampleSearchTemplate
218218
})
219219
export class SelectExampleSearch {
220-
public options:Array<any> = [{ name: "Example" }, { name: "Test"}, { name: "What"}, { name: "No"}, { name: "Benefit"}, { name: "Oranges"}, { name: "Artemis"}, { name: "Another"}];
220+
public options:Array<any> = [{ name: "Example" }, { name: "Test" }, { name: "What" }, { name: "No" }, { name: "Benefit" }, { name: "Oranges" }, { name: "Artemis" }, { name: "Another" }];
221221
}
222222

223223
@Component({

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ng2-semantic-ui",
33
"main": "ng2-semantic-ui.js",
44
"typings": "ng2-semantic-ui.d.ts",
5-
"version": "0.4.2",
5+
"version": "0.4.6",
66
"description": "Angular 2 Semantic UI Components",
77
"repository": {
88
"type": "git",

0 commit comments

Comments
 (0)