-
Notifications
You must be signed in to change notification settings - Fork 0
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
Maak projecten automatisch zichtbaar op een bepaald tijdstip #269
Merged
+596
−326
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9b2f9c2
add NoResourceFoundException tot errorhandling
Aqua-sc 19ef550
Merge branch 'frontend' into feature/project-automatically-visible
arnedierick 149f70f
Fixed imageExists
Triver1 23300f3
Added functionality for course_admins to make projects visible to stu…
arnedierick 355ff0b
Added UI in the projectTable (where useIsCourseAdmin is defined) so a…
arnedierick 851bdac
env builder 🎉
AWerbrouck ad77b1f
Merge remote-tracking branch 'origin/development' into development
AWerbrouck 0d56e76
Merge branch 'development' into feature/project-automatically-visible
arnedierick b03284c
Implemented requested changes
arnedierick e66fc4a
Test works now
arnedierick 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
136 changes: 85 additions & 51 deletions
136
frontend/src/components/forms/projectFormTabs/GeneralFormTab.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 |
---|---|---|
@@ -1,59 +1,93 @@ | ||
import { DatePicker, Form, FormInstance, Input, Switch, Typography } from "antd" | ||
import { useTranslation } from "react-i18next" | ||
import { FC } from "react" | ||
import { FC, useEffect, useState } from "react" | ||
import MarkdownEditor from "../../input/MarkdownEditor" | ||
|
||
const GeneralFormTab: FC<{ form: FormInstance }> = ({ form }) => { | ||
const { t } = useTranslation() | ||
const description = Form.useWatch("description", form) | ||
|
||
return ( | ||
<> | ||
<Form.Item | ||
label={t("project.change.name")} | ||
name="name" | ||
rules={[{ required: true, message: t("project.change.nameMessage") }]} | ||
> | ||
<Input /> | ||
</Form.Item> | ||
|
||
<Typography.Text> | ||
{t("project.change.description")} | ||
</Typography.Text> | ||
<MarkdownEditor value={description} maxLength={5000} /> | ||
|
||
<Form.Item | ||
label={t("project.change.visible")} | ||
required | ||
name="visible" | ||
valuePropName="checked" | ||
> | ||
<Switch /> | ||
</Form.Item> | ||
<Form.Item | ||
label={t("project.change.maxScore")} | ||
name="maxScore" | ||
tooltip={t("project.change.maxScoreHelp")} | ||
rules={[{ required: false, message: t("project.change.maxScoreMessage") }]} | ||
> | ||
<Input | ||
min={1} | ||
max={1000} | ||
type="number" | ||
/> | ||
</Form.Item> | ||
<Form.Item | ||
label={t("project.change.deadline")} | ||
name="deadline" | ||
rules={[{ required: true }]} | ||
> | ||
<DatePicker | ||
showTime | ||
format="YYYY-MM-DD HH:mm:ss" | ||
/> | ||
</Form.Item> | ||
</> | ||
) | ||
const { t } = useTranslation() | ||
const description = Form.useWatch("description", form) | ||
const visible = Form.useWatch("visible", form) | ||
const [isVisible, setIsVisible] = useState(visible) | ||
const [savedVisibleAfter, setSavedVisibleAfter] = useState<string | null>(null) | ||
|
||
useEffect(() => { | ||
setIsVisible(visible) | ||
if (visible && savedVisibleAfter) { | ||
form.setFieldsValue({ visibleAfter: null }) | ||
} | ||
}, [visible]) | ||
|
||
const handleVisibleChange = (checked: boolean) => { | ||
setIsVisible(checked) | ||
if (checked) { | ||
setSavedVisibleAfter(form.getFieldValue("visibleAfter")) | ||
form.setFieldsValue({ visibleAfter: null }) | ||
} else { | ||
form.setFieldsValue({ visibleAfter: savedVisibleAfter }) | ||
} | ||
} | ||
|
||
return ( | ||
<> | ||
<Form.Item | ||
label={t("project.change.name")} | ||
name="name" | ||
rules={[{ required: true, message: t("project.change.nameMessage") }]} | ||
> | ||
<Input /> | ||
</Form.Item> | ||
|
||
<Typography.Text> | ||
{t("project.change.description")} | ||
</Typography.Text> | ||
<MarkdownEditor value={description} maxLength={5000} /> | ||
|
||
<Form.Item | ||
label={t("project.change.visible")} | ||
required | ||
name="visible" | ||
valuePropName="checked" | ||
> | ||
<Switch onChange={handleVisibleChange} /> | ||
</Form.Item> | ||
|
||
{!isVisible && ( | ||
<Form.Item | ||
label={t("project.change.visibleAfter")} | ||
name="visibleAfter" | ||
> | ||
<DatePicker | ||
showTime | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hier moet nog There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ik heb het erbij gezet maar AllowClear is true by default |
||
format="YYYY-MM-DD HH:mm:ss" | ||
/> | ||
</Form.Item> | ||
)} | ||
|
||
<Form.Item | ||
label={t("project.change.maxScore")} | ||
name="maxScore" | ||
tooltip={t("project.change.maxScoreHelp")} | ||
rules={[{ required: false, message: t("project.change.maxScoreMessage") }]} | ||
> | ||
<Input | ||
min={1} | ||
max={1000} | ||
type="number" | ||
/> | ||
</Form.Item> | ||
|
||
<Form.Item | ||
label={t("project.change.deadline")} | ||
name="deadline" | ||
rules={[{ required: true }]} | ||
> | ||
<DatePicker | ||
showTime | ||
format="YYYY-MM-DD HH:mm:ss" | ||
/> | ||
</Form.Item> | ||
</> | ||
) | ||
} | ||
|
||
export default GeneralFormTab |
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.
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.
Ik denk dat het gemakkelijker is om dit te doen net voor je de POST/PUT request maakt.
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.
Ik heb deze logica verplaatst naar de handleCreation functies van EditProject en ProjectCreate en de overbodige code uit GeneralFormTab verwijderd