Skip to content

Commit

Permalink
Issue #2360: Removed unnecessary elements from admin modules and temp…
Browse files Browse the repository at this point in the history
…lates for new dynamic fields.
  • Loading branch information
stefanhaerter committed Jul 20, 2023
1 parent c4bf760 commit e9df51c
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 203 deletions.
15 changes: 2 additions & 13 deletions Kernel/Modules/AdminDynamicFieldAgent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ sub _AddAction {
for my $ConfigParam (
qw(
ObjectType ObjectTypeName FieldType FieldTypeName PossibleNone
ValidID Link LinkPreview Tooltip GroupFilter Multiselect MultiValue Namespace
ValidID Tooltip GroupFilter Multiselect MultiValue Namespace
)
)
{
Expand Down Expand Up @@ -217,8 +217,6 @@ sub _AddAction {
# set specific config
my $FieldConfig = {
PossibleNone => $GetParam{PossibleNone},
Link => $GetParam{Link},
LinkPreview => $GetParam{LinkPreview},
Tooltip => $GetParam{Tooltip},
GroupFilter => $GetParam{GroupFilter},
Multiselect => $GetParam{Multiselect},
Expand Down Expand Up @@ -299,8 +297,6 @@ sub _Change {

%Config = (
PossibleNone => $DynamicFieldData->{Config}->{PossibleNone},
Link => $DynamicFieldData->{Config}->{Link},
LinkPreview => $DynamicFieldData->{Config}->{LinkPreview},
GroupFilter => $DynamicFieldData->{Config}->{GroupFilter},
Multiselect => $DynamicFieldData->{Config}->{Multiselect},
MultiValue => $DynamicFieldData->{Config}->{MultiValue},
Expand Down Expand Up @@ -374,7 +370,7 @@ sub _ChangeAction {
for my $ConfigParam (
qw(
ObjectType ObjectTypeName FieldType FieldTypeName PossibleNone
ValidID Link LinkPreview Tooltip GroupFilter Multiselect MultiValue Namespace
ValidID Tooltip GroupFilter Multiselect MultiValue Namespace
)
)
{
Expand Down Expand Up @@ -484,8 +480,6 @@ sub _ChangeAction {
# set specific config
my $FieldConfig = {
PossibleNone => $GetParam{PossibleNone},
Link => $GetParam{Link},
LinkPreview => $GetParam{LinkPreview},
Tooltip => $GetParam{Tooltip},
GroupFilter => $GetParam{GroupFilter},
Multiselect => $GetParam{Multiselect},
Expand Down Expand Up @@ -708,9 +702,6 @@ sub _ShowScreen {
Class => 'Modernize W50pc',
);

my $Link = $Param{Link} || '';
my $LinkPreview = $Param{LinkPreview} || '';

# define tooltip
my $Tooltip = ( defined $Param{Config}->{Tooltip} ? $Param{Config}->{Tooltip} : '' );

Expand Down Expand Up @@ -789,8 +780,6 @@ sub _ShowScreen {
MultiValueStrg => $MultiValueStrg,
PossibleNoneStrg => $PossibleNoneStrg,
ReadonlyInternalField => $ReadonlyInternalField,
Link => $Link,
LinkPreview => $LinkPreview,
Tooltip => $Tooltip,
}
);
Expand Down
15 changes: 2 additions & 13 deletions Kernel/Modules/AdminDynamicFieldCustomerCompany.pm
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ sub _AddAction {
for my $ConfigParam (
qw(
ObjectType ObjectTypeName FieldType FieldTypeName PossibleNone
ValidID Link LinkPreview Tooltip Multiselect MultiValue Namespace
ValidID Tooltip Multiselect MultiValue Namespace
)
)
{
Expand Down Expand Up @@ -217,8 +217,6 @@ sub _AddAction {
# set specific config
my $FieldConfig = {
PossibleNone => $GetParam{PossibleNone},
Link => $GetParam{Link},
LinkPreview => $GetParam{LinkPreview},
Tooltip => $GetParam{Tooltip},
Multiselect => $GetParam{Multiselect},
MultiValue => $GetParam{MultiValue},
Expand Down Expand Up @@ -298,8 +296,6 @@ sub _Change {

%Config = (
PossibleNone => $DynamicFieldData->{Config}->{PossibleNone},
Link => $DynamicFieldData->{Config}->{Link},
LinkPreview => $DynamicFieldData->{Config}->{LinkPreview},
Multiselect => $DynamicFieldData->{Config}->{Multiselect},
MultiValue => $DynamicFieldData->{Config}->{MultiValue},
);
Expand Down Expand Up @@ -372,7 +368,7 @@ sub _ChangeAction {
for my $ConfigParam (
qw(
ObjectType ObjectTypeName FieldType FieldTypeName PossibleNone
ValidID Link LinkPreview Tooltip Multiselect MultiValue Namespace
ValidID Tooltip Multiselect MultiValue Namespace
)
)
{
Expand Down Expand Up @@ -482,8 +478,6 @@ sub _ChangeAction {
# set specific config
my $FieldConfig = {
PossibleNone => $GetParam{PossibleNone},
Link => $GetParam{Link},
LinkPreview => $GetParam{LinkPreview},
Tooltip => $GetParam{Tooltip},
Multiselect => $GetParam{Multiselect},
MultiValue => $GetParam{MultiValue},
Expand Down Expand Up @@ -692,9 +686,6 @@ sub _ShowScreen {
Class => 'Modernize W50pc',
);

my $Link = $Param{Link} || '';
my $LinkPreview = $Param{LinkPreview} || '';

# define tooltip
my $Tooltip = ( defined $Param{Config}->{Tooltip} ? $Param{Config}->{Tooltip} : '' );

Expand Down Expand Up @@ -772,8 +763,6 @@ sub _ShowScreen {
MultiValueStrg => $MultiValueStrg,
PossibleNoneStrg => $PossibleNoneStrg,
ReadonlyInternalField => $ReadonlyInternalField,
Link => $Link,
LinkPreview => $LinkPreview,
Tooltip => $Tooltip,
}
);
Expand Down
106 changes: 8 additions & 98 deletions Kernel/Modules/AdminDynamicFieldCustomerUser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ sub _AddAction {

for my $ConfigParam (
qw(
ObjectType ObjectTypeName FieldType FieldTypeName PossibleNone
ValidID Link LinkPreview Tooltip Multiselect MultiValue Namespace
ObjectType ObjectTypeName FieldType FieldTypeName ValidID Tooltip MultiValue Namespace
)
)
{
Expand Down Expand Up @@ -189,12 +188,6 @@ sub _AddAction {
}
}

# Prepare the multiselect and multivalue parameters
if ( defined $GetParam{Multiselect} ) {
$GetParam{Multiselect} = 'checked=checked';
$GetParam{MultiValue} = 0;
}

my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');

# uncorrectable errors
Expand All @@ -204,54 +197,20 @@ sub _AddAction {
);
}

my $PossibleValues = $Self->_GetPossibleValues();

# set errors for possible values entries
KEY:
for my $Key ( sort keys %{$PossibleValues} ) {

# check for empty original values
if ( $Key =~ m{\A $Self->{EmptyString} (?: \d+)}smx ) {

# set a true entry in KeyEmptyError
$Errors{'PossibleValueErrors'}->{'KeyEmptyError'}->{$Key} = 1;
}

# otherwise check for duplicate original values
elsif ( $Key =~ m{\A (.+) - $Self->{DuplicateString} (?: \d+)}smx ) {

# set an entry in OrigValueDuplicateError with the duplicate key as value
$Errors{'PossibleValueErrors'}->{'KeyDuplicateError'}->{$Key} = $1;
}

# check for empty new values
if ( !defined $PossibleValues->{$Key} ) {

# set a true entry in NewValueEmptyError
$Errors{'PossibleValueErrors'}->{'ValueEmptyError'}->{$Key} = 1;
}
}

# return to add screen if errors
if (%Errors) {
return $Self->_ShowScreen(
%Param,
%Errors,
%GetParam,
PossibleValues => $PossibleValues,
Mode => 'Add',
Mode => 'Add',
);
}

# set specific config
my $FieldConfig = {
PossibleValues => $PossibleValues,
PossibleNone => $GetParam{PossibleNone},
Link => $GetParam{Link},
LinkPreview => $GetParam{LinkPreview},
Tooltip => $GetParam{Tooltip},
Multiselect => $GetParam{Multiselect},
MultiValue => $GetParam{MultiValue},
Tooltip => $GetParam{Tooltip},
MultiValue => $GetParam{MultiValue},
};

# create a new field
Expand Down Expand Up @@ -327,12 +286,7 @@ sub _Change {
if ( IsHashRefWithData( $DynamicFieldData->{Config} ) ) {

%Config = (
PossibleValues => IsHashRefWithData( $DynamicFieldData->{Config}->{PossibleValues} ) ? $DynamicFieldData->{Config}->{PossibleValues} : {},
PossibleNone => $DynamicFieldData->{Config}->{PossibleNone},
Link => $DynamicFieldData->{Config}->{Link},
LinkPreview => $DynamicFieldData->{Config}->{LinkPreview},
Multiselect => $DynamicFieldData->{Config}->{Multiselect},
MultiValue => $DynamicFieldData->{Config}->{MultiValue},
MultiValue => $DynamicFieldData->{Config}->{MultiValue},
);

}
Expand Down Expand Up @@ -402,8 +356,7 @@ sub _ChangeAction {

for my $ConfigParam (
qw(
ObjectType ObjectTypeName FieldType FieldTypeName PossibleNone
ValidID Link LinkPreview Tooltip Multiselect MultiValue Namespace
ObjectType ObjectTypeName FieldType FieldTypeName ValidID Tooltip MultiValue Namespace
)
)
{
Expand Down Expand Up @@ -458,21 +411,13 @@ sub _ChangeAction {
}
}

# Prepare the multiselect and multivalue parameters
if ( defined $GetParam{Multiselect} ) {
$GetParam{Multiselect} = 'checked=checked';
$GetParam{MultiValue} = 0;
}

# uncorrectable errors
if ( !$GetParam{ValidID} ) {
return $LayoutObject->ErrorScreen(
Message => Translatable('Need ValidID'),
);
}

my $PossibleValues = $Self->_GetPossibleValues();

# Check if dynamic field is present in SysConfig setting
my $UpdateEntity = $ParamObject->GetParam( Param => 'UpdateEntity' ) || '';
my $SysConfigObject = $Kernel::OM->Get('Kernel::System::SysConfig');
Expand Down Expand Up @@ -514,13 +459,8 @@ sub _ChangeAction {

# set specific config
my $FieldConfig = {
PossibleValues => $PossibleValues,
PossibleNone => $GetParam{PossibleNone},
Link => $GetParam{Link},
LinkPreview => $GetParam{LinkPreview},
Tooltip => $GetParam{Tooltip},
Multiselect => $GetParam{Multiselect},
MultiValue => $GetParam{MultiValue},
Tooltip => $GetParam{Tooltip},
MultiValue => $GetParam{MultiValue},
};

# update dynamic field (FieldType and ObjectType cannot be changed; use old values)
Expand Down Expand Up @@ -713,22 +653,6 @@ sub _ShowScreen {
Class => 'Modernize W50pc',
);

my $PossibleNone = $Param{PossibleNone} || '0';

# create translatable values option list
my $PossibleNoneStrg = $LayoutObject->BuildSelection(
Data => {
0 => Translatable('No'),
1 => Translatable('Yes'),
},
Name => 'PossibleNone',
SelectedID => $PossibleNone,
Class => 'Modernize W50pc',
);

my $Link = $Param{Link} || '';
my $LinkPreview = $Param{LinkPreview} || '';

# define tooltip
my $Tooltip = ( defined $Param{Config}->{Tooltip} ? $Param{Config}->{Tooltip} : '' );

Expand Down Expand Up @@ -804,10 +728,7 @@ sub _ShowScreen {
ValidityStrg => $ValidityStrg,
DynamicFieldOrderStrg => $DynamicFieldOrderStrg,
MultiValueStrg => $MultiValueStrg,
PossibleNoneStrg => $PossibleNoneStrg,
ReadonlyInternalField => $ReadonlyInternalField,
Link => $Link,
LinkPreview => $LinkPreview,
Tooltip => $Tooltip,
}
);
Expand All @@ -817,15 +738,4 @@ sub _ShowScreen {
return $Output;
}

sub _GetPossibleValues {
my ( $Self, %Param ) = @_;

return {
$Kernel::OM->Get('Kernel::System::CustomerUser')->CustomerSearch(
Search => '*',
Valid => 1
)
};
}

1;
22 changes: 0 additions & 22 deletions Kernel/Output/HTML/Templates/Standard/AdminDynamicFieldAgent.tt
Original file line number Diff line number Diff line change
Expand Up @@ -202,28 +202,6 @@
</div>
<div class="Clear"></div>

<label for="Link">[% Translate("Show link") | html %]:</label>
<div class="Field">
<input id="Link" class="W50pc" type="text" maxlength="500" value="[% Data.Link | html %]" name="Link"/>
<p class="FieldExplanation">
[% Translate("Here you can specify an optional HTTP link for the field value in Overviews and Zoom screens.") | html %]
<br/>
[% Translate("If special characters (&, @, :, /, etc.) should not be encoded, use 'url' instead of 'uri' filter.") | html %]
<br/>
[% Translate("Example") | html %]: http://some.example.com/handle?query=<span>[</span>% Data.Field1 | uri %<span>]</span>
</p>
</div>
<div class="Clear"></div>

<label for="LinkPreview">[% Translate("Link for preview") | html %]:</label>
<div class="Field">
<input id="LinkPreview" class="W50pc" type="text" maxlength="500" value="[% Data.LinkPreview | html %]" name="LinkPreview"/>
<p class="FieldExplanation">
[% Translate("If filled in, this URL will be used for a preview which is shown when this link is hovered in ticket zoom. Please note that for this to work, the regular URL field above needs to be filled in, too.") | html %]
</p>
</div>
<div class="Clear"></div>

<label for="GroupFilter">[% Translate("Filter agents by group") | html %]</label>
<div class="Field">
[% Data.GroupFilterStrg %]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,28 +202,6 @@
</div>
<div class="Clear"></div>

<label for="Link">[% Translate("Show link") | html %]:</label>
<div class="Field">
<input id="Link" class="W50pc" type="text" maxlength="500" value="[% Data.Link | html %]" name="Link"/>
<p class="FieldExplanation">
[% Translate("Here you can specify an optional HTTP link for the field value in Overviews and Zoom screens.") | html %]
<br/>
[% Translate("If special characters (&, @, :, /, etc.) should not be encoded, use 'url' instead of 'uri' filter.") | html %]
<br/>
[% Translate("Example") | html %]: http://some.example.com/handle?query=<span>[</span>% Data.Field1 | uri %<span>]</span>
</p>
</div>
<div class="Clear"></div>

<label for="LinkPreview">[% Translate("Link for preview") | html %]:</label>
<div class="Field">
<input id="LinkPreview" class="W50pc" type="text" maxlength="500" value="[% Data.LinkPreview | html %]" name="LinkPreview"/>
<p class="FieldExplanation">
[% Translate("If filled in, this URL will be used for a preview which is shown when this link is hovered in ticket zoom. Please note that for this to work, the regular URL field above needs to be filled in, too.") | html %]
</p>
</div>
<div class="Clear"></div>

<label for="Multiselect">[% Translate("Multiselect") | html %]</label>
<div class="Field">
<input id="Multiselect" type="checkbox" name="Multiselect" [% Data.Multiselect | html %]/>
Expand Down
Loading

0 comments on commit e9df51c

Please sign in to comment.