Changeset 1090
- Timestamp:
- 2008-07-01 11:14:08 (6 months ago)
- Files:
-
- trunk/app/helpers/application_helper.rb (modified) (2 diffs)
- trunk/lib/parser/lib/rules/zena.rb (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/helpers/application_helper.rb
r1082 r1090 13 13 "#{params[:dom_id]}_#{node.zip}" 14 14 else 15 params[:udom_id] || params[:dom_id]15 @dom_id || params[:udom_id] || params[:dom_id] 16 16 end 17 17 end … … 32 32 page.replace "#{params[:dom_id]}_form", :file => fullpath_from_template_url + "_form.erb" 33 33 end 34 elsif params[:u_url] 35 # C. update another part of the page 36 if node_id = params[:u_id] 37 if node_id.to_i != obj.zip 38 if base_class == Node 39 instance_variable_set("@#{base_class.to_s.underscore}", secure(base_class) { base_class.find_by_zip(node_id) }) 40 else 41 instance_variable_set("@#{base_class.to_s.underscore}", secure(base_class) { base_class.find_by_id(node_id) }) 34 elsif params[:udom_id] 35 if params[:udom_id] == '_page' 36 # reload page 37 page << "document.location.href = document.location.href;" 38 else 39 # C. update another part of the page 40 if node_id = params[:u_id] 41 if node_id.to_i != obj.zip 42 if base_class == Node 43 instance_variable_set("@#{base_class.to_s.underscore}", secure(base_class) { base_class.find_by_zip(node_id) }) 44 else 45 instance_variable_set("@#{base_class.to_s.underscore}", secure(base_class) { base_class.find_by_id(node_id) }) 46 end 42 47 end 43 48 end 44 end 45 page.replace params[:udom_id], :file => fullpath_from_template_url(params[:u_url]) + ".erb" 46 if params[:done] 47 page.toggle "#{params[:dom_id]}_form", "#{params[:dom_id]}_add" 48 page << params[:done] 49 page.replace params[:udom_id], :file => fullpath_from_template_url(params[:u_url]) + ".erb" 50 if params[:upd_both] 51 @dom_id = params[:dom_id] 52 page.replace params[:dom_id], :file => fullpath_from_template_url + ".erb" 53 end 54 if params[:done] 55 page.toggle "#{params[:dom_id]}_form", "#{params[:dom_id]}_add" 56 page << params[:done] 57 end 49 58 end 50 59 else 51 60 # D. normal update 61 #if params[:dom_id] == '_page' 62 # # reload page 63 # page << "document.location.href = document.location.href;" 64 # 52 65 case params[:action] 53 66 when 'edit' trunk/lib/parser/lib/rules/zena.rb
r1087 r1090 503 503 # swap an attribute 504 504 # TODO: test 505 def r_swap 506 if block = ancestor('block') || ancestor('each') 505 def r_swap 506 if upd = @params[:update] 507 if upd == '_page' 508 block = nil 509 elsif block = find_target(upd) 510 # ok 511 if ancestor('block') || ancestor('each') 512 upd_both = '&upd_both=true' 513 else 514 upd_both = '' 515 end 516 else 517 return 518 end 519 elsif ancestor('block') || ancestor('each') 507 520 # ancestor: ok 521 block = self 508 522 elsif parent && block = parent.descendant('block') 509 523 # sibling: ok 524 upd_both = '' 510 525 else 511 526 return parser_error("missing 'block' in same parent") … … 513 528 states = ((@params[:states] || 'todo, done') + ' ').split(',').map(&:strip) 514 529 515 url_params = "node[#{@params[:attr]}]=\#{#{states.inspect}[ ((#{states.inspect}.index(#{node_attribute(@params[:attr])}.to_s) || 0)+1) % #{states.size}]}" 530 url_params = "node[#{@params[:attr]}]=\#{#{states.inspect}[ ((#{states.inspect}.index(#{node_attribute(@params[:attr])}.to_s) || 0)+1) % #{states.size}]}#{upd_both}" 531 516 532 517 533 out link_to_update(block, :url_params => url_params, :method => :put, :html_params => get_html_params(@params)) … … 1159 1175 opts = {} 1160 1176 1177 if upd = @params[:update] 1178 if upd == '_page' 1179 target = nil 1180 elsif target = find_target(upd) 1181 # ok 1182 else 1183 return 1184 end 1185 end 1186 1161 1187 unless target = ancestor('block') 1162 1188 target = self … … 1638 1664 @html_tag_done = true 1639 1665 end 1640 1641 1666 1642 1667 if upd = @params[:update] … … 2617 2642 2618 2643 if method == :get 2619 url_params << "t_url=#{CGI.escape(target.template_url)}" 2620 url_params << "dom_id=#{target.dom_id}" 2644 if target 2645 url_params << "t_url=#{CGI.escape(target.template_url)}" 2646 url_params << "dom_id=#{target.dom_id}" 2647 else 2648 url_params << "dom_id=_page" 2649 end 2621 2650 else 2622 2651 url_params << "t_url=#{CGI.escape(template_url)}" if method != :delete … … 2624 2653 url_params << "dom_id=#{dom_id}" 2625 2654 if target != self 2626 url_params << "u_url=#{CGI.escape(target.template_url)}" 2627 url_params << "udom_id=#{target.dom_id}" 2655 if target 2656 url_params << "u_url=#{CGI.escape(target.template_url)}" 2657 url_params << "udom_id=#{target.dom_id}" 2658 else 2659 url_params << "udom_id=_page" 2660 end 2628 2661 end 2629 2662 end
