Skip to content

Commit

Permalink
feat: display locations for races
Browse files Browse the repository at this point in the history
Fixes #100
  • Loading branch information
eXaminator committed Oct 9, 2022
1 parent d64d84b commit 9f4f6d4
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 38 deletions.
17 changes: 3 additions & 14 deletions src/KankaJournal/KankaJournalApplication.scss
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,9 @@
grid-column: 2;
padding-left: 1.5em;

&.path > a {
margin-right: 1em;
position: relative;

&:after {
content: '»';
position: absolute;
right: -0.8em;
pointer-events: none;
text-shadow: none;
}

&:last-child:after {
content: none;
&.path {
.delimiter {
margin: 0 .5em;
}
}
}
Expand Down
14 changes: 0 additions & 14 deletions src/KankaJournal/shared/detailRowAncestors.partial.hbs

This file was deleted.

17 changes: 17 additions & 0 deletions src/KankaJournal/shared/detailRowArray.partial.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{~#if references.length ~}}
<dt>
{{~#if rawLabel~}}
{{~rawLabel~}}
{{~else~}}
{{~ kankaLocalize 'journal' label ~}}
{{~/if~}}
</dt>
<dd class="path">
{{~#each references as | referenceId |~}}
{{~kankaLinkReference (kankaFindReference referenceId ../type) ~}}
{{#unless @last}}
<span class="delimiter">{{#if ../delimiter}}{{../delimiter}}{{else}}»{{/if}}</span>
{{/unless}}
{{~/each~}}
</dd>
{{~/if~}}
2 changes: 1 addition & 1 deletion src/KankaJournal/sheets/ability.partial.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#>../shared/baseLayout}}
{{#*inline 'profile'~}}
{{~>../shared/detailRow value=kankaEntity.type label='shared.labels.type' }}
{{~>../shared/detailRowAncestors ancestors=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRowArray references=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRow value=kankaEntity.charges label='ability.labels.charges' }}
{{~/inline}}
{{/../shared/baseLayout}}
2 changes: 1 addition & 1 deletion src/KankaJournal/sheets/event.partial.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#>../shared/baseLayout}}
{{#*inline 'profile'~}}
{{~>../shared/detailRow value=kankaEntity.type label='shared.labels.type' }}
{{~>../shared/detailRowAncestors ancestors=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRowArray references=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRow value=kankaEntity.location_id type='location' label='shared.labels.location' reference=true }}
{{~>../shared/detailRow value=kankaEntity.date label='event.labels.date' }}
{{~/inline}}
Expand Down
2 changes: 1 addition & 1 deletion src/KankaJournal/sheets/family.partial.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

{{#*inline 'profile'~}}
{{~>../shared/detailRow value=kankaEntity.type label='shared.labels.type' }}
{{~>../shared/detailRowAncestors ancestors=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRowArray references=kankaEntity.ancestors label='shared.labels.parent' }}
{{~/inline}}

{{#*inline 'content'}}
Expand Down
2 changes: 1 addition & 1 deletion src/KankaJournal/sheets/item.partial.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#>../shared/baseLayout}}
{{#*inline 'profile'~}}
{{~>../shared/detailRow value=kankaEntity.type label='shared.labels.type' }}
{{~>../shared/detailRowAncestors ancestors=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRowArray references=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRow value=kankaEntity.location_id type='location' label='shared.labels.location' reference=true }}
{{~>../shared/detailRow value=kankaEntity.character_id type='character' label='shared.labels.character' reference=true }}
{{~/inline}}
Expand Down
2 changes: 1 addition & 1 deletion src/KankaJournal/sheets/journal.partial.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#>../shared/baseLayout}}
{{#*inline 'profile'~}}
{{~>../shared/detailRow value=kankaEntity.type label='shared.labels.type' }}
{{~>../shared/detailRowAncestors ancestors=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRowArray references=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRow value=kankaEntity.location_id type='location' label='shared.labels.location' reference=true }}
{{~>../shared/detailRow value=kankaEntity.character_id type='character' label='shared.labels.character' reference=true }}
{{~>../shared/detailRow value=kankaEntity.date label='journal.labels.date' }}
Expand Down
2 changes: 1 addition & 1 deletion src/KankaJournal/sheets/location.partial.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#>../shared/baseLayout}}
{{#*inline 'profile'~}}
{{~>../shared/detailRow value=kankaEntity.type label='shared.labels.type' }}
{{~>../shared/detailRowAncestors ancestors=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRowArray references=kankaEntity.ancestors label='shared.labels.parent' }}
{{~/inline}}
{{/../shared/baseLayout}}
2 changes: 1 addition & 1 deletion src/KankaJournal/sheets/note.partial.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#>../shared/baseLayout}}
{{#*inline 'profile'~}}
{{~>../shared/detailRow value=kankaEntity.type label='shared.labels.type' }}
{{~>../shared/detailRowAncestors ancestors=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRowArray references=kankaEntity.ancestors label='shared.labels.parent' }}
{{~/inline}}
{{/../shared/baseLayout}}
2 changes: 1 addition & 1 deletion src/KankaJournal/sheets/organisation.partial.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

{{#*inline 'profile'~}}
{{~>../shared/detailRow value=kankaEntity.type label='shared.labels.type' }}
{{~>../shared/detailRowAncestors ancestors=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRowArray references=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRow value=kankaEntity.location_id type='location' label='shared.labels.location' reference=true }}

{{~#with (kankaFilterBy (kankaFilterReferences kankaEntity.members) 'pin_id' 'regex:2|3') as | starred |~}}
Expand Down
2 changes: 1 addition & 1 deletion src/KankaJournal/sheets/quest.partial.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

{{#*inline 'profile'~}}
{{~>../shared/detailRow value=kankaEntity.type label='shared.labels.type'~}}
{{~>../shared/detailRowAncestors ancestors=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRowArray references=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRow value=kankaEntity.character_id type='quest' label='quest.labels.instigator' reference=true~}}
{{~>../shared/detailRow value=kankaEntity.date label='quest.labels.date'~}}
{{~>../shared/detailRow value=kankaEntity.is_completed label='quest.labels.completed' localizeValue='shared.value'~}}
Expand Down
3 changes: 2 additions & 1 deletion src/KankaJournal/sheets/race.partial.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{#>../shared/baseLayout}}
{{#*inline 'profile'~}}
{{~>../shared/detailRow value=kankaEntity.type label='shared.labels.type' }}
{{~>../shared/detailRowAncestors ancestors=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRowArray references=kankaEntity.ancestors label='shared.labels.parent' }}
{{~>../shared/detailRowArray references=kankaEntity.locations type='location' label='shared.labels.location' delimiter=" " }}
{{~/inline}}
{{/../shared/baseLayout}}
30 changes: 30 additions & 0 deletions src/module/TypeLoaders/RaceTypeLoader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function createRace(data: Partial<KankaApiRace> = {}): KankaApiRace {
entity_abilities: [],
ancestors: [],
children: [],
locations: [],
...data,
} as KankaApiRace;
}
Expand Down Expand Up @@ -224,5 +225,34 @@ describe('RaceTypeLoader', () => {
},
});
});

it('includes locations from the lookup array', async () => {
const expectedResult = createRace({
locations: [2001, 2004],
});

const entities = [
createEntity(1001, 2001, 'location'),
createEntity(1002, 2002, 'race'),
createEntity(1003, 2003, 'quest'),
createEntity(1004, 2004, 'location'),
];

const loader = new RaceTypeLoader(api);
const collection = await loader.createReferenceCollection(4711, expectedResult, entities);

expect(collection.getRecord()).toMatchObject({
1001: {
id: 2001,
entityId: 1001,
type: 'location',
},
1004: {
id: 2004,
entityId: 1004,
type: 'location',
},
});
});
});
});
1 change: 1 addition & 0 deletions src/module/TypeLoaders/RaceTypeLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class RaceTypeLoader extends AbstractTypeLoader<KankaApiRace> {

await Promise.all([
collection.addById(entity.race_id, 'race'),
...entity.locations.map(location => collection.addById(location, 'location')),
...entity.ancestors.map(ancestor => collection.addByEntityId(ancestor)),
...entity.children.map(child => collection.addByEntityId(child.entity_id)),
]);
Expand Down
1 change: 1 addition & 0 deletions src/types/kanka.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ export interface KankaApiQuest extends KankaApiChildEntity {
export interface KankaApiRace extends KankaApiChildEntity {
ancestors: KankaApiEntityId[];
children: KankaApiChild[];
locations: KankaApiId[];
race_id: KankaApiId | null;
type: string | null;
}
Expand Down

0 comments on commit 9f4f6d4

Please sign in to comment.