Giter VIP home page Giter VIP logo

Comments (8)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 26, 2024
Also when I call columns[:product].update = [:batch] inside ItemsController, 
everytime I change Product value inside Items form, Batch column updates also 
inside Invoices form - parent

Original comment by [email protected] on 13 Jul 2010 at 10:09

from activescaffold.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 26, 2024
Add explaining screenshot to better understand `update` field problem.

Original comment by [email protected] on 13 Jul 2010 at 2:25

Attachments:

from activescaffold.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 26, 2024
Changed parent model assocation to `batch_no` instead of `batch`. Now I get an 
JS error: TypeError: $("record_batch_") is null

Original comment by [email protected] on 13 Jul 2010 at 5:37

from activescaffold.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 26, 2024
After some debugging and brain exertion, I came with solution for this problem.

Just needed to change one single variable (In 
"lib/active_scaffold/helpers/form_column_helpers.rb" 
javascript_for_update_column)
FROM:
url_params[:scope] = params[:scope] || scope
TO: 
url_params[:scope] = scope || scope

params[:scope] seems to be empty most of the time in this method.

And here is as_overrides.rb for people who encounters same problem:

module ActiveScaffold
  module Helpers
    module FormColumnHelpers
      def javascript_for_update_column(column, scope, options)
        if column.update_column
          form_action = :create
          form_action = :update if params[:action] == 'edit'
          url_params = {:action => 'render_field', :id => params[:id], :column => column.name, :update_column => column.update_column}
          url_params[:eid] = params[:eid] if params[:eid]
          url_params[:controller] = controller.class.active_scaffold_controller_for(@record.class).controller_path if scope
          url_params[:scope] = scope if scope 
          #url_params[:scope] = params[:scope] if scope # Was this, but params[:scope] seem to be always empty in this method
          ajax_options = {:method => :get, 
                          :url => url_for(url_params), :with => column.send_form_on_update_column ? "Form.serialize(this.form)" : "'value=' + this.value",
                          :after => "$('#{loading_indicator_id(:action => :render_field, :id => params[:id])}').style.visibility = 'visible'; Form.disable('#{element_form_id(:action => form_action)}');",
                          :complete => "$('#{loading_indicator_id(:action => :render_field, :id => params[:id])}').style.visibility = 'hidden'; Form.enable('#{element_form_id(:action => form_action)}');"}
          options[:onchange] = "#{remote_function(ajax_options)};#{options[:onchange]}"
        end
        options
      end
    end
  end
end


Original comment by [email protected] on 17 Jul 2010 at 8:44

from activescaffold.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 26, 2024
[deleted comment]

from activescaffold.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 26, 2024
params[:scope] should be filled when render_field action is requested, don't 
you get params[:scope] in your render_action request?

About your conditions for association issue, in a form for batch with items and 
invoices subforms, only methods from BatchesHelper will be used, unless you 
have helper :all in your application controller. You can test 
"@record.is_a?(Item) && assoc.name == :batch"

Another time submit one issue for each problem.

Original comment by [email protected] on 19 Jul 2010 at 7:07

from activescaffold.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 26, 2024
Nope, I do not get params[:scope] (maybe it is blacklisted param in AS?). I 
spent great deal of time trying to find in AS where things get wrong.

Situation with helpers is clear for me at the moment. However, maybe it would 
be better to call helper override methods also using class names, because if 
you have few separate models working in one window and these models have fields 
which have same names and you write a form or condition override method, then 
it applies to both fields, and this leads to pain and you have to rename 
columns. (Experienced this exact situation)

Sorry for mixing things up. 

Original comment by [email protected] on 20 Jul 2010 at 7:07

from activescaffold.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 26, 2024
I will improve naming of helper overrides if it's possible without breaking 
backwards compatibility.

A recent fix introduced a bug with render_field and fields with scope, 
params[:scope] shouldn't be used. I was confused because the line is 
url_options[:scope] = params[:scope] if scope, not url_options[:scope] = 
params[:scope] || scope. We need much more tests to avoid these issues.

It's fixed now

Original comment by [email protected] on 21 Jul 2010 at 8:15

  • Changed state: Fixed

from activescaffold.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.