Skip to content

Commit 574d881

Browse files
Added "view all" option to curvals [B: 1734] (#498)
1 parent 6838fdd commit 574d881

File tree

4 files changed

+48
-5
lines changed

4 files changed

+48
-5
lines changed

lib/GADS/Column/Curval.pm

+14-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,20 @@ extends 'GADS::Column::Curcommon';
3030
with 'GADS::Role::Curcommon::CurvalMulti';
3131

3232
has '+option_names' => (
33-
default => sub { [qw/override_permissions value_selector show_add delete_not_used limit_rows/] },
33+
default => sub { [qw/override_permissions value_selector show_add delete_not_used limit_rows show_view_all/] },
34+
);
35+
36+
has show_view_all => (
37+
is => 'rw',
38+
isa => Bool,
39+
lazy => 1,
40+
coerce => sub { $_[0] ? 1 : 0 },
41+
builder => sub {
42+
my $self = shift;
43+
return 0 unless $self->has_options;
44+
$self->options->{show_view_all};
45+
},
46+
trigger => sub { $_[0]->reset_options },
3447
);
3548

3649
has value_selector => (

lib/GADS/Role/Presentation/Column.pm

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ sub presentation {
5959
return_type => $self->return_type,
6060
show_in_edit => $self->show_in_edit,
6161
has_typeahead => $self->has_filter_typeahead,
62+
show_view_all => $self->has_options && $self->options->{show_view_all},
6263
};
6364

6465
if (my $sort = $options{sort})

views/layout.tt

+22
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,28 @@
10451045
%]
10461046
</div>
10471047
</div>
1048+
<div class="row">
1049+
<div class="col">
1050+
<fieldset class="fieldset" >
1051+
<div class="fieldset__legend ">
1052+
<legend >
1053+
Show View All:
1054+
</legend>
1055+
</div>
1056+
1057+
<div class="form-group ">
1058+
[%
1059+
INCLUDE fields/sub/checkbox.tt
1060+
id = "show_view_all"
1061+
name = "show_view_all"
1062+
label = "Always show view all option"
1063+
value = 1
1064+
checked = column.type == "curval" AND column.show_view_all ? 1 : 0;
1065+
%]
1066+
</div>
1067+
</fieldset>
1068+
</div>
1069+
</div>
10481070
<div class="row">
10491071
<div class="col">
10501072
[%

views/snippets/datum.tt

+11-4
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,21 @@
2525
[% render_datum(col_inner) %]
2626
</td>
2727
[% END %]
28-
</tr>
28+
</tr>
2929
[% curcommon_row_counter = curcommon_row_counter + 1%]
3030
[% END %]
3131
</table>
3232
[% END %]
33-
<p>
34-
<a href="/[% curval.parent_layout_identifier %]/data?curval_record_id=[% curval.record_id %]&curval_layout_id=[% curval.column_id %]" target="_blank">view all</a>
35-
</p>
33+
[% IF (col.limit_rows AND curval.links.size >= col.limit_rows) OR col.show_view_all %]
34+
<p><em>(showing
35+
[% IF col.limit_rows AND curval.links.size >= col.limit_rows %]
36+
maximum [% col.limit_rows %]
37+
[% ELSE %]
38+
[% curval.links.size %]
39+
[% END %]
40+
row[%IF curval.links.size != 1%]s[%END%].</em>
41+
<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>
42+
[% END %]
3643
[% END %]
3744

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

0 commit comments

Comments
 (0)