Skip to content

Commit

Permalink
feat(inventory): show stats in inventory table, rework some table
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Sep 18, 2023
1 parent 16ecf0c commit 92a0bb7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 15 deletions.
28 changes: 20 additions & 8 deletions client/src/app/components/item-stats/item-stats.component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
<div>
<ion-chip
class="stats readonly"
[color]="stat.value > 0 ? 'success' : 'danger'"
*ngFor="let stat of stats"
>
{{ stat.key }} +{{ stat.value }}
</ion-chip>
<div [class.one-per-line]="oneStatPerLine">
<ng-container *ngIf="useChips">
<ion-chip
class="stats readonly"
[color]="stat.value > 0 ? 'success' : 'danger'"
*ngFor="let stat of stats"
>
{{ stat.key }} +{{ stat.value }}
</ion-chip>
</ng-container>

<ng-container *ngIf="!useChips">
<ion-text
class="stats readonly"
[color]="stat.value > 0 ? 'success' : 'danger'"
*ngFor="let stat of stats"
>
[{{ stat.key }} +{{ stat.value }}]
</ion-text>
</ng-container>
</div>
10 changes: 10 additions & 0 deletions client/src/app/components/item-stats/item-stats.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

ion-chip, ion-text {
white-space: nowrap;
}

.one-per-line {
ion-chip, ion-text {
display: block;
}
}
2 changes: 2 additions & 0 deletions client/src/app/components/item-stats/item-stats.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { IEquipment, IItem, Stat } from '@interfaces';
export class ItemStatsComponent implements OnInit {
public stats: Array<{ key: string; value: number }> = [];

@Input() useChips = true;
@Input() oneStatPerLine = false;
@Input({ required: true }) item!: IItem;

constructor() {}
Expand Down
29 changes: 22 additions & 7 deletions client/src/app/pages/inventory/inventory.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ngx-datatable
class="dark"
[rows]="items"
[rowHeight]="64"
[rowHeight]="'auto'"
[columnMode]="'force'"
[sorts]="[{ prop: 'name', dir: 'asc' }]"
>
Expand All @@ -46,25 +46,40 @@
[cellClass]="'text-wrap-column'"
>
<ng-template let-row="row" ngx-datatable-cell-template>
<div><strong>{{ row.name }}</strong></div>
<div>
<strong>{{ row.name }}</strong>
<br />
Lv. {{ row.levelRequirement || 0 }}
</div>
</ng-template>
</ngx-datatable-column>

<ngx-datatable-column name="Rarity" [sortable]="false">
<ngx-datatable-column name="Item Type" [sortable]="false">
<ng-template let-row="row" ngx-datatable-cell-template>
<app-item-rarity [item]="row"></app-item-rarity>
</ng-template>
</ngx-datatable-column>

<ngx-datatable-column name="Level" [prop]="'levelRequirement'">
<ngx-datatable-column
name="Value"
[comparator]="valueComparison"
[maxWidth]="70"
>
<ng-template let-row="row" ngx-datatable-cell-template>
Lv. {{ row.levelRequirement || 0 }}
{{ getValueForItem(row) | number }}
</ng-template>
</ngx-datatable-column>

<ngx-datatable-column name="Value" [comparator]="valueComparison">
<ngx-datatable-column
name="Stats"
[cellClass]="'text-wrap-column'"
>
<ng-template let-row="row" ngx-datatable-cell-template>
{{ getValueForItem(row) | number }}
<app-item-stats
[item]="row"
[oneStatPerLine]="true"
[useChips]="false"
></app-item-stats>
</ng-template>
</ngx-datatable-column>

Expand Down

0 comments on commit 92a0bb7

Please sign in to comment.