Skip to content

Commit

Permalink
Added "view all" option to curvals [B: 1734] (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
droberts-ctrlo authored Dec 19, 2024
1 parent 6838fdd commit 574d881
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
15 changes: 14 additions & 1 deletion lib/GADS/Column/Curval.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,20 @@ extends 'GADS::Column::Curcommon';
with 'GADS::Role::Curcommon::CurvalMulti';

has '+option_names' => (
default => sub { [qw/override_permissions value_selector show_add delete_not_used limit_rows/] },
default => sub { [qw/override_permissions value_selector show_add delete_not_used limit_rows show_view_all/] },
);

has show_view_all => (
is => 'rw',
isa => Bool,
lazy => 1,
coerce => sub { $_[0] ? 1 : 0 },
builder => sub {
my $self = shift;
return 0 unless $self->has_options;
$self->options->{show_view_all};
},
trigger => sub { $_[0]->reset_options },
);

has value_selector => (
Expand Down
1 change: 1 addition & 0 deletions lib/GADS/Role/Presentation/Column.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ sub presentation {
return_type => $self->return_type,
show_in_edit => $self->show_in_edit,
has_typeahead => $self->has_filter_typeahead,
show_view_all => $self->has_options && $self->options->{show_view_all},
};

if (my $sort = $options{sort})
Expand Down
22 changes: 22 additions & 0 deletions views/layout.tt
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,28 @@
%]
</div>
</div>
<div class="row">
<div class="col">
<fieldset class="fieldset" >
<div class="fieldset__legend ">
<legend >
Show View All:
</legend>
</div>

<div class="form-group ">
[%
INCLUDE fields/sub/checkbox.tt
id = "show_view_all"
name = "show_view_all"
label = "Always show view all option"
value = 1
checked = column.type == "curval" AND column.show_view_all ? 1 : 0;
%]
</div>
</fieldset>
</div>
</div>
<div class="row">
<div class="col">
[%
Expand Down
15 changes: 11 additions & 4 deletions views/snippets/datum.tt
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,21 @@
[% render_datum(col_inner) %]
</td>
[% END %]
</tr>
</tr>
[% curcommon_row_counter = curcommon_row_counter + 1%]
[% END %]
</table>
[% END %]
<p>
<a href="/[% curval.parent_layout_identifier %]/data?curval_record_id=[% curval.record_id %]&curval_layout_id=[% curval.column_id %]" target="_blank">view all</a>
</p>
[% IF (col.limit_rows AND curval.links.size >= col.limit_rows) OR col.show_view_all %]
<p><em>(showing
[% IF col.limit_rows AND curval.links.size >= col.limit_rows %]
maximum [% col.limit_rows %]
[% ELSE %]
[% curval.links.size %]
[% END %]
row[%IF curval.links.size != 1%]s[%END%].</em>
<a href="/[% curval.parent_layout_identifier %]/data?curval_record_id=[% curval.record_id %]&curval_layout_id=[% curval.column_id %]" target="_blank">view all</a>)</p>
[% END %]
[% END %]

[% MACRO render_curcommon_datum(is_multivalue, curval, header, full_content) BLOCK %]
Expand Down

0 comments on commit 574d881

Please sign in to comment.