Skip to content

Commit

Permalink
Issue #2251: Adjusted dynamic field drivers to pass on readonly attri…
Browse files Browse the repository at this point in the history
…bute.
  • Loading branch information
stefanhaerter committed Feb 6, 2024
1 parent c2bb8c3 commit aa2c348
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 15 deletions.
4 changes: 3 additions & 1 deletion Kernel/System/DynamicField/Driver/BaseDatabase.pm
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,9 @@ sub EditFieldValueGet {
my @Data = $Param{ParamObject}->GetArray( Param => $FieldName );

# delete the template value
pop @Data;
if ( !$Param{DynamicFieldConfig}->{Readonly} ) {
pop @Data;
}

$Value = \@Data;
}
Expand Down
2 changes: 1 addition & 1 deletion Kernel/System/DynamicField/Driver/BaseDateTime.pm
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ sub EditFieldValueGet {
&& ref $Param{ParamObject} eq 'Kernel::System::Web::Request'
)
{
if ( $Param{DynamicFieldConfig}->{Config}->{MultiValue} ) {
if ( $Param{DynamicFieldConfig}->{Config}{MultiValue} ) {
my %Data;

# retrieve value parts as arrays
Expand Down
7 changes: 3 additions & 4 deletions Kernel/System/DynamicField/Driver/BaseEntity.pm
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ sub EditFieldRender {
my $FieldID = $FieldName . '_' . $ValueIndex;
push @SelectionHTML, $Param{LayoutObject}->BuildSelection(
Data => $PossibleValues || {},
Disabled => $Param{Readonly},
Readonly => $Param{Readonly},
Name => $FieldName,
ID => $FieldID,
SelectedID => $Value->[$ValueIndex],
Expand All @@ -289,7 +289,7 @@ sub EditFieldRender {
my @SelectedIDs = grep {$_} $Value->@*;
push @SelectionHTML, $Param{LayoutObject}->BuildSelection(
Data => $PossibleValues || {},
Disabled => $Param{Readonly},
Readonly => $Param{Readonly},
Name => $FieldName,
SelectedID => \@SelectedIDs,
Class => $FieldClass,
Expand Down Expand Up @@ -338,7 +338,6 @@ sub EditFieldRender {

my $SelectionHTML = $Param{LayoutObject}->BuildSelection(
Data => $PossibleValues || {},
Disabled => $Param{Readonly},
Name => $FieldName,
ID => $FieldTemplateData{FieldID},
Translation => $FieldConfig->{TranslatableValues} || 0,
Expand Down Expand Up @@ -421,7 +420,7 @@ sub EditFieldValueGet {
{
my @Data = $Param{ParamObject}->GetArray( Param => $FieldName );

if ( $Param{DynamicFieldConfig}->{Config}{MultiValue} ) {
if ( $Param{DynamicFieldConfig}->{Config}{MultiValue} && !$Param{DynamicFieldConfig}->{Readonly} ) {

# delete the template value
pop @Data;
Expand Down
4 changes: 3 additions & 1 deletion Kernel/System/DynamicField/Driver/BaseScript.pm
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ sub EditFieldValueGet {
)
{
$Value = $Param{ParamObject}->GetParam( Param => $FieldName );
if ( $Param{DynamicFieldConfig}->{Config}->{MultiValue} ) {

# TODO check what happens with template data
if ( $Param{DynamicFieldConfig}->{Config}{MultiValue} ) {
my @DataAll = $Param{ParamObject}->GetArray( Param => $FieldName );
my @Data;

Expand Down
6 changes: 4 additions & 2 deletions Kernel/System/DynamicField/Driver/BaseSelect.pm
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ sub EditFieldRender {

my $SelectionHTML = $Param{LayoutObject}->BuildSelection(
Data => $DataValues || {},
Disabled => $Param{Readonly},
Readonly => $Param{Readonly},
Name => $FieldName,
ID => $FieldID,
SelectedID => $Value->[$ValueIndex],
Expand Down Expand Up @@ -473,7 +473,9 @@ sub EditFieldValueGet {
my @Data;

# delete the template value
pop @DataAll;
if ( !$Param{DynamicFieldConfig}->{Readonly} ) {
pop @DataAll;
}

for my $Item (@DataAll) {
push @Data, $Item // '';
Expand Down
4 changes: 3 additions & 1 deletion Kernel/System/DynamicField/Driver/BaseText.pm
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ sub EditFieldValueGet {
my @Data;

# delete the template value
pop @DataAll;
if ( !$Param{DynamicFieldConfig}->{Readonly} ) {
pop @DataAll;
}

# delete empty values (can happen if the user has selected the "-" entry)
for my $Item (@DataAll) {
Expand Down
2 changes: 1 addition & 1 deletion Kernel/System/DynamicField/Driver/Checkbox.pm
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ sub EditFieldValueGet {
&& ref $Param{ParamObject} eq 'Kernel::System::Web::Request'
)
{
if ( $Param{DynamicFieldConfig}->{Config}->{MultiValue} ) {
if ( $Param{DynamicFieldConfig}->{Config}{MultiValue} ) {
my @DataValues = $Param{ParamObject}->GetArray( Param => $FieldName );
my @DataUsed = $Param{ParamObject}->GetArray( Param => $FieldName . 'Used' );

Expand Down
2 changes: 1 addition & 1 deletion Kernel/System/DynamicField/Driver/Date.pm
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ sub EditFieldValueGet {
&& ref $Param{ParamObject} eq 'Kernel::System::Web::Request'
)
{
if ( $Param{DynamicFieldConfig}->{Config}->{MultiValue} ) {
if ( $Param{DynamicFieldConfig}->{Config}{MultiValue} ) {
my %Data;

# retrieve value parts as arrays
Expand Down
8 changes: 5 additions & 3 deletions Kernel/System/DynamicField/Driver/WebService.pm
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ sub EditFieldRender {

my $SelectionHTML = $Param{LayoutObject}->BuildSelection(
Data => $DataValues || {},
Disabled => $Param{Readonly},
Readonly => $Param{Readonly},
Name => $FieldName,
ID => $FieldID,
SelectedID => $Value->[$ValueIndex],
Expand Down Expand Up @@ -406,10 +406,12 @@ sub EditFieldValueGet {
{
my @Data = $Param{ParamObject}->GetArray( Param => $FieldName );

if ( $Param{DynamicFieldConfig}->{Config}->{MultiValue} ) {
if ( $Param{DynamicFieldConfig}->{Config}{MultiValue} ) {

# delete the template value
pop @Data;
if ( !$Param{DynamicFieldConfig}->{Readonly} ) {
pop @Data;
}
$Value = \@Data;

}
Expand Down

0 comments on commit aa2c348

Please sign in to comment.