Commit 4467d7c062571d624e4429ce111800847be5e126
1 parent
44d63989
Exists in
master
and in
29 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,6 +4,29 @@ class ApplicationController < ActionController::Base | ||
| 4 | 4 | ||
| 5 | before_filter :detect_stuff_by_domain | 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 | protected | 30 | protected |
| 8 | 31 | ||
| 9 | def detect_stuff_by_domain | 32 | def detect_stuff_by_domain |
app/controllers/home_controller.rb
| 1 | class HomeController < ApplicationController | 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 | end | 17 | end |
app/helpers/application_helper.rb
| 1 | # Methods added to this helper will be available to all templates in the application. | 1 | # Methods added to this helper will be available to all templates in the application. |
| 2 | module ApplicationHelper | 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 | end | 10 | end |
app/models/block.rb
| @@ -7,4 +7,8 @@ class Block < ActiveRecord::Base | @@ -7,4 +7,8 @@ class Block < ActiveRecord::Base | ||
| 7 | # A block must be associated to a box | 7 | # A block must be associated to a box |
| 8 | validates_presence_of :box_id | 8 | validates_presence_of :box_id |
| 9 | 9 | ||
| 10 | + def to_html | ||
| 11 | + return '<p>bli</p>' | ||
| 12 | + end | ||
| 13 | + | ||
| 10 | end | 14 | end |
app/models/box.rb
| 1 | class Box < ActiveRecord::Base | 1 | class Box < ActiveRecord::Base |
| 2 | + has_many :blocks | ||
| 2 | belongs_to :owner, :polymorphic => true | 3 | belongs_to :owner, :polymorphic => true |
| 3 | 4 | ||
| 4 | #we cannot have two boxs with the same number to the same owner | 5 | #we cannot have two boxs with the same number to the same owner |
app/views/layouts/application.rhtml
| @@ -6,13 +6,20 @@ | @@ -6,13 +6,20 @@ | ||
| 6 | </head> | 6 | </head> |
| 7 | <body> | 7 | <body> |
| 8 | <%= image_tag 'loading.gif', :id=>'spinner', :style=>"display:none; float:right;" %> | 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 | <div id="box_1" > | 18 | <div id="box_1" > |
| 10 | - <ul> | ||
| 11 | - <li> lado esquerdo | ||
| 12 | - </li> | ||
| 13 | - </ul> | 19 | + <%= show_block(@owner, 1)%> |
| 14 | </div> | 20 | </div> |
| 15 | <div id="box_2" > | 21 | <div id="box_2" > |
| 22 | + <%= show_block(@owner, 1)%> | ||
| 16 | <ul> | 23 | <ul> |
| 17 | <li> | 24 | <li> |
| 18 | <%= yield %> | 25 | <%= yield %> |
| @@ -20,6 +27,7 @@ | @@ -20,6 +27,7 @@ | ||
| 20 | </ul> | 27 | </ul> |
| 21 | </div> | 28 | </div> |
| 22 | <div id="box_3" > | 29 | <div id="box_3" > |
| 30 | + <%= show_block(@owner, 1)%> | ||
| 23 | <ul> | 31 | <ul> |
| 24 | <li> lado direito | 32 | <li> lado direito |
| 25 | </li> | 33 | </li> |