Skip to content

Commit

Permalink
Merge pull request #192 from Vastra-Gotalandsregionen/#155031470_Komp…
Browse files Browse the repository at this point in the history
…onenter_med_samma_source

#155031470 komponenter med samma source
  • Loading branch information
FeliciaRingblom authored Feb 12, 2018
2 parents a637611 + 27f8ad9 commit 4f7d60f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"name": "vgr-komponentkartan",

"version": "2.1.2-rc17",

"author": "Västra Götalandsregionen",
"license": "MIT",
"scripts": {
Expand Down
10 changes: 4 additions & 6 deletions src/app/komponentkarta/komponentkarta.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,18 @@ <h2>Fyra alternativ, varav ett inaktivt</h2>
<vgr-radio-group [options]="[{value: '1', displayName: 'Ett', selected: false},{value: '2', displayName: 'Två'},{value: '3', displayName:
'Tre'}, {value: '4', displayName: 'Fyra', disabled:true}] " (selectedChanged)="onSelectedRadioOptionChanged($event) ">
</vgr-radio-group>
<div>Du har valt alternativ: {{selectedRadioOption.value}}</div>
</div>
<h2>Fyra alternativ, ingen förvald</h2>
<div>
<vgr-radio-group [options]="[{value: '1', displayName: 'Etta'},{value: '2', displayName: 'Tvåa'},{value: '3', displayName:
'Trea'}, {value: '4', displayName: 'Fyra'}] " (selectedChanged)="onSelectedRadioOptionChanged($event) ">
<vgr-radio-group [options]="options" (selectedChanged)="onSelectedRadioOptionChanged($event) ">
</vgr-radio-group>
<div>Du har valt alternativ: {{selectedRadioOption.value}}</div>
</div>
<h2>Fyra alternativ, alla selected = false</h2>
<div>
<vgr-radio-group [options]="[{value: '1', displayName: 'Etta', selected: false},{value: '2', displayName: 'Tvåa', selected: false},{value: '3', displayName:
'Trea', selected:false}, {value: '4', displayName: 'Fyra', selected:false}] " (selectedChanged)="onSelectedRadioOptionChanged($event) ">
<vgr-radio-group [options]="options" (selectedChanged)="onSelectedRadioOptionChanged($event) ">
</vgr-radio-group>
<br>
<br>
<div>Du har valt alternativ: {{selectedRadioOption.value}}</div>
</div>
<h2>Tre inaktiva alternativ, varav ett förvalt</h2>
Expand Down
8 changes: 8 additions & 0 deletions src/app/komponentkarta/komponentkarta.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class KomponentkartaComponent implements AfterViewInit {
expanded: boolean;
isReadonlyAndDisabled: boolean;
isReadonlyAndDisabledMulti: boolean;
options: SelectableItem<any>[];

constructor(private modalService: ModalService) {
this.isReadonlyAndDisabled = true;
this.isReadonlyAndDisabledMulti = true;
Expand Down Expand Up @@ -95,6 +97,11 @@ export class KomponentkartaComponent implements AfterViewInit {
this.dropMultipleDownItems8[2].selected = true;

this.dropDownItems9[7].selected = true;

this.options = [
{ value: '1', displayName: 'Etta' }, { value: '2', displayName: 'Tvåa' } as SelectableItem<any>,
{ value: '3', displayName: 'Trea' }, { value: '4', displayName: 'Fyra' } as SelectableItem<any>
];
}

showOneButtonModal() {
Expand Down Expand Up @@ -164,6 +171,7 @@ export class KomponentkartaComponent implements AfterViewInit {
onSelectedRadioOptionChanged(optionValue: number) {
this.selectedRadioOption.value = optionValue;
}

consoleLog(logText: string) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/controls/dropdown-base/dropdown.base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export abstract class DropdownBaseComponent {
@Input() set items(value: DropdownItem<any>[]) {
// The scrollbar component would not refresh when items were changed unless we added a timeout...
// Ugly solution for sure, but until a better one comes along it will have to do :(
this._items = value;
this._items = JSON.parse(JSON.stringify(value));

const selectedItems = this._items.filter(x => x.selected);
if (selectedItems.length > 0) {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/controls/radioGroup/radioGroup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ export class RadioGroupComponent implements ControlValueAccessor, OnChanges, Aft

public radiogroupItems: RadioGroupItem<any>[] = [];
@Input() set options(items: SelectableItem<any>[]) {
const _items = JSON.parse(JSON.stringify(items));

let newItem: RadioGroupItem<any>;
items.forEach(item => {
_items.forEach(item => {
newItem = item as RadioGroupItem<any>;
newItem.ariaid = Guid.newGuid();
this.radiogroupItems.push(newItem);
Expand Down

0 comments on commit 4f7d60f

Please sign in to comment.