Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use hooks instead of overwriting #17

Merged
merged 2 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) ?>