Sha256: e46f2464b5077e65e4605377917d70a9d086db0394d4f3d6121cef1cf542f263

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

Contents

module Netzke
  module Basepack
    class Form < Netzke::Base
      module Endpoints
        extend ActiveSupport::Concern

        included do
          # Called when the form gets submitted (e.g. by pressing the Apply button)
          endpoint :netzke_submit do |params, this|
            data = ActiveSupport::JSON.decode(params[:data])
            submit(data, this)
          end

          # Can be called when the form needs to load a record with given ID. E.g.:
          #
          #     someForm.netzkeLoad({id: 100});
          endpoint :netzke_load do |params, this|
            @record = data_class && data_adapter.find_record(params[:id])
            this.set_form_values js_record_data
          end

          # Returns options for a combobox
          # params receive:
          # +attr+ - column's name
          # +query+ - what's typed-in in the combobox
          # +id+ - selected record id
          endpoint :get_combobox_options do |params, this|
            attr = fields[params[:attr].to_sym]
            this.data = data_adapter.combo_data(attr, params[:query])
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
netzke-basepack-0.12.9 lib/netzke/basepack/form/endpoints.rb
netzke-basepack-0.12.8 lib/netzke/basepack/form/endpoints.rb
netzke-basepack-0.12.7 lib/netzke/basepack/form/endpoints.rb
netzke-basepack-0.12.6 lib/netzke/basepack/form/endpoints.rb
netzke-basepack-0.12.5 lib/netzke/basepack/form/endpoints.rb
netzke-basepack-0.12.4 lib/netzke/basepack/form/endpoints.rb
netzke-basepack-0.12.3 lib/netzke/basepack/form/endpoints.rb
netzke-basepack-0.12.2 lib/netzke/basepack/form/endpoints.rb
netzke-basepack-0.12.1 lib/netzke/basepack/form/endpoints.rb