Skip to content

Commit

Permalink
fix(fromanwser): status display enhancements (#2508)
Browse files Browse the repository at this point in the history
  • Loading branch information
btry authored Dec 21, 2021
1 parent 37001d2 commit e87cbdb
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 61 deletions.
63 changes: 24 additions & 39 deletions css/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -717,18 +717,6 @@ a.plugin_formcreator_formTile_title {
margin: 0 5px;
}

#plugin_formcreator_lastForms {
width: 265px;
position: absolute;
right: 0;
top: 0;


> div {
margin-bottom: 10px;
}
}

#plugin_formcreator_wizard .plugin_formcreator_lists_separator {
padding: 0;
}
Expand Down Expand Up @@ -823,38 +811,35 @@ a.plugin_formcreator_formTile_title {
}

#plugin_formcreator_lastForms {
.plugin_formcreator_card {
.plugin_formcreator_answer {
margin: 3px;
list-style: none;
padding: 0;
text-align: left;
border-bottom: 1px solid rgba(0,0,0,.1);
}
.plugin_formcreator_answer {
margin: 3px;
list-style: none;
padding: 0;
text-align: left;
border-bottom: 1px solid rgba(0,0,0,.1);
}

.plugin_formcreator_answer a {
margin: 3px;
background-repeat: no-repeat;
background-position: left center;
padding: 11px 11px 11px 20px;
}
li a {
background-repeat: no-repeat;
background-position: left center;
padding: 11px;
}

.plugin_formcreator_waiting {
background-image: url("../pics/waiting.png");
}
.plugin_formcreator_waiting {
background-image: url("../pics/waiting.png");
}

.plugin_formcreator_refused {
background-image: url("../pics/refused.png");
}
.plugin_formcreator_refused {
background-image: url("../pics/refused.png");
}

.plugin_formcreator_accepted {
background-image: url("../pics/accepted.png");
}
.plugin_formcreator_accepted {
background-image: url("../pics/accepted.png");
}

> div {
border-bottom: 1px solid rgba(0,0,0,.1);
padding: 11px;
}
> div {
border-bottom: 1px solid rgba(0,0,0,.1);
padding: 11px;
}
}

Expand Down
34 changes: 20 additions & 14 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ public function showList() : void {
// echo '</div>';

// echo '<div id="plugin_formcreator_lastForms"class="card-group" >';
echo '<div class="d-flex flex-column ms-sm-2">';
echo '<div id="plugin_formcreator_lastForms" class="d-flex flex-column ms-sm-2">';
$this->showMyLastForms();
echo '</div>';
echo '</div>';
Expand Down Expand Up @@ -1038,19 +1038,22 @@ protected function showMyLastForms() : void {
foreach ($result as $formAnswer) {
switch ($formAnswer['status']) {
case PluginFormcreatorFormAnswer::STATUS_WAITING:
$status = 'waiting';
$status = CommonITILObject::WAITING;
break;
case PluginFormcreatorFormAnswer::STATUS_REFUSED:
$status = 'refused';
$status = Change::REFUSED;
break;
case PluginFormcreatorFormAnswer::STATUS_ACCEPTED:
$status = 'accepted';
$status = CommonITILObject::ACCEPTED;
break;
default:
$status = $formAnswer['status'];
}
echo '<li data-itemtype="PluginFormcreatorFormanswer" data-id="' . $formAnswer['id'] . '">';
echo ' <a class="plugin_formcreator_'.$status.'" href="formanswer.form.php?id='.$formAnswer['id'].'">'.$formAnswer['name'].'</a>';
echo '<span class="plugin_formcreator_date">'.Html::convDateTime($formAnswer['request_date']).'</span>';
echo '</li>';
$status = CommonITILOBject::getStatusClass($status);
echo '<li data-itemtype="PluginFormcreatorFormanswer" data-id="' . $formAnswer['id'] . '">';
echo '<i class="'.$status.'"></i><a href="formanswer.form.php?id='.$formAnswer['id'].'">'.$formAnswer['name'].'</a>';
echo '<span class="plugin_formcreator_date">'.Html::convDateTime($formAnswer['request_date']).'</span>';
echo '</li>';
}
echo '</ul>';
echo '<div class="text-center card-footer">';
Expand Down Expand Up @@ -1082,21 +1085,24 @@ protected function showMyLastForms() : void {
echo '<div class="card-body text-center text-muted" >'.__('No form waiting for validation', 'formcreator').'</div>';
} else {
echo '<div class="card-body">';
echo '<ul>';
echo '<ul class="list-group">';
foreach ($result as $formAnswer) {
switch ($formAnswer['status']) {
case PluginFormcreatorFormAnswer::STATUS_WAITING:
$status = 'waiting';
$status = CommonITILObject::WAITING;
break;
case PluginFormcreatorFormAnswer::STATUS_REFUSED:
$status = 'refused';
$status = Change::REFUSED;
break;
case PluginFormcreatorFormAnswer::STATUS_ACCEPTED:
$status = 'accepted';
$status = CommonITILObject::ACCEPTED;
break;
default:
$status = $formAnswer['status'];
}
echo '<li data-itemtype="PluginFormcreatorFormanswer" data-id="' . $formAnswer['id'] . '>';
echo ' <a class="plugin_formcreator_'.$status.'" href="formanswer.form.php?id='.$formAnswer['id'].'">'.$formAnswer['name'].'</a>';
$status = CommonITILOBject::getStatusClass($status);
echo '<li data-itemtype="PluginFormcreatorFormanswer" data-id="' . $formAnswer['id'] . '">';
echo '<i class="'.$status.'"></i><a href="formanswer.form.php?id='.$formAnswer['id'].'">'.$formAnswer['name'].'</a>';
echo '<span class="plugin_formcreator_date">'.Html::convDateTime($formAnswer['request_date']).'</span>';
echo '</li>';
}
Expand Down
23 changes: 15 additions & 8 deletions inc/formanswer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,21 @@ public static function getSpecificValueToDisplay($field, $values, array $options
switch ($field) {
case 'status' :
if (!isAPI()) {
$language = $_SESSION["glpilanguage"];
Session::loadLanguage('en_GB');
$elements = self::getStatuses();
Session::loadLanguage($language);
$values = [$field => $elements[$values[$field]]];
$output = '<img src="' . FORMCREATOR_ROOTDOC . '/pics/' . strtolower($values[$field]) . '.png"
alt="' . __($values[$field], 'formcreator') . '" title="' . __($values[$field], 'formcreator') . '" /> ';
return $output;
switch ($values[$field]) {
case PluginFormcreatorFormAnswer::STATUS_WAITING:
$status = CommonITILObject::WAITING;
break;
case PluginFormcreatorFormAnswer::STATUS_REFUSED:
$status = Change::REFUSED;
break;
case PluginFormcreatorFormAnswer::STATUS_ACCEPTED:
$status = CommonITILObject::ACCEPTED;
break;
default:
$status = $values[$field];
}
$status = CommonITILOBject::getStatusClass($status);
return '<i class="'.$status.'"></i>';
}
break;
}
Expand Down

0 comments on commit e87cbdb

Please sign in to comment.