lib/muck_engine/flash_errors.rb in muck-engine-0.4.23 vs lib/muck_engine/flash_errors.rb in muck-engine-0.4.24

- old
+ new

@@ -38,14 +38,31 @@ :css_class => css_class } end # Output a page update that will display messages in the flash def output_admin_messages(fields = nil, title = '', options = { :class => 'notify-box' }, flash_only = false) - @fields = fields - @title = title - @options = options - @flash_only = flash_only - render :partial => 'admin/shared/output_admin_messages' + output_errors_ajax('admin-messages', fields, title, options, flash_only) + end + + # Output a message that can be show for an ajax request. + # Parameters: + # dom_id: The id of the dom element that will contain the message content. If growl is enabled this value is irrelevant. + # title: Title to display for the error. + # options: Options. Currently the css class can be specified via this parameter. + # fields: The instance object for which to display errors. ie @user, @project, etc. + # flash_only: If true show only flash messages. + # decode_html: Occasionally the html sent to the client is encoded and the result is visible html. Set this value to true if this happens. + # growl: Can be used to make this a growl message even if growl_enabled is false. Note that if growl_enabled is enabled setting this + # value will have no effect. + def output_errors_ajax(dom_id, title = '', options = { :class => 'notify-box' }, fields = nil, flash_only = false, decode_html = false, growl = false) + growl ||= GlobalConfig.growl_enabled + render :partial => 'shared/output_ajax_messages', :locals => {:fields => fields, + :title => title, + :options => options, + :flash_only => flash_only, + :dom_id => dom_id, + :growl => growl, + :decode_html => decode_html } end end end \ No newline at end of file