Skip to content

Commit

Permalink
feat(issue): add qtip for ticket types
Browse files Browse the repository at this point in the history
Signed-off-by: HUMBERTO Augusto Armenio Camilo Cruz <humberto.cruz@poupex.com.br>
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
HUMBERTO Augusto Armenio Camilo Cruz authored and btry committed Feb 28, 2019
1 parent a62e764 commit 4edcd06
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 21 deletions.
13 changes: 8 additions & 5 deletions inc/fields/dropdownfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,15 @@ public function lessThan($value) {

public function parseAnswerValues($input) {
$key = 'formcreator_field_' . $this->fields['id'];
if (!is_string($input[$key])) {
return false;
if (!isset($input[$key])) {
$input[$key] = '0';
} else {
if (!is_string($input[$key])) {
return false;
}
}

$this->value = $input[$key];
return true;
$this->value = $input[$key];
return true;
}

public function isAnonymousFormCompatible() {
Expand Down
12 changes: 8 additions & 4 deletions inc/fields/urgencyfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,16 @@ public function prepareQuestionInputForSave($input) {

public function parseAnswerValues($input) {
$key = 'formcreator_field_' . $this->fields['id'];
if (!is_string($input[$key])) {
return false;
if (!isset($input[$key])) {
$input[$key] = '3';
} else {
if (!is_string($input[$key])) {
return false;
}
}

$this->value = $input[$key];
return true;
$this->value = $input[$key];
return true;
}

public static function getPrefs() {
Expand Down
8 changes: 3 additions & 5 deletions inc/formanswer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -965,8 +965,8 @@ public function saveAnswers(PluginFormcreatorForm $form, $data, $fields) {
/**
* Update the answers
*
* @param [type] $input
* @return void
* @param array $input
* @return boolean
*/
public function updateAnswers($input) {
$form = new PluginFormcreatorForm();
Expand All @@ -985,7 +985,7 @@ public function updateAnswers($input) {
);
$fields[$id]->parseAnswerValues($input);
}
$this->saveAnswers($form, $input, $fields);
return $this->saveAnswers($form, $input, $fields);
}

/**
Expand Down Expand Up @@ -1018,7 +1018,6 @@ public function refuseAnswers($input) {
);
$fields[$id]->parseAnswerValues($input);
}

return $this->saveAnswers($form, $input, $fields);
}

Expand Down Expand Up @@ -1052,7 +1051,6 @@ public function acceptAnswers($input) {
);
$fields[$id]->parseAnswerValues($input);
}

return $this->saveAnswers($form, $input, $fields);
}

Expand Down
33 changes: 27 additions & 6 deletions inc/issue.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,29 +526,50 @@ public static function giveItem($itemtype, $option_id, $data, $num) {
switch ("$table.$field") {
case "glpi_plugin_formcreator_issues.name":
$name = $data[$num][0]['name'];
return "<a href='".FORMCREATOR_ROOTDOC."/front/issue.form.php?id=".$id."&sub_itemtype=".$data['raw']['sub_itemtype']."'>$name</a>";
break;
$subItemtype = $data['raw']['sub_itemtype'];
switch ($subItemtype) {
case Ticket::class:
$ticket = new Ticket();
$ticket->getFromDB($id);
$content = $ticket->fields['content'];
break;

// TODO : need some code refactor to properly provide qtip
// case PluginFormcreatorFormAnswer::class:
// $formAnswer = new PluginFormcreatorFormAnswer();
// $formAnswer->getFromDB($id);
// $content = $formAnswer->getFullForm();
// // TODO : need to replace tags before creating the qtip
// break;
default:
$content = '';
}
$link = FORMCREATOR_ROOTDOC . "/front/issue.form.php?id=".$id."&sub_itemtype=".$data['raw']['sub_itemtype'];
$tooltip = Html::showToolTip(nl2br(Html::Clean($content)), [
'applyto' => $itemtype.$data[$itemtype . '_' . $option_id][0]['id'],
'display' => false,
]);
return '<a id="' . $itemtype.$data[$itemtype . '_' . $option_id][0]['id'] . '" href="' . $link . '">'
. sprintf(__('%1$s %2$s'), $name, $tooltip)
. '</a>';

case "glpi_plugin_formcreator_issues.id":
return $data['raw']['id'];
break;

case "glpi_plugin_formcreator_issues.status":
switch ($data['raw']['sub_itemtype']) {
case Ticket::class:
$status = Ticket::getStatus($data['raw']["ITEM_$num"]);
return Ticket::getStatusIcon($data['raw']["ITEM_$num"])." ".$status;
break;

case PluginFormcreatorFormAnswer::class:
return PluginFormcreatorFormAnswer::getSpecificValueToDisplay('status', $data['raw']["ITEM_$num"])
." ".__($data['raw']["ITEM_$num"], 'formcreator');
break;
}
break;
}

return "";
return '';
}


Expand Down
1 change: 0 additions & 1 deletion inc/targetbase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,6 @@ protected function parseTags($content, PluginFormcreatorFormAnswer $formanswer,
return $content;
}


protected function showLocationSettings($rand) {
global $DB;

Expand Down

0 comments on commit 4edcd06

Please sign in to comment.