Skip to content

Commit

Permalink
Merge pull request #17 from alfredbuehler/patch-3
Browse files Browse the repository at this point in the history
Use hooks instead of overwriting
  • Loading branch information
jajm authored Feb 21, 2023
2 parents c7b6ac4 + 7923319 commit f8ca6c2
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 156 deletions.
3 changes: 2 additions & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class Plugin extends Base
public function initialize()
{
$this->template->hook->attach('template:user:integrations', 'StarredProjects:user/integrations');
$this->template->setTemplateOverride('dashboard/overview', 'StarredProjects:dashboard/overview');
$this->template->hook->attach('template:dashboard:show:after-filter-box','StarredProjects:dashboard/starred-projects');
$this->template->hook->attach('template:dashboard:project:before-title','StarredProjects:dashboard/projects');
$this->template->setTemplateOverride('header/board_selector', 'StarredProjects:header/board_selector');
$this->hook->on('template:layout:js', array('template' => 'plugins/StarredProjects/assets/js/starred-projects.js'));
$this->hook->on('template:layout:css', array('template' => 'plugins/StarredProjects/assets/css/starred-projects.css'));
Expand Down
142 changes: 0 additions & 142 deletions Template/dashboard/overview.php

This file was deleted.

7 changes: 7 additions & 0 deletions Template/dashboard/projects.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<span class="star-project" data-url="<?= $this->url->href('StarredProjectsController', 'starProject', array('plugin' => 'StarredProjects', 'project_id' => $project['id'])) ?>">
<?php if($this->app->starredProjectsModel->find($project['id'], $this->user->getId())): ?>
<?php else: ?>
<?php endif; ?>
</span>
36 changes: 36 additions & 0 deletions Template/dashboard/starred-projects.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php $starredProjects = $this->app->starredProjectsModel->findAllProjects($this->user->getId()); ?>
<?php if(!empty($starredProjects)): ?>
<div class="table-list">
<div class="table-list-header">
<div class="table-list-header-count"><?= t('Starred projects') ?></div>
<div class="table-list-header-menu">&nbsp;</div>
</div>
<?php foreach ($starredProjects as $project): ?>
<div class="table-list-row table-border-left">
<div>
<?php if ($this->user->hasProjectAccess('ProjectViewController', 'show', $project['id'])): ?>
<?= $this->render('project/dropdown', array('project' => $project)) ?>
<?php else: ?>
<strong><?= '#'.$project['id'] ?></strong>
<?php endif ?>

<span class="star-project" data-url="<?= $this->url->href('StarredProjectsController', 'starProject', array('plugin' => 'StarredProjects', 'project_id' => $project['id'])) ?>">
<?php if($this->app->starredProjectsModel->find($project['id'], $this->user->getId())): ?>
<?php else: ?>
<?php endif; ?>
</span>

<span class="table-list-title <?= $project['is_active'] == 0 ? 'status-closed' : '' ?>">
<?= $this->url->link($this->text->e($project['name']), 'BoardViewController', 'show', array('project_id' => $project['id'])) ?>
</span>

<?php if ($project['is_private']): ?>
<i class="fa fa-lock fa-fw" title="<?= t('Private project') ?>"></i>
<?php endif ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
14 changes: 1 addition & 13 deletions Template/header/board_selector.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,4 @@
}
}
?>

<?= $this->app->component('select-dropdown-autocomplete', array(
'name' => 'boardId',
'placeholder' => t('Display another project'),
'items' => $board_selector,
'redirect' => array(
'regex' => 'PROJECT_ID',
'url' => $this->url->to('BoardViewController', 'show', array('project_id' => 'PROJECT_ID')),
),
'onFocus' => array(
'board.selector.open',
)
)) ?>
<?= $this->render('kanboard:header/board_selector', array('board_selector' => $board_selector)) ?>

0 comments on commit f8ca6c2

Please # to comment.