Top Level Namespace
Defined Under Namespace
Modules: InlineForms, InlineFormsHelper, Kernel Classes: CuracaoIdNumberValidator, GeoCodeCuracao, GeoCodeCuracaoController, InlineFormsApplicationController, InlineFormsController, IsCuracaoPhoneValidator, IsEmailAddressValidator, MustBeAValueValidator
Constant Summary collapse
- APP_ROOT =
File.(File.dirname(File.dirname(__FILE__)))
Instance Method Summary collapse
- #check_box_edit(object, attribute) ⇒ Object
-
#check_box_show(object, attribute) ⇒ Object
boolean, bit unaptly named check_box.
- #check_box_update(object, attribute) ⇒ Object
- #check_list_edit(object, attribute) ⇒ Object
-
#check_list_show(object, attribute) ⇒ Object
checklist.
- #check_list_update(object, attribute) ⇒ Object
- #date_select_edit(object, attribute) ⇒ Object
-
#date_select_show(object, attribute) ⇒ Object
date.
- #date_select_update(object, attribute) ⇒ Object
- #decimal_field_edit(object, attribute) ⇒ Object
- #decimal_field_show(object, attribute) ⇒ Object
- #decimal_field_update(object, attribute) ⇒ Object
- #devise_password_field_edit(object, attribute) ⇒ Object
- #devise_password_field_show(object, attribute) ⇒ Object
- #devise_password_field_update(object, attribute) ⇒ Object
- #dnsrecords_edit(object, attribute) ⇒ Object
- #dnsrecords_show(object, attribute) ⇒ Object
- #dnsrecords_update(object, attribute) ⇒ Object
- #dropdown_edit(object, attribute) ⇒ Object
-
#dropdown_show(object, attribute) ⇒ Object
dropdown.
- #dropdown_update(object, attribute) ⇒ Object
- #dropdown_with_integers_edit(object, attribute) ⇒ Object
-
#dropdown_with_integers_show(object, attribute) ⇒ Object
dropdown_with_integers generates a dropdown menu with the given list of integers as options.
- #dropdown_with_integers_update(object, attribute) ⇒ Object
- #dropdown_with_other_edit(object, attribute) ⇒ Object
-
#dropdown_with_other_show(object, attribute) ⇒ Object
dropdown.
- #dropdown_with_other_update(object, attribute) ⇒ Object
- #dropdown_with_values_edit(object, attribute) ⇒ Object
-
#dropdown_with_values_show(object, attribute) ⇒ Object
dropdown_with_values.
- #dropdown_with_values_update(object, attribute) ⇒ Object
- #file_field_edit(object, attribute) ⇒ Object
- #file_field_show(object, attribute) ⇒ Object
- #file_field_update(object, attribute) ⇒ Object
- #geo_code_curacao_edit(object, attribute) ⇒ Object
-
#geo_code_curacao_show(object, attribute) ⇒ Object
geo_code_curacao.
- #geo_code_curacao_update(object, attribute) ⇒ Object
- #header_edit(object, attribute) ⇒ Object
-
#header_show(object, attribute) ⇒ Object
not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES=:string.
- #header_update(object, attribute, ) ⇒ Object
- #image_field_edit(object, attribute) ⇒ Object
- #image_field_show(object, attribute) ⇒ Object
- #image_field_update(object, attribute) ⇒ Object
- #info_edit(object, attribute) ⇒ Object
- #info_list_edit(object, attribute) ⇒ Object
-
#info_list_show(object, attribute) ⇒ Object
not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES=:string.
- #info_list_update(object, attribute, ) ⇒ Object
-
#info_show(object, attribute) ⇒ Object
not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES=:string.
- #info_update(object, attribute, ) ⇒ Object
- #integer_field_edit(object, attribute) ⇒ Object
- #integer_field_show(object, attribute) ⇒ Object
- #integer_field_update(object, attribute) ⇒ Object
- #kansen_slider_edit(object, attribute) ⇒ Object
-
#kansen_slider_show(object, attribute) ⇒ Object
kansen_slider.
- #kansen_slider_update(object, attribute) ⇒ Object
- #money_field_edit(object, attribute) ⇒ Object
- #money_field_show(object, attribute) ⇒ Object
- #money_field_update(object, attribute) ⇒ Object
- #month_year_picker_edit(object, attribute) ⇒ Object
-
#month_year_picker_show(object, attribute) ⇒ Object
date.
- #month_year_picker_update(object, attribute) ⇒ Object
- #move_edit(object, attribute) ⇒ Object
-
#move_show(object, attribute) ⇒ Object
InlineForms::SPECIAL_COLUMN_TYPES=:string.
- #move_update(object, attribute) ⇒ Object
- #pdf_link_edit(object, attribute) ⇒ Object
-
#pdf_link_show(object, attribute) ⇒ Object
not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES=:string.
- #pdf_link_update(object, attribute) ⇒ Object
- #plain_text_area_edit(object, attribute) ⇒ Object
- #plain_text_area_show(object, attribute) ⇒ Object
- #plain_text_area_update(object, attribute) ⇒ Object
- #question_list_edit(object, attribute) ⇒ Object
-
#question_list_show(object, attribute) ⇒ Object
checklist.
- #question_list_update(object, attribute) ⇒ Object
- #radio_button_edit(object, attribute) ⇒ Object
-
#radio_button_show(object, attribute) ⇒ Object
[ :sex , “gender”, :radio_button, { 1 => ‘male’, 2 => ‘female’ } ],.
- #radio_button_update(object, attribute) ⇒ Object
- #scale_with_integers_edit(object, attribute) ⇒ Object
-
#scale_with_integers_show(object, attribute) ⇒ Object
scale_with_integers generates a scale with the given list of integers as options.
- #scale_with_integers_update(object, attribute) ⇒ Object
- #scale_with_values_edit(object, attribute) ⇒ Object
-
#scale_with_values_show(object, attribute) ⇒ Object
scale_with_values generates a scale with the given list of values as options.
- #scale_with_values_update(object, attribute) ⇒ Object
- #slider_with_values_edit(object, attribute) ⇒ Object
-
#slider_with_values_show(object, attribute) ⇒ Object
slider_with_values.
- #slider_with_values_update(object, attribute) ⇒ Object
- #text_area_edit(object, attribute) ⇒ Object
- #text_area_show(object, attribute) ⇒ Object
- #text_area_update(object, attribute) ⇒ Object
- #text_area_without_ckeditor_edit(object, attribute) ⇒ Object
- #text_area_without_ckeditor_show(object, attribute) ⇒ Object
- #text_area_without_ckeditor_update(object, attribute) ⇒ Object
- #text_field_edit(object, attribute) ⇒ Object
- #text_field_show(object, attribute) ⇒ Object
- #text_field_update(object, attribute) ⇒ Object
Instance Method Details
#check_box_edit(object, attribute) ⇒ Object
9 10 11 |
# File 'lib/app/helpers/form_elements/check_box.rb', line 9 def check_box_edit(object, attribute) check_box_tag attribute.to_s, 1, object.send(attribute) end |
#check_box_show(object, attribute) ⇒ Object
boolean, bit unaptly named check_box
4 5 6 7 |
# File 'lib/app/helpers/form_elements/check_box.rb', line 4 def check_box_show(object, attribute) values = attribute_values(object, attribute) link_to_inline_edit object, attribute, values[object.send(attribute) ? 1 : 0 ][1] end |
#check_box_update(object, attribute) ⇒ Object
13 14 15 |
# File 'lib/app/helpers/form_elements/check_box.rb', line 13 def check_box_update(object, attribute) object[attribute.to_s.to_sym] = params[attribute.to_s.to_sym].nil? ? 0 : 1 end |
#check_list_edit(object, attribute) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/app/helpers/form_elements/check_list.rb', line 16 def check_list_edit(object, attribute) object.send(attribute).build if object.send(attribute).empty? if cancan_enabled? values = object.send(attribute).first.class.name.constantize.accessible_by(current_ability).order(attribute.to_s.singularize.camelcase.constantize.order_by_clause) else values = object.send(attribute).first.class.name.constantize.order(attribute.to_s.singularize.camelcase.constantize.order_by_clause) end out = '' values.each do | item | out << "<div class='row #{cycle('odd', 'even')}'>" out << check_box_tag( attribute.to_s + '[' + item.id.to_s + ']', 1, object.send(attribute.to_s.singularize + "_ids").include?(item.id) ) out << "<label for=#{attribute.to_s + '[' + item.id.to_s + ']'}>#{h(item._presentation)}</label>" out << '</div>' end out.html_safe end |
#check_list_show(object, attribute) ⇒ Object
checklist
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/app/helpers/form_elements/check_list.rb', line 5 def check_list_show(object, attribute) out = '' out = link_to_inline_edit(object, attribute, "<i class='fi-plus'></i>".html_safe) if object.send(attribute).empty? object.send(attribute).sort.each do | item | out << "<div class='row #{cycle('odd', 'even')}'>" out << link_to_inline_edit(object, attribute, item._presentation ) out << '</div>' end out.html_safe end |
#check_list_update(object, attribute) ⇒ Object
33 34 35 36 |
# File 'lib/app/helpers/form_elements/check_list.rb', line 33 def check_list_update(object, attribute) params[attribute] ||= {} object.send(attribute.to_s.singularize + '_ids=', params[attribute].keys) end |
#date_select_edit(object, attribute) ⇒ Object
9 10 11 12 13 |
# File 'lib/app/helpers/form_elements/date.rb', line 9 def date_select_edit(object, attribute) css_id = 'datepicker_' + object.class.to_s.underscore + '_' + object.id.to_s + '_' + attribute.to_s out = text_field_tag attribute, ( object.send(attribute).nil? ? "" : object.send(attribute).strftime("%d-%m-%Y") ), :id => css_id, :class =>'datepicker' out << "<script>$('##{css_id}').datepicker();</script>".html_safe end |
#date_select_show(object, attribute) ⇒ Object
date
5 6 7 |
# File 'lib/app/helpers/form_elements/date.rb', line 5 def date_select_show(object, attribute) link_to_inline_edit object, attribute, object.send(attribute).nil? ? "<i class='fi-plus'></i>".html_safe : object.send(attribute).strftime("%d-%m-%Y") end |
#date_select_update(object, attribute) ⇒ Object
15 16 17 |
# File 'lib/app/helpers/form_elements/date.rb', line 15 def date_select_update(object, attribute) object[attribute.to_sym] = params[attribute.to_sym] end |
#decimal_field_edit(object, attribute) ⇒ Object
8 9 10 |
# File 'lib/app/helpers/form_elements/decimal_field.rb', line 8 def decimal_field_edit(object, attribute) text_field_tag attribute, (object.send attribute.to_sym), :class => 'input_decimal_field' # for abide: , :required => true end |
#decimal_field_show(object, attribute) ⇒ Object
4 5 6 |
# File 'lib/app/helpers/form_elements/decimal_field.rb', line 4 def decimal_field_show(object, attribute) link_to_inline_edit object, attribute, object[attribute].nil? ? "<i class='fi-plus'></i>".html_safe : object[attribute] end |
#decimal_field_update(object, attribute) ⇒ Object
12 13 14 |
# File 'lib/app/helpers/form_elements/decimal_field.rb', line 12 def decimal_field_update(object, attribute) object.send :write_attribute, attribute.to_sym, params[attribute.to_sym] end |
#devise_password_field_edit(object, attribute) ⇒ Object
8 9 10 |
# File 'lib/app/helpers/form_elements/devise_password_field.rb', line 8 def devise_password_field_edit(object, attribute) password_field_tag attribute, '', :class => 'input_devise_password_field' end |
#devise_password_field_show(object, attribute) ⇒ Object
4 5 6 |
# File 'lib/app/helpers/form_elements/devise_password_field.rb', line 4 def devise_password_field_show(object, attribute) link_to_inline_edit object, attribute, '' end |
#devise_password_field_update(object, attribute) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/app/helpers/form_elements/devise_password_field.rb', line 12 def devise_password_field_update(object, attribute) if params[attribute.to_sym].blank? # nothing happens else object.password = params[attribute.to_sym] end end |
#dnsrecords_edit(object, attribute) ⇒ Object
10 11 |
# File 'lib/app/helpers/form_elements/dns_records.rb', line 10 def dnsrecords_edit(object, attribute) end |
#dnsrecords_show(object, attribute) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/app/helpers/form_elements/dns_records.rb', line 2 def dnsrecords_show(object, attribute) out = "" [object.a_records,object.template_a_records].flatten.collect do |r| out << r.djbdns_line(object.name) + "<br/>" end raw out end |
#dnsrecords_update(object, attribute) ⇒ Object
13 14 |
# File 'lib/app/helpers/form_elements/dns_records.rb', line 13 def dnsrecords_update(object, attribute) end |
#dropdown_edit(object, attribute) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/app/helpers/form_elements/dropdown.rb', line 10 def dropdown_edit(object, attribute) object.send('build_' + attribute.to_s) unless object.send(attribute) o = object.send(attribute).class.name.constantize if cancan_enabled? values = o.accessible_by(current_ability).order(o.order_by_clause) else values = o.order(o.order_by_clause) end values.each do |v| v.name = v._presentation end values.sort_by! &:name # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form! collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_s.foreign_key.to_sym, values, 'id', 'name', :selected => object.send(attribute).id) end |
#dropdown_show(object, attribute) ⇒ Object
dropdown
5 6 7 8 |
# File 'lib/app/helpers/form_elements/dropdown.rb', line 5 def dropdown_show(object, attribute) attribute_value = object.send(attribute)._presentation rescue "<i class='fi-plus'></i>".html_safe link_to_inline_edit object, attribute, attribute_value end |
#dropdown_update(object, attribute) ⇒ Object
26 27 28 29 |
# File 'lib/app/helpers/form_elements/dropdown.rb', line 26 def dropdown_update(object, attribute) foreign_key = object.class.reflect_on_association(attribute.to_sym).[:foreign_key] || attribute.to_s.foreign_key.to_sym object[foreign_key] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_s.foreign_key.to_sym] end |
#dropdown_with_integers_edit(object, attribute) ⇒ Object
13 14 15 16 17 |
# File 'lib/app/helpers/form_elements/dropdown_with_integers.rb', line 13 def dropdown_with_integers_edit(object, attribute) # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form! values = attribute_values(object, attribute) collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute)) end |
#dropdown_with_integers_show(object, attribute) ⇒ Object
dropdown_with_integers generates a dropdown menu with the given list of integers as options
values must be a Range or a one-dimensional array of Integers
8 9 10 11 |
# File 'lib/app/helpers/form_elements/dropdown_with_integers.rb', line 8 def dropdown_with_integers_show(object, attribute) values = attribute_values(object, attribute) link_to_inline_edit object, attribute, values[object.send(attribute)][1] end |
#dropdown_with_integers_update(object, attribute) ⇒ Object
19 20 21 |
# File 'lib/app/helpers/form_elements/dropdown_with_integers.rb', line 19 def dropdown_with_integers_update(object, attribute) object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym] end |
#dropdown_with_other_edit(object, attribute) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/app/helpers/form_elements/dropdown_with_other.rb', line 18 def dropdown_with_other_edit(object, attribute) attribute = attribute.to_s foreign_key = object.class.reflect_on_association(attribute.to_sym).[:foreign_key] || attribute.foreign_key.to_sym o = attribute.camelcase.constantize values = o.all values = o.accessible_by(current_ability) if cancan_enabled? values.each do |v| v.name = v._presentation end # values.sort_by! &:name collection = values.map {|v|[v.name, v.id]} collection << [object[attribute + '_other'], 0] unless object[attribute + '_other'].nil? || object[attribute + '_other'].empty? out = '<div class="ui-widget">' out << select('_' + object.class.to_s.underscore, foreign_key.to_sym, collection, {selected: object[foreign_key.to_sym]}, {id: '_' + object.class.to_s.underscore + '_' + object.id.to_s + '_' + foreign_key.to_s}) out << '</div> <script> (function( $ ) { $.widget( "custom.combobox", { _create: function() { this.wrapper = $( "<span>" ) .addClass( "custom-combobox" ) .insertAfter( this.element ); this.element.hide(); this._createAutocomplete(); this._createShowAllButton(); }, _createAutocomplete: function() { var selected = this.element.children( ":selected" ), value = selected.val() ? selected.text() : ""; this.input = $( "<input name=\'' out << '_' + object.class.to_s.underscore + '[' + attribute + '_other]' out << '\'>" ) .appendTo( this.wrapper ) .val( value ) .attr( "title", "" ) .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" ) .autocomplete({ delay: 0, minLength: 0, source: $.proxy( this, "_source" ) }) .tooltip({ tooltipClass: "ui-state-highlight" }); this._on( this.input, { autocompleteselect: function( event, ui ) { ui.item.option.selected = true; this._trigger( "select", event, { item: ui.item.option }); } }); }, _createShowAllButton: function() { var input = this.input, wasOpen = false; $( "<a>" ) .attr( "tabIndex", -1 ) .attr( "title", "Show All Items" ) .tooltip() .appendTo( this.wrapper ) .button({ icons: { primary: "ui-icon-triangle-1-s" }, text: false }) .removeClass( "ui-corner-all" ) .addClass( "custom-combobox-toggle ui-corner-right" ) .mousedown(function() { wasOpen = input.autocomplete( "widget" ).is( ":visible" ); }) .click(function() { input.focus(); // Close if already visible if ( wasOpen ) { return; } // Pass empty string as value to search for, displaying all results input.autocomplete( "search", "" ); }); }, _source: function( request, response ) { var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); response( this.element.children( "option" ).map(function() { var text = $( this ).text(); if ( this.value && ( !request.term || matcher.test(text) ) ) return { label: text, value: text, option: this }; }) ); }, }); })( jQuery ); $(function() { $( "' out << '#_' + object.class.to_s.underscore + '_' + object.id.to_s + '_' + attribute.foreign_key.to_s out << '" ).combobox(); }); </script>' out.html_safe end |
#dropdown_with_other_show(object, attribute) ⇒ Object
dropdown
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/app/helpers/form_elements/dropdown_with_other.rb', line 5 def dropdown_with_other_show(object, attribute) attribute = attribute.to_s foreign_key = object.class.reflect_on_association(attribute.to_sym).[:foreign_key] || attribute.foreign_key.to_sym id = object[foreign_key] if id == 0 attribute_value = object[attribute + '_other'] attribute_value = "<i class='fi-plus'></i>".html_safe if attribute_value.nil? || attribute_value.empty? else attribute_value = object.send(attribute)._presentation rescue "<i class='fi-plus'></i>".html_safe end link_to_inline_edit object, attribute, attribute_value end |
#dropdown_with_other_update(object, attribute) ⇒ Object
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/app/helpers/form_elements/dropdown_with_other.rb', line 138 def dropdown_with_other_update(object, attribute) attribute = attribute.to_s foreign_key = object.class.reflect_on_association(attribute.to_sym).[:foreign_key] || attribute.foreign_key.to_sym # if there is an attribute attr, then there must be an attribute attr_other other = params[('_' + object.class.to_s.underscore).to_sym][(attribute + "_other").to_sym] # see if it matches anything match = attribute.camelcase.constantize.where(name: other).first # problem if there are dupes! match.nil? ? object[foreign_key] = 0 : object[foreign_key] = match.id # problem if there is a record with id: 0 ! match.nil? ? object[attribute + '_other'] = other : object[attribute + '_other'] = nil end |
#dropdown_with_values_edit(object, attribute) ⇒ Object
9 10 11 12 13 |
# File 'lib/app/helpers/form_elements/dropdown_with_values.rb', line 9 def dropdown_with_values_edit(object, attribute) # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form! values = attribute_values(object, attribute) collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute)) end |
#dropdown_with_values_show(object, attribute) ⇒ Object
dropdown_with_values
5 6 7 8 |
# File 'lib/app/helpers/form_elements/dropdown_with_values.rb', line 5 def dropdown_with_values_show(object, attribute) values = attribute_values(object, attribute) link_to_inline_edit object, attribute, object.send(attribute) ? values.assoc(object.send(attribute))[1] : "<i class='fi-plus'></i>".html_safe end |
#dropdown_with_values_update(object, attribute) ⇒ Object
14 15 16 |
# File 'lib/app/helpers/form_elements/dropdown_with_values.rb', line 14 def dropdown_with_values_update(object, attribute) object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym] end |
#file_field_edit(object, attribute) ⇒ Object
13 14 15 |
# File 'lib/app/helpers/form_elements/file_field.rb', line 13 def file_field_edit(object, attribute) file_field_tag attribute, :class => 'input_text_field' end |
#file_field_show(object, attribute) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/app/helpers/form_elements/file_field.rb', line 4 def file_field_show(object, attribute) o = object.send(attribute) msg = o.to_s if o.send(:present?) msg = "<a href='#{o.send(:url)}'>#{o.send(:path).gsub(/^.*\//,'')}</a>".html_safe end link_to_inline_edit object, attribute, msg end |
#file_field_update(object, attribute) ⇒ Object
17 18 19 |
# File 'lib/app/helpers/form_elements/file_field.rb', line 17 def file_field_update(object, attribute) object.send(attribute.to_s + '=', params[attribute.to_sym]) end |
#geo_code_curacao_edit(object, attribute) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/app/helpers/form_elements/geo_code_curacao.rb', line 9 def geo_code_curacao_edit(object, attribute) attribute_value = object.send(attribute).presentation rescue nil out = text_field_tag attribute, attribute_value out << '<script> $( "#geo_code_curacao" ).autocomplete({ source: "/geo_code_curacao", minLength: 2, }); </script>'.html_safe end |
#geo_code_curacao_show(object, attribute) ⇒ Object
geo_code_curacao
5 6 7 8 |
# File 'lib/app/helpers/form_elements/geo_code_curacao.rb', line 5 def geo_code_curacao_show(object, attribute) attribute_value = GeoCodeCuracao.new(object.send(attribute)).presentation rescue nil link_to_inline_edit object, attribute, attribute_value end |
#geo_code_curacao_update(object, attribute) ⇒ Object
20 21 22 23 24 |
# File 'lib/app/helpers/form_elements/geo_code_curacao.rb', line 20 def geo_code_curacao_update(object, attribute) # extract the geocode geo_code = params[attribute].scan(/\d\d\d\d\d\d/).first || nil object[attribute.to_sym] = GeoCodeCuracao.new(geo_code).valid? ? geo_code : nil end |
#header_edit(object, attribute) ⇒ Object
9 10 11 12 |
# File 'lib/app/helpers/form_elements/header.rb', line 9 def header_edit(object, attribute) # just show the header attribute end |
#header_show(object, attribute) ⇒ Object
not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES=:string
4 5 6 7 |
# File 'lib/app/helpers/form_elements/header.rb', line 4 def header_show(object, attribute) # show the header which is the translated fake attribute attribute end |
#header_update(object, attribute, ) ⇒ Object
14 15 16 |
# File 'lib/app/helpers/form_elements/header.rb', line 14 def header_update(object, attribute) # do absolutely nothing end |
#image_field_edit(object, attribute) ⇒ Object
17 18 19 |
# File 'lib/app/helpers/form_elements/image_field.rb', line 17 def image_field_edit(object, attribute) file_field_tag attribute, :class => 'input_text_field' end |
#image_field_show(object, attribute) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/app/helpers/form_elements/image_field.rb', line 4 def image_field_show(object, attribute) o = object.send(attribute) msg = o.to_s if o.send(:present?) if o.respond_to? :palm msg = image_tag(o.send(:palm).send(:url)) else msg = image_tag(o.send(:url)) end end link_to_inline_edit object, attribute, msg end |
#image_field_update(object, attribute) ⇒ Object
21 22 23 |
# File 'lib/app/helpers/form_elements/image_field.rb', line 21 def image_field_update(object, attribute) object.send(attribute.to_s + '=', params[attribute.to_sym]) end |
#info_edit(object, attribute) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/app/helpers/form_elements/info.rb', line 12 def info_edit(object, attribute) o = object.send(attribute) o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + ")" if o.is_a?(Time) o = o._presentation if o.respond_to?(:_presentation) o end |
#info_list_edit(object, attribute) ⇒ Object
16 17 18 |
# File 'lib/app/helpers/form_elements/info_list.rb', line 16 def info_list_edit(object, attribute) # we should raise an error end |
#info_list_show(object, attribute) ⇒ Object
not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES=:string
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/app/helpers/form_elements/info_list.rb', line 4 def info_list_show(object, attribute) # we would expect out = '' out = "<div class='row #{cycle('odd', 'even')}'>--</div>" if object.send(attribute).empty? object.send(attribute).sort.each do | item | out << "<div class='row #{cycle('odd', 'even')}'>" out << item._presentation out << '</div>' end out.html_safe end |
#info_list_update(object, attribute, ) ⇒ Object
20 21 22 |
# File 'lib/app/helpers/form_elements/info_list.rb', line 20 def info_list_update(object, attribute) # we should raise an errror end |
#info_show(object, attribute) ⇒ Object
not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES=:string
4 5 6 7 8 9 10 |
# File 'lib/app/helpers/form_elements/info.rb', line 4 def info_show(object, attribute) # show the attribute. if it's a date/time, make it nicer. If it has a _presentation, show that instead o = object.send(attribute) o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + ")" if o.is_a?(Time) o = o._presentation if o.respond_to?(:_presentation) o end |
#info_update(object, attribute, ) ⇒ Object
19 20 21 |
# File 'lib/app/helpers/form_elements/info.rb', line 19 def info_update(object, attribute) # do absolutely nothing end |
#integer_field_edit(object, attribute) ⇒ Object
8 9 10 |
# File 'lib/app/helpers/form_elements/integer_field.rb', line 8 def integer_field_edit(object, attribute) number_field_tag attribute, (object.send attribute.to_sym), :class => 'input_integer_field' # for abide: , :required => true end |
#integer_field_show(object, attribute) ⇒ Object
4 5 6 |
# File 'lib/app/helpers/form_elements/integer_field.rb', line 4 def integer_field_show(object, attribute) link_to_inline_edit object, attribute, object[attribute].nil? ? "<i class='fi-plus'></i>".html_safe : object[attribute] end |
#integer_field_update(object, attribute) ⇒ Object
12 13 14 |
# File 'lib/app/helpers/form_elements/integer_field.rb', line 12 def integer_field_update(object, attribute) object.send :write_attribute, attribute.to_sym, params[attribute.to_sym] end |
#kansen_slider_edit(object, attribute) ⇒ Object
36 37 38 39 40 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 |
# File 'lib/app/helpers/form_elements/kansen_slider.rb', line 36 def (object, attribute) # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form! values = attribute_values(object, attribute) value = object.send(attribute).to_i # should be an int, will be 0 if nil css_id = "#{object.class.to_s.underscore}_#{object.id}_#{attribute}" display_value = values.assoc(value)[1] # values should be [ [ 0, value ], [ 3, value2 ] .... ] and we lookup the key, not the place in the array! out = "<div class='row collapse'>".html_safe out << "<div class='small-5 column kansen_slider_value' id='value_#{css_id}'>#{display_value}</div>".html_safe out << "<div class='small-7 column kansen_slider_edit slider slider_#{attribute.to_s}' id='slider_#{css_id}'></div>".html_safe out << "<input type='hidden' name='_#{object.class.to_s.underscore}[#{attribute}]' value='0' id='input_#{css_id}' />".html_safe out << ('<script> $(function() { var displayvalues = ' + values.collect {|x| x[1]}.inspect + '; $( "#slider_' + css_id + '" ).slider( { value:' + value.to_s + ', min: 0, max: ' + (values.length - 1 ).to_s + ', step: 1, slide: function( event, ui ) { $( "#input_' + css_id + '" ).val( ui.value ); $( "#value_' + css_id + '" ).html( displayvalues[ui.value] ); } } );').html_safe out << ('$( "#value_' + css_id + '" ).html(displayvalues[' + value.to_s + ']);').html_safe out << ('$( "#input_' + css_id + '" ).val(' + value.to_s + ');').html_safe out << ('}); </script>').html_safe out << '</div>'.html_safe out end |
#kansen_slider_show(object, attribute) ⇒ Object
kansen_slider
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/app/helpers/form_elements/kansen_slider.rb', line 5 def (object, attribute) values = attribute_values(object, attribute) value = object.send(attribute).to_i # should be an int display_value = values.assoc(value)[1] # values should be [ [ 0, value ], [ 3, value2 ] .... ] and we lookup the key, not the place in the array! css_id = "#{object.class.to_s.underscore}_#{object.id}_#{attribute}" if value == 0 || value > 5 out = display_value else out = "<div class='row collapse'>".html_safe out << "<div class='small-5 column slider_value' id='value_#{css_id}'>#{display_value}</div>".html_safe out << "<div class='small-7 column kansen_slider_show slider slider_#{attribute.to_s}' id='slider_#{css_id}'></div>".html_safe out << "<input type='hidden' name='_#{object.class.to_s.underscore}[#{attribute}]' value='0' id='input_#{css_id}' />".html_safe out << ('<script> $(function() { var displayvalues = ' + values.collect {|x| x[1]}.inspect + '; $( "#slider_' + css_id + '" ).slider( { value:' + value.to_s + ', disabled: true, min: 1, max: 5, step: 1, } ); }); </script>').html_safe out << "</div>".html_safe end link_to_inline_edit object, attribute, out end |
#kansen_slider_update(object, attribute) ⇒ Object
69 70 71 |
# File 'lib/app/helpers/form_elements/kansen_slider.rb', line 69 def (object, attribute) object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym] end |
#money_field_edit(object, attribute) ⇒ Object
8 9 10 |
# File 'lib/app/helpers/form_elements/money_field.rb', line 8 def money_field_edit(object, attribute) text_field_tag attribute, (object.send attribute), :class => 'input_money_field' end |
#money_field_show(object, attribute) ⇒ Object
4 5 6 |
# File 'lib/app/helpers/form_elements/money_field.rb', line 4 def money_field_show(object, attribute) link_to_inline_edit object, attribute, humanized_money_with_symbol(object.send attribute) end |
#money_field_update(object, attribute) ⇒ Object
12 13 14 |
# File 'lib/app/helpers/form_elements/money_field.rb', line 12 def money_field_update(object, attribute) object.send( "#{attribute}=", params[attribute]) end |
#month_year_picker_edit(object, attribute) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/app/helpers/form_elements/month_year_picker.rb', line 9 def month_year_picker_edit(object, attribute) css_id = 'datepicker_' + object.class.to_s.underscore + '_' + object.id.to_s + '_' + attribute.to_s out = text_field_tag attribute, ( object.send(attribute).nil? ? "" : object.send(attribute).strftime("%B %Y") ), :id => css_id, :class =>'datepicker' #out << (hidden_field_tag "hidden_" + attribute.to_s, ( object.send(attribute).nil? ? "" : object.send(attribute).strftime("%d-%m-%Y") ), :id => "hiddden_" + css_id) # http://jsfiddle.net/bopperben/DBpJe/ out << "<script>$('##{css_id}').datepicker( { changeMonth: true, changeYear: true, showButtonPanel: true, dateFormat: 'MM yy', regional: '', onClose: function(dateText, inst) { var month = $('#ui-datepicker-div .ui-datepicker-month :selected').val(); var year = $('#ui-datepicker-div .ui-datepicker-year :selected').val(); $(this).datepicker('setDate', new Date(year, month, 1)); } });</script>".html_safe end |
#month_year_picker_show(object, attribute) ⇒ Object
date
5 6 7 |
# File 'lib/app/helpers/form_elements/month_year_picker.rb', line 5 def month_year_picker_show(object, attribute) link_to_inline_edit object, attribute, object.send(attribute).nil? ? "<i class='fi-plus'></i>".html_safe : object.send(attribute).strftime("%B %Y") end |
#month_year_picker_update(object, attribute) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/app/helpers/form_elements/month_year_picker.rb', line 28 def month_year_picker_update(object, attribute) puts 'XXXXXXXXXXXXXXXXXXXXXXXXXX' + object[attribute.to_sym].inspect puts 'XXXXXXXXXXXXXXXXXXXXXXXXXX' + Date.parse(params[attribute.to_sym].to_s).strftime("%F").to_s object[attribute.to_sym] = Date.parse(params[attribute.to_sym].to_s).strftime("%F").to_s puts 'XXXXXXXXXXXXXXXXXXXXXXXXXX' + object[attribute.to_sym].inspect end |
#move_edit(object, attribute) ⇒ Object
8 9 10 11 |
# File 'lib/app/helpers/form_elements/move.rb', line 8 def move_edit(object, attribute) values = object.class.send :hash_tree_to_collection select( ('_' + object.class.to_s.underscore).to_sym, attribute, values, :selected => object.id ) end |
#move_show(object, attribute) ⇒ Object
4 5 6 |
# File 'lib/app/helpers/form_elements/move.rb', line 4 def move_show(object, attribute) link_to_inline_edit object, attribute, "<i class='fi-plus'></i>".html_safe end |
#move_update(object, attribute) ⇒ Object
13 14 15 16 |
# File 'lib/app/helpers/form_elements/move.rb', line 13 def move_update(object, attribute) parent = object.class.find_by_id(params['_' + object.class.to_s.underscore][attribute.to_sym]) parent.add_child(object) if parent end |
#pdf_link_edit(object, attribute) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/app/helpers/form_elements/pdf_link.rb', line 9 def pdf_link_edit(object, attribute) o = object.send(attribute) o = o.to_s + " (" + distance_of_time_in_words_to_now(o) + ")" if o.is_a?(Time) o = o._presentation if o.respond_to?(:_presentation) o end |
#pdf_link_show(object, attribute) ⇒ Object
not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES=:string
4 5 6 7 |
# File 'lib/app/helpers/form_elements/pdf_link.rb', line 4 def pdf_link_show(object, attribute) # the attribute is the action "#{link_to 'preview', "/#{attribute}/#{object.id}", :class => "pdf_preview"} #{link_to 'pdf', "/#{attribute}/#{object.id}.pdf", :class => "pdf_open"}".html_safe end |
#pdf_link_update(object, attribute) ⇒ Object
16 17 18 |
# File 'lib/app/helpers/form_elements/pdf_link.rb', line 16 def pdf_link_update(object, attribute) # do absolutely nothing end |
#plain_text_area_edit(object, attribute) ⇒ Object
8 9 10 |
# File 'lib/app/helpers/form_elements/plain_text_area.rb', line 8 def plain_text_area_edit(object, attribute) text_area_tag attribute, object[attribute], :class => 'attribute_text_area' end |
#plain_text_area_show(object, attribute) ⇒ Object
4 5 6 |
# File 'lib/app/helpers/form_elements/plain_text_area.rb', line 4 def plain_text_area_show(object, attribute) link_to_inline_edit object, attribute, (object[attribute].nil? || object[attribute].empty?) ? "<i class='fi-plus'></i>".html_safe : object[attribute] end |
#plain_text_area_update(object, attribute) ⇒ Object
12 13 14 |
# File 'lib/app/helpers/form_elements/plain_text_area.rb', line 12 def plain_text_area_update(object, attribute) object[attribute.to_sym] = params[attribute.to_sym] end |
#question_list_edit(object, attribute) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/app/helpers/form_elements/question_list.rb', line 17 def question_list_edit(object, attribute) object.send(attribute).build if object.send(attribute).empty? values = object.send(attribute).first.class.name.constantize.find(:all) # TODO bring order out = '<div class="edit_form_checklist">' out << '<ul>' Question.all.each do | question | out << '<li>' out << h(question._presentation) unless question.subquestions.empty? out << '<ul>' question.subquestions.each do | subquestion | out << '<li>' out << h(subquestion._presentation) out << '</li>' end out << '</ul>' end out << '</li>' end out << '</ul>' out << '</div>' out.html_safe end |
#question_list_show(object, attribute) ⇒ Object
checklist
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/app/helpers/form_elements/question_list.rb', line 5 def question_list_show(object, attribute) out = '<ul class="question_list">' out << link_to_inline_edit(object, attribute) if object.send(attribute).empty? object.send(attribute).sort.each do | item | out << '<li>' out << link_to_inline_edit(object, attribute, item._presentation ) out << '</li>' end out << '</ul>' out.html_safe end |
#question_list_update(object, attribute) ⇒ Object
41 42 43 44 |
# File 'lib/app/helpers/form_elements/question_list.rb', line 41 def question_list_update(object, attribute) params[attribute] ||= {} object.send(attribute.singularize + '_ids=', params[attribute].keys) end |
#radio_button_edit(object, attribute) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/app/helpers/form_elements/radio_button.rb', line 12 def (object, attribute) out ='' values = attribute_values(object, attribute) values.each do |key,value| out << "<div class='row #{cycle('odd', 'even')}'>" out << (attribute.to_s, key, key == object.send(attribute)) out << "<label for=#{key}>#{value}</label>" out << '</div>' end out.html_safe end |
#radio_button_show(object, attribute) ⇒ Object
[ :sex , “gender”, :radio_button, { 1 => ‘male’, 2 => ‘female’ } ],
7 8 9 10 |
# File 'lib/app/helpers/form_elements/radio_button.rb', line 7 def (object, attribute) values = attribute_values(object, attribute) link_to_inline_edit object, attribute, object.send(attribute) ? values.assoc(object.send(attribute))[1] : "" end |
#radio_button_update(object, attribute) ⇒ Object
24 25 26 |
# File 'lib/app/helpers/form_elements/radio_button.rb', line 24 def (object, attribute) object[attribute.to_s.to_sym] = params[attribute.to_s.to_sym] end |
#scale_with_integers_edit(object, attribute) ⇒ Object
14 15 16 17 18 |
# File 'lib/app/helpers/form_elements/scale_with_integers.rb', line 14 def scale_with_integers_edit(object, attribute) # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form! values = attribute_values(object, attribute) collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute)) end |
#scale_with_integers_show(object, attribute) ⇒ Object
scale_with_integers generates a scale with the given list of integers as options
values must be a Range or a one-dimensional array of Integers
9 10 11 12 |
# File 'lib/app/helpers/form_elements/scale_with_integers.rb', line 9 def scale_with_integers_show(object, attribute) values = attribute_values(object, attribute) link_to_inline_edit object, attribute, values[object.send(attribute).to_s] end |
#scale_with_integers_update(object, attribute) ⇒ Object
20 21 22 |
# File 'lib/app/helpers/form_elements/scale_with_integers.rb', line 20 def scale_with_integers_update(object, attribute) object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym] end |
#scale_with_values_edit(object, attribute) ⇒ Object
13 14 15 16 17 |
# File 'lib/app/helpers/form_elements/scale_with_values.rb', line 13 def scale_with_values_edit(object, attribute) # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form! values = attribute_values(object, attribute) collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute)) end |
#scale_with_values_show(object, attribute) ⇒ Object
scale_with_values generates a scale with the given list of values as options
values must be a hash { integer => string, … } or an one-dimensional array of strings
8 9 10 11 |
# File 'lib/app/helpers/form_elements/scale_with_values.rb', line 8 def scale_with_values_show(object, attribute) values = attribute_values(object, attribute) link_to_inline_edit object, attribute, values[object.send(attribute)][1] end |
#scale_with_values_update(object, attribute) ⇒ Object
19 20 21 |
# File 'lib/app/helpers/form_elements/scale_with_values.rb', line 19 def scale_with_values_update(object, attribute) object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym] end |
#slider_with_values_edit(object, attribute) ⇒ Object
37 38 39 40 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 |
# File 'lib/app/helpers/form_elements/slider_with_values.rb', line 37 def (object, attribute) # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form! values = attribute_values(object, attribute) value = object.send(attribute).to_i # should be an int, will be 0 if nil css_id = "#{object.class.to_s.underscore}_#{object.id}_#{attribute}" display_value = values.assoc(value)[1] # values should be [ [ 0, value ], [ 3, value2 ] .... ] and we lookup the key, not the place in the array! out = "".html_safe out << "<div class='slider slider_#{attribute.to_s}' id='slider_#{css_id}'></div>".html_safe out << "<div class='slider_value' id='value_#{css_id}'>#{display_value}</div>".html_safe out << "<div style='clear: both' />".html_safe out << "<input type='hidden' name='_#{object.class.to_s.underscore}[#{attribute}]' value='0' id='input_#{css_id}' />".html_safe out << ('<script> $(function() { var displayvalues = ' + values.collect {|x| x[1]}.inspect + '; $( "#slider_' + css_id + '" ).slider( { value:' + value.to_s + ', range: "min", min: 0, max: 5, step: 1, slide: function( event, ui ) { $( "#input_' + css_id + '" ).val( ui.value ); $( "#value_' + css_id + '" ).html( displayvalues[ui.value] ); } } );').html_safe out << ('$( "#value_' + css_id + '" ).html(displayvalues[' + value.to_s + ']);').html_safe out << ('$( "#input_' + css_id + '" ).val(' + value.to_s + ');').html_safe out << ('}); </script>').html_safe out end |
#slider_with_values_show(object, attribute) ⇒ Object
slider_with_values
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/app/helpers/form_elements/slider_with_values.rb', line 5 def (object, attribute) values = attribute_values(object, attribute) value = object.send(attribute).to_i # should be an int display_value = values.assoc(value)[1] # values should be [ [ 0, value ], [ 3, value2 ] .... ] and we lookup the key, not the place in the array! css_id = "#{object.class.to_s.underscore}_#{object.id}_#{attribute}" if value == 0 out = "?" # we use this as the 'unknown' value. So in the data, 0 should always be the unknown value. This gives problems with sliders where the real value is 0. else out = "".html_safe out << "<div class='slider slider_#{attribute.to_s}' id='slider_#{css_id}'></div>".html_safe out << "<div class='slider_value' id='value_#{css_id}'>#{display_value}</div>".html_safe out << "<div style='clear: both' />".html_safe out << "<input type='hidden' name='_#{object.class.to_s.underscore}[#{attribute}]' value='0' id='input_#{css_id}' />".html_safe out << ('<script> $(function() { var displayvalues = ' + values.collect {|x| x[1]}.inspect + '; $( "#slider_' + css_id + '" ).slider( { value:' + value.to_s + ', range: "min", disabled: true, min: 0, max: ' + values.length + ', step: 1, } ); }); </script>').html_safe end link_to_inline_edit object, attribute, out end |
#slider_with_values_update(object, attribute) ⇒ Object
71 72 73 |
# File 'lib/app/helpers/form_elements/slider_with_values.rb', line 71 def (object, attribute) object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym] end |
#text_area_edit(object, attribute) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/app/helpers/form_elements/text_area.rb', line 30 def text_area_edit(object, attribute) if defined? Ckeditor cktext_area_tag( attribute, object[attribute], :id => "textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}", :ckeditor => { :width => '100%', :height => '200px' } ) else text_area_tag attribute, object[attribute], :class => 'attribute_text_area' end end |
#text_area_show(object, attribute) ⇒ Object
4 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 'lib/app/helpers/form_elements/text_area.rb', line 4 def text_area_show(object, attribute) if defined? Ckeditor link_to_inline_edit object, attribute, '<div class="ckeditor_area">'.html_safe + cktext_area_tag( attribute, object[attribute], :id => "textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}", :ckeditor => { :width => '100%', :height => '200px', :toolbar => "None", :readOnly => "true", :resize_enabled => "false", :toolbarCanCollapse => "false" } ) + image_tag( 'glass_plate.gif', :class => "glass_plate", :title => '' ) + '</div>'.html_safe else link_to_inline_edit object, attribute, object[attribute] end end |
#text_area_update(object, attribute) ⇒ Object
45 46 47 |
# File 'lib/app/helpers/form_elements/text_area.rb', line 45 def text_area_update(object, attribute) object[attribute.to_sym] = params[attribute.to_sym] end |
#text_area_without_ckeditor_edit(object, attribute) ⇒ Object
8 9 10 |
# File 'lib/app/helpers/form_elements/text_area_without_ckeditor.rb', line 8 def text_area_without_ckeditor_edit(object, attribute) text_area_tag attribute, object[attribute], :class => 'attribute_text_area' end |
#text_area_without_ckeditor_show(object, attribute) ⇒ Object
4 5 6 |
# File 'lib/app/helpers/form_elements/text_area_without_ckeditor.rb', line 4 def text_area_without_ckeditor_show(object, attribute) link_to_inline_edit object, attribute, (object[attribute].nil? || object[attribute].empty?) ? "<i class='fi-plus'></i>".html_safe : object[attribute] end |
#text_area_without_ckeditor_update(object, attribute) ⇒ Object
12 13 14 |
# File 'lib/app/helpers/form_elements/text_area_without_ckeditor.rb', line 12 def text_area_without_ckeditor_update(object, attribute) object[attribute.to_sym] = params[attribute.to_sym] end |
#text_field_edit(object, attribute) ⇒ Object
8 9 10 |
# File 'lib/app/helpers/form_elements/text_field.rb', line 8 def text_field_edit(object, attribute) text_field_tag attribute, (object.send attribute.to_sym), :class => 'input_text_field' # for abide: , :required => true end |
#text_field_show(object, attribute) ⇒ Object
4 5 6 |
# File 'lib/app/helpers/form_elements/text_field.rb', line 4 def text_field_show(object, attribute) link_to_inline_edit object, attribute, (object[attribute].nil? || object[attribute].empty?) ? "<i class='fi-plus'></i>".html_safe : object[attribute] end |
#text_field_update(object, attribute) ⇒ Object
12 13 14 |
# File 'lib/app/helpers/form_elements/text_field.rb', line 12 def text_field_update(object, attribute) object.send :write_attribute, attribute.to_sym, params[attribute.to_sym] end |