summaryrefslogtreecommitdiff
path: root/app/helpers/link_helper.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-07-04 15:40:54 +0200
committerAzul <azul@leap.se>2014-07-05 10:21:07 +0200
commit87e9ccbcdf4f99dd898b0715750092a27fff7e94 (patch)
tree9e49a287c6e95d92323253d899afa367a6f1e14e /app/helpers/link_helper.rb
parent24d108e15c38ca572d5339a39cb110d9067c0b3d (diff)
Enable unblocking handles in identities tab
There's an identities tab now for admins that will allow unblocking blocked handles. It should be easy to expand for aliases and forwards and other types of actions such as editing.
Diffstat (limited to 'app/helpers/link_helper.rb')
-rw-r--r--app/helpers/link_helper.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb
index 55e392b..ddb063e 100644
--- a/app/helpers/link_helper.rb
+++ b/app/helpers/link_helper.rb
@@ -1,5 +1,30 @@
module LinkHelper
+ Action = Struct.new(:target, :verb, :options) do
+ def to_partial_path; 'common/action'; end
+ def label; options[:label]; end
+ def class; verb; end
+ def url
+ case verb
+ when :show, :destroy then target
+ when :edit, :new then [verb, target]
+ end
+ end
+
+ def html_options
+ if verb == :destroy
+ {method: :delete}
+ end
+ end
+ end
+
+ def actions(target)
+ target.actions.map do |action|
+ Action.new target, action,
+ label: t(".#{action}", cascade: true)
+ end
+ end
+
#
# markup for bootstrap button
#