Skip to content

Commit

Permalink
[New #94] Add aircraft model in the header
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope committed Feb 8, 2023
1 parent cb38d90 commit 71079e5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/components/Legend.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
height: 100%;
}

.legend-title {
color: #263238;
}

.item {
display: flex;
align-items: center;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Legend = ({ title, items, onSelectLegendItem }: Props) => {

return (
<div className={styles["container"]}>
<h3>{title}</h3>
<h3 className={styles["legend-title"]}>{title}</h3>
<>
{items.map((legendItem, index) => {
return (
Expand Down
10 changes: 5 additions & 5 deletions src/components/PlanEditor.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
h3, h4 {
color: white;
padding: .5rem;
}

.container {
display: flex;
flex-direction: column;
Expand All @@ -18,11 +23,6 @@
}
}

h4 {
color: white;
padding: .5rem;
}

.header {
display: flex;
flex-direction: column;
Expand Down
12 changes: 11 additions & 1 deletion src/components/PlanEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
pushResourcesToTaskList,
getRestrictedTasks,
pushRestrictionsToTaskList,
getAircraftModel,
} from "../utils/Utils";
import Legend from "./Legend";
import Tooltip from "./Tooltip";
Expand Down Expand Up @@ -43,6 +44,7 @@ const PlanEditor = ({
>([]);
const [filteredTaskTypes, setFilteredTaskTypes] = useState<Array<string>>([]);
const [unplannedTasksCount, setUnplannedTasksCount] = useState<number>(0);
const [aircraftModel, setAircraftModel] = useState<string | null>();

const workPackageItems: Array<PlanPartInterface> = [];
const taskListWithResources: Array<PlanPartInterface> = [];
Expand Down Expand Up @@ -92,6 +94,13 @@ const PlanEditor = ({
);
};

useEffect(() => {
const acmodel = getAircraftModel(taskList);
if (acmodel) {
setAircraftModel(acmodel.taskType.acmodel);
}
}, [taskList]);

const showPopUp = () => {
if (!isFullScreen) {
return { ["--display" as string]: "none" };
Expand Down Expand Up @@ -141,7 +150,8 @@ const PlanEditor = ({

{isActive.planEditor && taskList.length > 0 && taskList && (
<div style={showPopUp()}>
<h4>{workPackageTitle}</h4>
<h3>{workPackageTitle}</h3>
{aircraftModel && <h4>Aircraft Model: {aircraftModel}</h4>}
<div className={styles["editor-container"]}>
<div className={styles["editor"]}>
<PlanningTool
Expand Down
5 changes: 5 additions & 0 deletions src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ const getItemTitle = (items, item, itemParentId) => {
return item.title;
};

const getAircraftModel = (items) => {
return items.find((i) => i.taskType?.acmodel);
};

const pushItem = (
items: Array<any>,
itemId: number,
Expand Down Expand Up @@ -247,4 +251,5 @@ export {
pushResourcesToTaskList,
getRestrictedTasks,
pushRestrictionsToTaskList,
getAircraftModel,
};

0 comments on commit 71079e5

Please sign in to comment.