added IconsHelper extension to show icons instead of status and priority name
This commit is contained in:
parent
2651caa1df
commit
369f22444e
53
app/extensions/IconsHelper.php
Normal file
53
app/extensions/IconsHelper.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class IconsHelper extends \Prefab {
|
||||||
|
|
||||||
|
static public $status_icons = [
|
||||||
|
'New' => ['fas fa-plus-circle has-text-warning', "🆕"],
|
||||||
|
'In Progress' => ['fas fa-repeat has-text-link', "🔄"],
|
||||||
|
'On Hold' => ['fas fa-pause-circle has-text-danger',"⏸️"],
|
||||||
|
'Completed' => ['fas fa-check-circle has-text-success', "✅"]
|
||||||
|
];
|
||||||
|
|
||||||
|
static public $priority_icons = [
|
||||||
|
'Low' => ['fas fa-arrow-down',"🟢"],
|
||||||
|
'Medium' => ['fas fa-minus', "🟡"],
|
||||||
|
'High' => ['fas fa-arrow-up', "🔴"]
|
||||||
|
];
|
||||||
|
|
||||||
|
static public function icons($node){
|
||||||
|
|
||||||
|
$attr = $node['@attrib'];
|
||||||
|
|
||||||
|
$tpl = Template::instance();
|
||||||
|
$f3 = Base::instance();
|
||||||
|
|
||||||
|
$context = $f3->hive();
|
||||||
|
$inner = $tpl->token($node[0], $context);
|
||||||
|
|
||||||
|
return '<?php echo IconsHelper::do_the_switch("' . $attr['type'] . '", ' . $inner . '); ?>';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static function do_the_switch($type, $value){
|
||||||
|
|
||||||
|
$icon_class = '';
|
||||||
|
switch(strtolower($type)){
|
||||||
|
case 'status':
|
||||||
|
$icon_class = IconsHelper::$status_icons[$value] ?? ['fas fa-question-circle has-text-info', "🔲"];
|
||||||
|
break;
|
||||||
|
case 'priority':
|
||||||
|
$icon_class = IconsHelper::$priority_icons[$value] ?? ['fas fa-question-circle', "🔲"];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$icon_class = 'fas fa-question-circle';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '<span class="is-size-5">'.$icon_class[1].'</span>';
|
||||||
|
return '<i class="'.$icon_class[0].' is-size-4"></i>';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
\Template::instance()->extend('icons', 'IconsHelper::icons');
|
||||||
@ -15,7 +15,7 @@ $htmlpurifier = \HTMLPurifier::instance();
|
|||||||
$md = \ParsedownTableExtension::instance();
|
$md = \ParsedownTableExtension::instance();
|
||||||
$md->setSafeMode(true);
|
$md->setSafeMode(true);
|
||||||
|
|
||||||
$f3->set('EXT', [new ParsedownHelper, new BulmaFormHelper]);
|
$f3->set('EXT', [new ParsedownHelper, new BulmaFormHelper, new IconsHelper]);
|
||||||
|
|
||||||
$f3->set('DB', new \DB\SQL(
|
$f3->set('DB', new \DB\SQL(
|
||||||
'mysql:host=localhost;port=3306;dbname=' . $f3->get('database.db_name'),
|
'mysql:host=localhost;port=3306;dbname=' . $f3->get('database.db_name'),
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
<h1 class="title">Create Ticket Form</h1>
|
<h1 class="title">Create Ticket Form</h1>
|
||||||
|
|
||||||
|
|
||||||
<form action="/ticket/create" method="POST">
|
<form action="/ticket/create" method="POST">
|
||||||
|
|
||||||
<bulma type="H_FIELD_INPUT" label="Title:" name="title" value=""></bulma>
|
<bulma type="H_FIELD_INPUT" label="Title:" name="title" value=""></bulma>
|
||||||
@ -8,8 +7,13 @@
|
|||||||
<bulma type="H_FIELD_TEXTAREA" label="Description:" name="description" value=""></bulma>
|
<bulma type="H_FIELD_TEXTAREA" label="Description:" name="description" value=""></bulma>
|
||||||
|
|
||||||
<!-- TODO implement priority and status -->
|
<!-- TODO implement priority and status -->
|
||||||
<bulma type="H_FIELD_SELECT" label="Priority:" name="priority" options="['Low', 'Medium', 'High']" selected="Medium"></bulma>
|
<bulma type="H_FIELD_SELECT_NEW" label="Priority:" name="priority_id"
|
||||||
<bulma type="H_FIELD_SELECT" label="Status:" name="status" options="['New', 'In Progress', 'On Hold', 'Completed']" selected="New"></bulma>
|
options="priorities" option_value="id" option_name="name"
|
||||||
|
selected="2"></bulma>
|
||||||
|
|
||||||
|
<bulma type="H_FIELD_SELECT_NEW" label="Status:" name="status_id"
|
||||||
|
options="statuses" option_value="id" option_name="name"
|
||||||
|
selected="1"></bulma>
|
||||||
|
|
||||||
<!-- custom fields -->
|
<!-- custom fields -->
|
||||||
<hr>
|
<hr>
|
||||||
|
|||||||
@ -7,8 +7,13 @@
|
|||||||
<bulma type="H_FIELD_TEXTAREA" label="Description:" name="description" value="{{@ticket.description}}"></bulma>
|
<bulma type="H_FIELD_TEXTAREA" label="Description:" name="description" value="{{@ticket.description}}"></bulma>
|
||||||
|
|
||||||
|
|
||||||
<bulma type="H_FIELD_SELECT" label="Priority:" name="priority" options="['Low', 'Medium', 'High']" selected="{{@ticket.priority}}"></bulma>
|
<bulma type="H_FIELD_SELECT_NEW" label="Priority:" name="priority_id"
|
||||||
<bulma type="H_FIELD_SELECT" label="Status:" name="status" options="['New', 'In Progress', 'On Hold', 'Completed']" selected="{{@ticket.status}}"></bulma>
|
options="priorities" option_value="id" option_name="name"
|
||||||
|
selected="{{@ticket.priority_id}}"></bulma>
|
||||||
|
|
||||||
|
<bulma type="H_FIELD_SELECT_NEW" label="Status:" name="status_id"
|
||||||
|
options="statuses" option_value="id" option_name="name"
|
||||||
|
selected="@ticket.status_id"></bulma>
|
||||||
|
|
||||||
<include href="/ui/parts/clipboard.html"></include>
|
<include href="/ui/parts/clipboard.html"></include>
|
||||||
|
|
||||||
|
|||||||
@ -17,8 +17,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{@ticket.id}}</td>
|
<td>{{@ticket.id}}</td>
|
||||||
<td><a href="/ticket/{{@ticket.id}}">{{@ticket.title}}</a></td>
|
<td><a href="/ticket/{{@ticket.id}}">{{@ticket.title}}</a></td>
|
||||||
<td>{{@ticket.status}}</td>
|
<td><icons type="status">{{@ticket.status_name}}</icons></td>
|
||||||
<td>{{@ticket.priority}}</td>
|
<td><icons type="priority">{{@ticket.priority_name}}</icons></td>
|
||||||
<td>{{@ticket.created_at}}</td>
|
<td>{{@ticket.created_at}}</td>
|
||||||
<td>
|
<td>
|
||||||
<a class="button is-link is-small" href="/ticket/{{@ticket.id}}/edit">
|
<a class="button is-link is-small" href="/ticket/{{@ticket.id}}/edit">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user