allow to configure the amount of recent activity rows in an empty week (#3026)
This commit is contained in:
@@ -352,6 +352,11 @@ class SystemConfiguration implements SystemBundleConfiguration
|
||||
return $this->getIncrement('timesheet.time_increment', $this->getTimesheetDefaultRoundingEnd(), 0);
|
||||
}
|
||||
|
||||
public function getQuickEntriesRecentAmount(): int
|
||||
{
|
||||
return $this->getIncrement('quick_entry.recent_activities', 5, 0) ?? 5;
|
||||
}
|
||||
|
||||
// ========== Company configurations ==========
|
||||
|
||||
public function getFinancialYearStart(): ?string
|
||||
|
||||
@@ -106,7 +106,8 @@ class QuickEntryController extends AbstractController
|
||||
ksort($rows);
|
||||
|
||||
// attach recent activities
|
||||
$timesheets = $this->repository->getRecentActivities($this->getUser(), null, 5);
|
||||
$amount = $this->configuration->getQuickEntriesRecentAmount();
|
||||
$timesheets = $this->repository->getRecentActivities($this->getUser(), null, $amount);
|
||||
foreach ($timesheets as $timesheet) {
|
||||
$id = $timesheet->getProject()->getId() . '_' . $timesheet->getActivity()->getId();
|
||||
if (\array_key_exists($id, $rows)) {
|
||||
|
||||
@@ -266,8 +266,7 @@ final class SystemConfigurationController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
$authentication = (new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_AUTHENTICATION)
|
||||
$authentication = (new SystemConfigurationModel('authentication'))
|
||||
->setConfiguration([
|
||||
(new Configuration())
|
||||
->setName('user.login')
|
||||
@@ -319,9 +318,8 @@ final class SystemConfigurationController extends AbstractController
|
||||
$authentication->getConfigurationByName('user.password_reset_token_ttl')->setEnabled(false);
|
||||
}
|
||||
|
||||
$configurationModels = [
|
||||
(new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_TIMESHEET)
|
||||
return [
|
||||
(new SystemConfigurationModel('timesheet'))
|
||||
->setConfiguration([
|
||||
(new Configuration())
|
||||
->setName('timesheet.mode')
|
||||
@@ -387,8 +385,20 @@ final class SystemConfigurationController extends AbstractController
|
||||
->setType(YesNoType::class)
|
||||
->setOptions(['help' => 'default_value_new', 'label' => 'label.billable']),
|
||||
]),
|
||||
(new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_LOCKDOWN)
|
||||
(new SystemConfigurationModel('quick_entry'))
|
||||
->setTranslation('quick_entry.title')
|
||||
->setTranslationDomain('messages')
|
||||
->setConfiguration([
|
||||
(new Configuration())
|
||||
->setName('quick_entry.recent_activities')
|
||||
->setType(IntegerType::class)
|
||||
->setTranslationDomain('system-configuration')
|
||||
->setRequired(false)
|
||||
->setConstraints([
|
||||
new Range(['min' => 0, 'max' => 20]),
|
||||
]),
|
||||
]),
|
||||
(new SystemConfigurationModel('lockdown_period'))
|
||||
->setConfiguration([
|
||||
(new Configuration())
|
||||
->setName('timesheet.rules.lockdown_period_start')
|
||||
@@ -417,8 +427,7 @@ final class SystemConfigurationController extends AbstractController
|
||||
->setConstraints([new DateTimeFormat()])
|
||||
->setTranslationDomain('system-configuration'),
|
||||
]),
|
||||
(new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_ROUNDING)
|
||||
(new SystemConfigurationModel('rounding'))
|
||||
->setConfiguration([
|
||||
(new Configuration())
|
||||
->setName('timesheet.rounding.default.mode')
|
||||
@@ -450,8 +459,9 @@ final class SystemConfigurationController extends AbstractController
|
||||
->setType(WeekDaysType::class)
|
||||
->setTranslationDomain('system-configuration'),
|
||||
]),
|
||||
(new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_FORM_INVOICE)
|
||||
(new SystemConfigurationModel('invoice'))
|
||||
->setTranslation('invoices')
|
||||
->setTranslationDomain('messages')
|
||||
->setConfiguration([
|
||||
// TODO that should be a custom type with validation
|
||||
(new Configuration())
|
||||
@@ -468,8 +478,7 @@ final class SystemConfigurationController extends AbstractController
|
||||
->setTranslationDomain('system-configuration'),
|
||||
]),
|
||||
$authentication,
|
||||
(new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_FORM_CUSTOMER)
|
||||
(new SystemConfigurationModel('customer'))
|
||||
->setConfiguration([
|
||||
(new Configuration())
|
||||
->setName('defaults.customer.timezone')
|
||||
@@ -488,8 +497,7 @@ final class SystemConfigurationController extends AbstractController
|
||||
->setType(CurrencyType::class)
|
||||
->setOptions(['help' => 'default_value_new']),
|
||||
]),
|
||||
(new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_FORM_USER)
|
||||
(new SystemConfigurationModel('user'))
|
||||
->setConfiguration([
|
||||
(new Configuration())
|
||||
->setName('defaults.user.timezone')
|
||||
@@ -518,8 +526,7 @@ final class SystemConfigurationController extends AbstractController
|
||||
->setType(CheckboxType::class)
|
||||
->setTranslationDomain('system-configuration'),
|
||||
]),
|
||||
(new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_THEME)
|
||||
(new SystemConfigurationModel('theme'))
|
||||
->setConfiguration([
|
||||
(new Configuration())
|
||||
->setName('theme.autocomplete_chars')
|
||||
@@ -557,8 +564,9 @@ final class SystemConfigurationController extends AbstractController
|
||||
->setType(CheckboxType::class)
|
||||
->setTranslationDomain('system-configuration'),
|
||||
]),
|
||||
(new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_CALENDAR)
|
||||
(new SystemConfigurationModel('calendar'))
|
||||
->setTranslation('calendar')
|
||||
->setTranslationDomain('messages')
|
||||
->setConfiguration([
|
||||
(new Configuration())
|
||||
->setName('calendar.week_numbers')
|
||||
@@ -599,8 +607,7 @@ final class SystemConfigurationController extends AbstractController
|
||||
->setType(IntegerType::class)
|
||||
->setConstraints([new Range(['min' => 0, 'max' => 20]), new NotNull()]),
|
||||
]),
|
||||
(new SystemConfigurationModel())
|
||||
->setSection(SystemConfigurationModel::SECTION_BRANDING)
|
||||
(new SystemConfigurationModel('branding'))
|
||||
->setConfiguration([
|
||||
(new Configuration())
|
||||
->setName('theme.branding.logo')
|
||||
@@ -632,7 +639,5 @@ final class SystemConfigurationController extends AbstractController
|
||||
->setOptions(['input' => 'string']),
|
||||
]),
|
||||
];
|
||||
|
||||
return $configurationModels;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class Configuration implements ConfigurationInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('kimai');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -69,13 +69,32 @@ class Configuration implements ConfigurationInterface
|
||||
->append($this->getPermissionsNode())
|
||||
->append($this->getLdapNode())
|
||||
->append($this->getSamlNode())
|
||||
->append($this->getQuickEntryNode())
|
||||
->end()
|
||||
->end();
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
|
||||
protected function getTimesheetNode()
|
||||
private function getQuickEntryNode()
|
||||
{
|
||||
$builder = new TreeBuilder('quick_entry');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
$node = $builder->getRootNode();
|
||||
|
||||
$node
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->integerNode('recent_activities')
|
||||
->defaultValue(5)
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
private function getTimesheetNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('timesheet');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -259,7 +278,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getInvoiceNode()
|
||||
private function getInvoiceNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('invoice');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -292,7 +311,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getExportNode()
|
||||
private function getExportNode()
|
||||
{
|
||||
$builder = new TreeBuilder('export');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -319,7 +338,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getLanguagesNode()
|
||||
private function getLanguagesNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('languages');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -349,7 +368,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getCalendarNode()
|
||||
private function getCalendarNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('calendar');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -416,7 +435,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getThemeNode()
|
||||
private function getThemeNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('theme');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -506,7 +525,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getIndustryNode()
|
||||
private function getIndustryNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('industry');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -522,7 +541,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getCompanyNode()
|
||||
private function getCompanyNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('company');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -538,7 +557,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getUserNode()
|
||||
private function getUserNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('user');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -568,7 +587,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getWidgetsNode()
|
||||
private function getWidgetsNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('widgets');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -595,7 +614,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getDashboardNode()
|
||||
private function getDashboardNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('dashboard');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -624,7 +643,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getDefaultsNode()
|
||||
private function getDefaultsNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('defaults');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -662,7 +681,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getPermissionsNode()
|
||||
private function getPermissionsNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('permissions');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -712,7 +731,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getLdapNode()
|
||||
private function getLdapNode(): ArrayNodeDefinition
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('ldap');
|
||||
$node = $treeBuilder->getRootNode();
|
||||
@@ -835,7 +854,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
protected function getSamlNode()
|
||||
private function getSamlNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('saml');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
|
||||
@@ -65,12 +65,12 @@ final class MenuSubscriber implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
$menu->addItem(
|
||||
new MenuItemModel('calendar', 'calendar.title', 'calendar', [], $icons->icon('calendar'))
|
||||
new MenuItemModel('calendar', 'calendar', 'calendar', [], $icons->icon('calendar'))
|
||||
);
|
||||
}
|
||||
|
||||
if ($auth->isGranted('view_invoice')) {
|
||||
$invoice = new MenuItemModel('invoice', 'menu.invoice', 'invoice', [], $icons->icon('invoice'));
|
||||
$invoice = new MenuItemModel('invoice', 'invoices', 'invoice', [], $icons->icon('invoice'));
|
||||
$invoice->setChildRoutes(['admin_invoice_template', 'admin_invoice_template_edit', 'admin_invoice_template_create', 'admin_invoice_template_copy', 'admin_invoice_list', 'admin_invoice_document_upload']);
|
||||
$menu->addItem($invoice);
|
||||
}
|
||||
|
||||
@@ -9,33 +9,61 @@
|
||||
|
||||
namespace App\Form\Model;
|
||||
|
||||
class SystemConfiguration
|
||||
final class SystemConfiguration
|
||||
{
|
||||
/** @deprecated since 1.16.10 */
|
||||
public const SECTION_ROUNDING = 'rounding';
|
||||
/** @deprecated since 1.16.10 */
|
||||
public const SECTION_LOCKDOWN = 'lockdown_period';
|
||||
/** @deprecated since 1.16.10 */
|
||||
public const SECTION_TIMESHEET = 'timesheet';
|
||||
/** @deprecated since 1.16.10 */
|
||||
public const SECTION_FORM_INVOICE = 'invoice';
|
||||
/** @deprecated since 1.16.10 */
|
||||
public const SECTION_FORM_CUSTOMER = 'customer';
|
||||
/** @deprecated since 1.16.10 */
|
||||
public const SECTION_FORM_USER = 'user';
|
||||
/** @deprecated since 1.16.10 */
|
||||
public const SECTION_THEME = 'theme';
|
||||
/** @deprecated since 1.16.10 */
|
||||
public const SECTION_AUTHENTICATION = 'authentication';
|
||||
/** @deprecated since 1.16.10 */
|
||||
public const SECTION_CALENDAR = 'calendar';
|
||||
/** @deprecated since 1.16.10 */
|
||||
public const SECTION_BRANDING = 'branding';
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $section;
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $translation;
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $translationDomain = 'system-configuration';
|
||||
/**
|
||||
* @var Configuration[]
|
||||
*/
|
||||
private $configuration = [];
|
||||
|
||||
public function __construct(?string $section = null)
|
||||
{
|
||||
$this->section = $section;
|
||||
}
|
||||
|
||||
public function getSection(): ?string
|
||||
{
|
||||
return $this->section;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.16.10
|
||||
* @param string|null $section
|
||||
* @return $this
|
||||
*/
|
||||
public function setSection(?string $section): SystemConfiguration
|
||||
{
|
||||
$this->section = $section;
|
||||
@@ -43,6 +71,30 @@ class SystemConfiguration
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTranslation(string $translation): SystemConfiguration
|
||||
{
|
||||
$this->translation = $translation;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTranslation(): string
|
||||
{
|
||||
return $this->translation ?? $this->section;
|
||||
}
|
||||
|
||||
public function setTranslationDomain(string $domain): SystemConfiguration
|
||||
{
|
||||
$this->translationDomain = $domain;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTranslationDomain(): string
|
||||
{
|
||||
return $this->translationDomain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Configuration[]
|
||||
*/
|
||||
|
||||
@@ -28,11 +28,11 @@ class InitialViewType extends AbstractType
|
||||
private const ALLOWED_VIEWS = [
|
||||
'dashboard' => 'menu.homepage',
|
||||
'timesheet' => 'menu.timesheet',
|
||||
'calendar' => 'calendar.title',
|
||||
'calendar' => 'calendar',
|
||||
'quick_entry' => 'quick_entry.title',
|
||||
'my_profile' => 'profile.title',
|
||||
'admin_timesheet' => 'menu.admin_timesheet',
|
||||
'invoice' => 'menu.invoice',
|
||||
'invoice' => 'invoices',
|
||||
'admin_user' => 'users',
|
||||
'admin_customer' => 'customers',
|
||||
'admin_project' => 'projects',
|
||||
|
||||
Reference in New Issue
Block a user