Skip to content

Commit

Permalink
Merge pull request #86 from oatear/feature/show-singles
Browse files Browse the repository at this point in the history
add thumbnails option to show singles/copies
  • Loading branch information
hristoiankov authored Jul 23, 2023
2 parents f4db62c + 061fc31 commit ca712c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
optionLabel="label" optionValue="value"></p-selectButton>
<p-selectButton [options]="sideOptions" [(ngModel)]="sideSelected" class="p-mr-3"
optionLabel="label" optionValue="value"></p-selectButton>
<p-selectButton [options]="copyOptions" [(ngModel)]="copySelected" class="p-mr-3"
optionLabel="label" optionValue="value" (onChange)="refreshCards()"></p-selectButton>
<input type="search" pInputText placeholder="Search Cards" (input)="filter($event)">
</div>
<div class="card-thumbnails">
Expand Down
22 changes: 18 additions & 4 deletions cider-app/src/app/card-thumbnails/card-thumbnails.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,38 @@ export class CardThumbnailsComponent implements OnInit {
{ label: 'Both', value: 'both' }
];
filterFields: string = "";
copyOptions: any[] = [
{ label: 'Singles', value: 'singles' },
{ label: 'Copies', value: 'copies' }
];
copySelected: string = 'copies';



constructor(public cardsService: CardsService,
public templatesService: CardTemplatesService) { }

ngOnInit(): void {
this.refreshCards();
this.cardsService.getFields().then(fields => {
this.filterFields = fields.map(field => field.field).join(',');
});
}

refreshCards() {
this.cardsService.getAll().then(cards => {
const expandedList: Card[] = [];
cards.forEach(card => {
for (let i = 0; i < (typeof card.count === 'undefined' ? 1 : card.count); i++) {
if (this.copySelected === 'singles') {
expandedList.push(card);
} else {
for (let i = 0; i < (typeof card.count === 'undefined' ? 1 : card.count); i++) {
expandedList.push(card);
}
}
});
this.thumbnailCards = expandedList;
});
this.cardsService.getFields().then(fields => {
this.filterFields = fields.map(field => field.field).join(',');
});
}

filter(input: any) {
Expand Down

0 comments on commit ca712c9

Please sign in to comment.