Skip to content

Commit

Permalink
feat(client): display star map on ship page
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlatz committed May 12, 2024
1 parent a6cac3d commit 19d40a8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions client/app/controllers/ships/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ import { service } from '@ember/service';

import Ship from 'sokown-client/models/ship';
import type CurrentUserService from 'sokown-client/services/current-user';
import type LocationsService from 'sokown-client/services/locations';
import type Location from 'sokown-client/models/location';

export default class ShipsGetController extends Controller {
@service declare currentUser: CurrentUserService;
@service declare locations: LocationsService;

declare model: Ship;
@tracked newDestinationPositionX = '';
@tracked newDestinationPositionY = '';

get starMapLocations(): Location[] {
return this.locations.getAll();
}

@action
async setDestination(event: Event) {
event.preventDefault();
Expand Down
2 changes: 2 additions & 0 deletions client/app/templates/ships/get.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
</dd>
</dl>

<StarMap @locations={{this.starMapLocations}} @ship={{@model}} />

<h3>Autopilot</h3>
{{#if this.currentUser.isAuthenticated}}
<form class="row row-cols-lg-auto g-3 align-items-center" {{on "submit" this.setDestination}}>
Expand Down
5 changes: 4 additions & 1 deletion client/tests/acceptance/ship-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module('Acceptance | ship', function (hooks) {
setupMirage(hooks);

module('visiting /ships/:id', function () {
test('it displays ship public information', async function (assert) {
test('it displays ship public information and star map', async function (assert) {
// when
const screen = await visit('/');
await click(screen.getByRole('link', { name: 'Ships' }));
Expand Down Expand Up @@ -53,6 +53,9 @@ module('Acceptance | ship', function (hooks) {
assert
.dom(screen.getByRole('definition', { name: 'Est. time of arrival' }))
.hasText('—');
assert
.dom(screen.getByLabelText('A star map of the solar system'))
.exists();
});

module('when ship is moving', function () {
Expand Down

0 comments on commit 19d40a8

Please sign in to comment.