feat: add functionality to import tasks from a project
This commit is contained in:
parent
d90987a09c
commit
ac94004ea9
|
|
@ -164,4 +164,62 @@ class ProjectViewController extends BaseController
|
|||
|
||||
$this->response->redirect($this->helper->url->to('ProjectViewController', 'show', array('project_id' => $project_id)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Import another project's tasks into the currently opened project.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Kanboard\Core\Controller\AccessForbiddenException
|
||||
* @throws \Kanboard\Core\Controller\PageNotFoundException
|
||||
*/
|
||||
public function importTasks()
|
||||
{
|
||||
$project = $this->getProject();
|
||||
|
||||
// Fetch list of projects to copy tasks from.
|
||||
// Remove current project from the list of the user's projects.
|
||||
$otherProjects = array_filter(
|
||||
$this->projectUserRoleModel->getActiveProjectsByUser($this->getUser()['id']),
|
||||
static function ($projectId) use ($project) {
|
||||
return (int) $project['id'] !== $projectId;
|
||||
},
|
||||
ARRAY_FILTER_USE_KEY
|
||||
);
|
||||
|
||||
$this->response->html($this->helper->layout->project('project_view/importTasks', array(
|
||||
'project' => $project,
|
||||
'title' => t('Import Tasks'),
|
||||
'projects' => $otherProjects,
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a form submission to copy tasks of a project.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Kanboard\Core\Controller\AccessForbiddenException
|
||||
* @throws \Kanboard\Core\Controller\PageNotFoundException
|
||||
*/
|
||||
public function doTasksImport()
|
||||
{
|
||||
$this->checkCSRFForm();
|
||||
|
||||
$project = $this->getProject();
|
||||
$srcProjectId = $this->request->getRawFormValues()['projects'] ?? null;
|
||||
|
||||
if (empty($srcProjectId)) {
|
||||
$this->response->redirect($this->helper->url->to('ProjectViewController', 'importTasks', array('project_id' => $project['id'])));
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->projectTaskDuplicationModel->duplicate($srcProjectId, $project['id'])) {
|
||||
$this->flash->success(t('Tasks copied successfully.'));
|
||||
} else {
|
||||
$this->flash->failure(t('Unable to copy tasks.'));
|
||||
$this->response->redirect($this->helper->url->to('ProjectViewController', 'importTasks', array('project_id' => $project['id'])));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->response->redirect($this->helper->url->to('ProjectViewController', 'show', array('project_id' => $project['id'])));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,10 +177,13 @@ return array(
|
|||
'Task modification' => 'Aufgabe ändern',
|
||||
'Task creation' => 'Aufgabe erstellen',
|
||||
'Closing a task' => 'Aufgabe abschließen',
|
||||
'Tasks copied successfully.' => 'Die Aufgaben wurden erfolgreich kopiert.',
|
||||
'Unable to copy tasks.' => 'Die Aufgaben konnten nicht kopiert werden.',
|
||||
'Assign a color to a specific user' => 'Einem Benutzer eine Farbe zuordnen',
|
||||
'Position' => 'Position',
|
||||
'Duplicate to project' => 'In ein anderes Projekt duplizieren',
|
||||
'Duplicate' => 'Duplizieren',
|
||||
'Copy' => 'Kopieren',
|
||||
'Link' => 'Link',
|
||||
'Comment updated successfully.' => 'Kommentar erfolgreich aktualisiert.',
|
||||
'Unable to update your comment.' => 'Aktualisierung des Kommentars nicht möglich.',
|
||||
|
|
@ -1428,4 +1431,7 @@ return array(
|
|||
'You must select a file to upload as your avatar!' => 'Sie müssen eine Datei auswählen, die als Avatar hochgeladen werden soll!',
|
||||
'The file you uploaded is not a valid image! (Only *.gif, *.jpg, *.jpeg and *.png are allowed!)' => 'Die hochgeladene Datei ist kein gültiges Bild! (Nur *.gif, *.jpg, *.jpeg and *.png sind erlaubt!)',
|
||||
'Automatically set the due date when the task is moved away from a specific column' => 'Automatisches Setzen des Fälligkeitsdatums, wenn die Aufgabe aus einer bestimmten Spalte heraus verschoben wird',
|
||||
'No other projects found.' => 'Keine weiteren Projekte vorhanden.',
|
||||
'Please choose a project you want to copy the tasks from.'=> 'Bitte wählen Sie ein Projekt aus, dessen Tickets Sie kopieren möchten!',
|
||||
'Import Tasks' => 'Aufgaben importieren',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -177,10 +177,13 @@ return array(
|
|||
'Task modification' => 'Aufgabe ändern',
|
||||
'Task creation' => 'Aufgabe erstellen',
|
||||
'Closing a task' => 'Aufgabe abschließen',
|
||||
'Tasks copied successfully.' => 'Die Aufgaben wurden erfolgreich kopiert.',
|
||||
'Unable to copy tasks.' => 'Die Aufgaben konnten nicht kopiert werden.',
|
||||
'Assign a color to a specific user' => 'Einem Benutzer eine Farbe zuordnen',
|
||||
'Position' => 'Position',
|
||||
'Duplicate to project' => 'In ein anderes Projekt duplizieren',
|
||||
'Duplicate' => 'Duplizieren',
|
||||
'Copy' => 'Kopieren',
|
||||
'Link' => 'Link',
|
||||
'Comment updated successfully.' => 'Kommentar erfolgreich aktualisiert.',
|
||||
'Unable to update your comment.' => 'Aktualisierung des Kommentars nicht möglich.',
|
||||
|
|
@ -1428,4 +1431,7 @@ return array(
|
|||
'You must select a file to upload as your avatar!' => 'Du musst eine Datei auswählen, die als Avatar hochgeladen werden soll!',
|
||||
'The file you uploaded is not a valid image! (Only *.gif, *.jpg, *.jpeg and *.png are allowed!)' => 'Die hochgeladene Datei ist kein gültiges Bild! (Nur *.gif, *.jpg, *.jpeg and *.png sind erlaubt!)',
|
||||
'Automatically set the due date when the task is moved away from a specific column' => 'Automatisches Setzen des Fälligkeitsdatums, wenn die Aufgabe aus einer bestimmten Spalte heraus verschoben wird',
|
||||
'No other projects found.' => 'Keine weiteren Projekte vorhanden.',
|
||||
'Please choose a project you want to copy the tasks from.'=> 'Bitte wähle ein Projekt aus, dessen Tickets du kopieren möchten!',
|
||||
'Import Tasks' => 'Aufgaben importieren',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@
|
|||
</li>
|
||||
<li <?= $this->app->checkMenuSelection('ProjectViewController', 'duplicate') ?>>
|
||||
<?= $this->url->link(t('Duplicate'), 'ProjectViewController', 'duplicate', array('project_id' => $project['id'])) ?>
|
||||
</li>
|
||||
<li <?= $this->app->checkMenuSelection('ProjectViewController', 'importTasks') ?>>
|
||||
<?= $this->url->link(t('Import Tasks'), 'ProjectViewController', 'importTasks', array('project_id' => $project['id'])) ?>
|
||||
</li>
|
||||
<?php if ($project['is_active']): ?>
|
||||
<li>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
<div class="page-header">
|
||||
<h2><?= t('Import Tasks') ?></h2>
|
||||
</div>
|
||||
<p><?= t('Please choose a project you want to copy the tasks from.') ?></p>
|
||||
<?php if (count($projects) > 0) { ?>
|
||||
<form method="post" action="<?= $this->url->href('ProjectViewController', 'doTasksImport', ['project_id' => $project['id']]) ?>">
|
||||
<?= $this->form->csrf() ?>
|
||||
<select name="projects" id="projects">
|
||||
<option value="" disabled selected><?= t('Choose a project') ?></option>
|
||||
<?php foreach ($projects as $projectId => $projectName) { ?>
|
||||
<option value="<?= $projectId?>"><?= $projectName ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-red"><?= t('Copy') ?></button>
|
||||
<?= t('or') ?> <?= $this->url->link(t('cancel'), 'ProjectViewController', 'show', array('project_id' => $project['id'])) ?>
|
||||
</div>
|
||||
</form>
|
||||
<?php } else { ?>
|
||||
<p class="no-projects"><?= t('No other projects found.') ?></p>
|
||||
<?php } ?>
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -88,3 +88,8 @@
|
|||
.project-header .filter-box-component form {
|
||||
margin: 0
|
||||
}
|
||||
|
||||
.no-projects {
|
||||
margin: 1rem 0 0;
|
||||
font-style: italic;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue