From 87e9ccbcdf4f99dd898b0715750092a27fff7e94 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 4 Jul 2014 15:40:54 +0200 Subject: 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. --- app/helpers/link_helper.rb | 25 +++++++++++++++++++++++++ app/helpers/table_helper.rb | 13 +++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 app/helpers/table_helper.rb (limited to 'app/helpers') 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 # diff --git a/app/helpers/table_helper.rb b/app/helpers/table_helper.rb new file mode 100644 index 0000000..16a7019 --- /dev/null +++ b/app/helpers/table_helper.rb @@ -0,0 +1,13 @@ +module TableHelper + + # we do the translation here so the .key lookup is relative + # to the partial the helper was called from. + def table(content, columns) + render 'common/table', + content: content, + columns: columns, + headers: columns.map {|h| t(".#{h}", cascading: true) }, + none: t('.none', cascading: true) + end + +end -- cgit v1.2.3 From bdb4b0e275c205b0b44bbe3cc4ec4c162b309b37 Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 5 Jul 2014 11:41:43 +0200 Subject: make link_to_navigation more generic and reuse it Use link_to_navigation for all important navigation items. It creates a link in a list item for use with bootstrap. It supports an :active flag and an :icon option in the html_options now. It also translates the label. This way it can be used in a lot of places as the generic navigation link. --- app/helpers/navigation_helper.rb | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb index 19cb934..779ce58 100644 --- a/app/helpers/navigation_helper.rb +++ b/app/helpers/navigation_helper.rb @@ -1,19 +1,19 @@ module NavigationHelper # - # used to create a side navigation link. + # Create a navigation link. # - # Signature is the same as link_to, except it accepts an :active value in the html_options + # Signature is the same as link_to, except... + # * it accepts an :active flag in the html_options + # * it accepts an :icon string in the html_options + # * the label (first arg) will be translated # def link_to_navigation(*args) - if args.last.is_a? Hash - html_options = args.pop.dup - active_class = html_options.delete(:active) ? 'active' : nil - html_options[:class] = [html_options[:class], active_class].join(' ') - args << html_options - else - active_class = nil - end + html_options = args.extract_options! || {} + active_class = extract_active_class!(html_options) + icon = extract_icon!(html_options) + args[0] = icon + translate(args[0], cascade: true) + args << html_options if html_options.present? content_tag :li, :class => active_class do link_to(*args) end @@ -59,6 +59,21 @@ module NavigationHelper private + def extract_active_class!(options) + active_class = options.delete(:active) ? 'active' : nil + options[:class] = [options[:class], active_class].compact.join(' ') + active_class + end + + def extract_icon!(options) + icon = options.delete(:icon) + if icon.present? + content_tag(:i, '', class: 'icon-'+ icon) + else + "" + end + end + def controller_string @controller_string ||= params[:controller].to_s.gsub(/^\//, '') end -- cgit v1.2.3 From 0cc11ebb609de225fbeacbf80788b992b88b6ce6 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 9 Jul 2014 12:51:16 +0200 Subject: list identities based on search only --- app/helpers/search_helper.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 app/helpers/search_helper.rb (limited to 'app/helpers') diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb new file mode 100644 index 0000000..35b9358 --- /dev/null +++ b/app/helpers/search_helper.rb @@ -0,0 +1,9 @@ +module SearchHelper + + def search(target) + render 'common/search', path: url_for(target), + id: target.to_s.singularize, + submit_label: t('.search', cascade: true) + end + +end -- cgit v1.2.3