Module: ApplicationHelper
- Included in:
- TopContainersController
- Defined in:
- frontend/app/helpers/application_helper.rb
Instance Method Summary (collapse)
-
- (Object) add_new_event_url(record)
-
- (Object) button_confirm_action(label, target, opts = {})
-
- (Object) button_delete_action(url, opts = {})
-
- (Object) button_delete_multiple_action(target_action)
-
- (Object) button_edit_multiple_action(target_controller, target_action = :batch, opts = {})
-
- (Object) clean_mixed_content(content)
-
- (Object) current_repo
-
- (Object) current_user
-
- (Object) display_audit_info(hash, opts = {})
-
- (Boolean) has_permission_for_controller?(session, name)
-
- (Object) include_controller_js
-
- (Object) include_theme_css
-
- (Boolean) inline?
-
- (Object) link_to_help(opts = {})
-
- (Boolean) proxy_localhost?
-
- (Object) render_aspace_partial(args)
See: ApplicationController#render_aspace_partial.
-
- (Object) render_token(opts)
-
- (Object) set_title(title)
-
- (Object) setup_context(options)
-
- (Boolean) show_external_ids?
-
- (Object) wrap_with_tooltip(text, i18n_path, classes)
Instance Method Details
- (Object) add_new_event_url(record)
268 269 270 271 272 273 274 |
# File 'frontend/app/helpers/application_helper.rb', line 268 def add_new_event_url(record) if record.jsonmodel_type == "agent" url_for(:controller => :events, :action => :new, :agent_uri => record.uri, :event_type => "${event_type") else url_for(:controller => :events, :action => :new, :record_uri => record.uri, :record_type => record.jsonmodel_type, :event_type => "${event_type}") end end |
- (Object) button_confirm_action(label, target, opts = {})
164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'frontend/app/helpers/application_helper.rb', line 164 def (label, target, opts = {}) btn_opts = { :"data-target" => target, :method => :post, :class => "btn", :"data-confirmation" => true, :"data-authenticity_token" => form_authenticity_token, :type => "button" }.merge(opts) (label, btn_opts) end |
- (Object) button_delete_action(url, opts = {})
178 179 180 181 182 183 184 185 186 187 188 |
# File 'frontend/app/helpers/application_helper.rb', line 178 def (url, opts = {}) (opts[:label] || I18n.t("actions.delete"), url, { :class => "btn btn-sm btn-danger delete-record", :"data-title" => I18n.t("actions.delete_confirm_title"), :"data-message" => I18n.t("actions.delete_confirm_message"), :"data-confirm-btn-label" => "#{I18n.t("actions.delete")}", :"data-confirm-btn-class" => "btn-danger" }.merge(opts)) end |
- (Object) button_delete_multiple_action(target_action)
191 192 193 194 195 196 197 198 199 200 |
# File 'frontend/app/helpers/application_helper.rb', line 191 def (target_action) (url_for(:controller => :batch_delete, :action => target_action), { :class => "btn btn-sm btn-danger multiselect-enabled", :"data-multiselect" => "#tabledSearchResults", :"data-title" => I18n.t("actions.delete_multiple_confirm_title"), :"data-message" => I18n.t("actions.delete_multiple_confirm_message"), :"data-confirm-btn-label" => "#{I18n.t("actions.delete_multiple")}", :disabled => "disabled" }) end |
- (Object) button_edit_multiple_action(target_controller, target_action = :batch, opts = {})
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'frontend/app/helpers/application_helper.rb', line 202 def (target_controller, target_action = :batch, opts = {} ) label = opts[:label] || I18n.t("actions.edit_batch") btn_opts = { :"data-target" => url_for(:controller => target_controller, :action => target_action), :class => "btn btn-sm btn-default multiselect-enabled edit-batch", :method => "post", :type => "button", :"data-multiselect" => "#tabledSearchResults", :"data-confirmation" => true, :"data-title" => I18n.t("actions.edit_multiple_confirm_title"), :"data-message" => I18n.t("actions.edit_multiple_confirm_message"), :"data-confirm-btn-label" => "#{I18n.t("actions.edit_multiple")}", :"data-authenticity_token" => form_authenticity_token, :disabled => "disabled" }.merge(opts) (label, btn_opts) end |
- (Object) clean_mixed_content(content)
258 259 260 261 262 |
# File 'frontend/app/helpers/application_helper.rb', line 258 def clean_mixed_content(content) content = content.to_s return content if content.blank? MixedContentParser::parse(content, url_for(:root), { :wrap_blocks => false } ).to_s.html_safe end |
- (Object) current_repo
126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'frontend/app/helpers/application_helper.rb', line 126 def current_repo return nil if session[:repo].blank? return @current_repo if @current_repo != nil @current_repo = false MemoryLeak::Resources.get(:repository).each do |repo| @current_repo = repo if repo['uri'] === session[:repo] end @current_repo end |
- (Object) current_user
140 141 142 |
# File 'frontend/app/helpers/application_helper.rb', line 140 def current_user session[:user] end |
- (Object) display_audit_info(hash, opts = {})
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'frontend/app/helpers/application_helper.rb', line 221 def display_audit_info(hash, opts = {}) fmt = opts[:format] || 'wide' html = "<div class='audit-display-#{fmt}'><small>" if hash['create_time'] and hash['user_mtime'] if fmt == 'wide' html << "<strong>#{I18n.t("search_results.created")} #{hash['created_by']}</strong>" html << " #{Time.parse(hash['create_time']).getlocal}, " html << "<strong>#{I18n.t("search_results.modified")} #{hash['last_modified_by']}</strong>" html << " #{Time.parse(hash['user_mtime']).getlocal}" else html << "<dl>" html << "<dt>#{I18n.t("search_results.created")} #{hash['created_by']}</dt>" html << "<dd>#{Time.parse(hash['create_time']).getlocal}</dd>" html << "<dt>#{I18n.t("search_results.modified")} #{hash['last_modified_by']}</dt>" html << "<dd>#{Time.parse(hash['user_mtime']).getlocal}</dd>" html << "</dl>" end end html << "</small></div><div class='clearfix'></div>" html.html_safe end |
- (Boolean) has_permission_for_controller?(session, name)
244 245 246 247 248 249 |
# File 'frontend/app/helpers/application_helper.rb', line 244 def (session, name) controller_class_name = "#{name}_controller".classify controller_class = Kernel.const_get(controller_class_name) controller_class.can_access?(self, :index) end |
- (Object) include_controller_js
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'frontend/app/helpers/application_helper.rb', line 5 def include_controller_js scripts = "" scripts += javascript_include_tag "#{controller.controller_name}" if File.exists?("#{Rails.root}/app/assets/javascripts/#{controller_name}.js") || File.exists?("#{Rails.root}/app/assets/javascripts/#{controller_name}.js.erb") scripts += javascript_include_tag "#{controller.controller_name}.#{controller.action_name}" if File.exists?("#{Rails.root}/app/assets/javascripts/#{controller_name}.#{controller.action_name}.js") || File.exists?("#{Rails.root}/app/assets/javascripts/#{controller_name}.#{controller.action_name}.js.erb") if ["new", "create", "edit", "update"].include?(controller.action_name) scripts += javascript_include_tag "#{controller.controller_name}.crud" if File.exists?("#{Rails.root}/app/assets/javascripts/#{controller_name}.crud.js") || File.exists?("#{Rails.root}/app/assets/javascripts/#{controller_name}.crud.js.erb") end if ["batch_create"].include?(controller.action_name) scripts += javascript_include_tag "#{controller.controller_name}.batch" if File.exists?("#{Rails.root}/app/assets/javascripts/#{controller_name}.batch.js") || File.exists?("#{Rails.root}/app/assets/javascripts/#{controller_name}.batch.js.erb") end if ["defaults", "update_defaults"].include?(controller.action_name) ctrl_name = controller.controller_name == 'archival_objects' ? 'resources' : controller.controller_name scripts += javascript_include_tag "#{ctrl_name}.crud" if File.exists?("#{Rails.root}/app/assets/javascripts/#{ctrl_name}.crud.js") || File.exists?("#{Rails.root}/app/assets/javascripts/#{ctrl_name}.crud.js.erb") end scripts.html_safe end |
- (Object) include_theme_css
30 31 32 33 34 35 |
# File 'frontend/app/helpers/application_helper.rb', line 30 def include_theme_css css = "" css += stylesheet_link_tag("themes/#{ArchivesSpace::Application.config.frontend_theme}/bootstrap", :media => "all") css += stylesheet_link_tag("themes/#{ArchivesSpace::Application.config.frontend_theme}/application", :media => "all") css.html_safe end |
- (Boolean) inline?
121 122 123 |
# File 'frontend/app/helpers/application_helper.rb', line 121 def inline? params[:inline] === "true" end |
- (Object) link_to_help(opts = {})
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'frontend/app/helpers/application_helper.rb', line 98 def link_to_help(opts = {}) return if not ArchivesSpaceHelp.enabled? return if opts.has_key?(:topic) and not ArchivesSpaceHelp.topic?(opts[:topic]) href = (opts.has_key? :topic) ? ArchivesSpaceHelp.url_for_topic(opts[:topic]) : ArchivesSpaceHelp.base_url label = opts[:label] || I18n.t("help.icon") title = (opts.has_key? :topic) ? I18n.t("help.topics.#{opts[:topic]}", :default => I18n.t("help.default_tooltip", :default => "")) : I18n.t("help.default_tooltip", :default => "") link_to( label.html_safe, href, { :target => "_blank", :title => title, :class => "context-help has-tooltip", "data-placement" => "left", "data-container" => "body", }.merge(opts[:link_opts] || {}) ) end |
- (Boolean) proxy_localhost?
264 265 266 |
# File 'frontend/app/helpers/application_helper.rb', line 264 def proxy_localhost? AppConfig[:public_proxy_url] =~ /localhost/ end |
- (Object) render_aspace_partial(args)
See: ApplicationController#render_aspace_partial
253 254 255 256 |
# File 'frontend/app/helpers/application_helper.rb', line 253 def render_aspace_partial(args) defaults = {:formats => [:html], :handlers => [:erb]} return render(defaults.merge(args)) end |
- (Object) render_token(opts)
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'frontend/app/helpers/application_helper.rb', line 77 def render_token(opts) popover = "<div class='btn-group'>" link_opts = {:class => "btn btn-mini"} link_opts.merge!({:target => "_blank"}) if opts[:inside_token_editor] || opts[:inside_linker_browse] popover_url = url_for :controller => :resolver, :action => :resolve_readonly # TrimPath templates break if Rails escapes ${VALUE} style tokens: popover_url += "?uri=#{opts[:uri]}" popover += link_to I18n.t("actions.view"), popover_url, link_opts popover += "</div>" popover_template = "<div class='popover token-popover'><div class='arrow'></div><div class='popover-inner'><div class='popover-content'><p></p></div></div></div>" html = "<div class='" html += "token " if not opts[:inside_token_editor] html += "#{opts[:type]} has-popover' data-trigger='#{opts[:trigger] || "custom"}' data-html='true' data-placement='#{opts[:placement] || "bottom"}' data-content=\"#{CGI.escape_html(popover)}\" data-template=\"#{popover_template}\" tabindex='1'>" html += "<span class='icon-token'></span>" html += opts[:label] html += "</div>" html.html_safe end |
- (Object) set_title(title)
37 38 39 |
# File 'frontend/app/helpers/application_helper.rb', line 37 def set_title(title) @title = title end |
- (Object) setup_context(options)
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'frontend/app/helpers/application_helper.rb', line 41 def setup_context() = [:trail] || [] if .has_key? :object object = [:object] type = [:type] || object["jsonmodel_type"] controller = [:controller] || type.to_s.pluralize title = ([:title] || object["title"] || object["username"]).to_s .push(["#{I18n.t("#{controller.to_s.singularize}._plural")}", {:controller => controller, :action => :index}]) if object.id .push([title, {:controller => controller, :action => :show}]) .last.last[:id] = object.id unless object['username'] if ["edit", "update"].include? action_name .push([I18n.t("actions.edit")]) set_title("#{I18n.t("#{type}._plural")} | #{title} | #{I18n.t("actions.edit")}") else set_title("#{I18n.t("#{type}._plural")} | #{title}") end else # new object .push([[:title] || "#{I18n.t("actions.new_prefix")} #{I18n.t("#{type}._singular")}"]) set_title("#{I18n.t("#{controller.to_s.singularize}._plural")} | #{options[:title] || I18n.t("actions.new_prefix")}") end elsif .has_key? :title set_title([:title]) .push([[:title]]) end render_aspace_partial(:partial =>"shared/breadcrumb", :layout => false , :locals => { :trail => }).to_s if [:suppress_breadcrumb] != true end |
- (Boolean) show_external_ids?
276 277 278 |
# File 'frontend/app/helpers/application_helper.rb', line 276 def show_external_ids? AppConfig[:show_external_ids] == true end |
- (Object) wrap_with_tooltip(text, i18n_path, classes)
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'frontend/app/helpers/application_helper.rb', line 145 def wrap_with_tooltip(text, i18n_path, classes) tooltip = I18n.t_raw(i18n_path, :default => '') if tooltip.empty? return text else = {} [:title] = tooltip ["data-placement"] = "bottom" ["data-html"] = true ["data-delay"] = 500 ["data-trigger"] = "manual" ["data-template"] = '<div class="tooltip archivesspace-help"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' [:class] = " has-tooltip #{classes}" content_tag(:span, text, ) end end |