Skip to content

Commit

Permalink
Fixed preview form inside block.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed Mar 1, 2013
1 parent 13dbbd6 commit b2581eb
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 12 deletions.
2 changes: 2 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* Support for Range in zafu. <== TODO: Document
* Added options to query_parse to ignore unwanted parameters <== TODO: Document
* Added 'hparams' option to only return Hash parameters from params. <== TODO: Document
* Fixed query_parse to convert dates to UTC.
* Fixed form preview inside block.

== 1.2.2 2012-08-30

Expand Down
4 changes: 3 additions & 1 deletion lib/zafu/process/ajax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ def r_block
#node.dom_prefix = dom_name
@markup.set_id(node.dom_id(:list => false))
@markup.set_dyn_param(:"data-z", "<%= #{node}.zip %>")
expand_with
# Elements inside the block should render as normal (not transforming forms into remote
# forms or things like this).
expand_with(:template_url => nil)
elsif @context[:saved_template]
# already in a parent's store operation. Reset scope and simply render inline elements
# reset scope
Expand Down
2 changes: 2 additions & 0 deletions lib/zena/use/forms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ def form_options
end

def form_hidden_fields(opts)
dom_name = node.dom_prefix || dom_name

hidden_fields = super
add_params = @context[:add] ? @context[:add].params : {}
set_fields = []
Expand Down
41 changes: 30 additions & 11 deletions test/fixtures/files/TestNode.zafu
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,38 @@

<div class='test' id='filter3' do='selenium'>
<h3>filter3</h3>
<p>From with live preview.</p>
<p>Form with live preview.</p>
<r:form redir='url(this, :test => "filter3")' node[v_status]='50' preview='filter3_preview'>
<r:input label='t' name='title'/>
<r:textarea label='t' name='text'/>
<r:textarea label='t' name='text'/>
</r:form>

<div id='filter3_preview' do='block' do='preview_node'>
<r:ajax?>
<span id='filter3_msg' do='if' test='title == "Foobar"'>PREVIEW</span>
</r:ajax?>
<h3 id='filter3_title' do='title'/>
<div id='filter3_zazen' do='zazen' attr='text'/>
</div>
<div id='filter3_preview' do='block' do='preview_node'>
<r:ajax?>
<span id='filter3_msg' do='if' test='title == "Foobar"'>PREVIEW</span>
</r:ajax?>
<h3 id='filter3_title' do='title'/>
<div id='filter3_zazen' do='zazen' attr='text'/>
</div>
</div>

<div class='test' id='filter4' do='selenium'>
<h3>filter4</h3>
<p>Form with live preview from block.</p>
<div id='filter4_b' do='block'>
<r:form redir='url(this, :test => "filter4")' node[v_status]='50' preview='filter4_preview'>
<r:input label='t' name='title'/>
<r:textarea label='t' name='text'/>
</r:form>
</div>

<div id='filter4_preview' do='block' do='preview_node'>
<r:ajax?>
<span id='filter4_msg' do='if' test='title == "Foobar"'>PREVIEW</span>
</r:ajax?>
<h3 id='filter4_title' do='title'/>
<div id='filter4_zazen' do='zazen' attr='text'/>
</div>
</div>

//! form1
Expand Down Expand Up @@ -283,8 +302,8 @@
<div class='test' id='form4' do='selenium'>
<h3>form4</h3>
<p>Form to update hash property.</p>
<p id='form4_one' do='settings["one"]'/>
<p id='form4_two' do='settings["two"]'/>
<p id='form4_one' do='settings["one"]'/>
<p id='form4_two' do='settings["two"]'/>
<r:form node[v_status]='50'>
<ul>
<li><r:input label='t' name='settings[two]'/></li>
Expand Down
20 changes: 20 additions & 0 deletions test/selenium/Filter/filter4.rsel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
open '/oo/testnode37.html?test=filter4'
# Should render preview_node with current values
verify_text 'filter4_title', 'Kill the bugs'
type 'filter4_b_title', 'Foobar'
wait_for_element_present 'filter4_msg'
verify_text 'filter4_title', 'Foobar'
type 'filter4_b_text', '*hop*'
wait_for_element_present 'css=#filter4_zazen strong'

# submit
click_and_wait 'css=input[type=submit]'

# Redirected to same page
# Parameter on [form] properly passed
verify_text 'filter4_title', 'Foobar'
type 'filter4_b_title', 'Kill the bugs'
type 'filter4_b_text', ''
click_and_wait 'css=input[type=submit]'
# Reverted changes
verify_text 'filter4_title', 'Kill the bugs'

0 comments on commit b2581eb

Please sign in to comment.