-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Macro Buttons): Adds the ability to reorganize the macro buttons.
- Loading branch information
Showing
9 changed files
with
287 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
70 changes: 70 additions & 0 deletions
70
src/containers/FlightDirector/MacroButtons/sortableActionList.tsx
This file contains 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,70 @@ | ||
import React from "react"; | ||
import {SortableContainer, SortableElement} from "react-sortable-hoc"; | ||
import {ListGroup, ListGroupItem} from "reactstrap"; | ||
import EventName from "../MissionConfig/EventName"; | ||
import {FaBan} from "react-icons/fa"; | ||
|
||
const SortableAction = SortableElement( | ||
({ | ||
id, | ||
event, | ||
selectedAction, | ||
setSelectedAction, | ||
removeAction, | ||
}: { | ||
id: string; | ||
event: {id: string; event: string}; | ||
selectedAction?: string | null; | ||
setSelectedAction: (id: string) => void; | ||
removeAction: (id: string) => void; | ||
}) => ( | ||
<ListGroupItem | ||
key={`${id}-${event.id}`} | ||
onClick={() => setSelectedAction(event.id)} | ||
active={event.id === selectedAction} | ||
> | ||
<EventName id={event.event} />{" "} | ||
<FaBan | ||
className="text-danger pull-right" | ||
onClick={() => removeAction(event.id)} | ||
/> | ||
</ListGroupItem> | ||
), | ||
); | ||
|
||
const SortableActionList = SortableContainer( | ||
({ | ||
id, | ||
selectedAction, | ||
setSelectedAction, | ||
removeAction, | ||
actions, | ||
onSortEnd, | ||
...props | ||
}: { | ||
id: string; | ||
selectedAction?: string | null; | ||
setSelectedAction: (id: string) => void; | ||
removeAction: (id: string) => void; | ||
actions: {id: string; event: string}[]; | ||
onSortEnd: (newIndex: number) => void; | ||
}) => { | ||
return ( | ||
<ListGroup style={{maxHeight: "60vh", overflowY: "auto"}} {...props}> | ||
{actions.map((e, index) => ( | ||
<SortableAction | ||
key={e.id} | ||
index={index} | ||
id={id} | ||
event={e} | ||
selectedAction={selectedAction} | ||
setSelectedAction={() => setSelectedAction(e.id)} | ||
removeAction={() => removeAction(e.id)} | ||
/> | ||
))} | ||
</ListGroup> | ||
); | ||
}, | ||
); | ||
|
||
export default SortableActionList; |
58 changes: 58 additions & 0 deletions
58
src/containers/FlightDirector/MacroButtons/sortableMacroButtonList.tsx
This file contains 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,58 @@ | ||
import React from "react"; | ||
import {SortableContainer, SortableElement} from "react-sortable-hoc"; | ||
import {ListGroup, ListGroupItem} from "reactstrap"; | ||
|
||
const SortableButton = SortableElement( | ||
({ | ||
button, | ||
selectedButton, | ||
setSelectedButton, | ||
}: { | ||
button: {id: string; name: string; category: string}; | ||
selectedButton?: string | null; | ||
setSelectedButton: (id: string) => void; | ||
}) => ( | ||
<ListGroupItem | ||
key={`${button.id}`} | ||
onClick={() => setSelectedButton(button.id)} | ||
active={button.id === selectedButton} | ||
> | ||
{button.name} | ||
<br /> | ||
<small>{button.category}</small> | ||
</ListGroupItem> | ||
), | ||
); | ||
|
||
const SortableButtonList = SortableContainer( | ||
({ | ||
id, | ||
selectedButton, | ||
setSelectedButton, | ||
buttons, | ||
onSortEnd, | ||
...props | ||
}: { | ||
id: string; | ||
selectedButton?: string | null; | ||
setSelectedButton: (id: string) => void; | ||
buttons: {id: string; name: string; category: string}[]; | ||
onSortEnd: (newIndex: number) => void; | ||
}) => { | ||
return ( | ||
<ListGroup style={{maxHeight: "60vh", overflowY: "auto"}} {...props}> | ||
{buttons.map((b, index) => ( | ||
<SortableButton | ||
key={b.id} | ||
index={index} | ||
button={b} | ||
selectedButton={selectedButton} | ||
setSelectedButton={() => setSelectedButton(b.id)} | ||
/> | ||
))} | ||
</ListGroup> | ||
); | ||
}, | ||
); | ||
|
||
export default SortableButtonList; |
This file contains 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 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