Skip to content

Commit

Permalink
fix(shop): item not selectable
Browse files Browse the repository at this point in the history
scenario:
* select or pick an item
* select an item from the preview menu (from/into)
* unable to select or pick the first item again
  • Loading branch information
SteveVanOpstal committed Dec 15, 2016
1 parent fd82f3a commit 9639efe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/client/build/shop/preview/preview.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class PreviewComponent implements OnChanges {
selectItem(item: Item) {
this.item = item;
this.ngOnChanges();
return false; // stop context menu from appearing
}

pickItem(item: Item) {
Expand Down
21 changes: 9 additions & 12 deletions src/client/build/shop/shop.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {LolApiService} from '../../services/lolapi.service';
import {ToIterablePipe} from '../../shared/to-iterable.pipe';
import {Item} from '../item';
import {PreviewComponent} from './preview/preview.component';

@Component({
selector: 'lb-shop',
Expand Down Expand Up @@ -39,19 +40,19 @@ import {Item} from '../item';
<lb-item [item]="item"
[ngClass]="{disabled: item.disabled}"
[attr.title]="item.description"
(click)="selectItem(item)"
(contextmenu)="pickItem(item);selectItem(item)"
(dblclick)="pickItem(item);selectItem(item)">
(click)="preview.selectItem(item)"
(contextmenu)="pickItem(item);preview.selectItem(item)"
(dblclick)="pickItem(item);preview.selectItem(item)">
</lb-item>
</template>
<lb-loading [loading]="loading"></lb-loading>
<lb-retry [error]="error" (retry)="ngOnInit()"></lb-retry>
</div>
</div>
<div class="right">
<lb-preview [item]="selectedItem"
[items]="items | lbMap:11 | lbChampion:123"
(itemPicked)="pickItem($event)">
<lb-preview #preview
[items]="items | lbMap:11 | lbChampion:123"
(itemPicked)="pickItem($event)">
</lb-preview>
</div>
</div>`
Expand All @@ -60,6 +61,8 @@ import {Item} from '../item';
export class ShopComponent implements OnInit {
@Output() itemPicked: EventEmitter<Item> = new EventEmitter<Item>();

preview: PreviewComponent;

loading: boolean = true;
error: boolean = false;

Expand All @@ -68,7 +71,6 @@ export class ShopComponent implements OnInit {

data: Object;
items: Array<Item> = [];
selectedItem: Item;
private originalItems: Array<Item> = [];

constructor(private lolApi: LolApiService) {}
Expand Down Expand Up @@ -105,11 +107,6 @@ export class ShopComponent implements OnInit {
}
}

selectItem(item: Item) {
this.selectedItem = item;
return false; // stop context menu from appearing
}

pickItem(item: Item) {
this.itemPicked.emit(item);
return false; // stop context menu from appearing
Expand Down

0 comments on commit 9639efe

Please sign in to comment.