chg: [ui] Various UI improvement and cleanup
New according bootstrap component and small UI enhancementspull/93/head
parent
4ef6738053
commit
51d93d40af
|
@ -684,11 +684,10 @@ class CRUDComponent extends Component
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function genQuickFilterConditions(array $params, \Cake\ORM\Query $query, array $quickFilterFields): array
|
public function genQuickFilterConditions(array $params, array $quickFilterFields): array
|
||||||
{
|
{
|
||||||
$queryConditions = [];
|
$queryConditions = [];
|
||||||
foreach ($quickFilterFields as $filterField) {
|
foreach ($quickFilterFields as $filterField) {
|
||||||
$likeCondition = false;
|
|
||||||
if (is_array($filterField)) {
|
if (is_array($filterField)) {
|
||||||
reset($filterField);
|
reset($filterField);
|
||||||
$filterFieldName = array_key_first($filterField);
|
$filterFieldName = array_key_first($filterField);
|
||||||
|
@ -697,8 +696,6 @@ class CRUDComponent extends Component
|
||||||
} else {
|
} else {
|
||||||
$queryConditions[$filterField] = $params['quickFilter'];
|
$queryConditions[$filterField] = $params['quickFilter'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$query->where(['OR' => $queryConditions]);
|
|
||||||
} else {
|
} else {
|
||||||
$queryConditions[$filterField] = $params['quickFilter'];
|
$queryConditions[$filterField] = $params['quickFilter'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,11 @@ class MetaTemplatesNavigation extends BaseNavigation
|
||||||
'url' => '/metaTemplates/toggle/{{id}}/default',
|
'url' => '/metaTemplates/toggle/{{id}}/default',
|
||||||
'url_vars' => ['id' => 'id'],
|
'url_vars' => ['id' => 'id'],
|
||||||
]);
|
]);
|
||||||
|
$this->bcf->addRoute('MetaTemplates', 'update', [
|
||||||
|
'label' => __('Update'),
|
||||||
|
'icon' => 'download',
|
||||||
|
'url' => '/metaTemplates/update',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addParents()
|
public function addParents()
|
||||||
|
@ -36,6 +41,7 @@ class MetaTemplatesNavigation extends BaseNavigation
|
||||||
|
|
||||||
public function addActions()
|
public function addActions()
|
||||||
{
|
{
|
||||||
|
$this->bcf->addAction('MetaTemplates', 'index', 'MetaTemplates', 'update');
|
||||||
$this->bcf->addAction('MetaTemplates', 'view', 'MetaTemplates', 'enable');
|
$this->bcf->addAction('MetaTemplates', 'view', 'MetaTemplates', 'enable');
|
||||||
$this->bcf->addAction('MetaTemplates', 'view', 'MetaTemplates', 'set_default');
|
$this->bcf->addAction('MetaTemplates', 'view', 'MetaTemplates', 'set_default');
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,12 @@ class BootstrapHelper extends Helper
|
||||||
return $bsCollapse->collapse();
|
return $bsCollapse->collapse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function accordion($options, $content)
|
||||||
|
{
|
||||||
|
$bsAccordion = new BoostrapAccordion($options, $content, $this);
|
||||||
|
return $bsAccordion->accordion();
|
||||||
|
}
|
||||||
|
|
||||||
public function progressTimeline($options)
|
public function progressTimeline($options)
|
||||||
{
|
{
|
||||||
$bsProgressTimeline = new BoostrapProgressTimeline($options, $this);
|
$bsProgressTimeline = new BoostrapProgressTimeline($options, $this);
|
||||||
|
@ -1461,6 +1467,96 @@ class BoostrapCollapse extends BootstrapGeneric {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BoostrapAccordion extends BootstrapGeneric
|
||||||
|
{
|
||||||
|
private $defaultOptions = [
|
||||||
|
'stayOpen' => true,
|
||||||
|
'class' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
function __construct($options, $content, $btHelper)
|
||||||
|
{
|
||||||
|
$this->allowedOptionValues = [];
|
||||||
|
$this->content = $content;
|
||||||
|
$this->btHelper = $btHelper;
|
||||||
|
$this->processOptions($options);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function processOptions($options)
|
||||||
|
{
|
||||||
|
$this->options = array_merge($this->defaultOptions, $options);
|
||||||
|
$this->checkOptionValidity();
|
||||||
|
if (!is_array($this->options['class']) && !empty($this->options['class'])) {
|
||||||
|
$this->options['class'] = [$this->options['class']];
|
||||||
|
}
|
||||||
|
$this->seed = 'acc-' . mt_rand();
|
||||||
|
$this->contentSeeds = [];
|
||||||
|
foreach ($this->content as $accordionItem) {
|
||||||
|
$this->contentSeeds[] = mt_rand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function accordion()
|
||||||
|
{
|
||||||
|
return $this->genAccordion();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function genHeader($accordionItem, $i)
|
||||||
|
{
|
||||||
|
$html = $this->openNode('h2', [
|
||||||
|
'class' => ['accordion-header'],
|
||||||
|
'id' => 'head-' . $this->contentSeeds[$i]
|
||||||
|
]);
|
||||||
|
$content = !empty($accordionItem['header']['html']) ? $accordionItem['header']['html'] : h($accordionItem['header']['title'] ?? '- no title -');
|
||||||
|
$buttonOptions = [
|
||||||
|
'class' => array_merge(['accordion-button', empty($accordionItem['_open']) ? 'collapsed' : ''], $accordionItem['header']['__class'] ?? []),
|
||||||
|
'type' => 'button',
|
||||||
|
'data-bs-toggle' => 'collapse',
|
||||||
|
'data-bs-target' => '#body-' . $this->contentSeeds[$i],
|
||||||
|
'aria-expanded' => 'false',
|
||||||
|
'aria-controls' => 'body-' . $this->contentSeeds[$i],
|
||||||
|
];
|
||||||
|
$html .= $this->genNode('button', $buttonOptions, $content);
|
||||||
|
$html .= $this->closeNode(('h2'));
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function genBody($accordionItem, $i)
|
||||||
|
{
|
||||||
|
$content = $this->genNode('div', [
|
||||||
|
'class' => ['accordion-body']
|
||||||
|
], $accordionItem['body']);
|
||||||
|
$divOptions = [
|
||||||
|
'class' => array_merge(['accordion-collapse collapse', empty($accordionItem['_open']) ? '' : 'show'], $accordionItem['body']['__class'] ?? []),
|
||||||
|
'id' => 'body-' . $this->contentSeeds[$i],
|
||||||
|
'aria-labelledby' => 'head-' . $this->contentSeeds[$i],
|
||||||
|
];
|
||||||
|
if (!empty($this->options['stayOpen'])) {
|
||||||
|
$divOptions['data-bs-parent'] = '#' . $this->seed;
|
||||||
|
}
|
||||||
|
$html = $this->genNode('div', $divOptions, $content);
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function genAccordion()
|
||||||
|
{
|
||||||
|
$html = $this->openNode('div', [
|
||||||
|
'class' => array_merge(['accordion'], $this->options['class']),
|
||||||
|
'id' => $this->seed
|
||||||
|
]);
|
||||||
|
foreach ($this->content as $i => $accordionItem) {
|
||||||
|
$html .= $this->openNode('div', [
|
||||||
|
'class' => array_merge(['accordion-item'], $accordionItem['__class'] ?? [])
|
||||||
|
]);
|
||||||
|
$html .= $this->genHeader($accordionItem, $i);
|
||||||
|
$html .= $this->genBody($accordionItem, $i);
|
||||||
|
$html .= $this->closeNode('div');
|
||||||
|
}
|
||||||
|
$html .= $this->closeNode('div');
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class BoostrapProgressTimeline extends BootstrapGeneric {
|
class BoostrapProgressTimeline extends BootstrapGeneric {
|
||||||
private $defaultOptions = [
|
private $defaultOptions = [
|
||||||
'steps' => [],
|
'steps' => [],
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
$entity = isset($entity) ? $entity : null;
|
$entity = isset($entity) ? $entity : null;
|
||||||
$fieldsString = '';
|
$fieldsString = '';
|
||||||
$simpleFieldWhitelist = [
|
$simpleFieldWhitelist = [
|
||||||
'default', 'type', 'placeholder', 'label', 'empty', 'rows', 'div', 'required'
|
'default', 'type', 'placeholder', 'label', 'empty', 'rows', 'div', 'required', 'templates'
|
||||||
];
|
];
|
||||||
//$fieldsArrayForPersistence = array();
|
//$fieldsArrayForPersistence = array();
|
||||||
if (empty($data['url'])) {
|
if (empty($data['url'])) {
|
||||||
|
@ -116,17 +116,20 @@
|
||||||
$ajaxFlashMessage,
|
$ajaxFlashMessage,
|
||||||
$formCreate,
|
$formCreate,
|
||||||
$fieldsString,
|
$fieldsString,
|
||||||
empty($metaTemplateString) ? '' : $this->element(
|
empty($metaTemplateString) ? '' : $this->Bootstrap->accordion(
|
||||||
'genericElements/accordion_scaffold',
|
[
|
||||||
|
'class' => 'mb-2'
|
||||||
|
],
|
||||||
|
[
|
||||||
[
|
[
|
||||||
'children' => [
|
'_open' => true,
|
||||||
[
|
'header' => [
|
||||||
'body' => $metaTemplateString,
|
'title' => __('Meta fields')
|
||||||
'title' => 'Meta fields'
|
],
|
||||||
]
|
'body' => $metaTemplateString,
|
||||||
]
|
],
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
$formEnd
|
$formEnd
|
||||||
),
|
),
|
||||||
'actionButton' => $this->element('genericElements/Form/submitButton', $submitButtonData),
|
'actionButton' => $this->element('genericElements/Form/submitButton', $submitButtonData),
|
||||||
|
@ -142,15 +145,18 @@
|
||||||
$ajaxFlashMessage,
|
$ajaxFlashMessage,
|
||||||
$formCreate,
|
$formCreate,
|
||||||
$fieldsString,
|
$fieldsString,
|
||||||
empty($metaTemplateString) ? '' : $this->element(
|
empty($metaTemplateString) ? '' : $this->Bootstrap->accordion(
|
||||||
'genericElements/accordion_scaffold',
|
|
||||||
[
|
[
|
||||||
'children' => [
|
'class' => 'mb-2'
|
||||||
[
|
],
|
||||||
'body' => $metaTemplateString,
|
[
|
||||||
'title' => 'Meta fields'
|
[
|
||||||
]
|
'_open' => true,
|
||||||
]
|
'header' => [
|
||||||
|
'title' => __('Meta fields')
|
||||||
|
],
|
||||||
|
'body' => $metaTemplateString,
|
||||||
|
],
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
$formEnd
|
$formEnd
|
||||||
|
@ -167,16 +173,18 @@
|
||||||
$data['description']
|
$data['description']
|
||||||
),
|
),
|
||||||
sprintf('<div class="panel">%s</div>', $fieldsString),
|
sprintf('<div class="panel">%s</div>', $fieldsString),
|
||||||
empty($metaTemplateString) ? '' : $this->element(
|
empty($metaTemplateString) ? '' : $this->Bootstrap->accordion(
|
||||||
'genericElements/accordion_scaffold',
|
|
||||||
[
|
[
|
||||||
'children' => [
|
|
||||||
[
|
|
||||||
'body' => $metaTemplateString,
|
|
||||||
'title' => 'Meta fields',
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'class' => 'mb-2'
|
'class' => 'mb-2'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'_open' => true,
|
||||||
|
'header' => [
|
||||||
|
'title' => __('Meta fields')
|
||||||
|
],
|
||||||
|
'body' => $metaTemplateString,
|
||||||
|
],
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
$this->element('genericElements/Form/submitButton', $submitButtonData),
|
$this->element('genericElements/Form/submitButton', $submitButtonData),
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
} else {
|
} else {
|
||||||
echo $this->Form->button(empty($text) ? __('Submit') : h($text), [
|
echo $this->Form->button(empty($text) ? __('Submit') : h($text), [
|
||||||
'class' => 'btn btn-' . (empty($type) ? 'primary' : h($type)),
|
'class' => 'btn btn-' . (empty($type) ? 'primary' : h($type)),
|
||||||
'type' => 'submit'
|
'type' => 'submit',
|
||||||
|
'data-form-id' => '#form-' . h($formRandomValue)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -58,7 +58,8 @@
|
||||||
$filterEffective ? '' : 'disabled="disabled"'
|
$filterEffective ? '' : 'disabled="disabled"'
|
||||||
);
|
);
|
||||||
echo sprintf(
|
echo sprintf(
|
||||||
'<div class="input-group" data-table-random-value="%s" style="margin-left: auto;">%s%s</div>',
|
'<div class="input-group %s" data-table-random-value="%s" style="margin-left: auto;">%s%s</div>',
|
||||||
|
$filterEffective ? '' : 'd-none',
|
||||||
h($tableRandomValue),
|
h($tableRandomValue),
|
||||||
$input,
|
$input,
|
||||||
$button
|
$button
|
||||||
|
|
Loading…
Reference in New Issue