Skip to content

Commit 4edcd06

Browse files
HUMBERTO Augusto Armenio Camilo Cruzbtry
authored andcommitted
feat(issue): add qtip for ticket types
Signed-off-by: HUMBERTO Augusto Armenio Camilo Cruz <humberto.cruz@poupex.com.br> Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent a62e764 commit 4edcd06

File tree

5 files changed

+46
-21
lines changed

5 files changed

+46
-21
lines changed

inc/fields/dropdownfield.class.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,12 +372,15 @@ public function lessThan($value) {
372372

373373
public function parseAnswerValues($input) {
374374
$key = 'formcreator_field_' . $this->fields['id'];
375-
if (!is_string($input[$key])) {
376-
return false;
375+
if (!isset($input[$key])) {
376+
$input[$key] = '0';
377+
} else {
378+
if (!is_string($input[$key])) {
379+
return false;
380+
}
377381
}
378-
379-
$this->value = $input[$key];
380-
return true;
382+
$this->value = $input[$key];
383+
return true;
381384
}
382385

383386
public function isAnonymousFormCompatible() {

inc/fields/urgencyfield.class.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,16 @@ public function prepareQuestionInputForSave($input) {
7171

7272
public function parseAnswerValues($input) {
7373
$key = 'formcreator_field_' . $this->fields['id'];
74-
if (!is_string($input[$key])) {
75-
return false;
74+
if (!isset($input[$key])) {
75+
$input[$key] = '3';
76+
} else {
77+
if (!is_string($input[$key])) {
78+
return false;
79+
}
7680
}
7781

78-
$this->value = $input[$key];
79-
return true;
82+
$this->value = $input[$key];
83+
return true;
8084
}
8185

8286
public static function getPrefs() {

inc/formanswer.class.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -965,8 +965,8 @@ public function saveAnswers(PluginFormcreatorForm $form, $data, $fields) {
965965
/**
966966
* Update the answers
967967
*
968-
* @param [type] $input
969-
* @return void
968+
* @param array $input
969+
* @return boolean
970970
*/
971971
public function updateAnswers($input) {
972972
$form = new PluginFormcreatorForm();
@@ -985,7 +985,7 @@ public function updateAnswers($input) {
985985
);
986986
$fields[$id]->parseAnswerValues($input);
987987
}
988-
$this->saveAnswers($form, $input, $fields);
988+
return $this->saveAnswers($form, $input, $fields);
989989
}
990990

991991
/**
@@ -1018,7 +1018,6 @@ public function refuseAnswers($input) {
10181018
);
10191019
$fields[$id]->parseAnswerValues($input);
10201020
}
1021-
10221021
return $this->saveAnswers($form, $input, $fields);
10231022
}
10241023

@@ -1052,7 +1051,6 @@ public function acceptAnswers($input) {
10521051
);
10531052
$fields[$id]->parseAnswerValues($input);
10541053
}
1055-
10561054
return $this->saveAnswers($form, $input, $fields);
10571055
}
10581056

inc/issue.class.php

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,29 +526,50 @@ public static function giveItem($itemtype, $option_id, $data, $num) {
526526
switch ("$table.$field") {
527527
case "glpi_plugin_formcreator_issues.name":
528528
$name = $data[$num][0]['name'];
529-
return "<a href='".FORMCREATOR_ROOTDOC."/front/issue.form.php?id=".$id."&sub_itemtype=".$data['raw']['sub_itemtype']."'>$name</a>";
530-
break;
529+
$subItemtype = $data['raw']['sub_itemtype'];
530+
switch ($subItemtype) {
531+
case Ticket::class:
532+
$ticket = new Ticket();
533+
$ticket->getFromDB($id);
534+
$content = $ticket->fields['content'];
535+
break;
536+
537+
// TODO : need some code refactor to properly provide qtip
538+
// case PluginFormcreatorFormAnswer::class:
539+
// $formAnswer = new PluginFormcreatorFormAnswer();
540+
// $formAnswer->getFromDB($id);
541+
// $content = $formAnswer->getFullForm();
542+
// // TODO : need to replace tags before creating the qtip
543+
// break;
544+
default:
545+
$content = '';
546+
}
547+
$link = FORMCREATOR_ROOTDOC . "/front/issue.form.php?id=".$id."&sub_itemtype=".$data['raw']['sub_itemtype'];
548+
$tooltip = Html::showToolTip(nl2br(Html::Clean($content)), [
549+
'applyto' => $itemtype.$data[$itemtype . '_' . $option_id][0]['id'],
550+
'display' => false,
551+
]);
552+
return '<a id="' . $itemtype.$data[$itemtype . '_' . $option_id][0]['id'] . '" href="' . $link . '">'
553+
. sprintf(__('%1$s %2$s'), $name, $tooltip)
554+
. '</a>';
531555

532556
case "glpi_plugin_formcreator_issues.id":
533557
return $data['raw']['id'];
534-
break;
535558

536559
case "glpi_plugin_formcreator_issues.status":
537560
switch ($data['raw']['sub_itemtype']) {
538561
case Ticket::class:
539562
$status = Ticket::getStatus($data['raw']["ITEM_$num"]);
540563
return Ticket::getStatusIcon($data['raw']["ITEM_$num"])." ".$status;
541-
break;
542564

543565
case PluginFormcreatorFormAnswer::class:
544566
return PluginFormcreatorFormAnswer::getSpecificValueToDisplay('status', $data['raw']["ITEM_$num"])
545567
." ".__($data['raw']["ITEM_$num"], 'formcreator');
546-
break;
547568
}
548569
break;
549570
}
550571

551-
return "";
572+
return '';
552573
}
553574

554575

inc/targetbase.class.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,6 @@ protected function parseTags($content, PluginFormcreatorFormAnswer $formanswer,
10381038
return $content;
10391039
}
10401040

1041-
10421041
protected function showLocationSettings($rand) {
10431042
global $DB;
10441043

0 commit comments

Comments
 (0)