Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #184 from lunatech-labs/TK-350_entry_RedDayWarning
Browse files Browse the repository at this point in the history
Tk 350 entry red day warning
  • Loading branch information
tkuy authored Jun 19, 2020
2 parents 2e523c4 + a5cce4c commit 7a786d4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions frontend/src/components/Card/CardWeekCalendar.less
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@
}
}
}

.tk_CardWeekCalendar_Body_With_Warn {
background-color: rgba(233, 73, 78, .2);
}

}


12 changes: 8 additions & 4 deletions frontend/src/components/TimeSheet/WeekCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const WeekCalendar = (props) => {
}
};

const today = (day) => {
const isToday = (day) => {
return moment().isSame(day, 'day');
};

Expand All @@ -159,15 +159,18 @@ const WeekCalendar = (props) => {
onMouseOver={() => setShowButton(index)}
onMouseLeave={() => setShowButton(-1)}>
<div className="tk_CardWeekCalendar_Head">
<p className={today(moment(item.date)) ? 'tk_CurrentDay' : ''}>{item.date.format(dateFormat)}</p>
<p className={isToday(moment(item.date)) ? 'tk_CurrentDay' : ''}>{item.date.format(dateFormat)}</p>
{((props.hiddenButtons && showButton === index) || (!props.hiddenButtons)) &&
<Button
shape="circle"
disabled={isDisabled(item)}
icon={<PlusOutlined/>}
onClick={(e) => props.onClickAddTask && props.onClickAddTask(e, item.date)}/>}
</div>
<div className="tk_CardWeekCalendar_Body" disabled={isDisabled(item)}>
<div className={props.warningCardPredicate && props.warningCardPredicate(item.date, item.day) ?
"tk_CardWeekCalendar_Body tk_CardWeekCalendar_Body_With_Warn":
"tk_CardWeekCalendar_Body"}
disabled={isDisabled(item)}>
{renderDay()}
</div>
</CardWeekCalendar>
Expand All @@ -194,7 +197,8 @@ WeekCalendar.propTypes = {
).isRequired,
hiddenButtons: PropTypes.bool,
onClickAddTask: PropTypes.func, // (event, moment) => void
onPanelChange: PropTypes.func // (id, start, end) => void
onPanelChange: PropTypes.func, // (id, start, end) => void
warningCardPredicate : PropTypes.func // (date, day) => bool
};

export default WeekCalendar;
7 changes: 7 additions & 0 deletions frontend/src/pages/TimeSheet/timeEntriesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ const TimeEntriesPage = () => {
const openModal = () => setVisibleEntryModal(true);
const closeModal = () => setVisibleEntryModal(false);
const resetForm = () => form.resetFields();

// A day without entries in the past should be displayed with "warn" design
const hasWarnNoEntryInPastDay =(date,day) => {
return moment().subtract("1","days").isAfter(date) && !day
};

return (
<MainPage title="Time entries">
<Modal
Expand Down Expand Up @@ -104,6 +110,7 @@ const TimeEntriesPage = () => {
);
}}
days={datas.days}
warningCardPredicate={(date, day) => hasWarnNoEntryInPastDay(date,day)}
/>
</MainPage>
);
Expand Down

0 comments on commit 7a786d4

Please sign in to comment.