From 28646f0f3bdebc66d7d4db50995dc900d597b290 Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Thu, 30 Nov 2023 22:37:48 -0600 Subject: [PATCH] Update Gathering to Ember 4.12 (#33) --- gathering/.ember-cli | 8 +- gathering/.eslintignore | 3 + gathering/.eslintrc.js | 38 +- gathering/.github/workflows/ci.yml | 47 + gathering/.gitignore | 6 + gathering/.prettierignore | 4 + gathering/.prettierrc.js | 1 - gathering/.stylelintignore | 8 + gathering/.stylelintrc.js | 5 + gathering/README.md | 4 +- gathering/app/components/loading.gjs | 10 +- gathering/app/components/mappable-region.gjs | 25 +- .../output/clandestine-rendezvous/answers.gjs | 9 +- .../output/clandestine-rendezvous/cards.gjs | 14 +- .../output/clandestine-rendezvous/maps.gjs | 8 +- .../app/components/output/txtbeyond/cards.gjs | 15 +- .../output/txtbeyond/transparencies.gjs | 4 +- .../output/unmnemonic-devices/answers.gjs | 161 +- .../output/unmnemonic-devices/overlays.gjs | 25 +- .../unmnemonic-devices/team-overviews.gjs | 42 +- .../unmnemonic-devices/verification.gjs | 7 +- .../output/unmnemonic-devices/vrssql.gjs | 39 +- gathering/app/components/region-options.gjs | 17 +- gathering/app/components/region-row.gjs | 7 +- .../app/components/scheduler-destination.gjs | 10 +- gathering/app/components/scheduler-team.js | 4 +- .../app/components/scheduler-waypoint.gjs | 10 +- .../region-container-destinations.gjs | 13 +- gathering/app/components/waypoint-row.gjs | 8 +- gathering/app/controllers/destination.js | 5 +- .../app/controllers/destinations/index.js | 2 +- gathering/app/controllers/region.js | 5 +- gathering/app/controllers/regions/index.js | 5 +- gathering/app/controllers/scheduler.js | 19 +- gathering/app/controllers/teams.js | 12 +- gathering/app/controllers/waypoint.js | 5 +- gathering/app/controllers/waypoints/index.js | 5 +- gathering/app/index.html | 7 +- gathering/app/models/destination.js | 26 +- gathering/app/models/meeting.js | 49 +- gathering/app/models/region.js | 18 +- gathering/app/models/team.js | 35 +- gathering/app/models/waypoint.js | 13 +- gathering/app/routes/scheduler.js | 19 +- .../app/services/clandestine-rendezvous.js | 3 +- gathering/app/services/pathfinder.js | 12 +- gathering/app/services/txtbeyond.js | 65 +- gathering/app/styles/app.css | 1 + gathering/app/templates/sync.hbs | 2 +- gathering/app/templates/teams.hbs | 10 +- gathering/config/deprecation-workflow.js | 2 +- gathering/config/ember-cli-update.json | 6 +- gathering/config/environment.js | 9 +- gathering/config/targets.js | 15 - gathering/ember-cli-build.js | 16 +- gathering/package-lock.json | 55598 ++++++++-------- gathering/package.json | 75 +- .../tests/acceptance/destinations-test.js | 86 +- gathering/tests/acceptance/regions-test.js | 69 +- gathering/tests/acceptance/scheduler-test.js | 176 +- gathering/tests/acceptance/settings-test.js | 8 +- gathering/tests/acceptance/sync-test.js | 30 +- gathering/tests/acceptance/teams-test.js | 52 +- gathering/tests/acceptance/waypoints-test.js | 64 +- gathering/tests/helpers/.gitkeep | 0 gathering/tests/helpers/index.js | 42 + gathering/tests/index.html | 5 +- .../services/clandestine-rendezvous-test.js | 26 +- .../tests/unit/services/pathfinder-test.js | 4 +- .../tests/unit/services/txtbeyond-test.js | 20 +- .../unit/services/unmnemonic-devices-test.js | 14 +- gathering/vendor/.gitkeep | 0 72 files changed, 26937 insertions(+), 30250 deletions(-) create mode 100644 gathering/.github/workflows/ci.yml create mode 100644 gathering/.stylelintignore create mode 100644 gathering/.stylelintrc.js delete mode 100644 gathering/tests/helpers/.gitkeep create mode 100644 gathering/tests/helpers/index.js delete mode 100644 gathering/vendor/.gitkeep diff --git a/gathering/.ember-cli b/gathering/.ember-cli index ee64cfed..8c1812cf 100644 --- a/gathering/.ember-cli +++ b/gathering/.ember-cli @@ -5,5 +5,11 @@ Setting `disableAnalytics` to true will prevent any data from being sent. */ - "disableAnalytics": false + "disableAnalytics": false, + + /** + Setting `isTypeScriptProject` to true will force the blueprint generators to generate TypeScript + rather than JavaScript by default, when a TypeScript version of a given blueprint is available. + */ + "isTypeScriptProject": false } diff --git a/gathering/.eslintignore b/gathering/.eslintignore index 701947ed..d474a40b 100644 --- a/gathering/.eslintignore +++ b/gathering/.eslintignore @@ -19,4 +19,7 @@ # ember-try /.node_modules.ember-try/ /bower.json.ember-try +/npm-shrinkwrap.json.ember-try /package.json.ember-try +/package-lock.json.ember-try +/yarn.lock.ember-try diff --git a/gathering/.eslintrc.js b/gathering/.eslintrc.js index a2ab60e6..31c63bb0 100644 --- a/gathering/.eslintrc.js +++ b/gathering/.eslintrc.js @@ -2,12 +2,15 @@ module.exports = { root: true, - parser: 'babel-eslint', + parser: '@babel/eslint-parser', parserOptions: { - ecmaVersion: 2018, + ecmaVersion: 'latest', sourceType: 'module', - ecmaFeatures: { - legacyDecorators: true, + requireConfigFile: false, + babelOptions: { + plugins: [ + ['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true }], + ], }, }, plugins: ['ember'], @@ -30,21 +33,7 @@ module.exports = { }, }, ], - 'import/no-unresolved': [ - 2, - { - ignore: [ - '^@ember', - '^adventure-gathering', - '^ember$', - '^ember-cli-page-object', - '^ember-feature-flags', - '^ember-local-storage', - '^ember-pouch', - 'htmlbars-inline-precompile', - ], - }, - ], + 'import/no-unresolved': 'off', }, overrides: [ // node files @@ -52,6 +41,7 @@ module.exports = { files: [ './.eslintrc.js', './.prettierrc.js', + './.stylelintrc.js', './.template-lintrc.js', './ember-cli-build.js', './testem.js', @@ -67,16 +57,10 @@ module.exports = { browser: false, node: true, }, - plugins: ['node'], - extends: ['plugin:node/recommended'], - rules: { - // this can be removed once the following is fixed - // https://github.com/mysticatea/eslint-plugin-node/issues/77 - 'node/no-unpublished-require': 'off', - }, + extends: ['plugin:n/recommended'], }, { - // Test files: + // test files files: ['tests/**/*-test.{js,ts}'], extends: ['plugin:qunit/recommended'], }, diff --git a/gathering/.github/workflows/ci.yml b/gathering/.github/workflows/ci.yml new file mode 100644 index 00000000..83762c9a --- /dev/null +++ b/gathering/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +name: CI + +on: + push: + branches: + - main + - master + pull_request: {} + +concurrency: + group: ci-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + lint: + name: "Lint" + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v3 + - name: Install Node + uses: actions/setup-node@v3 + with: + node-version: 14.x + cache: npm + - name: Install Dependencies + run: npm ci + - name: Lint + run: npm run lint + + test: + name: "Test" + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - uses: actions/checkout@v3 + - name: Install Node + uses: actions/setup-node@v3 + with: + node-version: 14.x + cache: npm + - name: Install Dependencies + run: npm ci + - name: Run Tests + run: npm test diff --git a/gathering/.gitignore b/gathering/.gitignore index 7e0f7ddc..f1e859b2 100644 --- a/gathering/.gitignore +++ b/gathering/.gitignore @@ -23,4 +23,10 @@ # ember-try /.node_modules.ember-try/ /bower.json.ember-try +/npm-shrinkwrap.json.ember-try /package.json.ember-try +/package-lock.json.ember-try +/yarn.lock.ember-try + +# broccoli-debug +/DEBUG/ diff --git a/gathering/.prettierignore b/gathering/.prettierignore index 92216555..4178fd57 100644 --- a/gathering/.prettierignore +++ b/gathering/.prettierignore @@ -14,8 +14,12 @@ /coverage/ !.* .eslintcache +.lint-todo/ # ember-try /.node_modules.ember-try/ /bower.json.ember-try +/npm-shrinkwrap.json.ember-try /package.json.ember-try +/package-lock.json.ember-try +/yarn.lock.ember-try diff --git a/gathering/.prettierrc.js b/gathering/.prettierrc.js index 05596264..c83c692e 100644 --- a/gathering/.prettierrc.js +++ b/gathering/.prettierrc.js @@ -1,7 +1,6 @@ 'use strict'; module.exports = { - singleQuote: true, plugins: ['prettier-plugin-ember-template-tag'], overrides: [ { diff --git a/gathering/.stylelintignore b/gathering/.stylelintignore new file mode 100644 index 00000000..a0cf71cb --- /dev/null +++ b/gathering/.stylelintignore @@ -0,0 +1,8 @@ +# unconventional files +/blueprints/*/files/ + +# compiled output +/dist/ + +# addons +/.node_modules.ember-try/ diff --git a/gathering/.stylelintrc.js b/gathering/.stylelintrc.js new file mode 100644 index 00000000..021c539a --- /dev/null +++ b/gathering/.stylelintrc.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = { + extends: ['stylelint-config-standard', 'stylelint-prettier/recommended'], +}; diff --git a/gathering/README.md b/gathering/README.md index 9aaaf29b..45e95051 100644 --- a/gathering/README.md +++ b/gathering/README.md @@ -12,7 +12,7 @@ You will need the following things properly installed on your computer. - [Git](https://git-scm.com/) - [Node.js](https://nodejs.org/) (with npm) -- [Ember CLI](https://ember-cli.com/) +- [Ember CLI](https://cli.emberjs.com/release/) - [Google Chrome](https://google.com/chrome/) ## Installation @@ -53,7 +53,7 @@ Specify what it takes to deploy your app. ## Further Reading / Useful Links - [ember.js](https://emberjs.com/) -- [ember-cli](https://ember-cli.com/) +- [ember-cli](https://cli.emberjs.com/release/) - Development Browser Extensions - [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi) - [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/) diff --git a/gathering/app/components/loading.gjs b/gathering/app/components/loading.gjs index 16465cf6..7e4bdc95 100644 --- a/gathering/app/components/loading.gjs +++ b/gathering/app/components/loading.gjs @@ -1,7 +1,3 @@ -import Component from '@glimmer/component'; - -export default class LoadingComponent extends Component { - -} + diff --git a/gathering/app/components/mappable-region.gjs b/gathering/app/components/mappable-region.gjs index b61e4e27..c79f23fd 100644 --- a/gathering/app/components/mappable-region.gjs +++ b/gathering/app/components/mappable-region.gjs @@ -1,3 +1,4 @@ +import { on } from '@ember/modifier'; import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { htmlSafe } from '@ember/template'; @@ -5,7 +6,6 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { ref } from 'ember-ref-bucket'; import createRef from 'ember-ref-bucket/modifiers/create-ref'; -import { on } from '@ember/modifier'; import { and } from 'ember-truth-helpers'; // FIXME not used but needed by Foundation?? @@ -49,10 +49,11 @@ export default class MappableRegionComponent extends Component { const meetingAncestorRegionIds = highlightedTeam .hasMany('meetings') .value() - .rejectBy('isNew') + .filter((m) => !m.isNew) .map((meeting) => meeting.belongsTo('destination').value()) - .map((destination) => destination.belongsTo('region').value()) - .mapBy('ancestor.id'); + .map( + (destination) => destination.belongsTo('region').value().ancestor.id + ); const index = meetingAncestorRegionIds.indexOf(regionId); @@ -78,11 +79,9 @@ export default class MappableRegionComponent extends Component { const waypointMeetingAncestorRegionIds = highlightedTeam .hasMany('meetings') .value() - .rejectBy('isNew') - .filterBy('waypoint') + .filter((m) => !m.isNew && m.waypoint) .map((meeting) => meeting.belongsTo('waypoint').value()) - .map((waypoint) => waypoint.belongsTo('region').value()) - .mapBy('ancestor.id'); + .map((waypoint) => waypoint.belongsTo('region').value().ancestor.id); const index = waypointMeetingAncestorRegionIds.indexOf(regionId); @@ -102,7 +101,7 @@ export default class MappableRegionComponent extends Component { return; } - let { clientX, clientY, offsetX } = e; + let { clientX, clientY } = e; this.unsavedX = undefined; this.unsavedY = undefined; @@ -156,12 +155,12 @@ export default class MappableRegionComponent extends Component { {{! template-lint-disable no-invalid-interactive }}
m.index)).sort(); this.args.teams.forEach((team) => { doc.text( @@ -38,7 +39,7 @@ export default class ClandestineRendezvousAnswersComponent extends Component { doc.moveDown(); - const meetingsWithIndex = meetings.filterBy('index', index); + const meetingsWithIndex = meetings.filter((m) => m.index === index); doc.text( meetingsWithIndex @@ -46,7 +47,7 @@ export default class ClandestineRendezvousAnswersComponent extends Component { const teamNames = meeting .hasMany('teams') .value() - .mapBy('name') + .map((t) => t.name) .sort() .join(', '); diff --git a/gathering/app/components/output/clandestine-rendezvous/cards.gjs b/gathering/app/components/output/clandestine-rendezvous/cards.gjs index ccf2ed0a..535ce5ce 100644 --- a/gathering/app/components/output/clandestine-rendezvous/cards.gjs +++ b/gathering/app/components/output/clandestine-rendezvous/cards.gjs @@ -1,14 +1,13 @@ -import { alias } from '@ember/object/computed'; import { inject as service } from '@ember/service'; import Component from '@glimmer/component'; import Loading from 'adventure-gathering/components/loading'; -import { get } from '@ember/object'; import config from 'adventure-gathering/config/environment'; import blobStream from 'blob-stream'; import { trackedFunction } from 'ember-resources/util/function'; +import sortBy from 'lodash.sortby'; import moment from 'moment'; import PDFDocument from 'pdfkit'; @@ -167,7 +166,7 @@ export default class ClandestineRendezvousCardsComponent extends Component { label: `from ${cardData.otherTeamName}`, }; - const sortedTeams = [cardData.team, otherTeam].sortBy('name'); + const sortedTeams = sortBy([cardData.team, otherTeam], ['name']); if (sortedTeams[0] === cardData.team) { rows.push(myRow); @@ -274,7 +273,8 @@ export default class ClandestineRendezvousCardsComponent extends Component { team .hasMany('meetings') .value() - .sortBy('index') + .slice() + .sort((a, b) => a.index - b.index) .map((meeting, index) => { return this._rendezvousCardDataForTeamMeeting(team, meeting, index); }) @@ -294,13 +294,13 @@ export default class ClandestineRendezvousCardsComponent extends Component { const rendezvousLetter = String.fromCharCode(65 + index); const rendezvousTime = this._getRendezvousTimeForIndex(index); - const otherTeams = teams.rejectBy('id', team.id); - const otherTeamName = otherTeams.mapBy('name'); + const otherTeams = teams.filter((t) => t.id !== team.id); + const otherTeamName = otherTeams.map((t) => t.name); const answer = destination.get('answer'); const mask = destination.get('mask'); - const goalLetter = get(this.args.settings, 'goal')[index]; + const goalLetter = this.args.settings.goal[index]; const goalDigit = parseInt(goalLetter); const chosenBlankIndex = this.puzzles.implementation.chooseBlankIndex({ diff --git a/gathering/app/components/output/clandestine-rendezvous/maps.gjs b/gathering/app/components/output/clandestine-rendezvous/maps.gjs index 1188cce6..15aad903 100644 --- a/gathering/app/components/output/clandestine-rendezvous/maps.gjs +++ b/gathering/app/components/output/clandestine-rendezvous/maps.gjs @@ -1,9 +1,8 @@ -import Component from '@glimmer/component'; import { inject as service } from '@ember/service'; +import Component from '@glimmer/component'; +import Loading from 'adventure-gathering/components/loading'; import blobStream from 'blob-stream'; -import classic from 'ember-classic-decorator'; import { trackedFunction } from 'ember-resources/util/function'; -import Loading from 'adventure-gathering/components/loading'; import PDFDocument from 'pdfkit'; @@ -73,7 +72,8 @@ export default class ClandestineRendezvousMapsComponent extends Component { team .hasMany('meetings') .value() - .sortBy('index') + .slice() + .sort((a, b) => a.index - b.index) .forEach((meeting, index) => { const destination = meeting.belongsTo('destination').value(); const region = destination.belongsTo('region').value(); diff --git a/gathering/app/components/output/txtbeyond/cards.gjs b/gathering/app/components/output/txtbeyond/cards.gjs index 417add7c..1e284fce 100644 --- a/gathering/app/components/output/txtbeyond/cards.gjs +++ b/gathering/app/components/output/txtbeyond/cards.gjs @@ -1,13 +1,11 @@ -import Component from '@glimmer/component'; -import { alias } from '@ember/object/computed'; import { inject as service } from '@ember/service'; -import { tagName } from '@ember-decorators/component'; +import Component from '@glimmer/component'; -import config from 'adventure-gathering/config/environment'; -import { trackedFunction } from 'ember-resources/util/function'; import Loading from 'adventure-gathering/components/loading'; +import config from 'adventure-gathering/config/environment'; import blobStream from 'blob-stream'; +import { trackedFunction } from 'ember-resources/util/function'; import moment from 'moment'; import PDFDocument from 'pdfkit'; @@ -238,7 +236,8 @@ export default class TxtbeyondCardsComponent extends Component { team .hasMany('meetings') .value() - .sortBy('index') + .slice() + .sort((a, b) => a.index - b.index) .map((meeting, index) => { return this._rendezvousCardDataForTeamMeeting(team, meeting, index); }) @@ -255,8 +254,8 @@ export default class TxtbeyondCardsComponent extends Component { // const rendezvousLetter = String.fromCharCode(65 + index); // const rendezvousTime = this._getRendezvousTimeForIndex(index); - const otherTeams = teams.rejectBy('id', team.id); - const otherTeamName = otherTeams.mapBy('name'); + const otherTeams = teams.filter((t) => t.id !== team.id); + const otherTeamName = otherTeams.map((t) => t.name); const answer = destination.get('answer'); const mask = destination.get('mask'); diff --git a/gathering/app/components/output/txtbeyond/transparencies.gjs b/gathering/app/components/output/txtbeyond/transparencies.gjs index d33bb31f..8ea77093 100644 --- a/gathering/app/components/output/txtbeyond/transparencies.gjs +++ b/gathering/app/components/output/txtbeyond/transparencies.gjs @@ -1,6 +1,7 @@ -import Component from '@glimmer/component'; import { inject as service } from '@ember/service'; +import Component from '@glimmer/component'; +import Loading from 'adventure-gathering/components/loading'; import { pixelLength, drawnLength, @@ -10,7 +11,6 @@ import { } from 'adventure-gathering/utils/nokia-font'; import blobStream from 'blob-stream'; import { trackedFunction } from 'ember-resources/util/function'; -import Loading from 'adventure-gathering/components/loading'; import MaxRectsPackerPackage from 'maxrects-packer'; import PDFDocument from 'pdfkit'; diff --git a/gathering/app/components/output/unmnemonic-devices/answers.gjs b/gathering/app/components/output/unmnemonic-devices/answers.gjs index 914a5dec..d60323f9 100644 --- a/gathering/app/components/output/unmnemonic-devices/answers.gjs +++ b/gathering/app/components/output/unmnemonic-devices/answers.gjs @@ -1,98 +1,99 @@ -import Component from '@glimmer/component'; -import { tracked } from '@glimmer/tracking'; import { inject as service } from '@ember/service'; -import { trackedFunction } from 'ember-resources/util/function'; +import Component from '@glimmer/component'; import Loading from 'adventure-gathering/components/loading'; import blobStream from 'blob-stream'; +import { trackedFunction } from 'ember-resources/util/function'; import PDFDocument from 'pdfkit'; export default class AnswersComponent extends Component { @service('unmnemonic-devices') devices; generator = trackedFunction(this, async () => { - let debug = this.args.debug; - let regular = this.args.assets.regular; let doc = new PDFDocument({ layout: 'portrait', font: regular }); let stream = doc.pipe(blobStream()); - this.args.teams.sortBy('createdAt').forEach((team, index) => { - if (index > 0) { - doc.addPage(); - } - - doc.fontSize(14); - - doc.text(`${team.truncatedName}`, 50, 50); - doc.text(' '); - - doc.fontSize(12); - - doc.text(team.users); - doc.text(team.notes); - doc.text(`voicepass: ${team.identifier}`); - - doc.text(' '); - - doc.fontSize(10); - - team - .hasMany('meetings') - .value() - .sortBy('destination.id') - .forEach((meeting) => { - let waypoint = meeting.belongsTo('waypoint').value(); - let waypointRegion = waypoint.belongsTo('region').value(); - - let destination = meeting.belongsTo('destination').value(); - let destinationRegion = destination.belongsTo('region').value(); - - let fullExcerpt = waypoint.excerpt; - let preExcerpt = this.devices.preExcerpt(fullExcerpt); - let innerExcerpt = this.devices.trimmedInnerExcerpt(fullExcerpt); - let postExcerpt = this.devices.postExcerpt(fullExcerpt); - - doc.text(waypointRegion.name); - doc.text( - `${waypoint.name} (${waypoint.call}, page ${waypoint.page})` - ); - doc.moveDown(); - - doc - .text(`${preExcerpt} | `, { continued: true }) - .font(this.args.assets.bold) - .text(innerExcerpt, { continued: true }) - .font(this.args.assets.regular) - .text(` | ${postExcerpt}`); - - doc.text(' '); - - let answer = destination.answer; - let mask = destination.mask; - - let preAnswer = this.devices.preAnswer(answer, mask); - let answerOnly = this.devices.extractAnswer(answer, mask); - let postAnswer = this.devices.postAnswer(answer, mask); - - doc.text(destinationRegion.name); - doc.moveDown(); - - doc - .text(`${destination.description}: ${preAnswer}`, { - continued: true, - }) - .font(this.args.assets.bold) - .text(answerOnly, { continued: true }) - .font(this.args.assets.regular) - .text(postAnswer); - - doc.text(' '); - doc.text('-------'); - doc.text(' '); - }); - }); + this.args.teams + .slice() + .sort((a, b) => a.createdAt - b.createdAt) + .forEach((team, index) => { + if (index > 0) { + doc.addPage(); + } + + doc.fontSize(14); + + doc.text(`${team.truncatedName}`, 50, 50); + doc.text(' '); + + doc.fontSize(12); + + doc.text(team.users); + doc.text(team.notes); + doc.text(`voicepass: ${team.identifier}`); + + doc.text(' '); + + doc.fontSize(10); + + team + .hasMany('meetings') + .value() + .slice() + .sort((a, b) => a.destination.id - b.destination.id) + .forEach((meeting) => { + let waypoint = meeting.belongsTo('waypoint').value(); + let waypointRegion = waypoint.belongsTo('region').value(); + + let destination = meeting.belongsTo('destination').value(); + let destinationRegion = destination.belongsTo('region').value(); + + let fullExcerpt = waypoint.excerpt; + let preExcerpt = this.devices.preExcerpt(fullExcerpt); + let innerExcerpt = this.devices.trimmedInnerExcerpt(fullExcerpt); + let postExcerpt = this.devices.postExcerpt(fullExcerpt); + + doc.text(waypointRegion.name); + doc.text( + `${waypoint.name} (${waypoint.call}, page ${waypoint.page})` + ); + doc.moveDown(); + + doc + .text(`${preExcerpt} | `, { continued: true }) + .font(this.args.assets.bold) + .text(innerExcerpt, { continued: true }) + .font(this.args.assets.regular) + .text(` | ${postExcerpt}`); + + doc.text(' '); + + let answer = destination.answer; + let mask = destination.mask; + + let preAnswer = this.devices.preAnswer(answer, mask); + let answerOnly = this.devices.extractAnswer(answer, mask); + let postAnswer = this.devices.postAnswer(answer, mask); + + doc.text(destinationRegion.name); + doc.moveDown(); + + doc + .text(`${destination.description}: ${preAnswer}`, { + continued: true, + }) + .font(this.args.assets.bold) + .text(answerOnly, { continued: true }) + .font(this.args.assets.regular) + .text(postAnswer); + + doc.text(' '); + doc.text('-------'); + doc.text(' '); + }); + }); doc.end(); diff --git a/gathering/app/components/output/unmnemonic-devices/overlays.gjs b/gathering/app/components/output/unmnemonic-devices/overlays.gjs index 9a2a22e8..d5b6be23 100644 --- a/gathering/app/components/output/unmnemonic-devices/overlays.gjs +++ b/gathering/app/components/output/unmnemonic-devices/overlays.gjs @@ -1,21 +1,20 @@ +import { Input } from '@ember/component'; +import { inject as service } from '@ember/service'; import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; -import { inject as service } from '@ember/service'; -import { trackedFunction } from 'ember-resources/util/function'; -import { Input } from '@ember/component'; import Loading from 'adventure-gathering/components/loading'; +import blobStream from 'blob-stream'; +import { trackedFunction } from 'ember-resources/util/function'; + +import PDFDocument from 'pdfkit'; import { drawZigzagBackground, drawConcentricCirclesBackground, drawSpiralBackground, - drawConcentricSquaresBackground, drawConcentricStarsBackground, } from './overlay-backgrounds'; -import blobStream from 'blob-stream'; -import PDFDocument from 'pdfkit'; - export const PAGE_MARGIN = 0.3 * 72; export const PAGE_PADDING = 0.2 * 72; @@ -52,12 +51,11 @@ export default class UnmnemonicDevicesOverlaysComponent extends Component { let waypointsToGenerate; if (this.allOverlays) { - waypointsToGenerate = this.args.waypoints.filterBy('isComplete'); + waypointsToGenerate = this.args.waypoints.filter((w) => w.isComplete); if (this.excludeAvailable) { - waypointsToGenerate = waypointsToGenerate.rejectBy( - 'status', - 'available' + waypointsToGenerate = waypointsToGenerate.filter( + (w) => w.status !== 'available' ); } } else { @@ -65,7 +63,8 @@ export default class UnmnemonicDevicesOverlaysComponent extends Component { team .hasMany('meetings') .value() - .sortBy('destination.id') + .slice() + .sort((a, b) => a.destination.id - b.destination.id) .forEach((meeting, index) => { waypoints.push({ team, @@ -204,7 +203,7 @@ export default class UnmnemonicDevicesOverlaysComponent extends Component { doc.text(fullOutline); doc.text(excerpt); - outlines.forEach((outline, index) => { + outlines.forEach((outline) => { doc.text(JSON.stringify(outline)); }); diff --git a/gathering/app/components/output/unmnemonic-devices/team-overviews.gjs b/gathering/app/components/output/unmnemonic-devices/team-overviews.gjs index 0abe9510..e5aa561a 100644 --- a/gathering/app/components/output/unmnemonic-devices/team-overviews.gjs +++ b/gathering/app/components/output/unmnemonic-devices/team-overviews.gjs @@ -1,10 +1,9 @@ -import Component from '@glimmer/component'; -import { tracked } from '@glimmer/tracking'; -import { trackedFunction } from 'ember-resources/util/function'; import { inject as service } from '@ember/service'; +import Component from '@glimmer/component'; import Loading from 'adventure-gathering/components/loading'; import blobStream from 'blob-stream'; +import { trackedFunction } from 'ember-resources/util/function'; import PDFDocument from 'pdfkit'; const pageMargin = 0.5 * 72; @@ -34,8 +33,6 @@ export default class TeamOverviewsComponent extends Component { let mapBase64String = await this.map.blobToBase64String(mapBlob); let lowMapBase64String = await this.map.blobToBase64String(lowMapBlob); - let mapHighToLowRatio = lowMapBitmap.width / mapBitmap.width; - let mapTeamFontSize = 18; let mapMarkerFontSize = 12; let mapMarkerCircleRadius = 10; @@ -58,22 +55,25 @@ export default class TeamOverviewsComponent extends Component { let devices = this.devices; - this.args.teams.sortBy('createdAt').forEach((team, index) => { - if (index > 0) { - doc.addPage(); - } + this.args.teams + .slice() + .sort((a, b) => a.createdAt - b.createdAt) + .forEach((team, index) => { + if (index > 0) { + doc.addPage(); + } - drawMargins(doc, () => { - drawHeader(team); - drawMap(); - drawMeetingPoints(team); - drawExtras(); + drawMargins(doc, () => { + drawHeader(team); + drawMap(); + drawMeetingPoints(team); + drawExtras(); - doc.addPage(); + doc.addPage(); - drawMeetingBlanks(team); + drawMeetingBlanks(team); + }); }); - }); doc.end(); @@ -137,7 +137,8 @@ export default class TeamOverviewsComponent extends Component { team .hasMany('meetings') .value() - .sortBy('destination.id') + .slice() + .sort((a, b) => a.destination.id - b.destination.id) .forEach((meeting, index) => { const rendezvousLetter = identifierForMeeting(index); @@ -297,7 +298,8 @@ export default class TeamOverviewsComponent extends Component { team .hasMany('meetings') .value() - .sortBy('destination.id') + .slice() + .sort((a, b) => a.destination.id - b.destination.id) .forEach((meeting, index) => { const rendezvousLetter = identifierForMeeting(index); @@ -372,8 +374,6 @@ export default class TeamOverviewsComponent extends Component { doc.fontSize(meetingHeadingFontSize); - let parent = destinationRegion.belongsTo('parent').value(); - doc.text(destinationRegion.name, 0, meetingPadding, { width: meetingHalfWithoutPadding, }); diff --git a/gathering/app/components/output/unmnemonic-devices/verification.gjs b/gathering/app/components/output/unmnemonic-devices/verification.gjs index f9c066a7..e6f0b54c 100644 --- a/gathering/app/components/output/unmnemonic-devices/verification.gjs +++ b/gathering/app/components/output/unmnemonic-devices/verification.gjs @@ -1,18 +1,15 @@ -import Component from '@glimmer/component'; -import { tracked } from '@glimmer/tracking'; import { inject as service } from '@ember/service'; -import { trackedFunction } from 'ember-resources/util/function'; +import Component from '@glimmer/component'; import Loading from 'adventure-gathering/components/loading'; import blobStream from 'blob-stream'; +import { trackedFunction } from 'ember-resources/util/function'; import PDFDocument from 'pdfkit'; export default class TeamOverviewsComponent extends Component { @service('unmnemonic-devices') devices; generator = trackedFunction(this, async () => { - let debug = this.args.debug; - let regular = this.args.assets.regular; let doc = new PDFDocument({ layout: 'portrait', font: regular }); diff --git a/gathering/app/components/output/unmnemonic-devices/vrssql.gjs b/gathering/app/components/output/unmnemonic-devices/vrssql.gjs index a4051998..3a9debd3 100644 --- a/gathering/app/components/output/unmnemonic-devices/vrssql.gjs +++ b/gathering/app/components/output/unmnemonic-devices/vrssql.gjs @@ -1,9 +1,9 @@ +import { concat } from '@ember/helper'; +import { inject as service } from '@ember/service'; import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; -import { inject as service } from '@ember/service'; import CopyButton from 'ember-cli-clipboard/components/copy-button'; import knex from 'knex'; -import { concat } from '@ember/helper'; export default class TeamOverviewsComponent extends Component { @tracked src; @@ -30,11 +30,13 @@ export default class TeamOverviewsComponent extends Component { get regions() { return knex({ client: 'pg' })('unmnemonic_devices.regions') .insert( - this.args.regions.filterBy('isComplete').map((region) => ({ - id: region.get('id'), - name: this.stripString(region.get('name')), - inserted_at: region.get('createdAt').toISOString(), - })) + this.args.regions + .filter((r) => r.isComplete) + .map((region) => ({ + id: region.get('id'), + name: this.stripString(region.get('name')), + inserted_at: region.get('createdAt').toISOString(), + })) ) .onConflict('id') .merge(); @@ -44,8 +46,7 @@ export default class TeamOverviewsComponent extends Component { return knex({ client: 'pg' })('unmnemonic_devices.destinations') .insert( this.args.destinations - .filterBy('isComplete') - .filterBy('isAvailable') + .filter((d) => d.isComplete && d.isAvailable) .map((destination) => ({ id: destination.get('id'), description: this.stripString(destination.get('description')), @@ -64,14 +65,16 @@ export default class TeamOverviewsComponent extends Component { get books() { return knex({ client: 'pg' })('unmnemonic_devices.books') .insert( - this.args.waypoints.filterBy('isComplete').map((waypoint) => ({ - id: waypoint.get('id'), - title: this.stripString(waypoint.get('name')), - excerpt: this.stripString( - this.devices.trimmedInnerExcerpt(waypoint.get('excerpt')) - ), - inserted_at: waypoint.get('createdAt').toISOString(), - })) + this.args.waypoints + .filter((w) => w.isComplete) + .map((waypoint) => ({ + id: waypoint.get('id'), + title: this.stripString(waypoint.get('name')), + excerpt: this.stripString( + this.devices.trimmedInnerExcerpt(waypoint.get('excerpt')) + ), + inserted_at: waypoint.get('createdAt').toISOString(), + })) ) .onConflict('id') .merge(); @@ -82,7 +85,7 @@ export default class TeamOverviewsComponent extends Component { .insert( this.args.meetings.map((meeting) => ({ id: meeting.get('id'), - team_id: meeting.get('teams.firstObject.id'), + team_id: meeting.get('teams.[0].id'), book_id: meeting.get('waypoint.id'), destination_id: meeting.get('destination.id'), })) diff --git a/gathering/app/components/region-options.gjs b/gathering/app/components/region-options.gjs index 9096d997..7336cd43 100644 --- a/gathering/app/components/region-options.gjs +++ b/gathering/app/components/region-options.gjs @@ -1,12 +1,9 @@ -import Component from '@glimmer/component'; import RegionOption from 'adventure-gathering/components/region-option'; -export default class RegionOptions extends Component { - -} + diff --git a/gathering/app/components/region-row.gjs b/gathering/app/components/region-row.gjs index a6dbfabf..9f3b2e40 100644 --- a/gathering/app/components/region-row.gjs +++ b/gathering/app/components/region-row.gjs @@ -1,8 +1,5 @@ -import Component from '@glimmer/component'; -import { action } from '@ember/object'; -import { on } from '@ember/modifier'; -import { htmlSafe } from '@ember/template'; import { LinkTo } from '@ember/routing'; +import Component from '@glimmer/component'; export default class RegionRow extends Component { get nesting() { @@ -16,7 +13,7 @@ export default class RegionRow extends Component {