Permalink
Browse files

Fix netzkeReload

  • Loading branch information...
1 parent b130e21 commit 664a689c9ba15295afc88e27dd61d4f16a5ac193 nomadcoder committed Dec 22, 2012
View
@@ -1,6 +1,7 @@
# v0.8.2 - WIP
* bug fix
* RuntimeError "can't add a new key into hash during iteration" in Composition in some scenarious - by @wupdiwup
+ * netzkeReload works again
# v0.8.1 - 2012-12-15
* bug fix
View
@@ -356,12 +356,15 @@ Ext.define(null, {
},
/**
- * Reloads current component (calls the parent to reload us as its component)
+ * Reloads itself by instructing the parent to call `netzkeLoadComponent`.
+ * Note: in order for this to work, the component must be nested in a container with the 'fit' layout.
*/
netzkeReload: function(){
var parent = this.netzkeGetParentComponent();
+
if (parent) {
- parent.netzkeLoadComponent({id:this.netzkeLocalId(parent), container:this.ownerCt.id});
+ var name = this.netzkeLocalId(parent);
+ parent.netzkeLoadComponent(name, {container:this.ownerCt.id});
} else {
window.location.reload();
}
View
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["nomadcoder"]
- s.date = "2012-12-21"
+ s.date = "2012-12-22"
s.description = "Allows building complex RIA by greatly facilitating modular development"
s.email = "nmcoder@gmail.com"
s.extra_rdoc_files = [
@@ -124,6 +124,7 @@ Gem::Specification.new do |s|
"test/core_test_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb",
"test/core_test_app/app/components/scoped_components/extended_scoped_component.rb",
"test/core_test_app/app/components/scoped_components/some_scoped_component.rb",
+ "test/core_test_app/app/components/self_reloading.rb",
"test/core_test_app/app/components/server_caller.rb",
"test/core_test_app/app/components/server_caller/javascripts/server_caller.js",
"test/core_test_app/app/components/server_counter.rb",
@@ -23,6 +23,7 @@ class ComponentLoader < Netzke::Base
c.excluded = true
end
+ component :self_reloading
# this action is using netzkeLoadComponent "special" callback
action :load_with_feedback
@@ -45,9 +46,11 @@ class ComponentLoader < Netzke::Base
action :inaccessible
+ action :load_self_reloading
+
def configure(c)
super
- c.bbar = [:load_component, :load_in_window, :load_with_feedback, :load_window_with_simple_component, :load_composite, :load_with_params, :non_existing_component, :inaccessible, :config_only]
+ c.bbar = [:load_component, :load_in_window, :load_with_feedback, :load_window_with_simple_component, :load_composite, :load_with_params, :non_existing_component, :inaccessible, :config_only, :load_self_reloading]
end
endpoint :deliver_component do |params, this|
@@ -45,5 +45,10 @@
var instance = Ext.ComponentManager.create(config);
this.add(instance);
}, scope: this});
+ },
+
+ onLoadSelfReloading: function() {
+ this.netzkeLoadComponent('self_reloading');
}
+
}
@@ -0,0 +1,24 @@
+class SelfReloading < Netzke::Base
+ action :reload
+
+ def configure(c)
+ super
+ c.bbar = [:reload]
+ end
+
+ def js_configure(c)
+ super
+ state[:loaded_times] ||= 0
+ state[:loaded_times] += 1
+
+ c.title = "Loaded #{state[:loaded_times]} time(s)"
+ end
+
+ js_configure do |c|
+ c.on_reload = <<-JS
+ function(){
+ this.netzkeReload();
+ }
+ JS
+ end
+end
@@ -50,3 +50,20 @@ Feature: Component loader
Given I am on the ComponentLoader test page
When I press "Config only"
Then I should see "SimpleComponent (overridden)"
+
+ @javascript
+ Scenario: Component autoreloading
+ When I go to the SelfReloading test page
+ Then I should see panel title saying "Loaded 1 time(s)"
+ When I press "Reload"
+ Then I should see panel title saying "Loaded 2 time(s)"
+
+ @javascript
+ Scenario: Component autoreloading when in container
+ Given I am on the ComponentLoader test page
+ When I press "Load self reloading"
+ And I wait for response from server
+ Then I should see panel title saying "Loaded 1 time(s)"
+ When I press "Reload"
+ And I wait for response from server
+ Then I should see panel title saying "Loaded 2 time(s)"
@@ -62,3 +62,9 @@
When /I sleep (\d+) seconds?/ do |arg1|
sleep arg1.to_i
end
+
+Then /^I should see panel title saying "(.*?)"$/ do |title|
+ page.driver.browser.execute_script(<<-JS).should == true
+ return Ext.ComponentQuery.query('header[title="#{title}"]').length > 0;
+ JS
+end

0 comments on commit 664a689

Please sign in to comment.