OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/app/views/my_projects_overviews/page_layout.rhtml

120 lines
3.9 KiB

<% field_list = ['top', 'left', 'right', 'hidden'] %>
13 years ago
<script language="JavaScript">
//<![CDATA[
function recreateSortables() {
<% field_list.each do |f| %>
Sortable.destroy('list-<%= f %>');
<% end %>
<% field_list.each do |f| %>
Sortable.create("list-<%= f %>", {
constraint: false,
containment: <%= field_list.collect {|x| "list-#{x}" }.inspect %>,
dropOnEmpty: true,
handle: 'handle',
onUpdate: function () {
new Ajax.Request('<%= url_for(:controller => 'my_projects_overviews',
:action => 'order_blocks',
:group => f) %>',
{ asynchronous: true,
evalScripts: true,
parameters: Sortable.serialize("list-<%= f %>")
});
},
only: 'mypage-box',
tag: 'div' });
<% end %>
13 years ago
}
function updateSelect() {
s = $('block-select')
for (var i = 0; i < s.options.length; i++) {
if ($('block_' + s.options[i].value)) {
s.options[i].disabled = true;
} else {
s.options[i].disabled = false;
}
}
s.options[0].selected = true;
}
function afterAddBlock() {
recreateSortables();
updateSelect();
}
function removeBlock(block) {
Effect.DropOut(block);
updateSelect();
}
//]]>
</script>
<div class="contextual">
<% form_tag({:action => "add_block"}, :id => "block-form") do %>
<%= label_tag('block-select', l(:label_my_page_block)) %>:
<%= select_tag 'block', "<option></option>" + options_for_select(@block_options), :id => "block-select" %>
<%= link_to_remote l(:button_add),
{:url => { :action => "add_block" },
:with => "Form.serialize('block-form')",
:update => "list-hidden",
:position => :top,
:complete => "afterAddBlock();"
}, :class => 'icon icon-add'
%>
<% end %>
<%= link_to l(:button_back), {:action => 'index'}, :class => 'icon icon-cancel' %>
</div>
<h2><%=l(:label_overview)%></h2>
<h4><%=l(:label_hidden_elements) %></h4>
<div id="list-hidden" class="block-receiver">
<% @blocks['hidden'].each do |b| %>
<% if MyProjectsOverviewsController::BLOCKS.keys.include? b %>
<%= 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}) %>
<% end %>
<% end %>
13 years ago
</div>
<h4><%=l(:label_visible_elements) %></h4>
<% (field_list - ['hidden']).each do |f| %>
<div id="list-<%= f %>" class="splitcontent<%= f %> block-receiver">
<% @blocks[f].each do |b| %>
<% if MyProjectsOverviewsController::BLOCKS.keys.include? b %>
<%= 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}) %>
<% end %>
<% end %>
</div>
<% end %>
13 years ago
<% field_list.each do |f| %>
<%= sortable_element "list-#{f}",
13 years ago
:tag => 'div',
:only => 'mypage-box',
:handle => "handle",
:dropOnEmpty => true,
:containment => field_list.collect {|x| "list-#{x}" },
13 years ago
:constraint => false,
:url => { :action => "order_blocks", :group => f }
13 years ago
%>
<% end %>
13 years ago
<%= javascript_tag "updateSelect()" %>
<% content_for :header_tags do %>
<%= stylesheet_link_tag "my_projects_overview.css", :plugin => "chiliproject_my_project_page", :media => 'all' %>
<%= javascript_include_tag('jstoolbar/jstoolbar') %>
<%= javascript_include_tag('jstoolbar/textile') %>
<%= javascript_include_tag("jstoolbar/lang/jstoolbar-#{current_language.to_s.downcase}") %>
<%= stylesheet_link_tag('jstoolbar') %>
13 years ago
<% end %>
<% html_title(l(:label_overview)) -%>