This repository was archived by the owner on Nov 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Roster selection #611
Draft
g3rg
wants to merge
23
commits into
Floppy:main
Choose a base branch
from
g3rg:roster-selection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Roster selection #611
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
a32a16d
Determine if a battlescribe file is for a roster or not
g3rg 42b60da
Display roster operatives
g3rg 5f9136b
Merge branch 'main' into roster-selection
g3rg 7b8bfc0
Playing with operative display
g3rg e851e0a
Add parse and store BattleScribe UUID for use in Roster/Kill team sel…
g3rg 2e9b03d
Merge branch 'main' into roster-selection
g3rg cde7594
Move roster selection to a new component
g3rg f2eee71
Merge branch 'main' into roster-selection
g3rg a66eab1
Use table for Roster list
g3rg b9dfdef
Roster selection/deselection working
g3rg 8c02119
Switched to use checkbox to take up less room, and grey out row when …
g3rg f7f5777
Allow hiding of roster list when printing, and add setting for it
g3rg be9ac48
Merge branch 'main' into roster-selection
g3rg b2e5f99
Use better key
g3rg 3eb5a14
Boy scout lint fixes
g3rg 648956e
Remove console.log
g3rg a0b422c
Merge branch 'main' into roster-selection
g3rg 10c7fe5
Merge branch 'main' into roster-selection
g3rg b61652b
Merge branch 'main' into roster-selection
g3rg 4389079
Merge branch 'main' into roster-selection
g3rg 73df4b7
Add setting to turn roster selection view on / off and marked as WIP
g3rg 66a8658
Some linting issues, though line is now super long
g3rg e10d8e3
Update key for datasheet, using just datacard name caused problems wh…
g3rg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { Operative, Weapon } from '../../types/KillTeam2021' | ||
| import { Form, Row, Table } from 'react-bootstrap' | ||
| import React from 'react' | ||
|
|
||
| interface Props { | ||
| operatives: Operative[] | ||
| selectedOperatives: string[] | ||
| setSelectedOperatives: (opIds: string[]) => void | ||
| } | ||
|
|
||
| const weaponNames = (weapons: Weapon[]): JSX.Element[] => { | ||
| return weapons.map((weapon, index) => { | ||
| return <Row key={weapon.name}>{weapon.name}</Row> | ||
| }) | ||
| } | ||
|
|
||
| const operativeName = (operative: Operative): JSX.Element => { | ||
| // TODO: Hasn't been tested with a roster with actual names for units, I think this is only supported if you pay for battlescribe | ||
| const name = operative.name.includes(operative.datacard) ? operative.name : `${operative.name} [${operative.datacard}]` | ||
| return <span>{name}</span> | ||
| } | ||
|
|
||
| const flipSelection = (selectedOperatives: string[], opId: string): string[] => { | ||
| return selectionChanged(selectedOperatives, opId, !selectedOperatives.includes(opId)) | ||
| } | ||
|
|
||
| const selectionChanged = (selectedOperatives: string[], opId: string, selected: boolean): string[] => { | ||
| let selectedOps = [] | ||
| if (selected) { | ||
| selectedOps = [ | ||
| opId, | ||
| ...selectedOperatives | ||
| ] | ||
| } else { | ||
| const idx = selectedOperatives.indexOf(opId) | ||
| if (idx > -1) { | ||
| selectedOperatives.splice(idx, 1) | ||
| } | ||
| selectedOps = selectedOperatives | ||
| } | ||
| return selectedOps | ||
| } | ||
|
|
||
| export function RosterSelection (props: Props) { | ||
| return ( | ||
| <Table> | ||
| <thead> | ||
| <tr> | ||
| <th>Operative</th> | ||
| <th>Weapons</th> | ||
| <th /> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {props.operatives.map((op) => { | ||
| const selected = props.selectedOperatives.includes(op.id) | ||
| const className = selected ? '' : 'unselected' | ||
| return ( | ||
| <tr | ||
| key={op.id} onClick={(event) => { props.setSelectedOperatives(flipSelection(props.selectedOperatives, op.id)) }} | ||
| className={className} | ||
| > | ||
| <td>{operativeName(op)}</td> | ||
| <td>{weaponNames(op.weapons)}</td> | ||
| <td> | ||
| <Form.Check | ||
| type='checkbox' | ||
| id='operative' | ||
| label='' | ||
| checked={selected} | ||
| /> | ||
| </td> | ||
| </tr> | ||
| ) | ||
| })} | ||
| </tbody> | ||
| </Table> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| export interface Settings { | ||
| showWoundTrack: boolean | ||
| printRosterList: boolean | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.