Module: Netzke::Basepack::GridPanel::Services
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/netzke/basepack/grid_panel/services.rb
Instance Method Summary collapse
-
#add_form__form_panel0__netzke_submit_endpoint(params) ⇒ Object
Edit in form specific endpoint.
-
#deliver_component_endpoint(params) ⇒ Object
When providing the edit_form component, fill in the form with the requested record.
- #edit_form__form_panel0__netzke_submit_endpoint(params) ⇒ Object
-
#get_data(*args) ⇒ Object
Implementation for the “get_data” endpoint.
- #multi_edit_form__multi_edit_form0__netzke_submit_endpoint(params) ⇒ Object
Instance Method Details
#add_form__form_panel0__netzke_submit_endpoint(params) ⇒ Object
Edit in form specific endpoint
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/netzke/basepack/grid_panel/services.rb', line 96 def add_form__form_panel0__netzke_submit_endpoint(params) res = component_instance(:add_form__form_panel0).netzke_submit(params) if res[:set_form_values] # successful creation on_data_changed res[:set_form_values] = nil end res.to_nifty_json end |
#deliver_component_endpoint(params) ⇒ Object
When providing the edit_form component, fill in the form with the requested record
138 139 140 141 |
# File 'lib/netzke/basepack/grid_panel/services.rb', line 138 def deliver_component_endpoint(params) components[:edit_form][:items].first.merge!(:record_id => params[:record_id].to_i) if params[:name] == 'edit_form' super end |
#edit_form__form_panel0__netzke_submit_endpoint(params) ⇒ Object
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/netzke/basepack/grid_panel/services.rb', line 107 def edit_form__form_panel0__netzke_submit_endpoint(params) res = component_instance(:edit_form__form_panel0).netzke_submit(params) if res[:set_form_values] on_data_changed res[:set_form_values] = nil end res.to_nifty_json end |
#get_data(*args) ⇒ Object
Implementation for the “get_data” endpoint
144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/netzke/basepack/grid_panel/services.rb', line 144 def get_data(*args) params = args.first || {} # params are optional! if !config[:prohibit_read] {}.tap do |res| records = get_records(params) res[:data] = records.map{|r| r.netzke_array(columns(:with_meta => true))} res[:total] = count_records(params) if config[:enable_pagination] end else flash :error => "You don't have permissions to read data" { :netzke_feedback => @flash } end end |
#multi_edit_form__multi_edit_form0__netzke_submit_endpoint(params) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/netzke/basepack/grid_panel/services.rb', line 118 def multi_edit_form__multi_edit_form0__netzke_submit_endpoint(params) ids = ActiveSupport::JSON.decode(params.delete(:ids)) data = ids.collect{ |id| ActiveSupport::JSON.decode(params[:data]).merge("id" => id) } data.map!{|el| el.delete_if{ |k,v| v.is_a?(String) && v.blank? }} # only interested in set values mod_records_count = process_data(data, :update).count # remove duplicated flash messages @flash = @flash.inject([]){ |r,hsh| r.include?(hsh) ? r : r.push(hsh) } if mod_records_count > 0 on_data_changed {:set_result => "ok", :netzke_feedback => @flash}.to_nifty_json else {:netzke_feedback => @flash}.to_nifty_json end end |