Render a dropdown menu for external task providers

This commit is contained in:
Frederic Guillot 2017-10-12 14:01:39 -07:00
parent ad6f898134
commit 4bb422b41f
32 changed files with 109 additions and 3 deletions

View File

@ -55,4 +55,14 @@ class ExternalTaskManager
return array();
}
/**
* Get all providers
*
* @return ExternalTaskProviderInterface[]
*/
public function getProviders()
{
return $this->providers;
}
}

View File

@ -18,6 +18,22 @@ interface ExternalTaskProviderInterface
*/
public function getName();
/**
* Get provider icon
*
* @access public
* @return string
*/
public function getIcon();
/**
* Get label for adding a new task
*
* @access public
* @return string
*/
public function getMenuAddLabel();
/**
* Retrieve task from external system or cache
*

View File

@ -256,4 +256,58 @@ class TaskHelper extends Base
$html .= '</ul></div></small>';
return $html;
}
public function getNewBoardTaskButton(array $swimlane, array $column)
{
$html = '<div class="board-add-icon">';
$providers = $this->externalTaskManager->getProviders();
if (empty($providers)) {
$html .= $this->helper->modal->largeIcon(
'plus',
t('Add a new task'),
'TaskCreationController',
'show', array(
'project_id' => $column['project_id'],
'column_id' => $column['id'],
'swimlane_id' => $swimlane['id'],
)
);
} else {
$html .= '<div class="dropdown">';
$html .= '<a href="#" class="dropdown-menu"><i class="fa fa-plus" aria-hidden="true"></i></a><ul>';
$link = $this->helper->modal->large(
'plus',
t('Add a new Kanboard task'),
'TaskCreationController',
'show', array(
'project_id' => $column['project_id'],
'column_id' => $column['id'],
'swimlane_id' => $swimlane['id'],
)
);
$html .= '<li>'.$link.'</li>';
foreach ($providers as $provider) {
$link = $this->helper->url->link(
$provider->getMenuAddLabel(),
'ExternalTaskCreationController',
'step1',
array('project_id' => $column['project_id'], 'swimlane_id' => $swimlane['id'], 'column_id' => $column['id'], 'provider_name' => $provider->getName()),
false,
'js-modal-large'
);
$html .= '<li>'.$provider->getIcon().' '.$link.'</li>';
}
$html .= '</ul></div>';
}
$html .= '</div>';
return $html;
}
}

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
'Write one subject by line.' => 'Schreibe ein Betreff pro Zeile.',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
'Write one subject by line.' => 'Escriba un asunto por línea.',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
'Write one subject by line.' => 'Écrivez un sujet par ligne.',
'Create another link' => 'Créer un autre lien',
'BRL - Brazilian Real' => 'BRL - Real brésilien',
'Add a new Kanboard task' => 'Ajouter une nouvelle tâche Kanboard',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
'Write one subject by line.' => 'Escreva um assunto por linha.',
'Create another link' => 'Criar outro link',
'BRL - Brazilian Real' => 'BRL - Real Brasileiro',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
'Write one subject by line.' => 'Escreva um assunto por linha.',
'Create another link' => 'Criar outro link',
'BRL - Brazilian Real' => 'BRL - Real Brasileiro',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
'Write one subject by line.' => 'Записываются по одной теме на строку.',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
'Write one subject by line.' => 'Her satıra bir konu yazınız',
'Create another link' => 'Başka bağlantı oluştur',
'BRL - Brazilian Real' => 'BRL - Brezilya Reali',
// 'Add a new Kanboard task' => '',
);

View File

@ -1346,4 +1346,5 @@ return array(
'Write one subject by line.' => 'Viết một chủ đề theo dòng.',
'Create another link' => 'Tạo liên kết khác',
'BRL - Brazilian Real' => 'BRL - Brazilian Real',
// 'Add a new Kanboard task' => '',
);

View File

@ -1340,4 +1340,5 @@ return array(
// 'Write one subject by line.' => '',
// 'Create another link' => '',
// 'BRL - Brazilian Real' => '',
// 'Add a new Kanboard task' => '',
);

View File

@ -16,9 +16,7 @@
<!-- column in expanded mode -->
<div class="board-column-expanded">
<?php if (! $not_editable && $this->projectRole->canCreateTaskInColumn($column['project_id'], $column['id'])): ?>
<div class="board-add-icon">
<?= $this->modal->largeIcon('plus', t('Add a new task'), 'TaskCreationController', 'show', array('project_id' => $column['project_id'], 'column_id' => $column['id'], 'swimlane_id' => $swimlane['id'])) ?>
</div>
<?= $this->task->getNewBoardTaskButton($swimlane, $column) ?>
<?php endif ?>
<?php if ($swimlane['nb_swimlanes'] > 1 && ! empty($column['column_nb_tasks'])): ?>