Months shown setting and style colors
This commit is contained in:
parent
0727798af7
commit
2ea0d9363e
5 changed files with 55 additions and 46 deletions
23
app.js
23
app.js
|
|
@ -6,7 +6,7 @@ const state = {
|
|||
};
|
||||
|
||||
const settingKeys = [
|
||||
'planning_start_year', 'planning_start_month', 'planning_months',
|
||||
'previous_months', 'future_months',
|
||||
'vacation_days_per_month', 'feriefridage_per_year', 'feriefridage_expiry_month',
|
||||
'normal_day_hours', 'friday_hours', 'opening_vacation_days',
|
||||
'opening_feriefridage_days', 'opening_flex_hours'
|
||||
|
|
@ -55,8 +55,8 @@ async function loadState() {
|
|||
|
||||
function normalizeSettings(settings) {
|
||||
const normalized = { ...settings };
|
||||
normalized.planning_start_month = Number(normalized.planning_start_month || 1);
|
||||
normalized.planning_months = Number(normalized.planning_months || (Number(normalized.planning_years || 3) * 12));
|
||||
normalized.previous_months = Number(normalized.previous_months ?? 5);
|
||||
normalized.future_months = Number(normalized.future_months ?? 30);
|
||||
return normalized;
|
||||
}
|
||||
|
||||
|
|
@ -338,9 +338,13 @@ function renderMonthRow(month) {
|
|||
}
|
||||
|
||||
function calculatePlan(settings, entries, corrections = {}) {
|
||||
const startYear = Number(settings.planning_start_year || new Date().getFullYear());
|
||||
const startMonth = Number(settings.planning_start_month || 1);
|
||||
const monthCount = Number(settings.planning_months || (Number(settings.planning_years || 3) * 12));
|
||||
const today = dateFromParts(new Date().getFullYear(), new Date().getMonth() + 1, new Date().getDate());
|
||||
const previousMonths = Number(settings.previous_months ?? 5);
|
||||
const futureMonths = Number(settings.future_months ?? 30);
|
||||
const startCursor = dateFromParts(today.getFullYear(), today.getMonth() + 1 - previousMonths, 1);
|
||||
const startYear = startCursor.getFullYear();
|
||||
const startMonth = startCursor.getMonth() + 1;
|
||||
const monthCount = previousMonths + futureMonths + 1;
|
||||
const startDate = dateFromParts(startYear, startMonth, 1);
|
||||
const endDate = dateFromParts(startYear, startMonth + monthCount, 0);
|
||||
const months = [];
|
||||
|
|
@ -371,7 +375,6 @@ function calculatePlan(settings, entries, corrections = {}) {
|
|||
}
|
||||
|
||||
const avgDayHours = averageDayHours(settings);
|
||||
const today = dateFromParts(new Date().getFullYear(), new Date().getMonth() + 1, new Date().getDate());
|
||||
const currentFlexHours = Number(settings.current_flex_hours ?? flexBalance);
|
||||
|
||||
for (let i = 0; i < monthCount; i++) {
|
||||
|
|
@ -504,8 +507,10 @@ function calculatePlan(settings, entries, corrections = {}) {
|
|||
|
||||
function calculateCurrentSnapshot(settings, entries, corrections = {}) {
|
||||
const today = dateFromParts(new Date().getFullYear(), new Date().getMonth() + 1, new Date().getDate());
|
||||
const startYear = Number(settings.planning_start_year || today.getFullYear());
|
||||
const startMonth = Number(settings.planning_start_month || 1);
|
||||
const previousMonths = Number(settings.previous_months ?? 5);
|
||||
const startCursor = dateFromParts(today.getFullYear(), today.getMonth() + 1 - previousMonths, 1);
|
||||
const startYear = startCursor.getFullYear();
|
||||
const startMonth = startCursor.getMonth() + 1;
|
||||
const startDate = dateFromParts(startYear, startMonth, 1);
|
||||
const avgDayHours = averageDayHours(settings);
|
||||
const warnings = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue