Skip to content

Commit

Permalink
added import button
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpapst committed May 19, 2024
1 parent 3c2b9f3 commit 6dba118
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Compatibility: requires minimum Kimai 2.11.0

- Support importing seconds
- Fixed Clockify duration import rounding issue (see [#4838](https://github.com/kimai/kimai/issues/4838))
- Added quick links from Customer and Project listing

## Version 2.12.0

Expand Down
31 changes: 31 additions & 0 deletions EventSubscriber/Actions/CustomersSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/*
* This file is part of the "Import bundle" for Kimai.
* All rights reserved by Kevin Papst (www.kevinpapst.de).
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace KimaiPlugin\ImportBundle\EventSubscriber\Actions;

use App\Event\PageActionsEvent;
use App\EventSubscriber\Actions\AbstractActionsSubscriber;

class CustomersSubscriber extends AbstractActionsSubscriber
{
public static function getActionName(): string
{
return 'customers';
}

public function onActions(PageActionsEvent $event): void
{
if (!$this->isGranted('importer')) {
return;
}

$event->addQuickImport($this->path('importer_customer'));
}
}
31 changes: 31 additions & 0 deletions EventSubscriber/Actions/ProjectsSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/*
* This file is part of the "Import bundle" for Kimai.
* All rights reserved by Kevin Papst (www.kevinpapst.de).
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace KimaiPlugin\ImportBundle\EventSubscriber\Actions;

use App\Event\PageActionsEvent;
use App\EventSubscriber\Actions\AbstractActionsSubscriber;

class ProjectsSubscriber extends AbstractActionsSubscriber
{
public static function getActionName(): string
{
return 'projects';
}

public function onActions(PageActionsEvent $event): void
{
if (!$this->isGranted('importer')) {
return;
}

$event->addQuickImport($this->path('importer_project'));
}
}
22 changes: 12 additions & 10 deletions EventSubscriber/MenuSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ public function onMenuConfigure(ConfigureMainMenuEvent $event): void
return;
}

if ($auth->isGranted('importer')) {
$system = $event->getSystemMenu();
$system->addChild(
new MenuItemModel('importer', 'Importer', 'importer', [], 'fas fa-file-import')
);
$system->addChildRoute('importer_timesheet');
$system->addChildRoute('importer_customer');
$system->addChildRoute('importer_project');
$system->addChildRoute('importer_grandtotal');
$system->addChildRoute('importer_clockify');
if (!$auth->isGranted('importer')) {
return;
}

$system = $event->getSystemMenu();
$system->addChild(
new MenuItemModel('importer', 'Importer', 'importer', [], 'fas fa-file-import')
);
$system->addChildRoute('importer_timesheet');
$system->addChildRoute('importer_customer');
$system->addChildRoute('importer_project');
$system->addChildRoute('importer_grandtotal');
$system->addChildRoute('importer_clockify');
}
}

0 comments on commit 6dba118

Please sign in to comment.