Commit 4467d7c062571d624e4429ce111800847be5e126
1 parent
44d63989
Exists in
staging
and in
42 other branches
ActionItem0: Adding list an link blocks
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@35 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
12 changed files
with
96 additions
and
4 deletions
Show diff stats
app/controllers/application.rb
| ... | ... | @@ -4,6 +4,29 @@ class ApplicationController < ActionController::Base |
| 4 | 4 | |
| 5 | 5 | before_filter :detect_stuff_by_domain |
| 6 | 6 | |
| 7 | + before_filter :detect_edit_layout | |
| 8 | + | |
| 9 | + def detect_edit_layout | |
| 10 | + @edit_layout = true unless params[:edit_layout].nil? | |
| 11 | + end | |
| 12 | + | |
| 13 | +# after_filter :render_actions | |
| 14 | + | |
| 15 | + def render_actions | |
| 16 | +@bla = 'funfou' | |
| 17 | +#return @bla | |
| 18 | + render_action('index', nil, true) | |
| 19 | +# render :update do |page| | |
| 20 | +# page.replace_html 'box_1', :partial => 'pending_todos' | |
| 21 | +# page.replace_html 'completed_todos', :partial => 'completed_todos' | |
| 22 | +# page.replace_html 'working_todos', :partial => 'working_todos' | |
| 23 | +# end | |
| 24 | + end | |
| 25 | + | |
| 26 | +# def render(type = nil) | |
| 27 | +# render_actions | |
| 28 | +# end | |
| 29 | + | |
| 7 | 30 | protected |
| 8 | 31 | |
| 9 | 32 | def detect_stuff_by_domain | ... | ... |
app/controllers/home_controller.rb
| 1 | 1 | class HomeController < ApplicationController |
| 2 | + | |
| 3 | + def index | |
| 4 | + #TODO this is a test case of owner | |
| 5 | + @owner = User.find(1) | |
| 6 | + end | |
| 7 | + | |
| 8 | +def teste | |
| 9 | + render :update do |page| | |
| 10 | + page.replace_html 'box_1', :partial => 'leo' | |
| 11 | +#'nem acredito' | |
| 12 | +# page.replace_html 'completed_todos', :partial => 'completed_todos' | |
| 13 | +# page.replace_html 'working_todos', :partial => 'working_todos' | |
| 14 | + end | |
| 15 | + | |
| 16 | +end | |
| 2 | 17 | end | ... | ... |
app/helpers/application_helper.rb
| 1 | 1 | # Methods added to this helper will be available to all templates in the application. |
| 2 | 2 | module ApplicationHelper |
| 3 | + | |
| 4 | + | |
| 5 | + def show_block(owner,box_number) | |
| 6 | + blocks = owner.boxes.find(:first, :conditions => ['number = ?', box_number]).blocks | |
| 7 | + @out = blocks.map {|b| b.to_html}.join('') | |
| 8 | + end | |
| 9 | + | |
| 3 | 10 | end | ... | ... |
app/models/block.rb
app/models/box.rb
app/views/layouts/application.rhtml
| ... | ... | @@ -6,13 +6,20 @@ |
| 6 | 6 | </head> |
| 7 | 7 | <body> |
| 8 | 8 | <%= image_tag 'loading.gif', :id=>'spinner', :style=>"display:none; float:right;" %> |
| 9 | + | |
| 10 | + <%= link_to _('edit layout'), params.merge({:edit_layout => true}) %> | |
| 11 | + <%= link_to _('show layout'), params.merge({:edit_layout => false}) %> | |
| 12 | + <%= link_to _('acao diferente'), :action => 'teste' %> | |
| 13 | + | |
| 14 | +teste | |
| 15 | +<%= @bla %> | |
| 16 | +oxe | |
| 17 | + | |
| 9 | 18 | <div id="box_1" > |
| 10 | - <ul> | |
| 11 | - <li> lado esquerdo | |
| 12 | - </li> | |
| 13 | - </ul> | |
| 19 | + <%= show_block(@owner, 1)%> | |
| 14 | 20 | </div> |
| 15 | 21 | <div id="box_2" > |
| 22 | + <%= show_block(@owner, 1)%> | |
| 16 | 23 | <ul> |
| 17 | 24 | <li> |
| 18 | 25 | <%= yield %> |
| ... | ... | @@ -20,6 +27,7 @@ |
| 20 | 27 | </ul> |
| 21 | 28 | </div> |
| 22 | 29 | <div id="box_3" > |
| 30 | + <%= show_block(@owner, 1)%> | |
| 23 | 31 | <ul> |
| 24 | 32 | <li> lado direito |
| 25 | 33 | </li> | ... | ... |