-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task 17 modal do eksportu #184
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
08d5945
added modal.
Dushess0 783cdaf
tslint fix
Dushess0 7d18e4d
fixed extension
Dushess0 786dff8
Merge branch 'develop' into TASK-17
Qwebeck 6b5adc5
Merge branch 'develop' into TASK-17
Dushess0 f21167b
Merge branch 'develop' into TASK-17
Qwebeck 8f0e9fe
Merge branch 'develop' of https://github.com/Project-Summer-AI-Lab-Gl…
Dushess0 422f1ab
fixed scroll
Dushess0 e077136
Merge branch 'TASK-17' of https://github.com/Project-Summer-AI-Lab-Gl…
Dushess0 102c05a
updated tests
Dushess0 44c1920
Merge branch 'develop' into TASK-17
Dushess0 40f24e9
fixed styles
Dushess0 4899747
Merge branch 'TASK-17' of https://github.com/Project-Summer-AI-Lab-Gl…
Dushess0 6469414
added logic to exporting with overtime, exporting with extra workers.
Dushess0 1254b10
Merge branch 'develop' of https://github.com/Project-Summer-AI-Lab-Gl…
Dushess0 414bfe4
updated dependencies
Dushess0 117cc79
Merge branch 'develop' into TASK-17
Qwebeck 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
@import "variables"; | ||
.label { | ||
color: $primary-header-color; | ||
font-size: $font-size-lg; | ||
font-family: $font-family-primary; | ||
font-weight: $font-weight-extra-bold; | ||
line-height: $modal-title-line-height; | ||
} |
140 changes: 140 additions & 0 deletions
140
src/components/common-components/modal/export-modal/export.modal.component.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,140 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
import { | ||
Checkbox, | ||
CheckboxProps, | ||
FormControlLabel, | ||
FormGroup, | ||
withStyles, | ||
} from "@material-ui/core"; | ||
import { blue } from "@material-ui/core/colors"; | ||
import React from "react"; | ||
import { Button } from "../.."; | ||
import { ScheduleDataModel } from "../../../../common-models/schedule-data.model"; | ||
import { ScheduleExportLogic } from "../../../../logic/schedule-exporter/schedule-export.logic"; | ||
import { ButtonData, DropdownButtons } from "../../dropdown-buttons/dropdown-buttons.component"; | ||
import DefaultModal from "../modal.component"; | ||
|
||
export interface ExportModalComponent { | ||
setOpen: (open: boolean) => void; | ||
open: boolean; | ||
model: ScheduleDataModel; | ||
} | ||
const BlueCheckBox = withStyles({ | ||
root: { | ||
color: blue[400], | ||
"&$checked": { | ||
color: blue[600], | ||
}, | ||
}, | ||
checked: {}, | ||
})((props: CheckboxProps) => <Checkbox color="default" {...props} />); | ||
|
||
export default function ExportModal(options: ExportModalComponent): JSX.Element { | ||
const { setOpen, open, model } = options; | ||
const [exportMode, setexportMode] = React.useState("XLSX"); | ||
const handleClose = (): void => { | ||
setOpen(false); | ||
}; | ||
const date = new Date(); | ||
const DEFAULT_FILENAME = `${date.getDate()}_${date.getMonth() + 1}_${date.getFullYear()}.xlsx`; | ||
|
||
const [exportOptions, setExportOptions] = React.useState({ | ||
extraWorkers: { value: true, label: "dzienni pracownicy" }, | ||
overtime: { value: true, label: "nadgodzinny" }, | ||
}); | ||
|
||
const exportExtensions = { | ||
xlsx: (): void => { | ||
new ScheduleExportLogic( | ||
model, | ||
exportOptions.overtime.value, | ||
exportOptions.extraWorkers.value | ||
).formatAndSave(DEFAULT_FILENAME); | ||
}, | ||
}; | ||
const handleExport = (): void => { | ||
exportExtensions[exportMode.toLowerCase()](); | ||
setOpen(false); | ||
}; | ||
|
||
const btnData: ButtonData[] = []; | ||
for (const key of Object.keys(exportExtensions)) { | ||
const button: ButtonData = { | ||
label: key.toUpperCase(), | ||
action: () => setexportMode(key.toUpperCase()), | ||
}; | ||
btnData.push(button); | ||
} | ||
|
||
const title = "Pobierz plan"; | ||
|
||
const footer = ( | ||
<div> | ||
<Button onClick={handleExport} size="small" variant="primary" data-cy="confirm-export-button"> | ||
Potwierdż | ||
</Button> | ||
<Button onClick={handleClose} size="small" variant="secondary"> | ||
Anuluj | ||
</Button> | ||
</div> | ||
); | ||
const handleChange = (event): void => { | ||
setExportOptions({ | ||
...exportOptions, | ||
[event.target.name]: { | ||
value: event.target.checked, | ||
label: exportOptions[event.target.name].label, | ||
}, | ||
}); | ||
}; | ||
|
||
const body = ( | ||
<div> | ||
<div style={{ display: "flex", msFlexDirection: "row" }}> | ||
<p className="label">Format pliku: </p> | ||
<div style={{ top: "50%", marginTop: "-15px" }}> | ||
<DropdownButtons | ||
buttons={btnData} | ||
mainLabel={exportMode} | ||
buttonVariant="secondary" | ||
variant="extension" | ||
/> | ||
</div> | ||
</div> | ||
<div> | ||
<p className="label">Opcje pliku: </p> | ||
<FormGroup row> | ||
{Object.keys(exportOptions).map((key) => ( | ||
<FormControlLabel | ||
style={{ color: "black" }} | ||
control={ | ||
<BlueCheckBox | ||
checked={exportOptions[key].value} | ||
onChange={handleChange} | ||
name={key} | ||
/> | ||
} | ||
label={exportOptions[key].label} | ||
/> | ||
))} | ||
</FormGroup> | ||
</div> | ||
</div> | ||
); | ||
|
||
return ( | ||
<div> | ||
<DefaultModal | ||
height={500} | ||
open={open} | ||
setOpen={setOpen} | ||
title={title} | ||
body={body} | ||
footer={footer} | ||
/> | ||
</div> | ||
); | ||
} |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, to można by było to zrobić tak, żeby można było przekazywać
minWidth
iminHeigth
.Ewentualnie, można też zrobić tak, że to będzie liczone automatycznie na podstawie maxWith/maxHeight.