updated ticket create to match edit. updated IconsHelper to create template selection
This commit is contained in:
parent
4a421564c2
commit
acb428f4ee
@ -31,7 +31,28 @@ class IconsHelper extends \Prefab {
|
||||
|
||||
static public function icons($node){
|
||||
|
||||
// debug_print($node);
|
||||
|
||||
$required = ['type', 'path'];
|
||||
$check = self::checkAttributes($node, $required);
|
||||
if(!is_null($check)){
|
||||
return sprintf('<div class="notification is-danger is-light">%s</div>', $check);
|
||||
}
|
||||
|
||||
$attr = $node['@attrib'];
|
||||
$type = $attr['type'];
|
||||
$path = $attr['path'];
|
||||
$selected = $attr['selected'];
|
||||
|
||||
switch($attr['type']){
|
||||
case 'status-selector':
|
||||
$selected = Base::instance()->get('GET.status') ?: null;
|
||||
return '<?php echo \IconsHelper::instance()->renderStatusSelector("'.$selected.'", "'.$path.'"); ?>';
|
||||
return self::renderStatusSelector($selected, $path);
|
||||
|
||||
default:
|
||||
return '<div class="notification">unknown icon selector type</div>';
|
||||
}
|
||||
|
||||
$tpl = Template::instance();
|
||||
$f3 = Base::instance();
|
||||
@ -43,6 +64,42 @@ class IconsHelper extends \Prefab {
|
||||
|
||||
}
|
||||
|
||||
private static function checkAttributes($node, array $required){
|
||||
if(isset($node['@attrib'])){
|
||||
$attr = $node['@attrib'];
|
||||
$errors = [];
|
||||
|
||||
foreach($required as $key){
|
||||
if(empty($attr[$key])){
|
||||
$errors[] = "Error: '$key' is missing.";
|
||||
}
|
||||
}
|
||||
|
||||
return empty($errors) ? null : implode(" ", $errors);
|
||||
}
|
||||
return "Error: '@attrib' is missing";
|
||||
}
|
||||
|
||||
public static function renderStatusSelector($current_status, $path)
|
||||
{
|
||||
$output = '<div class="block"><div class="field has-addons">';
|
||||
|
||||
foreach (self::$status_icons as $k => $icon) {
|
||||
$active = ($current_status == $k);
|
||||
$url = $path . ($active ? '' : '/?status=' . $k);
|
||||
$class = 'button' . ($active ? ' is-primary' : '');
|
||||
|
||||
$output .= '<p class="control">';
|
||||
$output .= '<a href="' . $url . '" class="' . $class . '">';
|
||||
$output .= '<span class="icon is-small"><i class="fas fa-' . $icon[0] . '"></i></span>';
|
||||
$output .= '<span>' . self::$status_names[$k] . '</span>';
|
||||
$output .= '</a>';
|
||||
$output .= '</p>';
|
||||
}
|
||||
$output .= '</div></div>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
static function do_the_switch($type, $value){
|
||||
|
||||
if($value !== null) {
|
||||
|
||||
@ -1,30 +1,69 @@
|
||||
<h1 class="title">Create Ticket Form</h1>
|
||||
|
||||
<!-- Ticket - View -->
|
||||
<!-- made to look more in line with view-->
|
||||
<form action="/ticket/create" method="POST">
|
||||
{{ \CSRFHelper::field() | raw }}
|
||||
<div class="is-flex">
|
||||
<div class="is-flex-grow-1">
|
||||
<bulma type="FIELD_INPUT" name="title" value="" class="mr-3"></bulma>
|
||||
</div>
|
||||
<div class="field is-grouped is-grouped-right">
|
||||
<div class="field is-grouped">
|
||||
<div class="control">
|
||||
<label class="label">Key:</label>
|
||||
<input class="input" type="text" name="meta_key[]" placeholder="eg. Category">
|
||||
<a class="button is-secondary" href="/tickets">Cancel</a>
|
||||
</div>
|
||||
<div class="control">
|
||||
<label class="label">Value:</label>
|
||||
<input class="input" type="text" name="meta_value[]" placeholder="eg. Urgent">
|
||||
<button class="button is-primary" type="submit">Create Ticket</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field is-grouped is-grouped-right">
|
||||
<div class="control">
|
||||
<a class="button is-secondary" href="/tickets">Cancel</a>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit">Create Ticket</button>
|
||||
<hr>
|
||||
<div class="block">
|
||||
<div class="columns">
|
||||
<div class="column is-two-thirds">
|
||||
|
||||
<div class="block">
|
||||
<bulma type="FIELD_INPUT" name="created_at" value="" label="Created At:"></bulma>
|
||||
</div>
|
||||
|
||||
<div class="tabs">
|
||||
<ul>
|
||||
<li class="is-active">
|
||||
<a data-tab="write"><span class="icon is-small">
|
||||
<i class="fas fa-pen" aria-hidden="true"></i></span><span>Write</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a data-tab="preview"><span class="icon is-small">
|
||||
<i class="fas fa-magnifying-glass"
|
||||
aria-hidden="true"></i></span><span>Preview</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="tab-write" class="tab-content block">
|
||||
<bulma type="FIELD_TEXTAREA" name="description" value="" rows="20"></bulma>
|
||||
</div>
|
||||
<div id="tab-preview" class="tab-content content">
|
||||
<div id="preview-output"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
|
||||
|
||||
|
||||
<bulma type="FIELD_SELECT" label="Priority:" name="priority_id"
|
||||
options="{{@priorities}}" option_value="id" option_name="name" selected="0"></bulma>
|
||||
|
||||
<bulma type="FIELD_SELECT" label="Status:" name="status_id"
|
||||
options="{{@statuses}}" option_value="id" option_name="name" selected="0"></bulma>
|
||||
|
||||
<bulma type="FIELD_SELECT" label="Assigned User:" name="assigned_to"
|
||||
options="{{@users}}" option_value="id" option_name="display_name" selected="0"></bulma>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
52
app/ui/views/ticket/create.html.v1
Normal file
52
app/ui/views/ticket/create.html.v1
Normal file
@ -0,0 +1,52 @@
|
||||
<h1 class="title">Create Ticket Form</h1>
|
||||
|
||||
<form action="/ticket/create" method="POST">
|
||||
|
||||
<bulma type="H_FIELD_INPUT" label="Title:" name="title" value=""></bulma>
|
||||
<bulma type="H_FIELD_INPUT" label="Created At:" name="created_at" value=""></bulma>
|
||||
<bulma type="H_FIELD_TEXTAREA" label="Description:" name="description" value=""></bulma>
|
||||
|
||||
<!-- priority and status -->
|
||||
<bulma type="H_FIELD_SELECT_NEW" label="Priority:" name="priority_id"
|
||||
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 -->
|
||||
<hr>
|
||||
<div class="block">
|
||||
<div class="field is-grouped is-grouped-right">
|
||||
<div class="control">
|
||||
<label class="label">Key:</label>
|
||||
<input class="input" type="text" name="meta_key[]" placeholder="eg. Department">
|
||||
</div>
|
||||
<div class="control">
|
||||
<label class="label">Value:</label>
|
||||
<input class="input" type="text" name="meta_value[]" placeholder="eg. Finance">
|
||||
</div>
|
||||
</div>
|
||||
<div class="field is-grouped is-grouped-right">
|
||||
<div class="control">
|
||||
<label class="label">Key:</label>
|
||||
<input class="input" type="text" name="meta_key[]" placeholder="eg. Category">
|
||||
</div>
|
||||
<div class="control">
|
||||
<label class="label">Value:</label>
|
||||
<input class="input" type="text" name="meta_value[]" placeholder="eg. Urgent">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field is-grouped is-grouped-right">
|
||||
<div class="control">
|
||||
<a class="button is-secondary" href="/tickets">Cancel</a>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit">Create Ticket</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -20,19 +20,26 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="block">
|
||||
<div class="field has-addons">
|
||||
<!-- TODO: move this into a template -->
|
||||
<repeat group="{{ IconsHelper::$status_icons}}" key="{{ @k }}" value="{{ @icon }}">
|
||||
<p class="control">
|
||||
<a href="{{ @PATH }}/?status={{ @k }}" class="button">
|
||||
<span class="icon is-small"><i class="fas fa-{{ @icon[0] }}"></i></span>
|
||||
<span>{{ IconsHelper::$status_names[@k] }}</span>
|
||||
</a>
|
||||
</p>
|
||||
</repeat>
|
||||
</div>
|
||||
<icons type="status-selector" selected="{{ @GET.status ?: null }}" path="tickets"></icons>25
|
||||
</div>
|
||||
|
||||
<exclude>
|
||||
<div class="block">
|
||||
<div class="field has-addons">
|
||||
<!-- TODO: move this into a template -->
|
||||
<repeat group="{{ IconsHelper::$status_icons}}" key="{{ @k }}" value="{{ @icon }}">
|
||||
<p class="control">
|
||||
<a href="{{ @PATH }}/?status={{ @k }}" class="button">
|
||||
<span class="icon is-small"><i class="fas fa-{{ @icon[0] }}"></i></span>
|
||||
<span>{{ IconsHelper::$status_names[@k] }}</span>
|
||||
</a>
|
||||
</p>
|
||||
</repeat>
|
||||
</div>
|
||||
</div>
|
||||
</exclude>
|
||||
<hr>
|
||||
|
||||
<div id="ticket_list">
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
<div class="block">
|
||||
<h6 class="title is-6">Tags
|
||||
<span class="icon"><i class="fas fa-cog"></i></span></h6>
|
||||
|
||||
<!-- tags -->
|
||||
<div class="block">
|
||||
<div class="tags">
|
||||
@ -45,10 +44,9 @@
|
||||
<h6 class="title is-6">Projects
|
||||
<span class="icon"><i class="fas fa-cog"></i></span></h6>
|
||||
<hr>
|
||||
<h6 class="title is-6">Assignees</h6>
|
||||
<h6 class="title is-6">Assigned User:</h6>
|
||||
<check if="{{ @assigned_user }}">
|
||||
<div class="block">
|
||||
<h4 class="title">Assigned User</h4>
|
||||
<p>{{ @assigned_user.display_name ?: @assigned_user.username }}</p>
|
||||
</div>
|
||||
</check>
|
||||
@ -84,6 +82,7 @@
|
||||
</div>
|
||||
</check>
|
||||
<form action="/ticket/{{ @ticket.id }}/add-subtask" method="POST">
|
||||
{{ \CSRFHelper::field() | raw }}
|
||||
<div class="field">
|
||||
<label class="label">Add existing ticket as child ticket (ID):</label>
|
||||
<div class="control">
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
function debug_print($obj)
|
||||
{
|
||||
printf('<pre>%s</pre>', print_r($obj,1));
|
||||
}
|
||||
|
||||
require '../lib/autoload.php';
|
||||
|
||||
$f3 = \Base::instance();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user