Skip to content

Commit 4ca2779

Browse files
Fix ticket title/description edition (#19727)
* Fix ticket title/description edition * Apply suggestions from code review Co-authored-by: Cédric Anne <cedric.anne@gmail.com> * Fix typo --------- Co-authored-by: Cédric Anne <cedric.anne@gmail.com>
1 parent fe1e599 commit 4ca2779

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

phpunit/functional/TicketTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8680,4 +8680,31 @@ public function testConditionalSearchOptions()
86808680
SearchOption::clearSearchOptionCache(Ticket::class);
86818681
$this->assertArrayNotHasKey('111', SearchOption::getCleanedOptions(Ticket::class));
86828682
}
8683+
8684+
public function testShowSubForm(): void
8685+
{
8686+
// Arrange: create a ticket
8687+
$ticket = $this->createItem(Ticket::class, [
8688+
'name' => 'My ticket',
8689+
'content' => 'My content',
8690+
'entities_id' => $this->getTestRootEntity(only_id: true),
8691+
]);
8692+
8693+
// Act: render sub form for this ticket
8694+
$this->login();
8695+
ob_start();
8696+
Ticket::showSubForm($ticket, $ticket->getId(), [
8697+
// Note: these parameters are ugly (ticket is both the target and
8698+
// the parent somehow) but this is how its called from the actual
8699+
// front files so we need to replicate it.
8700+
'parent' => $ticket,
8701+
'tickets_id' => $ticket->getID(),
8702+
]);
8703+
$html = ob_get_clean();
8704+
8705+
// Assert: make sure some html was generated
8706+
$crawler = new Crawler($html);
8707+
$this->assertCount(1, $crawler->filter('input[name="name"]'));
8708+
$this->assertCount(1, $crawler->filter('textarea[name="content"]'));
8709+
}
86838710
}

templates/components/form/basic_inputs_macros.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@
382382
</script>
383383
{% endif %}
384384

385-
{% if options.mention_options.enabled and config('use_notifications') %}
385+
{% if options.mention_options.enabled|default(false) and config('use_notifications') %}
386386
<script>
387387
$(function() {
388388
const user_mention = new GLPI.RichText.UserMention(

templates/components/form/fields_macros.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@
797797
{% set field = field|replace({'%id%': id}) %}
798798
{% set add_field_html = options.add_field_html|length > 0 ? options.add_field_html : '' %}
799799

800-
{% if options.fields_template is not defined or not options.fields_template.isHiddenField(name) %}
800+
{% if not options.fields_template.isHiddenField(name)|default(false) %}
801801
{% if options.no_label %}
802802
{{ _self.noLabelField(field, id, add_field_html, options) }}
803803
{% elseif options.is_horizontal %}

templates/components/itilobject/timeline/simple_form.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
{% set field_options = {
4040
'is_horizontal': false,
4141
'full_width': true,
42-
'fields_template': itiltemplate,
42+
'fields_template': itiltemplate|default(null),
4343
'disabled': (not (canupdate or can_requester)),
4444
} %}
4545

@@ -86,8 +86,8 @@
8686
__('Description'),
8787
field_options|merge({
8888
'enable_richtext': true,
89-
'enable_fileupload': (itiltemplate.isHiddenField('_documents_id')) ? false : true,
90-
'mention_options': mention_options,
89+
'enable_fileupload': itiltemplate.isHiddenField('_documents_id')|default(false) ? false : true,
90+
'mention_options': mention_options|default({}),
9191
'entities_id': item.isNewItem() ? entities_id : item.fields['entities_id'],
9292
'uploads': uploads,
9393
'add_field_class': 'col-12 itil-textarea-content',

0 commit comments

Comments
 (0)