Skip to content
Merged
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
6 changes: 5 additions & 1 deletion docs/docs/concepts/user_interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ For tables which reference other objects within the system, clicking on a row wi

## Calendar Views

Some [table views](#table-views) can be switched to a calendar view, which provides a visual representation of data based on date fields. The calendar view allows users to easily see and interact with data that is organized by date, such as scheduled tasks, events, or deadlines.
Some [table views](#table-views) associated with various order types can be switched to a calendar view, which provides a visual representation of data based on date fields. The calendar view allows users to easily see and interact with data that is organized by date, such as scheduled tasks, events, or deadlines.

To switch to the "calendar view" (for a table which supports it), click on the "calendar view" button located above and to the right of the table view:

Expand All @@ -218,6 +218,10 @@ This will display the data in a calendar format:

{{ image("concepts/ui_calendar_view.png", "Calendar View") }}

### Calendar Horizon

The calendar view provides a configurable "horizon" setting, which allows users to adjust the number of months displayed in the calendar view.

## Parametric Views

Some [table views](#table-views) can be switched to a parametric view, which provides a visual representation of data based on specific parameters or attributes. The parametric view allows users to easily see and interact with data that is organized by certain characteristics, such as categories, types, or other relevant attributes.
Expand Down
1 change: 1 addition & 0 deletions docs/docs/settings/global.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Configuration of basic server settings:
{{ globalsetting("DISPLAY_FULL_NAMES") }}
{{ globalsetting("DISPLAY_PROFILE_INFO") }}
{{ globalsetting("WEEK_STARTS_ON") }}
{{ globalsetting("CALENDAR_HORIZON_MONTHS") }}
{{ globalsetting("INVENTREE_UPLOAD_MAX_SIZE") }}
{{ globalsetting("INVENTREE_STRICT_URLS") }}

Expand Down
9 changes: 9 additions & 0 deletions src/backend/InvenTree/common/setting/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,15 @@ class SystemSetId:
('6', _('Saturday')),
],
},
'CALENDAR_HORIZON_MONTHS': {
'name': _('Calendar Horizon'),
'description': _(
'Number of months into the future to display in calendar views'
),
'default': 12,
'validator': [int, MinValueValidator(1)],
'units': _('months'),
},
'TEST_STATION_DATA': {
'name': _('Enable Test Station Data'),
'description': _('Enable test station data collection for test results'),
Expand Down
43 changes: 38 additions & 5 deletions src/frontend/src/components/calendar/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ export default function Calendar({
}: Readonly<InvenTreeCalendarProps>) {
const globalSettings = useGlobalSettingsState();

const horizonMonths = useMemo(
() =>
Number.parseInt(
globalSettings.getSetting('CALENDAR_HORIZON_MONTHS') ?? '12',
10
),
[globalSettings]
);

// When the horizon is a single month, fall back to the standard month grid.
const isScrollView = horizonMonths > 1;

const [monthSelectOpened, setMonthSelectOpened] = useState<boolean>(false);

const [filtersVisible, setFiltersVisible] = useState<boolean>(false);
Expand Down Expand Up @@ -114,18 +126,30 @@ export default function Calendar({
const datesSet = useCallback(
(dateInfo: DatesSetArg) => {
if (state.ref?.current) {
const api = state.ref.current.getApi();
// Show the starting month of the view (advance 15 days past any padding days)
const viewStart = new Date(dateInfo.start);
viewStart.setDate(viewStart.getDate() + 15);
const startMonthLabel = new Intl.DateTimeFormat(calendarLocale, {
month: 'long',
year: 'numeric'
}).format(viewStart);

// Update calendar state
state.setMonthName(api.view.title);
state.setMonthName(startMonthLabel);
state.setStartDate(dateInfo.start);
state.setEndDate(dateInfo.end);
}

// Pass the dates set to the parent component
calendarProps.datesSet?.(dateInfo);
},
[calendarProps.datesSet, state.ref, state.setMonthName]
[
calendarLocale,
calendarProps.datesSet,
state.ref,
state.setMonthName,
state.setStartDate,
state.setEndDate
]
);

const wrappedEventContent = useCallback(
Expand Down Expand Up @@ -264,7 +288,16 @@ export default function Calendar({
<FullCalendar
ref={state.ref}
plugins={[dayGridPlugin, interactionPlugin]}
initialView='dayGridMonth'
initialView={isScrollView ? 'scrollMultiMonth' : 'dayGridMonth'}
{...(isScrollView && {
views: {
scrollMultiMonth: {
type: 'dayGrid',
duration: { months: horizonMonths }
}
},
height: 'calc(100vh - 160px)'
})}
locales={allLocales}
locale={calendarLocale}
firstDay={Number.parseInt(
Expand Down
23 changes: 12 additions & 11 deletions src/frontend/src/hooks/UseCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ export default function useCalendar({

// Generate a set of API query filters
const queryFilters: Record<string, any> = useMemo(() => {
// Expand date range by one month, to ensure we capture all events

let params = {
...(queryParams || {})
};
Expand All @@ -91,9 +89,7 @@ export default function useCalendar({
min_date: startDate
? dayjs(startDate).subtract(1, 'month').format('YYYY-MM-DD')
: null,
max_date: endDate
? dayjs(endDate).add(1, 'month').format('YYYY-MM-DD')
: null,
max_date: endDate ? dayjs(endDate).format('YYYY-MM-DD') : null,
search: searchTerm
};

Expand All @@ -102,7 +98,7 @@ export default function useCalendar({

const query = useQuery({
enabled: !!startDate && !!endDate,
queryKey: ['calendar', name, endpoint, queryFilters, startDate, endDate],
queryKey: ['calendar', name, endpoint, queryFilters],
throwOnError: (error: any) => {
showApiErrorMessage({
error: error,
Expand All @@ -112,7 +108,6 @@ export default function useCalendar({
return true;
},
queryFn: async () => {
// Fetch data from the API
return api
.get(apiUrl(endpoint), {
params: queryFilters
Expand All @@ -123,14 +118,20 @@ export default function useCalendar({
}
});

// Navigate to the previous month
// Navigate to the previous month (move start date back by 1 month)
const prevMonth = useCallback(() => {
ref.current?.getApi().prev();
const api = ref.current?.getApi();
if (api) {
api.gotoDate(dayjs(api.getDate()).subtract(1, 'month').toDate());
}
}, [ref]);

// Navigate to the next month
// Navigate to the next month (move start date forward by 1 month)
const nextMonth = useCallback(() => {
ref.current?.getApi().next();
const api = ref.current?.getApi();
if (api) {
api.gotoDate(dayjs(api.getDate()).add(1, 'month').toDate());
}
}, [ref]);

// Navigate to the current month
Expand Down
19 changes: 16 additions & 3 deletions src/frontend/src/pages/Index/Settings/SystemSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
IconBox,
IconBuildingFactory2,
IconCurrencyDollar,
IconDeviceDesktop,
IconFileAnalytics,
IconFingerprint,
IconList,
Expand Down Expand Up @@ -54,9 +55,6 @@ export default function SystemSettings() {
'INVENTREE_SHOW_SUPERUSER_BANNER',
'INVENTREE_SHOW_ADMIN_BANNER',
'INVENTREE_RESTRICT_ABOUT',
'DISPLAY_FULL_NAMES',
'DISPLAY_PROFILE_INFO',
'WEEK_STARTS_ON',
'INVENTREE_UPLOAD_MAX_SIZE',
'INVENTREE_STRICT_URLS'
]}
Expand Down Expand Up @@ -128,6 +126,21 @@ export default function SystemSettings() {
/>
)
},
{
name: 'display',
label: t`Display`,
icon: <IconDeviceDesktop />,
content: (
<GlobalSettingList
keys={[
'DISPLAY_FULL_NAMES',
'DISPLAY_PROFILE_INFO',
'WEEK_STARTS_ON',
'CALENDAR_HORIZON_MONTHS'
]}
/>
)
},
{
name: 'notifications',
label: t`Notifications`,
Expand Down
5 changes: 5 additions & 0 deletions src/frontend/src/styles/overrides.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/* fullcalendar multimonth single-column (scroll-year) overrides */
.fc-multimonth-singlecol .fc-multimonth-title {
padding: 0.35em 0;
}

/* mantine-datatable overrides */
.mantine-datatable-pointer-cursor,
.mantine-datatable-context-menu-cursor {
Expand Down
4 changes: 3 additions & 1 deletion src/frontend/tests/pages/pui_build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,9 @@
// Issue the order
await page.getByRole('button', { name: 'Issue Order' }).click();
await page.getByRole('button', { name: 'Submit' }).click();
await page.getByText('Order issued').waitFor();

await page.getByText('Production').first().waitFor();
await page.getByRole('button', { name: 'Complete Order' }).waitFor();

// Navigate to the "required parts" tab - and auto-allocate stock
await loadTab(page, 'Required Parts');
Expand Down Expand Up @@ -755,7 +757,7 @@

await navigate(page, 'manufacturing/build-order/24/details');
await page.getByLabel('action-menu-build-order-').click();
await page.getByLabel('action-menu-build-order-actions-duplicate').click();

Check failure on line 760 in src/frontend/tests/pages/pui_build.spec.ts

View workflow job for this annotation

GitHub Actions / Tests [Firefox 1 / 2]

[firefox] › tests/pages/pui_build.spec.ts:755:1 › Build Order - Duplicate

2) [firefox] › tests/pages/pui_build.spec.ts:755:1 › Build Order - Duplicate ───────────────────── Error: locator.click: Test ended. Call log: - waiting for getByLabel('action-menu-build-order-actions-duplicate') 758 | await navigate(page, 'manufacturing/build-order/24/details'); 759 | await page.getByLabel('action-menu-build-order-').click(); > 760 | await page.getByLabel('action-menu-build-order-actions-duplicate').click(); | ^ 761 | 762 | // Ensure a new reference is suggested 763 | await expect( at /home/runner/work/InvenTree/InvenTree/src/frontend/tests/pages/pui_build.spec.ts:760:70

// Ensure a new reference is suggested
await expect(
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/tests/pages/pui_purchasing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ test('Purchase Orders - Calendar', async ({ browser }) => {
await page.getByRole('button', { name: 'Feb' }).waitFor();
await page.getByRole('button', { name: 'Dec' }).click();

await page.getByText('December').waitFor();
await page.getByText('December').first().waitFor();

// Put back into table view
await activateTableView(page);
Expand Down
1 change: 0 additions & 1 deletion src/frontend/tests/pages/pui_stock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,6 @@ test('Transfer Order - Allocate and Transfer', async ({ browser }) => {
// Issue the order
await page.getByRole('button', { name: 'Issue Order' }).click();
await page.getByRole('button', { name: 'Submit' }).click();
await page.getByText('Order issued').waitFor();
await page.getByText('Issued', { exact: true }).first().waitFor();

await loadTab(page, 'Line Items');
Expand Down
Loading
Loading