Skip to content
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

110 support for minute viewmode #162

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ npm start

| Parameter Name | Type | Description |
| :------------- | :------ | :---------------------------------------------------------------------------------------------------------- |
| viewMode | enum | Specifies the time scale. Hour, Quarter Day, Half Day, Day, Week(ISO-8601, 1st day is Monday), Month, QuarterYear, Year. |
| viewMode | enum | Specifies the time scale. Minute, Hour, Quarter Day, Half Day, Day, Week(ISO-8601, 1st day is Monday), Month, QuarterYear, Year. |
| viewDate | date | Specifies display date and time for display. |
| preStepsCount | number | Specifies empty space before the fist task |
| locale | string | Specifies the month name language. Able formats: ISO 639-2, Java Locale. |
Expand Down
51 changes: 51 additions & 0 deletions src/components/calendar/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,54 @@ export const Calendar: React.FC<CalendarProps> = ({
return [topValues, bottomValues];
};

const getCalendarValuesForMinute = () => {
const topValues: ReactChild[] = [];
const bottomValues: ReactChild[] = [];
const topDefaultHeight = headerHeight * 0.5;
const dates = dateSetup.dates;

for (let i = 0; i < dates.length; i++) {
const date = dates[i];
const bottomValue = getCachedDateTimeFormat(locale, {
minute: "numeric",
}).format(date);

bottomValues.push(
<text
key={date.getTime()}
y={headerHeight * 0.8}
x={columnWidth * (i + +rtl)}
className={styles.calendarBottomText}
fontFamily={fontFamily}
>
{bottomValue}
</text>
);
if (i !== 0 && date.getHours() !== dates[i - 1].getHours()) {
const displayDate = dates[i - 1];
const topValue = `${getLocalDayOfWeek(
displayDate,
locale,
"long"
)}, ${displayDate.getDate()} ${getLocaleMonth(displayDate, locale)} (${displayDate.getHours()}:00)`;
const topPosition = (date.getMinutes() - 60) / 2;
topValues.push(
<TopPartOfCalendar
key={topValue + displayDate.getFullYear()}
value={topValue}
x1Line={columnWidth * i}
y1Line={0}
y2Line={topDefaultHeight}
xText={columnWidth * (i + topPosition)}
yText={topDefaultHeight * 0.9}
/>
);
}
}
return [topValues, bottomValues];
};


let topValues: ReactChild[] = [];
let bottomValues: ReactChild[] = [];
switch (dateSetup.viewMode) {
Expand All @@ -377,6 +425,9 @@ export const Calendar: React.FC<CalendarProps> = ({
case ViewMode.HalfDay:
[topValues, bottomValues] = getCalendarValuesForPartOfDay();
break;
case ViewMode.Minute:
[topValues, bottomValues] = getCalendarValuesForMinute();
break;
case ViewMode.Hour:
[topValues, bottomValues] = getCalendarValuesForHour();
}
Expand Down
9 changes: 9 additions & 0 deletions src/helpers/date-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ export const ganttDateRange = (
newEndDate = startOfDate(newEndDate, "day");
newEndDate = addToDate(newEndDate, 1, "day");
break;
case ViewMode.Minute:
newStartDate = startOfDate(newStartDate, "minute");
newStartDate = addToDate(newStartDate, -1 * preStepsCount, "minute");
newEndDate = startOfDate(newEndDate, "hour");
newEndDate = addToDate(newEndDate, 1, "hour");
break;
}
return [newStartDate, newEndDate];
};
Expand Down Expand Up @@ -174,6 +180,9 @@ export const seedDates = (
case ViewMode.Hour:
currentDate = addToDate(currentDate, 1, "hour");
break;
case ViewMode.Minute:
currentDate = addToDate(currentDate, 1, "minute");
break;
}
dates.push(currentDate);
}
Expand Down
1 change: 1 addition & 0 deletions src/types/public-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export enum ViewMode {
Minute = "Minute",
Hour = "Hour",
QuarterDay = "Quarter Day",
HalfDay = "Half Day",
Expand Down