Skip to content

Commit

Permalink
feat(project task): Increase maximum planned duration
Browse files Browse the repository at this point in the history
  • Loading branch information
Rom1-B authored Jan 21, 2025
1 parent f18e27b commit 79e9950
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
15 changes: 13 additions & 2 deletions src/ProjectTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,19 @@ public function showForm($ID, array $options = [])
}

$duration_dropdown_to_add = [];
for ($i = 9; $i <= 100; $i++) {
$duration_dropdown_to_add[] = $i * HOUR_TIMESTAMP;
for ($i = 1; $i <= 10; $i++) {
$duration_dropdown_to_add[$i * MINUTE_TIMESTAMP] = sprintf('00h%02d', $i);
}
for ($i = 10; $i <= 10 * 60; $i += 5) {
$h = intdiv($i, 60);
$m = $i % 60;
$duration_dropdown_to_add[$i * MINUTE_TIMESTAMP] = sprintf('%02dh%02d', $h, $m);
}
for ($i = 10; $i <= 5 * 24; $i++) {
$duration_dropdown_to_add[$i * HOUR_TIMESTAMP] = sprintf('%02dh%02d', $i, 0);
}
for ($i = 5; $i <= 366; $i++) {
$duration_dropdown_to_add[$i * DAY_TIMESTAMP] = sprintf(_n('%s day', '%s days', $i), $i);
}

$this->initForm($ID, $options);
Expand Down
18 changes: 6 additions & 12 deletions templates/pages/tools/project_task.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -218,31 +218,25 @@
}
) }}

{{ fields.dropdownTimestampField(
{{ fields.dropdownArrayField(
'planned_duration',
item.fields.planned_duration,
duration_dropdown_to_add,
__('Planned duration'),
{
'min': 0,
'max': 8 * constant('HOUR_TIMESTAMP'),
'addfirstminutes': true,
'inhours': true,
'toadd': duration_dropdown_to_add,
'field_class': 'col-12 col-sm-6 is_milestone ' ~ (item.fields.is_milestone ? 'd-none' : ''),
'display_emptychoice': true,
},
) }}

{{ fields.dropdownTimestampField(
{{ fields.dropdownArrayField(
'effective_duration',
item.fields.effective_duration,
duration_dropdown_to_add,
__('Effective duration'),
{
'min': 0,
'max': 8 * constant('HOUR_TIMESTAMP'),
'addfirstminutes': true,
'inhours': true,
'toadd': duration_dropdown_to_add,
'field_class': 'col-12 col-sm-6 is_milestone ' ~ (item.fields.is_milestone ? 'd-none' : ''),
'display_emptychoice': true,
},
) }}

Expand Down

0 comments on commit 79e9950

Please sign in to comment.