Skip to content

Commit

Permalink
2000: Fixed repeat active checkbox ui flow
Browse files Browse the repository at this point in the history
  • Loading branch information
tuj committed Aug 14, 2024
1 parent 7ac5b56 commit 4d38df7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/components/util/schedule/schedule.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function Schedule({ schedules, onChange }) {
const byMonthOptions = getByMonthOptions(t);
const [localSchedules, setLocalSchedules] = useState([]);
const [durationError, setDurationError] = useState(false);
const [repeatActivated, setRepeatActivated] = useState(false);

useEffect(() => {
const newSchedules = schedules.map((schedule) =>
Expand Down Expand Up @@ -223,9 +222,9 @@ function Schedule({ schedules, onChange }) {
}

const toggleRepeat = (schedule) => {
if ((isRepeatingEvent(schedule) || repeatActivated)) {
if ((isRepeatingEvent(schedule) || schedule.repeatActivated)) {
// Disable repeating schedule.
setRepeatActivated(false);
changeSchedule(schedule.id, 'repeatActivated', false);
changeSchedule(schedule.id, 'duration', 60 * 60);
changeSchedule(schedule.id, 'freq', RRule.DAILY);
changeSchedule(schedule.id, 'count', 1);
Expand All @@ -238,7 +237,7 @@ function Schedule({ schedules, onChange }) {
changeSchedule(schedule.id, 'byweekno', null);
} else {
// Activate repeating schedule.
setRepeatActivated(true);
changeSchedule(schedule.id, 'repeatActivated', true);
changeSchedule(schedule.id, 'count', null);
}
}
Expand All @@ -254,6 +253,10 @@ function Schedule({ schedules, onChange }) {
{t("schedule.add-schedule-button-text")}
</Button>

<div>
<small>{t('schedule.helptext')}</small>
</div>

{localSchedules &&
localSchedules.map((schedule, index) => (
<div key={schedule.id} className="Schedule-item card mt-2 mb-2">
Expand Down Expand Up @@ -304,13 +307,13 @@ function Schedule({ schedules, onChange }) {
onChange={() => toggleRepeat(schedule)}
name="enableRepeat"
type="checkbox"
value={(isRepeatingEvent(schedule) || repeatActivated)}
value={(isRepeatingEvent(schedule) || schedule.repeatActivated)}
label={t('schedule.enable-repeat')}
formGroupClasses="d-inline-block mb-2"
/>
<Tooltip id={'tooltip-enable-repeat'} content={t('schedule.enable-repeat-tooltip')}></Tooltip>

{(isRepeatingEvent(schedule) || repeatActivated) && (
{(isRepeatingEvent(schedule) || schedule.repeatActivated) && (
<>
<div className="row mt-2">
<div className={`col col-md-${!isNaN(schedule.byhour) ? "3" : "6"}`}>
Expand Down Expand Up @@ -457,7 +460,7 @@ function Schedule({ schedules, onChange }) {
</>
)}
</div>
{(isRepeatingEvent(schedule) || repeatActivated) && (
{(isRepeatingEvent(schedule) || schedule.repeatActivated) && (
<div className="card-footer">
<div id="schedule_details" className="row">
<div className="mb-2">
Expand Down
3 changes: 2 additions & 1 deletion src/translations/da/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,8 @@
"tooltip-byweekday": "På hvilke dage skal reglen gælde?",
"tooltip-bymonth": "I hvilke månender skal reglen gælde?",
"tooltip-byweekno": "Hvilket ugenummer skal reglen gælde for?",
"until-tooltip": "Hvornår skal gentagelserne afsluttes? Dette tidspunkt påvirker starttidspunktet på en gentagelse, ikke sluttidspunktet."
"until-tooltip": "Hvornår skal gentagelserne afsluttes? Dette tidspunkt påvirker starttidspunktet på en gentagelse, ikke sluttidspunktet.",
"helptext": "Når minimum én planlægning er tilføjet, bliver spillelisten kun vist i planlægningsintervallet."
},
"duration": {
"hours": "t.",
Expand Down

0 comments on commit 4d38df7

Please sign in to comment.