Skip to content

Commit

Permalink
Issue #1060: Change how IDSuffix is used for dynamic fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven committed Nov 8, 2021
1 parent ca39f07 commit 9a4e260
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 52 deletions.
34 changes: 21 additions & 13 deletions Kernel/Modules/CustomerTicketProcess.pm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ sub Run {
my $ActivityDialogHashRef;

# extend used ids in html to enable multiple dialogs per page
$Self->{IDSuffix} = $ActivityDialogEntityID ? $ActivityDialogEntityID =~ s/^ActivityDialog-//r : '';
$Self->{IDSuffix} = $ActivityDialogEntityID ? $ActivityDialogEntityID =~ s/^ActivityDialog-/_/r : '';

# get needed objects
my $LayoutObject = $Kernel::OM->Create('Kernel::Output::HTML::Layout');
Expand Down Expand Up @@ -448,7 +448,10 @@ sub _RenderAjax {

# extract the dynamic field value from the web request
$DynamicFieldValues{ $DynamicFieldConfig->{Name} } = $BackendObject->EditFieldValueGet(
DynamicFieldConfig => $DynamicFieldConfig,
DynamicFieldConfig => {
%{ $DynamicFieldConfig },
Name => $DynamicFieldConfig->{Name} . $Self->{IDSuffix},
},
ParamObject => $ParamObject,
LayoutObject => $LayoutObject,
);
Expand Down Expand Up @@ -896,7 +899,10 @@ sub _GetParam {

# Get DynamicField Values
$Value = $BackendObject->EditFieldValueGet(
DynamicFieldConfig => $DynamicFieldConfig,
DynamicFieldConfig => {
%{ $DynamicFieldConfig },
Name => $DynamicFieldConfig->{Name} . $Self->{IDSuffix},
},
ParamObject => $ParamObject,
LayoutObject => $LayoutObject,
);
Expand Down Expand Up @@ -1910,7 +1916,10 @@ sub _RenderDynamicField {
}

my $DynamicFieldHTML = $BackendObject->EditFieldRender(
DynamicFieldConfig => $DynamicFieldConfig,
DynamicFieldConfig => {
%{ $DynamicFieldConfig },
Name => $DynamicFieldConfig->{Name} . $Self->{IDSuffix},
},
PossibleValuesFilter => $PossibleValuesFilter,
Value => $Param{GetParam}{ 'DynamicField_' . $Param{FieldName} },
LayoutObject => $LayoutObject,
Expand All @@ -1921,7 +1930,6 @@ sub _RenderDynamicField {
ServerError => $ServerError,
ErrorMessage => $ErrorMessage,
CustomerInterface => 1,
IDSuffix => $Self->{IDSuffix},
);

my %Data = (
Expand All @@ -1930,12 +1938,6 @@ sub _RenderDynamicField {
Content => $DynamicFieldHTML->{Field},
);

# extend IDs to enable simultaneous activities; might be done directly in the dynamic fields if important at any other place, somewhen
$Data{Content} =~ s/id="([\w\s_]+)"/id="$1_$Self->{IDSuffix}"/g;
if ( $Data{Label} ) {
$Data{Label} =~ s/(id|for)="([\w\s_]+)"/$1="$2_$Self->{IDSuffix}"/g;
}

$LayoutObject->Block(
Name => $Param{ActivityDialogField}->{LayoutBlock} || 'rw:DynamicField',
Data => \%Data,
Expand Down Expand Up @@ -3179,7 +3181,10 @@ sub _StoreActivityDialog {
else {
# Check DynamicField Values
my $ValidationResult = $BackendObject->EditFieldValueValidate(
DynamicFieldConfig => $DynamicFieldConfig,
DynamicFieldConfig => {
%{ $DynamicFieldConfig },
Name => $DynamicFieldConfig->{Name} . $Self->{IDSuffix},
},
PossibleValuesFilter => $PossibleValuesFilter,
ParamObject => $ParamObject,
Mandatory => $ActivityDialog->{Fields}->{$CurrentField}->{Display} == 2,
Expand All @@ -3201,7 +3206,10 @@ sub _StoreActivityDialog {

$TicketParam{$CurrentField} =
$BackendObject->EditFieldValueGet(
DynamicFieldConfig => $DynamicFieldConfig,
DynamicFieldConfig => {
%{ $DynamicFieldConfig },
Name => $DynamicFieldConfig->{Name} . $Self->{IDSuffix},
},
ParamObject => $ParamObject,
LayoutObject => $LayoutObject,
);
Expand Down
14 changes: 5 additions & 9 deletions Kernel/Output/HTML/Layout.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3501,7 +3501,6 @@ Depending on the SysConfig settings the controls to set the date could be multip
# client side with JS
Disabled => 1, # optional (1 or 0), when active select and checkbox controls gets the
# disabled attribute and input fields gets the read only attribute
IDSuffix => '...', # optional, used by CustomerTicketProcess to enable several activities
);
=cut
Expand Down Expand Up @@ -3835,17 +3834,14 @@ sub BuildDateSelection {
Data => $VacationDays,
);

# special suffix for CustomerTicketProcess
my $Suffix = $Param{IDSuffix} ? ' + Core.App.EscapeSelector("_' . $Param{IDSuffix} . '")' : '';

# Add Datepicker JS to output.
my $DatepickerJS = '
Core.UI.Datepicker.Init({
Day: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Day"' . $Suffix . '),
Month: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Month"' . $Suffix . '),
Year: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Year"' . $Suffix . '),
Hour: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Hour"' . $Suffix . '),
Minute: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Minute"' . $Suffix . '),
Day: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Day"),
Month: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Month"),
Year: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Year"),
Hour: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Hour"),
Minute: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Minute"),
VacationDays: ' . $VacationDaysJSON . ',
DateInFuture: ' . ( $ValidateDateInFuture ? 'true' : 'false' ) . ',
DateNotInFuture: ' . ( $ValidateDateNotInFuture ? 'true' : 'false' ) . ',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[% RenderBlockStart("rw:Article") %]
<div class="Row">
<div class="Field">
<input type="text" id="Subject_[% Data.IDSuffix | html %]" name="Subject" value="[% Data.Subject | html %]" class="W75pc [% Data.ValidateRequired | html %] [% Data.SubjectServerError | html %] Validate_DependingRequiredAND Validate_Depending_RichText Validate_Depending_AttachmentExists Validate_Depending_TimeUnits"/>
<input type="text" id="Subject[% Data.IDSuffix | html %]" name="Subject" value="[% Data.Subject | html %]" class="W75pc [% Data.ValidateRequired | html %] [% Data.SubjectServerError | html %] Validate_DependingRequiredAND Validate_Depending_RichText Validate_Depending_AttachmentExists Validate_Depending_TimeUnits"/>
</div>
[% RenderBlockStart("rw:Article:DescriptionLong") %]
<div class="Tooltip">
Expand All @@ -33,26 +33,26 @@
[% RenderBlockStart("rw:Article:DescriptionShort") %]
<p class="FieldExplanation ooo12g">[% Translate(Data.DescriptionShort) | html %]</p>
[% RenderBlockEnd("rw:Article:DescriptionShort") %]
<div id="Subject_[% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="Subject_[% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="Subject[% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="Subject[% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div class="Clear"></div>
</div>

<div class="RichTextHolder">
<textarea id="RichText_[% Data.IDSuffix | html %]" class="RichText [% Data.ValidateRequired | html %] [% Data.BodyServerError | html %] Validate_DependingRequiredAND Validate_Depending_Subject Validate_Depending_AttachmentExists Validate_Depending_TimeUnits" name="Body" rows="15" cols="[% Config("Ticket::Frontend::TextAreaNote") %]">[% Data.Body | html %]</textarea>
<label class="[% Data.MandatoryClass | html %]" for="RichText_[% Data.IDSuffix | html %]">
<textarea id="RichText[% Data.IDSuffix | html %]" class="RichText [% Data.ValidateRequired | html %] [% Data.BodyServerError | html %] Validate_DependingRequiredAND Validate_Depending_Subject Validate_Depending_AttachmentExists Validate_Depending_TimeUnits" name="Body" rows="15" cols="[% Config("Ticket::Frontend::TextAreaNote") %]">[% Data.Body | html %]</textarea>
<label class="[% Data.MandatoryClass | html %]" for="RichText[% Data.IDSuffix | html %]">
[% RenderBlockStart("LabelSpanBody") %]
<span class="Marker">*</span>
[% RenderBlockEnd("LabelSpanBody") %]
[% Data.LabelBody | html %]
</label>
<div id="RichText_[% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="RichText_[% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="RichText[% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="RichText[% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div class="Clear"></div>
</div>

<div class="Row">
<div id="oooAttachments_[% Data.IDSuffix | html %]" class="Field DnDUploadContainer">
<div id="oooAttachments[% Data.IDSuffix | html %]" class="Field DnDUploadContainer">
<div class="DnDUploadBox">
[% INCLUDE "FormElements/CustomerAttachmentList.tt" %]
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<p>[% Translate(Data.DescriptionLong) | html | html_line_break %]</p>
</div>
[% RenderBlockEnd("rw:Priority:DescriptionLong") %]
<label for="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]" class="[% Data.MandatoryClass | html %]">
<label for="[% Data.FieldID | html %][% Data.IDSuffix | html %]" class="[% Data.MandatoryClass | html %]">
[% RenderBlockStart("LabelSpan") %]
<span class="Marker">*</span>
[% RenderBlockEnd("LabelSpan") %]
Expand All @@ -33,8 +33,8 @@
[% RenderBlockStart("rw:Priority:DescriptionShort") %]
<p class="FieldExplanation ooo12g">[% Data.DescriptionShort | html %]</p>
[% RenderBlockEnd("rw:Priority:DescriptionShort") %]
<div id="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %][% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %][% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div class="Clear"></div>
</div>
[% RenderBlockEnd("rw:Priority") %]
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<p>[% Translate(Data.DescriptionLong) | html | html_line_break %]</p>
</div>
[% RenderBlockEnd("rw:Queue:DescriptionLong") %]
<label for="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]" class="[% Data.MandatoryClass | html %]">
<label for="[% Data.FieldID | html %][% Data.IDSuffix | html %]" class="[% Data.MandatoryClass | html %]">
[% RenderBlockStart("LabelSpan") %]
<span class="Marker">*</span>
[% RenderBlockEnd("LabelSpan") %]
Expand All @@ -33,8 +33,8 @@
[% RenderBlockStart("rw:Queue:DescriptionShort") %]
<p class="FieldExplanation ooo12g">[% Translate(Data.DescriptionShort) | html %]</p>
[% RenderBlockEnd("rw:Queue:DescriptionShort") %]
<div id="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %][% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %][% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div class="Clear"></div>
</div>
[% RenderBlockEnd("rw:Queue") %]
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<p>[% Translate(Data.DescriptionLong) | html | html_line_break %]</p>
</div>
[% RenderBlockEnd("rw:SLA:DescriptionLong") %]
<label for="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]" class="[% Data.MandatoryClass | html %]">
<label for="[% Data.FieldID | html %][% Data.IDSuffix | html %]" class="[% Data.MandatoryClass | html %]">
[% RenderBlockStart("LabelSpan") %]
<span class="Marker">*</span>
[% RenderBlockEnd("LabelSpan") %]
Expand All @@ -33,8 +33,8 @@
[% RenderBlockStart("rw:SLA:DescriptionShort") %]
<p class="FieldExplanation ooo12g">[% Data.DescriptionShort %]</p>
[% RenderBlockEnd("rw:SLA:DescriptionShort") %]
<div id="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %][% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %][% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div class="Clear"></div>
</div>
[% RenderBlockEnd("rw:SLA") %]
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<p>[% Translate(Data.DescriptionLong) | html | html_line_break %]</p>
</div>
[% RenderBlockEnd("rw:Service:DescriptionLong") %]
<label for="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]" class="[% Data.MandatoryClass | html %]">
<label for="[% Data.FieldID | html %][% Data.IDSuffix | html %]" class="[% Data.MandatoryClass | html %]">
[% RenderBlockStart("LabelSpan") %]
<span class="Marker">*</span>
[% RenderBlockEnd("LabelSpan") %]
Expand All @@ -33,8 +33,8 @@
[% RenderBlockStart("rw:Service:DescriptionShort") %]
<p class="FieldExplanation ooo12g">[% Translate(Data.DescriptionShort) | html %]</p>
[% RenderBlockEnd("rw:Service:DescriptionShort") %]
<div id="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %][% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %][% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div class="Clear"></div>
</div>
[% RenderBlockEnd("rw:Service") %]
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<p>[% Translate(Data.DescriptionLong) | html | html_line_break %]</p>
</div>
[% RenderBlockEnd("rw:State:DescriptionLong") %]
<label for="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]" class="[% Data.MandatoryClass | html %]">
<label for="[% Data.FieldID | html %][% Data.IDSuffix | html %]" class="[% Data.MandatoryClass | html %]">
[% RenderBlockStart("LabelSpan") %]
<span class="Marker">*</span>
[% RenderBlockEnd("LabelSpan") %]
Expand All @@ -33,8 +33,8 @@
[% RenderBlockStart("rw:State:DescriptionShort") %]
<p class="FieldExplanation ooo12g">[% Translate(Data.DescriptionShort) | html %]</p>
[% RenderBlockEnd("rw:State:DescriptionShort") %]
<div id="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %][% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %][% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div class="Clear"></div>
</div>
[% RenderBlockEnd("rw:State") %]
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
[% RenderBlockStart("rw:Title") %]
<div class="Row">
<div class="Field">
<input class="W50pc DynamicFieldText [% Data.ValidateRequired | html %] [% Data.ServerError | html %]" type="text" name="[% Data.FieldID | html %]" id="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]" value="[% Data.Value | html %]"/>
<input class="W50pc DynamicFieldText [% Data.ValidateRequired | html %] [% Data.ServerError | html %]" type="text" name="[% Data.FieldID | html %]" id="[% Data.FieldID | html %][% Data.IDSuffix | html %]" value="[% Data.Value | html %]"/>
</div>
[% RenderBlockStart("rw:Title:DescriptionLong") %]
<div class="Tooltip">
<i class="ooofo ooofo-help"></i>
<p>[% Translate(Data.DescriptionLong) | html | html_line_break %]</p>
</div>
[% RenderBlockEnd("rw:Title:DescriptionLong") %]
<label for="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]" class="[% Data.MandatoryClass | html %]">
<label for="[% Data.FieldID | html %][% Data.IDSuffix | html %]" class="[% Data.MandatoryClass | html %]">
[% RenderBlockStart("LabelSpan") %]
<span class="Marker">*</span>
[% RenderBlockEnd("LabelSpan") %]
Expand All @@ -33,8 +33,8 @@
[% RenderBlockStart("rw:Title:DescriptionShort") %]
<p class="FieldExplanation ooo12g">[% Translate(Data.DescriptionShort) | html %]</p>
[% RenderBlockEnd("rw:Title:DescriptionShort") %]
<div id="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %]_[% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %][% Data.IDSuffix | html %]Error" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div id="[% Data.FieldID | html %][% Data.IDSuffix | html %]ServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
<div class="Clear"></div>
</div>
[% RenderBlockEnd("rw:Title") %]
Loading

0 comments on commit 9a4e260

Please sign in to comment.