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. 12
      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
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
end
@ -72,6 +74,7 @@ class MyProjectsOverviewsController < ApplicationController
render(:partial => "block_textilizable",
:locals => { :user => @user,
:project => @project,
:block_title => l(:label_custom_element),
:block_name => @overview.hidden.first.first,
:textile => @overview.hidden.first.last})
else

@ -4,17 +4,17 @@ class MyProjectsOverview < ActiveRecord::Base
serialize :right, 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}
return unless el
el.pop
el << new_content
el[1] = title
el[2] = new_content
save
end
def new_custom_element
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
def elements

@ -9,6 +9,10 @@
</div>
<div class="handle">
<div style="float:right;margin-right:16px;z-index:500;">
<a href="#" onclick="$('<%= block_name %>-form-div').toggle(); $('<%= block_name %>-preview-div').toggle(); return false" class="preview-icon">Preview</a>
</div>
<div id="<%= block_name %>-form-div" style="display: none">
<% form_for :overview, @overview,
:url => {:action => 'update_custom_element'},
:html => {:id => "block_form_#{block_name.dasherize}",
@ -17,10 +21,18 @@
:multipart => true} do |f| %>
<fieldset>
<%= hidden_field_tag 'block_name', block_name %>
<%= 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>

@ -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>
<%= textilizable(textile) %>
</ul>

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

@ -76,7 +76,9 @@ function removeBlock(block) {
<%= render(:partial => 'block', :locals => {:block_name => b}) %>
<% elsif b.respond_to? :to_ary %>
<%= 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 %>
</div>
@ -89,7 +91,9 @@ function removeBlock(block) {
<%= render(:partial => 'block', :locals => {:block_name => b}) %>
<% elsif b.respond_to? :to_ary %>
<%= 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 %>
</div>

Loading…
Cancel
Save