add preview and title to teaser elements, as per niels request

pull/6827/head
Tim Felgentreff 13 years ago
parent fb53d2f41a
commit 69e6305e9a
  1. 5
      app/controllers/my_projects_overviews_controller.rb
  2. 8
      app/models/my_projects_overview.rb
  3. 38
      app/views/my_projects_overviews/_block_textilizable.rhtml
  4. 2
      app/views/my_projects_overviews/blocks/_textilizable.rhtml
  5. 1
      app/views/my_projects_overviews/index.rhtml
  6. 8
      app/views/my_projects_overviews/page_layout.rhtml

@ -47,7 +47,9 @@ class MyProjectsOverviewsController < ApplicationController
def update_custom_element def update_custom_element
block_name = params["block_name"] block_name = params["block_name"]
@overview.save_custom_element(block_name, params["textile_#{block_name}"]) block_title = params["block_title_#{block_name}"]
textile = params["textile_#{block_name}"]
@overview.save_custom_element(block_name, block_title, textile)
redirect_to :back redirect_to :back
end end
@ -72,6 +74,7 @@ class MyProjectsOverviewsController < ApplicationController
render(:partial => "block_textilizable", render(:partial => "block_textilizable",
:locals => { :user => @user, :locals => { :user => @user,
:project => @project, :project => @project,
:block_title => l(:label_custom_element),
:block_name => @overview.hidden.first.first, :block_name => @overview.hidden.first.first,
:textile => @overview.hidden.first.last}) :textile => @overview.hidden.first.last})
else else

@ -4,17 +4,17 @@ class MyProjectsOverview < ActiveRecord::Base
serialize :right, Array serialize :right, Array
serialize :hidden, Array serialize :hidden, Array
def save_custom_element(name, new_content) def save_custom_element(name, title, new_content)
el = custom_elements.detect {|x| x.first == name} el = custom_elements.detect {|x| x.first == name}
return unless el return unless el
el.pop el[1] = title
el << new_content el[2] = new_content
save save
end end
def new_custom_element def new_custom_element
idx = custom_elements.any? ? custom_elements.sort.last.first.next : "a" idx = custom_elements.any? ? custom_elements.sort.last.first.next : "a"
[idx, "h2. #{l(:info_custom_text)}"] [idx, l(:label_custom_text), "h2. #{l(:info_custom_text)}"]
end end
def elements def elements

@ -9,18 +9,30 @@
</div> </div>
<div class="handle"> <div class="handle">
<% form_for :overview, @overview, <div style="float:right;margin-right:16px;z-index:500;">
:url => {:action => 'update_custom_element'}, <a href="#" onclick="$('<%= block_name %>-form-div').toggle(); $('<%= block_name %>-preview-div').toggle(); return false" class="preview-icon">Preview</a>
:html => {:id => "block_form_#{block_name.dasherize}", </div>
:class => nil, <div id="<%= block_name %>-form-div" style="display: none">
:method => :put, <% form_for :overview, @overview,
:multipart => true} do |f| %> :url => {:action => 'update_custom_element'},
<fieldset> :html => {:id => "block_form_#{block_name.dasherize}",
<%= hidden_field_tag 'block_name', block_name %> :class => nil,
<%= text_area_tag "textile_#{block_name}", textile, :cols => 40, :rows => 5, :class => 'wiki-edit' %> :method => :put,
<%= wikitoolbar_for "textile_#{block_name}" %> :multipart => true} do |f| %>
</fieldset> <fieldset>
<%= submit_tag l(:button_submit) %> <%= hidden_field_tag 'block_name', block_name %>
<% end %> <%= text_field_tag "block_title_#{block_name}", block_title %>
<%= text_area_tag "textile_#{block_name}", textile, :cols => 40, :rows => 5, :class => 'wiki-edit' %>
<%= wikitoolbar_for "textile_#{block_name}" %>
</fieldset>
<%= submit_tag l(:button_submit) %>
<% end %>
</div>
<div id="<%= block_name %>-preview-div">
<%= render :partial => "my_projects_overviews/blocks/textilizable",
:locals => { :block_title => block_title,
:textile => textile }
%>
</div>
</div> </div>
</div> </div>

@ -1,4 +1,4 @@
<h2 class="page-layout-only"><%=l(:label_custom_text)%></h2> <h2 class="page-layout-only"><%= block_title || l(:label_custom_text) %></h2>
<ul> <ul>
<%= textilizable(textile) %> <%= textilizable(textile) %>
</ul> </ul>

@ -30,6 +30,7 @@
<%= render :partial => "my_projects_overviews/blocks/textilizable", <%= render :partial => "my_projects_overviews/blocks/textilizable",
:locals => { :project => @project, :locals => { :project => @project,
:user => @user, :user => @user,
:block_title => b[1],
:textile => b.last } %> :textile => b.last } %>
<% end %> <% end %>
</div> </div>

@ -76,7 +76,9 @@ function removeBlock(block) {
<%= render(:partial => 'block', :locals => {:block_name => b}) %> <%= render(:partial => 'block', :locals => {:block_name => b}) %>
<% elsif b.respond_to? :to_ary %> <% elsif b.respond_to? :to_ary %>
<%= render(:partial => 'block_textilizable', <%= render(:partial => 'block_textilizable',
:locals => {:block_name => b.first, :textile => b.last}) %> :locals => {:block_name => b.first,
:block_title => b[1],
:textile => b.last}) %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>
@ -89,7 +91,9 @@ function removeBlock(block) {
<%= render(:partial => 'block', :locals => {:block_name => b}) %> <%= render(:partial => 'block', :locals => {:block_name => b}) %>
<% elsif b.respond_to? :to_ary %> <% elsif b.respond_to? :to_ary %>
<%= render(:partial => 'block_textilizable', <%= render(:partial => 'block_textilizable',
:locals => {:block_name => b.first, :textile => b.last}) %> :locals => {:block_name => b.first,
:block_title => b[1],
:textile => b.last}) %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>

Loading…
Cancel
Save