Skip to content

Commit

Permalink
more info for inquest config badge
Browse files Browse the repository at this point in the history
  • Loading branch information
cconard96 committed May 28, 2024
1 parent 8c7d6da commit 3b974fd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
41 changes: 37 additions & 4 deletions src/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -2526,7 +2526,38 @@ public static function getSpecificValueToDisplay($field, $values, array $options
if ($values[$field] === self::CONFIG_PARENT) {
return __('Inheritance of the parent entity');
}
return CommonITILSatisfaction::getTypeInquestName($values[$field]);
$inherit =
$inquest_rate = self::getUsedConfig(
$field,
$options['entity']->fields['entities_id'],
str_replace('config', 'rate', $field)
);
$inherit .= '<br>';
if ($inquest_rate === 0) {
$inherit .= __('Disabled');
} else {
$inherit .= CommonITILSatisfaction::getTypeInquestName($values[$field]) . '<br>';
$inqconf = self::getUsedConfig(
$field,
$options['entity']->fields['entities_id'],
str_replace('config', 'delay', $field)
);

$inherit .= sprintf(_n('%d day', '%d days', $inqconf), $inqconf);
$inherit .= "<br>";
//TRANS: %d is the percentage. %% to display %
$inherit .= sprintf(__('%d%%'), $inquest_rate);

if ($values[$field] === 2) {
$inherit .= "<br>";
$inherit .= self::getUsedConfig(
$field,
$options['entity']->fields['entities_id'],
str_replace('config', 'URL', $field)
);
}
}
return $inherit;

case 'default_contract_alert':
return Contract::getAlertName($values[$field]);
Expand Down Expand Up @@ -2785,7 +2816,7 @@ public static function inheritedValue($value = "", bool $inline = false, bool $d
* @param mixed $default_value
* @return string|null The badge HTML or null if the field is not inherited
*/
private function getInheritedValueBadge(string $field, ?string $strategy_field = null, mixed $default_value = self::CONFIG_PARENT, mixed $inherit_parent_value = self::CONFIG_PARENT): ?string
public function getInheritedValueBadge(string $field, ?string $strategy_field = null, mixed $default_value = self::CONFIG_PARENT, mixed $inherit_parent_value = self::CONFIG_PARENT): ?string
{
$result = null;
if ($this->fields[$field] === $inherit_parent_value) {
Expand All @@ -2797,7 +2828,9 @@ private function getInheritedValueBadge(string $field, ?string $strategy_field =
? self::getUsedConfig($strategy_field, $this->fields['entities_id'], $field, $default_value)
: $inherited_strategy;
$result = self::inheritedValue(
self::getSpecificValueToDisplay($field, $inherited_value),
self::getSpecificValueToDisplay($field, $inherited_value, [
'entity' => $this,
]),
false,
false
);
Expand All @@ -2813,7 +2846,7 @@ private function getInheritedValueBadge(string $field, ?string $strategy_field =
* @param int $default_value The default value
* @return string|null The badge HTML or null if the field is not inherited
*/
private function getInheritedLinkedValueBadge(string $itemtype, string $empty_value = Dropdown::EMPTY_VALUE, ?string $field = null, int $default_value = 0): ?string
public function getInheritedLinkedValueBadge(string $itemtype, string $empty_value = Dropdown::EMPTY_VALUE, ?string $field = null, int $default_value = 0): ?string
{
$item = new $itemtype();
$field = $field ?? $item::getForeignKeyField();
Expand Down
2 changes: 1 addition & 1 deletion templates/pages/admin/entity/survey_config.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

{{ fields.numberField('inquest_mandatory_comment' ~ config_suffix, inquest_mandatory_comment, __('Comment required if score is <= to'), {
full_width: true,
min: 1,
min: 0,
max: 10,
toadd: {
0: __('Disabled')
Expand Down

0 comments on commit 3b974fd

Please sign in to comment.