Duplicate project metadata when duplicating project (#2074)
This commit is contained in:
committed by
Frédéric Guillot
parent
754b2bf1f0
commit
58ccf9f692
@@ -21,7 +21,7 @@ class ProjectDuplication extends Base
|
|||||||
*/
|
*/
|
||||||
public function getOptionalSelection()
|
public function getOptionalSelection()
|
||||||
{
|
{
|
||||||
return array('category', 'projectPermission', 'action', 'swimlane', 'task');
|
return array('category', 'projectPermission', 'action', 'swimlane', 'task', 'projectMetadata');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +32,7 @@ class ProjectDuplication extends Base
|
|||||||
*/
|
*/
|
||||||
public function getPossibleSelection()
|
public function getPossibleSelection()
|
||||||
{
|
{
|
||||||
return array('board', 'category', 'projectPermission', 'action', 'swimlane', 'task');
|
return array('board', 'category', 'projectPermission', 'action', 'swimlane', 'task', 'projectMetadata');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,4 +27,23 @@ class ProjectMetadata extends Metadata
|
|||||||
{
|
{
|
||||||
return 'project_id';
|
return 'project_id';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to duplicate all metadata to another project
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $src_project_id
|
||||||
|
* @param integer $dst_project_id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function duplicate($src_project_id, $dst_project_id)
|
||||||
|
{
|
||||||
|
$metadata = $this->getAll($src_project_id);
|
||||||
|
|
||||||
|
if (! $this->save($dst_project_id, $metadata)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
<?= $this->form->checkbox('action', t('Actions'), 1, true) ?>
|
<?= $this->form->checkbox('action', t('Actions'), 1, true) ?>
|
||||||
<?= $this->form->checkbox('swimlane', t('Swimlanes'), 1, false) ?>
|
<?= $this->form->checkbox('swimlane', t('Swimlanes'), 1, false) ?>
|
||||||
<?= $this->form->checkbox('task', t('Tasks'), 1, false) ?>
|
<?= $this->form->checkbox('task', t('Tasks'), 1, false) ?>
|
||||||
|
<?= $this->form->checkbox('projectMetadata', t('Metadata'), 1, false) ?>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-red"><?= t('Duplicate') ?></button>
|
<button type="submit" class="btn btn-red"><?= t('Duplicate') ?></button>
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ class ProjectDuplicationTest extends Base
|
|||||||
public function testGetSelections()
|
public function testGetSelections()
|
||||||
{
|
{
|
||||||
$projectDuplicationModel = new ProjectDuplication($this->container);
|
$projectDuplicationModel = new ProjectDuplication($this->container);
|
||||||
$this->assertCount(5, $projectDuplicationModel->getOptionalSelection());
|
$this->assertCount(6, $projectDuplicationModel->getOptionalSelection());
|
||||||
$this->assertCount(6, $projectDuplicationModel->getPossibleSelection());
|
$this->assertCount(7, $projectDuplicationModel->getPossibleSelection());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetClonedProjectName()
|
public function testGetClonedProjectName()
|
||||||
|
|||||||
Reference in New Issue
Block a user