Skip to content

Commit

Permalink
Merge branch '6.0/canonicalize-page-layout-widgets'
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrandtbuffalo committed Feb 28, 2025
2 parents a84745c + 6b9d3ad commit e9321ae
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions share/html/Elements/EditPageLayout
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,20 @@ my $widget_key = sub {
};

my %available_widgets = map { $widget_key->($_) => $_ } @AvailableWidgets;
my $canonicalize_widget = sub {
my $widget = shift;
my $key = $widget_key->($widget);
return unless $available_widgets{$key};

# For references, %available_widgets contains full info.
# For strings, use the original version as it might contain argument.
if ( ref $available_widgets{$key} ) {
return $available_widgets{$key};
}
else {
return $widget;
}
};

my @rows;
my @items;
Expand All @@ -263,7 +277,7 @@ for my $item (@$Content) {
Title => $item->{Title},
Layout => $item->{Layout},
Class => $column_classes[ $col % @column_classes ],
Elements => [ grep { $available_widgets{ $widget_key->($_) } } @{ $item->{Elements}[$col] } ],
Elements => [ map { $canonicalize_widget->($_) } @{ $item->{Elements}[$col] } ],
};
}
push @rows, $new_row;
Expand All @@ -274,12 +288,12 @@ for my $item (@$Content) {
Title => $item->{Title},
Layout => $item->{Layout},
Classes => \@column_classes,
Elements => [ grep { $available_widgets{ $widget_key->($_) } } @{ $item->{Elements} } ],
Elements => [ map { $canonicalize_widget->($_) } @{ $item->{Elements} } ],
};
}
}
else {
push @items, $item if $available_widgets{ $widget_key->($item) };
push @items, $canonicalize_widget->($item);
}
}
push @rows, \@items if @items;
Expand Down

0 comments on commit e9321ae

Please sign in to comment.