Skip to content

Commit

Permalink
Merge pull request #143 from NetrunnerDB/upgrade-dependencies
Browse files Browse the repository at this point in the history
Upgrade dependencies
  • Loading branch information
locks authored Nov 8, 2024
2 parents 0962bfd + 4248704 commit ae2fce1
Show file tree
Hide file tree
Showing 9 changed files with 1,125 additions and 1,063 deletions.
51 changes: 51 additions & 0 deletions app/components/decklist/images.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import Component from '@glimmer/component';
import CardLinkTo from '../card/link-to';
import Icon from '../icon';
import { get } from '@ember/helper';
import { Range } from 'netrunnerdb/helpers/range';

export default class DecklistImages extends Component {
cardsByType = (cardType) => {
let cards = this.args.decklist.cards;

return cards.filter(({ cardTypeId }) => cardTypeId === cardType);
};

countByType = (cardType) => {
let cardSlots = this.args.decklist.cardSlots;

return this.cardsByType(cardType)
.map((card) => cardSlots[card.id])
.reduce((acc, i) => acc + i);
};

<template>
{{#each @cardTypes as |type|}}
{{#let (this.cardsByType type.id) as |cards|}}
{{#if cards}}
<h3 class='mt-4 font-size-20'>
<Icon @icon='{{type.id}}' />
{{type.name}}
({{this.countByType type.id}})
</h3>
<div class='row row-cols-8 g-3'>
{{#each cards as |card|}}
<div class='col'>
<CardLinkTo @printing={{card.latestPrinting}}>
<div class='decklist-card'>
{{#each (Range (get @decklist.cardSlots card.id))}}
<img
src='{{card.latestPrinting.largeImage}}'
alt={{card.title}}
/>
{{/each}}
</div>
</CardLinkTo>
</div>
{{/each}}
</div>
{{/if}}
{{/let}}
{{/each}}
</template>
}
4 changes: 2 additions & 2 deletions app/components/ruling.gjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MarkdownToHtml from 'ember-cli-showdown/components/markdown-to-html';
import { FormatDate } from 'netrunnerdb/helpers/format-date';
import { formatDate } from 'netrunnerdb/helpers/format-date';

<template>
<div class='ruling'>
Expand All @@ -11,7 +11,7 @@ import { FormatDate } from 'netrunnerdb/helpers/format-date';
{{/if}}
<span class='fst-italic ms-1 font-size-14'>
Updated
{{FormatDate @ruling.updatedAt}}
{{formatDate @ruling.updatedAt}}
</span>
</div>
{{#if @ruling.question}}
Expand Down
3 changes: 1 addition & 2 deletions app/helpers/format-date.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { helper } from '@ember/component/helper';

function formatDate(date) {
export function formatDate(date) {
return new Intl.DateTimeFormat('en-GB')
.format(new Date(date))
.replaceAll('/', '-');
}

export const FormatDate = formatDate;
export default helper(formatDate);
6 changes: 1 addition & 5 deletions app/helpers/range.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { helper } from '@ember/component/helper';

function range(n) {
let array = [];
for (let i = 0; i < n; i++) {
array.push(i);
}
return array;
return Array(n);
}

export const Range = range;
Expand Down
26 changes: 4 additions & 22 deletions app/routes/decklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,12 @@ import { hash } from 'rsvp';
export default class DecklistRoute extends Route {
@service store;

async model(params) {
let cardTypes = await this.store.findAll('cardType');

let decklist = await this.store.findRecord('decklist', params.id, {
async model({ id }) {
let cardTypes = this.store.findAll('cardType');
let decklist = this.store.findRecord('decklist', id, {
include: 'cards,cards.printings',
});
let cards = decklist.cards;

let cardsByType = {};
cardTypes.forEach((type) => {
cardsByType[type.id] = [];
});
cards.forEach((card) => {
cardsByType[card.cardTypeId].push(card);
});

let countsByType = {};
cardTypes.forEach((type) => {
countsByType[type.id] = 0;
});
cards.forEach((card) => {
countsByType[card.cardTypeId] += decklist.cardSlots[card.id];
});

return hash({ decklist, cardTypes, cardsByType, countsByType });
return hash({ cardTypes, decklist });
}
}
12 changes: 5 additions & 7 deletions app/templates/card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,15 @@
</div>
</tab.pane>
<tab.pane @title="Rulings ">
{{#if @model.rulings}}
{{#each @model.rulings as |ruling|}}
<div class="mt-4">
<Ruling @ruling={{ruling}} />
</div>
{{/each}}
{{#each @model.rulings as |ruling|}}
<div class="mt-4">
<Ruling @ruling={{ruling}} />
</div>
{{else}}
<div class="ruling-answer mt-4">
This card has no rulings!
</div>
{{/if}}
{{/each}}
</tab.pane>
<tab.pane @title="Alt arts">
<p> ... </p>
Expand Down
41 changes: 4 additions & 37 deletions app/templates/decklist.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -176,43 +176,10 @@
</:quantity>
</Card::List>
{{else if (eq this.displayType "images")}}
{{#each @model.cardTypes as |type|}}
{{#let (get @model.cardsByType type.id) as |cards|}}
{{#if cards}}
<h3 class="mt-4 font-size-20">
<Icon @icon="{{type.id}}" />
{{type.name}}
({{get @model.countsByType type.id}})
</h3>
<div class="row row-cols-8 g-3">
{{#each cards as |card|}}
<div class="col">
<Card::LinkTo @printing={{card.latestPrinting}}>
<div class="decklist-card">
<img
src="{{card.latestPrinting.largeImage}}"
alt={{card.title}}
/>
{{#if (gt (get @model.decklist.cardSlots card.id) 1)}}
<img
src="{{card.latestPrinting.mediumImage}}"
alt={{card.title}}
/>
{{/if}}
{{#if (gt (get @model.decklist.cardSlots card.id) 2)}}
<img
src="{{card.latestPrinting.tinyImage}}"
alt={{card.title}}
/>
{{/if}}
</div>
</Card::LinkTo>
</div>
{{/each}}
</div>
{{/if}}
{{/let}}
{{/each}}
<Decklist::Images
@decklist={{@model.decklist}}
@cardTypes={{@model.cardTypes}}
/>
{{/if}}
</div>

Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
"@glimmer/tracking": "^1.1.2",
"bootstrap": "^5.3.0",
"broccoli-asset-rev": "^3.0.0",
"concurrently": "^8.2.2",
"concurrently": "^9.1.0",
"ember-auto-import": "^2.10.0",
"ember-bootstrap": "^5.1.1",
"ember-cli": "~5.12.0",
"ember-cli-app-version": "^7.0.0",
"ember-cli-babel": "^8.2.0",
"ember-cli-clean-css": "^3.0.0",
"ember-cli-dependency-checker": "^3.3.2",
"ember-cli-deprecation-workflow": "^2.1.0",
"ember-cli-deprecation-workflow": "^3.0.2",
"ember-cli-htmlbars": "^6.3.0",
"ember-cli-inject-live-reload": "^2.1.0",
"ember-cli-showdown": "^9.0.1",
Expand All @@ -59,28 +59,28 @@
"ember-data": "~4.12",
"ember-fetch": "^8.1.2",
"ember-google-fonts": "^1.0.1",
"ember-load-initializers": "^2.1.2",
"ember-math-helpers": "^3.0.0",
"ember-load-initializers": "^3.0.1",
"ember-math-helpers": "^4.0.0",
"ember-modifier": "^4.2.0",
"ember-page-title": "^8.2.3",
"ember-power-select": "^8.3.1",
"ember-qunit": "^8.1.0",
"ember-resolver": "^12.0.1",
"ember-resolver": "^13.0.2",
"ember-simple-auth-oidc": "^7.0.3",
"ember-source": "~5.12.0",
"ember-svg-jar": "^2.4.7",
"ember-template-imports": "^3.4.2",
"ember-template-imports": "^4.1.3",
"ember-template-lint": "^6.0.0",
"ember-tooltips": "^3.6.0",
"ember-truth-helpers": "^3.1.1",
"ember-truth-helpers": "^4.0.3",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-ember": "^12.2.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-qunit": "^8.1.2",
"loader.js": "^4.7.0",
"markdown-it": "^13.0.2",
"markdown-it": "^14.1.0",
"prettier": "^3.3.3",
"prettier-plugin-ember-template-tag": "^1.0.0",
"qunit": "^2.22.0",
Expand Down
Loading

0 comments on commit ae2fce1

Please sign in to comment.