improved duration and minute selector (#2264)
* do not close modal if form is dirty * deprecated TimesheetConfiguration * inject timezone in form types * cleanup usage of UserDateTimeFactory * allow to configure increment steps for minutes * use 15 minutes step for datetimepicker in project edit form * use rounding rules for increments in minute select for begin and end * allow duration in multi user and admin timesheet forms * make dropdown values configurable
This commit is contained in:
@@ -23,10 +23,7 @@ class SystemConfiguration implements SystemBundleConfiguration
|
||||
return $repository->getConfiguration();
|
||||
}
|
||||
|
||||
public function getTimesheetDefaultBeginTime(): string
|
||||
{
|
||||
return (string) $this->find('timesheet.default_begin');
|
||||
}
|
||||
// ========== Calendar configurations ==========
|
||||
|
||||
public function getCalendarBusinessDays(): array
|
||||
{
|
||||
@@ -83,6 +80,8 @@ class SystemConfiguration implements SystemBundleConfiguration
|
||||
return (string) $this->find('calendar.slot_duration');
|
||||
}
|
||||
|
||||
// ========== Customer configurations ==========
|
||||
|
||||
public function getCustomerDefaultTimezone(): ?string
|
||||
{
|
||||
return $this->find('defaults.customer.timezone');
|
||||
@@ -98,6 +97,8 @@ class SystemConfiguration implements SystemBundleConfiguration
|
||||
return $this->find('defaults.customer.country');
|
||||
}
|
||||
|
||||
// ========== User configurations ==========
|
||||
|
||||
public function getUserDefaultTimezone(): ?string
|
||||
{
|
||||
return $this->find('defaults.user.timezone');
|
||||
@@ -117,4 +118,114 @@ class SystemConfiguration implements SystemBundleConfiguration
|
||||
{
|
||||
return $this->find('defaults.user.currency');
|
||||
}
|
||||
|
||||
// ========== Timesheet configurations ==========
|
||||
|
||||
public function getTimesheetDefaultBeginTime(): string
|
||||
{
|
||||
return (string) $this->find('timesheet.default_begin');
|
||||
}
|
||||
|
||||
public function isTimesheetAllowFutureTimes(): bool
|
||||
{
|
||||
return (bool) $this->find('timesheet.rules.allow_future_times');
|
||||
}
|
||||
|
||||
public function isTimesheetAllowOverlappingRecords(): bool
|
||||
{
|
||||
return (bool) $this->find('timesheet.rules.allow_overlapping_records');
|
||||
}
|
||||
|
||||
public function getTimesheetTrackingMode(): string
|
||||
{
|
||||
return (string) $this->find('timesheet.mode');
|
||||
}
|
||||
|
||||
public function isTimesheetMarkdownEnabled(): bool
|
||||
{
|
||||
return (bool) $this->find('timesheet.markdown_content');
|
||||
}
|
||||
|
||||
public function getTimesheetActiveEntriesHardLimit(): int
|
||||
{
|
||||
return (int) $this->find('timesheet.active_entries.hard_limit');
|
||||
}
|
||||
|
||||
public function getTimesheetActiveEntriesSoftLimit(): int
|
||||
{
|
||||
return (int) $this->find('timesheet.active_entries.soft_limit');
|
||||
}
|
||||
|
||||
public function getTimesheetDefaultRoundingDays(): string
|
||||
{
|
||||
return (string) $this->find('timesheet.rounding.default.days');
|
||||
}
|
||||
|
||||
public function getTimesheetDefaultRoundingMode(): string
|
||||
{
|
||||
return (string) $this->find('timesheet.rounding.default.mode');
|
||||
}
|
||||
|
||||
public function getTimesheetDefaultRoundingBegin(): int
|
||||
{
|
||||
return (int) $this->find('timesheet.rounding.default.begin');
|
||||
}
|
||||
|
||||
public function getTimesheetDefaultRoundingEnd(): int
|
||||
{
|
||||
return (int) $this->find('timesheet.rounding.default.end');
|
||||
}
|
||||
|
||||
public function getTimesheetDefaultRoundingDuration(): int
|
||||
{
|
||||
return (int) $this->find('timesheet.rounding.default.duration');
|
||||
}
|
||||
|
||||
public function getTimesheetLockdownPeriodStart(): string
|
||||
{
|
||||
return (string) $this->find('timesheet.rules.lockdown_period_start');
|
||||
}
|
||||
|
||||
public function getTimesheetLockdownPeriodEnd(): string
|
||||
{
|
||||
return (string) $this->find('timesheet.rules.lockdown_period_end');
|
||||
}
|
||||
|
||||
public function getTimesheetLockdownGracePeriod(): string
|
||||
{
|
||||
return (string) $this->find('timesheet.rules.lockdown_grace_period');
|
||||
}
|
||||
|
||||
public function isTimesheetLockdownActive(): bool
|
||||
{
|
||||
return !empty($this->find('timesheet.rules.lockdown_period_start')) && !empty($this->find('timesheet.rules.lockdown_period_end'));
|
||||
}
|
||||
|
||||
private function getIncrement(string $key, int $fallback, int $min = 1): ?int
|
||||
{
|
||||
$config = $this->find($key);
|
||||
|
||||
if ($config === null || trim($config) === '') {
|
||||
return $fallback;
|
||||
}
|
||||
|
||||
$config = (int) $config;
|
||||
|
||||
return $config < $min ? null : $config;
|
||||
}
|
||||
|
||||
public function getTimesheetIncrementDuration(): ?int
|
||||
{
|
||||
return $this->getIncrement('timesheet.duration_increment', $this->getTimesheetDefaultRoundingDuration(), 1);
|
||||
}
|
||||
|
||||
public function getTimesheetIncrementBegin(): ?int
|
||||
{
|
||||
return $this->getIncrement('timesheet.time_increment', $this->getTimesheetDefaultRoundingBegin(), 0);
|
||||
}
|
||||
|
||||
public function getTimesheetIncrementEnd(): ?int
|
||||
{
|
||||
return $this->getIncrement('timesheet.time_increment', $this->getTimesheetDefaultRoundingEnd(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user