Skip to content

Commit

Permalink
Merge pull request #65 from Jieiku/compact-layout
Browse files Browse the repository at this point in the history
Compact layout
  • Loading branch information
Jieiku authored Feb 1, 2022
2 parents 85b57f5 + fc6d053 commit 3fd7007
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 64 deletions.
24 changes: 24 additions & 0 deletions Helper/SizeAvatarHelperExtend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Kanboard\Plugin\Group_assign\Helper;

use Kanboard\Helper\AvatarHelper;
use Kanboard\Core\Base;
/**
* Avatar Helper
*
* @package helper
* @author Frederic Guillot
*/
class sizeAvatarHelperExtend extends AvatarHelper
{
public function sizeMultiple($owner_ms, $css = '', $size = 20) {
$assignees = $this->multiselectMemberModel->getMembers($owner_ms);
$html = "";
foreach ($assignees as $assignee) {
$user = $this->userModel->getById($assignee['user_id']);
$html .= $this->render($assignee['user_id'], $user['username'], $user['name'], $user['email'], $user['avatar_path'], $css, $size);
}
return $html;
}
}
35 changes: 0 additions & 35 deletions Helper/SmallAvatarHelperExtend.php

This file was deleted.

53 changes: 28 additions & 25 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,26 @@

class Plugin extends Base
{

public function initialize()
{
//Events & Changes
//Events & Changes
$this->template->setTemplateOverride('task/changes', 'group_assign:task/changes');

//Notifications
$this->container['userNotificationFilterModel'] = $this->container->factory(function ($c) {
return new NewUserNotificationFilterModel($c);
});

//Helpers
$this->helper->register('newTaskHelper', '\Kanboard\Plugin\Group_assign\Helper\NewTaskHelper');
$this->helper->register('smallAvatarHelperExtend', '\Kanboard\Plugin\Group_assign\Helper\SmallAvatarHelperExtend');
$this->helper->register('sizeAvatarHelperExtend', '\Kanboard\Plugin\Group_assign\Helper\SizeAvatarHelperExtend');


//Models and backward compatibility

$applications_version = str_replace('v', '', APP_VERSION);
if (strpos(APP_VERSION, 'master') !== false && file_exists('ChangeLog')) { $applications_version = trim(file_get_contents('ChangeLog', false, null, 8, 6), ' '); }
$clean_appversion = preg_replace('/\s+/', '', $applications_version);

if (version_compare($clean_appversion, '1.2.5', '>')) {
if (file_exists('plugins/MetaMagik')){
$this->container['taskFinderModel'] = $this->container->factory(function ($c) {
Expand Down Expand Up @@ -98,44 +96,49 @@ public function initialize()
return new TaskRecurrenceModel ($c);
});
}

//Task - Template - details.php
$this->template->hook->attach('template:task:details:third-column', 'group_assign:task/details');
$this->template->hook->attach('template:task:details:third-column', 'group_assign:task/multi');

//Forms - task_creation.php and task_modification.php
$this->template->setTemplateOverride('task_creation/show', 'group_assign:task_creation/show');
$this->template->setTemplateOverride('task_modification/show', 'group_assign:task_modification/show');

//Board
$this->template->hook->attach('template:board:private:task:before-title', 'group_assign:board/group');
$this->template->hook->attach('template:board:private:task:before-title', 'group_assign:board/multi');

if ($this->configModel->get('boardcustomizer_compactlayout', '') == 'enable') {
$this->template->hook->attach('template:board:private:task:before-avatar', 'group_assign:board/multi');
} else {
$this->template->hook->attach('template:board:private:task:before-title', 'group_assign:board/multi');
}
$groupmodel = $this->projectGroupRoleModel;
$this->template->hook->attachCallable('template:app:filters-helper:after', 'group_assign:board/filter', function($array = array()) use ($groupmodel) {
if(!empty($array) && $array['id'] >= 1){
return ['grouplist' => array_column($groupmodel->getGroups($array['id']), 'name')];
} else {
return ['grouplist' => array()];
}
});
});

//Filter
$this->container->extend('taskLexer', function($taskLexer, $c) {
$taskLexer->withFilter(TaskAllAssigneeFilter::getInstance()->setDatabase($c['db'])
->setCurrentUserId($c['userSession']->getId()));
return $taskLexer;
});

//Actions
$this->actionManager->register(new EmailGroup($this->container));
$this->actionManager->register(new EmailGroupDue($this->container));
$this->actionManager->register(new EmailOtherAssignees($this->container));
$this->actionManager->register(new EmailOtherAssigneesDue($this->container));
$this->actionManager->register(new AssignGroup($this->container));

//Params
$this->template->setTemplateOverride('action_creation/params', 'group_assign:action_creation/params');

//CSS
$this->hook->on('template:layout:css', array('template' => 'plugins/Group_assign/Assets/css/group_assign.css'));

Expand All @@ -144,30 +147,30 @@ public function initialize()

//Calendar Events
$container = $this->container;

$this->hook->on('controller:calendar:user:events', function($user_id, $start, $end) use ($container) {
$model = new GroupAssignCalendarModel($container);
return $model->getUserCalendarEvents($user_id, $start, $end); // Return new events
});

//Roles

$this->template->hook->attach('template:config:application', 'group_assign:config/toggle');
if ($this->configModel->get('enable_am_group_management', '2') == 1) {

if ($this->configModel->get('enable_am_group_management', '2') == 1) {
$this->applicationAccessMap->add('GroupListController', '*', Role::APP_MANAGER);
$this->applicationAccessMap->add('GroupCreationController', '*', Role::APP_MANAGER);
$this->template->setTemplateOverride('header/user_dropdown', 'group_assign:header/user_dropdown');
$this->template->setTemplateOverride('header/user_dropdown', 'group_assign:header/user_dropdown');
}


}

public function onStartup()
{
Translator::load($this->languageModel->getCurrentLanguage(), __DIR__.'/Locale');
}

public function getClasses()
{
return [
Expand All @@ -191,7 +194,7 @@ public function getPluginAuthor()
}
public function getPluginVersion()
{
return '1.7.11';
return '1.7.12';
}
public function getPluginHomepage()
{
Expand Down
23 changes: 20 additions & 3 deletions Template/board/multi.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
<?php if ($task['owner_ms'] > 0 && count($this->task->multiselectMemberModel->getMembers($task['owner_ms'])) > 0) : ?>
<strong class="assigned-other-label"><small><?= t('Other Assignees:') ?></small></strong>
<?= $this->helper->smallAvatarHelperExtend->miniMultiple($task['owner_ms'], 'avatar-inline') ?>
<br>

<?php if ($this->user->userMetadataModel->exists($this->user->getid(), "boardcustomizer_compactlayout")) {
/* compact card layout */
?>

<strong class="assigned-other-label"><small><?= t('Other Assignees:') ?></small></strong>
<?= $this->helper->sizeAvatarHelperExtend->sizeMultiple($task['owner_ms'], 'avatar-inline avatar-bdyn', $this->task->configModel->get('b_av_size','20')) ?>

<?php
} else {
?>

<strong class="assigned-other-label"><small><?= t('Other Assignees:') ?></small></strong>
<?= $this->helper->sizeAvatarHelperExtend->sizeMultiple($task['owner_ms'], 'avatar-inline avatar-bdyn', 13) ?>
<br>

<?php
}
?>

<?php endif ?>
2 changes: 1 addition & 1 deletion Template/task/multi.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<li>
<strong><?= t('Other Assignees:') ?></strong>
</li>
<?= $this->helper->smallAvatarHelperExtend->smallMultiple($task['owner_ms'], 'avatar-inline') ?>
<?= $this->helper->sizeAvatarHelperExtend->sizeMultiple($task['owner_ms'], 'avatar-inline', 20) ?>
<?php endif ?>

0 comments on commit 3fd7007

Please sign in to comment.