Skip to content

Commit

Permalink
Add the possibility to make tags global from project settings
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoStahl authored Feb 11, 2020
1 parent f394547 commit 2c98be3
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 5 deletions.
26 changes: 26 additions & 0 deletions app/Controller/ProjectTagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,30 @@ public function remove()

$this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id'])));
}

public function confirmMakeGlobalTag()
{
$project = $this->getProject();
$tag = $this->getProjectTag($project);

$this->response->html($this->template->render('project_tag/make_global', array(
'tag' => $tag,
'project' => $project,
)));
}

public function makeGlobalTag(){
if ($this->userSession->isAdmin()) {
$project = $this->getProject();
$tag = $this->getProjectTag($project);

if ($this->tagModel->update($tag['id'], $tag['name'], $tag['color_id'], 0)) {
$this->flash->success(t('Tag updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this tag.'));
}

$this->response->redirect($this->helper->url->to('ProjectTagController', 'index', array('project_id' => $project['id'])));
}
}
}
2 changes: 2 additions & 0 deletions app/Locale/de_DE/translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -1411,4 +1411,6 @@
'Task limits apply to each swimlane individually' => 'Aufgabenlimit gilt pro Swimlane',
'Task limits are applied to each swimlane individually' => 'Aufgabenlimit gilt pro Swimlane',
'Task limits are applied across swimlanes' => 'Aufgabenlimit gilt Swimlane übergreifend',
'Change to global tag' => 'Zu globalem Schlagwort machen',
'Do you really want to make the tag "%s" global?' => 'Das Schlagwort "%s" wirklich global machen?',
);
2 changes: 2 additions & 0 deletions app/Locale/fr_FR/translations.php
Original file line number Diff line number Diff line change
Expand Up @@ -1411,4 +1411,6 @@
'Task limits apply to each swimlane individually' => 'Les limites de tâches s\'appliquent à chaque swimlane individuellement',
'Task limits are applied to each swimlane individually' => 'Les limites de tâches sont appliquées à chaque swimlane individuellement',
'Task limits are applied across swimlanes' => 'Les limites de tâches sont appliquées entre les swimlanes',
// 'Change to global tag' => '',
// 'Do you really want to make the tag "%s" global?' => '',
);
18 changes: 13 additions & 5 deletions app/Model/TagModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,20 @@ public function create($project_id, $tag, $color_id = null)
* @param string $tag
* @return bool
*/
public function update($tag_id, $tag, $color_id = null)
public function update($tag_id, $tag, $color_id = null, $project_id = null)
{
return $this->db->table(self::TABLE)->eq('id', $tag_id)->update(array(
'name' => $tag,
'color_id' => $color_id,
));
if($project_id !== null){
return $this->db->table(self::TABLE)->eq('id', $tag_id)->update(array(
'name' => $tag,
'color_id' => $color_id,
'project_id' => $project_id
));
} else {
return $this->db->table(self::TABLE)->eq('id', $tag_id)->update(array(
'name' => $tag,
'color_id' => $color_id
));
}
}

/**
Expand Down
5 changes: 5 additions & 0 deletions app/Template/project_tag/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<li>
<?= $this->modal->medium('edit', t('Edit'), 'ProjectTagController', 'edit', array('tag_id' => $tag['id'], 'project_id' => $project['id'])) ?>
</li>
<?php if ($this->user->isAdmin()): ?>
<li>
<?= $this->modal->confirm('globe', t('Change to global tag'), 'ProjectTagController', 'confirmMakeGlobalTag', array('tag_id' => $tag['id'], 'project_id' => $project['id'])) ?>
</li>
<?php endif ?>
<li>
<?= $this->modal->confirm('trash-o', t('Remove'), 'ProjectTagController', 'confirm', array('tag_id' => $tag['id'], 'project_id' => $project['id'])) ?>
</li>
Expand Down
15 changes: 15 additions & 0 deletions app/Template/project_tag/make_global.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="page-header">
<h2><?= t('Change to global tag') ?></h2>
</div>

<div class="confirm">
<p class="alert alert-info">
<?= t('Do you really want to make the tag "%s" global?', $tag['name']) ?>
</p>

<?= $this->modal->confirmButtons(
'ProjectTagController',
'makeGlobalTag',
array('tag_id' => $tag['id'], 'project_id' => $project['id'])
) ?>
</div>

0 comments on commit 2c98be3

Please sign in to comment.