Refactoring/rewrite of modal boxes handling
This commit is contained in:
73
app/Helper/ModalHelper.php
Normal file
73
app/Helper/ModalHelper.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Helper;
|
||||
|
||||
use Kanboard\Core\Base;
|
||||
|
||||
/**
|
||||
* Class ModalHelper
|
||||
*
|
||||
* @package Kanboard\Helper
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class ModalHelper extends Base
|
||||
{
|
||||
public function submitButtons(array $params = array())
|
||||
{
|
||||
return $this->helper->app->component('submit-buttons', array(
|
||||
'submitLabel' => isset($params['submitLabel']) ? $params['submitLabel'] : t('Save'),
|
||||
'orLabel' => t('or'),
|
||||
'cancelLabel' => t('cancel'),
|
||||
'color' => isset($params['color']) ? $params['color'] : 'blue',
|
||||
'tabindex' => isset($params['tabindex']) ? $params['tabindex'] : null,
|
||||
'disabled' => isset($params['disabled']) ? true : false,
|
||||
));
|
||||
}
|
||||
|
||||
public function confirmButtons($controller, $action, array $params = array(), $submitLabel = '', $tabindex = null)
|
||||
{
|
||||
return $this->helper->app->component('confirm-buttons', array(
|
||||
'url' => $this->helper->url->href($controller, $action, $params, true),
|
||||
'submitLabel' => $submitLabel ?: t('Yes'),
|
||||
'orLabel' => t('or'),
|
||||
'cancelLabel' => t('cancel'),
|
||||
'tabindex' => $tabindex,
|
||||
));
|
||||
}
|
||||
|
||||
public function largeIcon($icon, $label, $controller, $action, array $params = array())
|
||||
{
|
||||
$html = '<i class="fa fa-'.$icon.' fa-fw js-modal-large" aria-hidden="true"></i>';
|
||||
return $this->helper->url->link($html, $controller, $action, $params, false, 'js-modal-large', $label);
|
||||
}
|
||||
|
||||
public function large($icon, $label, $controller, $action, array $params = array())
|
||||
{
|
||||
$html = '<i class="fa fa-'.$icon.' fa-fw js-modal-large" aria-hidden="true"></i> '.$label;
|
||||
return $this->helper->url->link($html, $controller, $action, $params, false, 'js-modal-large');
|
||||
}
|
||||
|
||||
public function medium($icon, $label, $controller, $action, array $params = array())
|
||||
{
|
||||
$html = '<i class="fa fa-'.$icon.' fa-fw js-modal-medium" aria-hidden="true"></i> '.$label;
|
||||
return $this->helper->url->link($html, $controller, $action, $params, false, 'js-modal-medium');
|
||||
}
|
||||
|
||||
public function small($icon, $label, $controller, $action, array $params = array())
|
||||
{
|
||||
$html = '<i class="fa fa-'.$icon.' fa-fw js-modal-small" aria-hidden="true"></i> '.$label;
|
||||
return $this->helper->url->link($html, $controller, $action, $params, false, 'js-modal-small');
|
||||
}
|
||||
|
||||
public function mediumButton($icon, $label, $controller, $action, array $params = array())
|
||||
{
|
||||
$html = '<i class="fa fa-'.$icon.' fa-fw js-modal-medium" aria-hidden="true"></i> '.$label;
|
||||
return $this->helper->url->link($html, $controller, $action, $params, false, 'js-modal-medium btn');
|
||||
}
|
||||
|
||||
public function confirm($icon, $label, $controller, $action, array $params = array())
|
||||
{
|
||||
$html = '<i class="fa fa-'.$icon.' fa-fw js-modal-confirm" aria-hidden="true"></i> '.$label;
|
||||
return $this->helper->url->link($html, $controller, $action, $params, false, 'js-modal-confirm');
|
||||
}
|
||||
}
|
||||
@@ -42,16 +42,23 @@ class TaskHelper extends Base
|
||||
|
||||
public function selectTitle(array $values, array $errors)
|
||||
{
|
||||
$html = $this->helper->form->label(t('Title'), 'title');
|
||||
$html .= $this->helper->form->text('title', $values, $errors, array('autofocus', 'required', 'maxlength="200"', 'tabindex="1"'), 'form-input-large');
|
||||
return $html;
|
||||
return $this->helper->form->text(
|
||||
'title',
|
||||
$values,
|
||||
$errors,
|
||||
array(
|
||||
'autofocus',
|
||||
'required',
|
||||
'maxlength="200"',
|
||||
'tabindex="1"',
|
||||
'placeholder="'.t('Title').'"'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function selectDescription(array $values, array $errors)
|
||||
{
|
||||
$html = $this->helper->form->label(t('Description'), 'description');
|
||||
$html .= $this->helper->form->textEditor('description', $values, $errors, array('tabindex' => 2));
|
||||
return $html;
|
||||
return $this->helper->form->textEditor('description', $values, $errors, array('tabindex' => 2));
|
||||
}
|
||||
|
||||
public function selectTags(array $project, array $tags = array())
|
||||
@@ -152,7 +159,7 @@ class TaskHelper extends Base
|
||||
|
||||
public function selectScore(array $values, array $errors = array(), array $attributes = array())
|
||||
{
|
||||
$attributes = array_merge(array('tabindex="8"'), $attributes);
|
||||
$attributes = array_merge(array('tabindex="13"'), $attributes);
|
||||
|
||||
$html = $this->helper->form->label(t('Complexity'), 'score');
|
||||
$html .= $this->helper->form->number('score', $values, $errors, $attributes);
|
||||
@@ -162,7 +169,7 @@ class TaskHelper extends Base
|
||||
|
||||
public function selectReference(array $values, array $errors = array(), array $attributes = array())
|
||||
{
|
||||
$attributes = array_merge(array('tabindex="9"'), $attributes);
|
||||
$attributes = array_merge(array('tabindex="14"'), $attributes);
|
||||
|
||||
$html = $this->helper->form->label(t('Reference'), 'reference');
|
||||
$html .= $this->helper->form->text('reference', $values, $errors, $attributes, 'form-input-small');
|
||||
@@ -172,7 +179,7 @@ class TaskHelper extends Base
|
||||
|
||||
public function selectTimeEstimated(array $values, array $errors = array(), array $attributes = array())
|
||||
{
|
||||
$attributes = array_merge(array('tabindex="10"'), $attributes);
|
||||
$attributes = array_merge(array('tabindex="11"'), $attributes);
|
||||
|
||||
$html = $this->helper->form->label(t('Original estimate'), 'time_estimated');
|
||||
$html .= $this->helper->form->numeric('time_estimated', $values, $errors, $attributes);
|
||||
@@ -183,7 +190,7 @@ class TaskHelper extends Base
|
||||
|
||||
public function selectTimeSpent(array $values, array $errors = array(), array $attributes = array())
|
||||
{
|
||||
$attributes = array_merge(array('tabindex="11"'), $attributes);
|
||||
$attributes = array_merge(array('tabindex="12"'), $attributes);
|
||||
|
||||
$html = $this->helper->form->label(t('Time spent'), 'time_spent');
|
||||
$html .= $this->helper->form->numeric('time_spent', $values, $errors, $attributes);
|
||||
@@ -194,13 +201,13 @@ class TaskHelper extends Base
|
||||
|
||||
public function selectStartDate(array $values, array $errors = array(), array $attributes = array())
|
||||
{
|
||||
$attributes = array_merge(array('tabindex="12"'), $attributes);
|
||||
$attributes = array_merge(array('tabindex="10"'), $attributes);
|
||||
return $this->helper->form->datetime(t('Start Date'), 'date_started', $values, $errors, $attributes);
|
||||
}
|
||||
|
||||
public function selectDueDate(array $values, array $errors = array(), array $attributes = array())
|
||||
{
|
||||
$attributes = array_merge(array('tabindex="13"'), $attributes);
|
||||
$attributes = array_merge(array('tabindex="9"'), $attributes);
|
||||
return $this->helper->form->date(t('Due Date'), 'date_due', $values, $errors, $attributes);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ class UrlHelper extends Base
|
||||
*/
|
||||
public function button($icon, $label, $controller, $action, array $params = array(), $class = '')
|
||||
{
|
||||
$icon = '<i class="fa '.$icon.' fa-fw"></i> ';
|
||||
$html = '<i class="fa fa-'.$icon.' fa-fw"></i> '.$label;
|
||||
$class = 'btn '.$class;
|
||||
return $this->link($icon.$label, $controller, $action, $params, false, $class);
|
||||
return $this->link($html, $controller, $action, $params, false, $class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user