From 13d3724914bc241ba6e230d2f3b2df2c707af39e Mon Sep 17 00:00:00 2001 From: Andy Beverley Date: Fri, 6 Oct 2023 17:13:15 +0100 Subject: [PATCH] Do not show add record button for curvals with add button --- lib/GADS/Layout.pm | 10 ++++++++++ views/data_table.tt | 16 +++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/GADS/Layout.pm b/lib/GADS/Layout.pm index 42b141e7b..6bfae2f80 100644 --- a/lib/GADS/Layout.pm +++ b/lib/GADS/Layout.pm @@ -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, diff --git a/views/data_table.tt b/views/data_table.tt index a0ed44055..e85ac4209 100755 --- a/views/data_table.tt +++ b/views/data_table.tt @@ -4,13 +4,15 @@
- - [% IF user.has_draft(layout.instance_id) %] - Continue draft record - [% ELSE %] - Add [% layout.record_name_with_article | html %] - [% END %] - + [% IF layout.show_add_record %] + + [% IF user.has_draft(layout.instance_id) %] + Continue draft record + [% ELSE %] + Add [% layout.record_name_with_article | html %] + [% END %] + + [% END %]