Handle project tags duplication

This commit is contained in:
Frederic Guillot
2016-07-02 15:20:59 -04:00
parent 3fcc0cb918
commit 6d5577fa0b
7 changed files with 599 additions and 485 deletions

View File

@@ -22,7 +22,15 @@ class ProjectDuplicationModel extends Base
*/
public function getOptionalSelection()
{
return array('categoryModel', 'projectPermissionModel', 'actionModel', 'swimlaneModel', 'taskModel', 'projectMetadataModel');
return array(
'categoryModel',
'projectPermissionModel',
'actionModel',
'swimlaneModel',
'tagDuplicationModel',
'projectMetadataModel',
'taskModel',
);
}
/**
@@ -33,7 +41,16 @@ class ProjectDuplicationModel extends Base
*/
public function getPossibleSelection()
{
return array('boardModel', 'categoryModel', 'projectPermissionModel', 'actionModel', 'swimlaneModel', 'taskModel', 'projectMetadataModel');
return array(
'boardModel',
'categoryModel',
'projectPermissionModel',
'actionModel',
'swimlaneModel',
'tagDuplicationModel',
'projectMetadataModel',
'taskModel',
);
}
/**

View File

@@ -12,6 +12,26 @@ use Kanboard\Core\Base;
*/
class TagDuplicationModel extends Base
{
/**
* Duplicate project tags to another project
*
* @access public
* @param integer $src_project_id
* @param integer $dst_project_id
* @return bool
*/
public function duplicate($src_project_id, $dst_project_id)
{
$tags = $this->tagModel->getAllByProject($src_project_id);
$results = array();
foreach ($tags as $tag) {
$results[] = $this->tagModel->create($dst_project_id, $tag['name']);
}
return ! in_array(false, $results, true);
}
/**
* Link tags to the new tasks
*

View File

@@ -23,6 +23,7 @@
<?php endif ?>
<?= $this->form->checkbox('categoryModel', t('Categories'), 1, true) ?>
<?= $this->form->checkbox('tagDuplicationModel', t('Tags'), 1, true) ?>
<?= $this->form->checkbox('actionModel', t('Actions'), 1, true) ?>
<?= $this->form->checkbox('swimlaneModel', t('Swimlanes'), 1, true) ?>
<?= $this->form->checkbox('taskModel', t('Tasks'), 1, false) ?>

View File

@@ -15,10 +15,11 @@
<?php endif ?>
<?= $this->form->checkbox('categoryModel', t('Categories'), 1, true) ?>
<?= $this->form->checkbox('tagDuplicationModel', t('Tags'), 1, true) ?>
<?= $this->form->checkbox('actionModel', t('Actions'), 1, true) ?>
<?= $this->form->checkbox('swimlaneModel', t('Swimlanes'), 1, false) ?>
<?= $this->form->checkbox('taskModel', t('Tasks'), 1, false) ?>
<?= $this->form->checkbox('projectMetadataModel', t('Metadata'), 1, false) ?>
<?= $this->form->checkbox('taskModel', t('Tasks'), 1, false) ?>
<div class="form-actions">
<button type="submit" class="btn btn-red"><?= t('Duplicate') ?></button>