Skip to content

Commit

Permalink
Do not show add record button for curvals with add button
Browse files Browse the repository at this point in the history
  • Loading branch information
abeverley committed Oct 6, 2023
1 parent 9cfeb83 commit 13d3724
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
10 changes: 10 additions & 0 deletions lib/GADS/Layout.pm
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ sub record_name_with_article
{ A shift->record_name;
}

# Whether to show the add record button on this table. It is not shown if this
# table is referred to by another table's curval which has an add button,
# unless the current user has manage fields permission on this table.
sub show_add_record
{ my $self = shift;
return 1 if $self->user_can('layout');
return 0 if grep $self->column($_->id)->show_add, @{$self->referred_by};
1;
}

has site => (
is => 'ro',
lazy => 1,
Expand Down
16 changes: 9 additions & 7 deletions views/data_table.tt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
<div class="content-block__info col-lg-6"></div>

<div class="content-block__aside col-lg-6">
<a href="[% url.page %]/[% layout.identifier %]/record/" class="btn btn-add">
[% IF user.has_draft(layout.instance_id) %]
Continue draft record
[% ELSE %]
Add [% layout.record_name_with_article | html %]
[% END %]
</a>
[% IF layout.show_add_record %]
<a href="[% url.page %]/[% layout.identifier %]/record/" class="btn btn-add">
[% IF user.has_draft(layout.instance_id) %]
Continue draft record
[% ELSE %]
Add [% layout.record_name_with_article | html %]
[% END %]
</a>
[% END %]
</div>
</div>

Expand Down

0 comments on commit 13d3724

Please sign in to comment.