From ae9f75fb405fc0a61b79ca4862d9f052a1fb4fea Mon Sep 17 00:00:00 2001 From: jpl Date: Mon, 28 Nov 2016 17:23:20 +0100 Subject: Refs #2019: updating table_builder helper with policies conditions --- app/helpers/newfront_helper.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/helpers/newfront_helper.rb b/app/helpers/newfront_helper.rb index c943b0f76..3d94cebe6 100644 --- a/app/helpers/newfront_helper.rb +++ b/app/helpers/newfront_helper.rb @@ -62,7 +62,22 @@ module NewfrontHelper polymorph_url << item if action == :delete - content_tag :li, link_to(t("table.#{action}"), polymorph_url, method: :delete, data: { confirm: 'Etes-vous sûr(e) de vouloir effectuer cette action ?' }) + if policy(item).present? + if policy(item).destroy? + content_tag :li, link_to(t("table.#{action}"), polymorph_url, method: :delete, data: { confirm: 'Etes-vous sûr(e) de vouloir effectuer cette action ?' }) + end + else + content_tag :li, link_to(t("table.#{action}"), polymorph_url, method: :delete, data: { confirm: 'Etes-vous sûr(e) de vouloir effectuer cette action ?' }) + end + + elsif action == :edit + if policy(item).present? + if policy(item).update? + content_tag :li, link_to(t("table.#{action}"), polymorph_url) + end + else + content_tag :li, link_to(t("table.#{action}"), polymorph_url) + end else content_tag :li, link_to(t("table.#{action}"), polymorph_url) end -- cgit v1.2.3