Provides list of javascripts to include with javascript_include_tag You can use this with your javascripts like <%= javascript_include_tag :defaults, 'your_own_cool_script', active_scaffold_javascripts, :cache => true %>.
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 202defaction_link_html(link,url,html_options,record)# issue 260, use url_options[:link] if it exists. This prevents DB data from being localized.
label=url.delete(:link)ifurl.is_a?(Hash)label||=link.labeliflink.image.nil?html=link_to(label,url,html_options)elsehtml=link_to(image_tag(link.image[:name],:size=>link.image[:size],:alt=>label),url,html_options)end# if url is nil we would like to generate an anchor without href attribute
url.nil??html.sub(/href=".*?"/,'').html_safe:html.html_safeend
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 162defaction_link_html_options(link,url_options,record,html_options)link_id=get_action_link_id(url_options,record,link.column)html_options.reverse_merge!link.html_options.merge(:class=>link.action.to_s)# Needs to be in html_options to as the adding _method to the url is no longer supported by Rails
html_options[:method]=link.methodiflink.method!=:gethtml_options['data-confirm']=link.confirm(record.try(:to_label))iflink.confirm?html_options['data-position']=link.positioniflink.positionandlink.inline?html_options[:class]+=' as_action'iflink.inline?html_options['data-action']=link.actioniflink.inline?iflink.popup?html_options['data-popup']=truehtml_options[:target]='_blank'endhtml_options[:id]=link_idhtml_options[:remote]=trueunlesslink.page?||link.popup?iflink.dhtml_confirm?html_options[:class]+=' as_action'if!link.inline?html_options[:page_link]='true'if!link.inline?html_options[:dhtml_confirm]=link.dhtml_confirm.valuehtml_options[:onclick]=link.dhtml_confirm.onclick_function(controller,link_id)endhtml_options[:class]+="#{link.html_options[:class]}"unlesslink.html_options[:class].blank?html_optionsend
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 147defaction_link_url_options(link,url_options,record,options={})url_options=url_options.cloneurl_options[:action]=link.actionurl_options[:controller]=link.controller.to_siflink.controllerurl_options.delete(:search)iflink.controllerandlink.controller.to_s!=params[:controller]url_options.merge!link.parametersiflink.parameters@link_record=recordurl_options.merge!self.instance_eval(&(link.dynamic_parameters))iflink.dynamic_parameters.is_a?(Proc)@link_record=nilurl_options_for_nested_link(link.column,record,link,url_options,options)iflink.nested_link?url_options_for_sti_link(link.column,record,link,url_options,options)unlessrecord.nil?||active_scaffold_config.sti_children.nil?url_options[:_method]=link.methodif!link.confirm?&&link.inline?&&link.method!=:geturl_optionsend
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 28defactive_scaffold_controller_for(*args)controller.class.active_scaffold_controller_for(*args)end
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 318defactive_scaffold_error_messages_for(*params)options=params.extract_options!.symbolize_keysoptions.reverse_merge!(:container_tag=>:div,:list_type=>:ul)objects=Array.wrap(options.delete(:object)||params).mapdo|object|object=instance_variable_get("@#{object}")unlessobject.respond_to?(:to_model)object=convert_to_model(object)ifobject.class.respond_to?(:model_name)options[:object_name]||=object.class.model_name.human.downcaseendobjectendobjects.compact!count=objects.inject(0){|sum,object|sum+object.errors.count}unlesscount.zero?html={}[:id,:class].eachdo|key|ifoptions.include?(key)value=options[key]html[key]=valueunlessvalue.blank?elsehtml[key]='errorExplanation'endendoptions[:object_name]||=params.firstheader_message=ifoptions.include?(:header_message)options[:header_message]elseas_('errors.template.header',:count=>count,:model=>options[:object_name].to_s.gsub('_',''))endmessage=options.include?(:message)?options[:message]:as_('errors.template.body')error_messages=objects.sumdo|object|object.errors.full_messages.mapdo|msg|options[:list_type]!=:br?content_tag(:li,msg):msgendenderror_messages=ifoptions[:list_type]==:brerror_messages.join('<br/>').html_safeelsecontent_tag(options[:list_type],error_messages.join.html_safe)endcontents=[]contents<<content_tag(options[:header_tag]||:h2,header_message)unlessheader_message.blank?contents<<content_tag(:p,message)unlessmessage.blank?contents<<error_messagescontents=contents.join.html_safeoptions[:container_tag]?content_tag(options[:container_tag],contents,html):contentselse''endend
Provides stylesheets for IE to include with stylesheet_link_tag
96
97
98
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 96defactive_scaffold_ie_stylesheets(frontend=:default)[ActiveScaffold::Config::Core.asset_path("stylesheet-ie.css",frontend)]end
Provides list of javascripts to include with javascript_include_tag
You can use this with your javascripts like
<%= javascript_include_tag :defaults, 'your_own_cool_script', active_scaffold_javascripts, :cache => true %>
Provides stylesheets to include with stylesheet_link_tag
91
92
93
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 91defactive_scaffold_stylesheets(frontend=:default)[ActiveScaffold::Config::Core.asset_path("stylesheet.css",frontend)]end
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 267defas_main_div_classclasses=["active-scaffold","active-scaffold-#{controller_id}","#{params[:controller]}-view","#{active_scaffold_config.theme}-theme"]classes<<"as_touch"iftouch_device?classes.join('')end
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 280defcolumn_calculation(column)unlesscolumn.calculate.instance_of?Procconditions=controller.send(:all_conditions)includes=active_scaffold_config.list.count_includesincludes||=controller.send(:active_scaffold_includes)unlessconditions.nil?calculation=beginning_of_chain.calculate(column.calculate,column.name,:conditions=>conditions,:joins=>controller.send(:joins_for_collection),:include=>includes)elsecolumn.calculate.call(@records)endend
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 243defcolumn_class(column,column_value,record)classes=[]classes<<"#{column.name}-column"ifcolumn.css_class.is_a?(Proc)css_class=column.css_class.call(column_value,record)classes<<css_classunlesscss_class.nil?elseclasses<<column.css_classendunlesscolumn.css_class.nil?classes<<'empty'ifcolumn_empty?column_valueclasses<<'sorted'ifactive_scaffold_config.list.user.sorting.sorts_on?(column)classes<<'numeric'ifcolumn.columnand[:decimal,:float,:integer].include?(column.column.type)classes.join('').rstripend
#column_empty?(column_value) ⇒ Boolean
Returns:
(Boolean)
273
274
275
276
277
278
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 273defcolumn_empty?(column_value)empty=column_value.nil?empty||=column_value.blank?ifcolumn_value.respond_to?:blank?empty||=[' ',active_scaffold_config.list.empty_field_text].include?column_valueifString===column_valuereturnemptyend
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 300defcolumn_show_add_existing(column)(column.allow_add_existingandoptions_for_association_count(column.association)>0)end
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 304defcolumn_show_add_new(column,associated,record)value=(column.plural_association?&&!column.readonly_association?)||(column.singular_association?andnotassociated.empty?)value=falseunlesscolumn.association.klass.authorized_for?(:crud_type=>:create)valueend
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 36defcontroller_path_for_activerecord(klass)begincontroller=active_scaffold_controller_for(klass)controller.controller_pathrescueActiveScaffold::ControllerNotFoundcontroller=nilendend
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 45defgenerate_temporary_id(Time.now.to_f*1000).to_i.to_send
#get_action_link_id(url_options, record = nil, column = nil) ⇒ Object
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 189defget_action_link_id(url_options,record=nil,column=nil)id=url_options[:id]||url_options[:parent_id]id="#{column.association.name}-#{record.id}"ifcolumn&&column.plural_association?ifrecord.try(column.association.name.to_sym).present?id="#{column.association.name}-#{record.send(column.association.name).id}-#{record.id}"elseid="#{column.association.name}-#{record.id}"unlessrecord.nil?endifcolumn&&column.singular_association?id="#{id}-#{url_options[:batch_scope].downcase}"ifurl_options[:batch_scope]action_id="#{id_from_controller(url_options[:controller])+'-'ifurl_options[:parent_controller]}#{url_options[:action].to_s}"action_link_id(action_id,id)end
#in_subform?(column, parent_record) ⇒ Boolean
Should this column be displayed in the subform?
Returns:
(Boolean)
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 60defin_subform?(column,parent_record)returntrueunlesscolumn.association# Polymorphic associations can't appear because they *might* be the reverse association, and because you generally don't assign an association from the polymorphic side ... I think.
returnfalseifcolumn.polymorphic_association?# A column shouldn't be in the subform if it's the reverse association to the parent
returnfalseifcolumn.association.reverse_for?(parent_record.class)returntrueend
Creates a javascript-based link that toggles the visibility of some element on the page.
By default, it toggles the visibility of the sibling after the one it's nested in. You may pass custom javascript logic in options to change that, though. For example, you could say :of => '$("my_div_id")'.
You may also flag whether the other element is visible by default or not, and the initial text will adjust accordingly.
122
123
124
125
126
127
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 122deflink_to_visibility_toggle(id,options={})options[:default_visible]=trueifoptions[:default_visible].nil?options[:hide_label]=as_(:hide)options[:show_label]=as_(:show)javascript_tag("ActiveScaffold.create_visibility_toggle('#{id}', #{options.to_json});")end
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 51defoption_tags_for(select_options,options={})select_options.insert(0,[as_(:_select_),nil])ifoptions[:include_blank]select_options.collectdo|option|label,value=option[0],option[1]value.nil??"<option value="">#{label}</option>":"<option value=\"#{value}\">#{label}</option>"endend
#render_action_link(link, url_options, record = nil, html_options = {}) ⇒ Object
133
134
135
136
137
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 133defrender_action_link(link,url_options,record=nil,html_options={})url_options=action_link_url_options(link,url_options,record)html_options=action_link_html_options(link,url_options,record,html_options)action_link_html(link,url_options,html_options,record)end
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 129defskip_action_link(link,*args)(!link.ignore_method.nil?andcontroller.try(link.ignore_method,*args))||((link.security_method_set?orcontroller.respond_to?link.security_method)and!controller.send(link.security_method,*args))end
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 215defurl_options_for_nested_link(column,record,link,url_options,options={})ifcolumn&&column.associationurl_options[:assoc_id]=url_options.delete(:id)url_options[:id]=record.send(column.association.name).idifcolumn.singular_association?&&record.send(column.association.name).present?link.eid="#{controller_id.from(3)}_#{record.id}_#{column.association.name}"unlessoptions.has_key?(:reuse_eid)url_options[:eid]=link.eidelsiflink.parameters&&link.parameters[:named_scope]url_options[:assoc_id]=url_options.delete(:id)link.eid="#{controller_id.from(3)}_#{record.id}_#{link.parameters[:named_scope]}"unlessoptions.has_key?(:reuse_eid)url_options[:eid]=link.eidendend
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 228defurl_options_for_sti_link(column,record,link,url_options,options={})#need to find out controller of current record type
#and set parameters
# its quite difficult to detect an sti link
# if link.column.nil? we are sure that it is nt an singular association inline autolink
# howver that will not work if a sti parent is an singular association inline autolink
iflink.column.nil?sti_controller_path=controller_path_for_activerecord(record.class)ifsti_controller_pathurl_options[:controller]=sti_controller_pathurl_options[:parent_sti]=controller_pathendendend