aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorcedricnjanga2018-01-23 22:46:16 -0800
committercedricnjanga2018-01-23 22:46:16 -0800
commit0f59b9c1d0133393f68194a366aafc27ca23392b (patch)
treeab04bbd04b977a683ee181f0b0bc38c47c2db7f0 /app/helpers
parent5ecadfdead964381304fcf56a2564e2045988ef7 (diff)
downloadchouette-core-0f59b9c1d0133393f68194a366aafc27ca23392b.tar.bz2
First draft for including calendars into workgroup for having appropriate scoping
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/table_builder_helper.rb8
-rw-r--r--app/helpers/table_builder_helper/custom_links.rb7
-rw-r--r--app/helpers/table_builder_helper/url.rb5
3 files changed, 14 insertions, 6 deletions
diff --git a/app/helpers/table_builder_helper.rb b/app/helpers/table_builder_helper.rb
index dede51920..9ead7180a 100644
--- a/app/helpers/table_builder_helper.rb
+++ b/app/helpers/table_builder_helper.rb
@@ -308,7 +308,7 @@ module TableBuilderHelper
menu = content_tag :ul, class: 'dropdown-menu' do
(
- CustomLinks.new(item, pundit_user, links, referential).links +
+ CustomLinks.new(item, pundit_user, links, referential, workgroup).links +
item.action_links.select { |link| link.is_a?(Link) }
).map do |link|
gear_menu_link(link)
@@ -391,4 +391,10 @@ module TableBuilderHelper
# cases, avoid a `NoMethodError`.
@__referential__ ||= try(:current_referential)
end
+
+ def workgroup
+ # Certain controllers don't define a `#current_referential`. In these
+ # cases, avoid a `NoMethodError`.
+ @__workgroup__ ||= try(:current_workgroup)
+ end
end
diff --git a/app/helpers/table_builder_helper/custom_links.rb b/app/helpers/table_builder_helper/custom_links.rb
index b1bb11f10..e09078be0 100644
--- a/app/helpers/table_builder_helper/custom_links.rb
+++ b/app/helpers/table_builder_helper/custom_links.rb
@@ -8,13 +8,14 @@ module TableBuilderHelper
unarchive: :put
}
- attr_reader :actions, :object, :user_context, :referential
+ attr_reader :actions, :object, :user_context, :referential, :workgroup
- def initialize(object, user_context, actions, referential = nil)
+ def initialize(object, user_context, actions, referential = nil, workgroup = nil)
@object = object
@user_context = user_context
@actions = actions
@referential = referential
+ @workgroup = workgroup
end
def links
@@ -34,7 +35,7 @@ module TableBuilderHelper
polymorph_url << action
end
- polymorph_url += URL.polymorphic_url_parts(object, referential)
+ polymorph_url += URL.polymorphic_url_parts(object, referential, workgroup)
end
def method_for_action(action)
diff --git a/app/helpers/table_builder_helper/url.rb b/app/helpers/table_builder_helper/url.rb
index 28f1ade76..40e1f839f 100644
--- a/app/helpers/table_builder_helper/url.rb
+++ b/app/helpers/table_builder_helper/url.rb
@@ -1,9 +1,9 @@
module TableBuilderHelper
class URL
- def self.polymorphic_url_parts(item, referential)
+ def self.polymorphic_url_parts(item, referential, workgroup)
polymorph_url = []
- unless item.is_a?(Calendar) || item.is_a?(Referential) || item.is_a?(ComplianceControlSet)
+ unless item.is_a?(Referential) || item.is_a?(ComplianceControlSet)
if referential
polymorph_url << referential
polymorph_url << item.line if item.respond_to? :line
@@ -20,6 +20,7 @@ module TableBuilderHelper
end
end
else
+ polymorph_url << item.workgroup if item.is_a?(Calendar)
polymorph_url << item
end