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 %>.
This is the template finder logic, keep it updated with however we find stuff in rails currently this very similar to the logic in ActionBase::Base.render for options file.
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 211defaction_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.labelbeginiflink.image.nil?#http://www.continuousthinking.com/2011/09/22/rails-3-1-engine-namespaces-can-creep-into-urls-in-application-layout.html#its not possible to link from a namespacedcontroller back to a non namespaced-controller anymore# seems to be only working with named_routes...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 attributeurl.nil?? html.sub(/href=".*?"/,'').html_safe:html.html_saferescueActionController::RoutingError=>eRails.logger.error("ActiveScaffold link_to routing Error: #{e.inspect}")"Routing Error"endend
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 173defaction_link_html_options(link,url_options,record,html_options)html_options.reverse_merge!link.html_options.merge(:class=>link.action)# 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-controller']=link.controller.to_siflink.controlleriflink.inline?html_options['data-position']=link.positioniflink.positionhtml_options[:class]+=' as_action'html_options['data-action']=link.actionhtml_options['data-keep_open']=trueiflink.keep_open?endiflink.popup?html_options['data-popup']=truehtml_options[:target]='_blank'endhtml_options[:remote]=trueunlesslink.page?||link.popup?html_options[:class]+=" #{link.html_options[:class]}"unlesslink.html_options[:class].blank?html_optionsend
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 158defaction_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
Provides stylesheets for IE to include with stylesheet_link_tag
102
103
104
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 102defactive_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 %>
90
91
92
93
94
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 90defactive_scaffold_javascripts(frontend=:default)ActiveScaffold::Config::Core.javascripts(frontend).collectdo|name|ActiveScaffold::Config::Core.asset_path(name,frontend)endend
Provides stylesheets to include with stylesheet_link_tag
97
98
99
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 97defactive_scaffold_stylesheets(frontend=:default)[ActiveScaffold::Config::Core.asset_path("stylesheet.css",frontend)]end
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 299defcolumn_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_scope=beginning_of_chainappend_to_query(calculation_scope,{:where=>conditions,:joins=>controller.send(:joins_for_collection),:includes=>includes})calculation_scope.calculate(column.calculate,column.name)elsecolumn.calculate.call(@records)endend
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 260defcolumn_class(column,column_value,record)@numeric_classes||=[:decimal,:float,:integer]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.column&&@numeric_classes.include?(column.column.type)classes.join(' ').rstripend
#column_empty?(column_value) ⇒ Boolean
Returns:
(Boolean)
291
292
293
294
295
296
297
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 291defcolumn_empty?(column_value)@empty_column_strings||=[' ',active_scaffold_config.list.empty_field_text]empty=column_value.nil?empty||=column_value.empty?ifcolumn_value.respond_to?:empty?empty||=@empty_column_strings.include?(column_value)ifString===column_valuereturnemptyend
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 323defcolumn_show_add_existing(column)(column.allow_add_existingandoptions_for_association_count(column.association)>0)end
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 327defcolumn_show_add_new(column,associated,record)value=(column.plural_association?&&!column.readonly_association?)||(column.singular_association?andnotassociated.empty?)value=falseunlessrecord.class.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 51defgenerate_temporary_id(Time.now.to_f*1000).to_i.to_send
#get_action_link_id(url_options, record = nil, column = nil) ⇒ Object
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 198defget_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]) + '-' if url_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)
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 66defin_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 parentreturnfalseifcolumn.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.
128
129
130
131
132
133
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 128deflink_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 57defoption_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
139
140
141
142
143
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 139defrender_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 135defskip_action_link(link,*args)(!link.ignore_method.nil?&&controller.respond_to?(link.ignore_method,true)&&controller.send(link.ignore_method,*args))||((link.security_method_set?orcontroller.respond_to?(link.security_method,true))and!controller.send(link.security_method,*args))end
This is the template finder logic, keep it updated with however we find stuff in rails
currently this very similar to the logic in ActionBase::Base.render for options file
Returns:
(Boolean)
47
48
49
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 47deftemplate_exists?(template_name,partial=false)lookup_context.exists?template_name,'',partialend
# File 'lib/active_scaffold/helpers/view_helpers.rb', line 232defurl_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 245defurl_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 autolinkiflink.column.nil?sti_controller_path=controller_path_for_activerecord(record.class)ifsti_controller_pathurl_options[:controller]=sti_controller_pathurl_options[:parent_sti]=controller_pathendendend