Skip to content

Commit

Permalink
Issue #1060: Fix Datepicker? TODO: Check whether this works for savin…
Browse files Browse the repository at this point in the history
…g stuff, etc.
  • Loading branch information
Sven committed Nov 8, 2021
1 parent 8babcad commit 52ed031
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions Kernel/Modules/CustomerTicketProcess.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1921,6 +1921,7 @@ sub _RenderDynamicField {
ServerError => $ServerError,
ErrorMessage => $ErrorMessage,
CustomerInterface => 1,
IDSuffix => $Self->{IDSuffix},
);

my %Data = (
Expand All @@ -1930,8 +1931,10 @@ sub _RenderDynamicField {
);

# 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}"/;
$Data{Label} =~ s/(id|for)="([\w\s_]+)"/$1="$2_$Self->{IDSuffix}"/;
$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',
Expand Down
14 changes: 9 additions & 5 deletions Kernel/Output/HTML/Layout.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3501,6 +3501,7 @@ 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 @@ -3834,14 +3835,17 @@ 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"),
Month: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Month"),
Year: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Year"),
Hour: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Hour"),
Minute: $("#" + Core.App.EscapeSelector("' . $Prefix . '") + "Minute"),
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 . '),
VacationDays: ' . $VacationDaysJSON . ',
DateInFuture: ' . ( $ValidateDateInFuture ? 'true' : 'false' ) . ',
DateNotInFuture: ' . ( $ValidateDateNotInFuture ? 'true' : 'false' ) . ',
Expand Down

0 comments on commit 52ed031

Please sign in to comment.