Changes for structure

This commit is contained in:
Christophe Vilayphiou 2012-05-22 14:45:49 +08:00
parent aa114568c4
commit 5e9836f371
13 changed files with 42 additions and 39 deletions

View File

@ -1,14 +1,5 @@
var history_edited = false;
$('#back_sidebar a, #back_main a.nav').live('click',
function () {
$.getScript(this.href);
history.pushState(null, document.title, this.href);
history_edited = true;
return false;
}
);
$('#back_main a.reload').live('click',
function () {
$.getScript(this.href);
@ -18,7 +9,7 @@ $('#back_main a.reload').live('click',
}
);
$('#back_main .form').live('submit', function () {
$('#back_main form').live('submit', function () {
$.post(this.action, $(this).serialize(), null, 'script');
history_edited = true;
return false;

View File

@ -18,6 +18,9 @@
padding: 3px 0px;
display: block;
}
.nav-list>li>ol {
margin-left: 0;
}
/*
#back_sidebar h1 {
background: url(<%= asset_path "h1_bg.png" %>) repeat-x scroll left top transparent;
@ -126,7 +129,7 @@
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid #DDDDDD;
border-radius: 5px 5px 5px 5px;
margin: 0 0 0 3px;
margin: 0 0 0 20px;
padding: 0;
z-index:1;
position: absolute;
@ -155,7 +158,7 @@ ol.nav>li>.icons-moves {
}
.sortable i {
position: absolute;
left: -20px;
left: 0px;
top: 6px;
margin-right: 0;
opacity: 0.3;
@ -166,6 +169,9 @@ ol.nav>li>.icons-moves {
opacity: 0.7;
filter: alpha(opacity=70);
}
.with_action {
padding-left: 20px;
}
.placeholder {
background-color: rgba(0,136,204,.6);
border-radius: 3px;

View File

@ -65,9 +65,11 @@ class Admin::LinksController < ApplicationController
end
def delete
@item = Link.find(params[:id])
@item.destroy
respond_to do |format|
format.html {}
format.js { destroy }
format.js { @item = @item.parent }
end
end

View File

@ -51,7 +51,7 @@ class Admin::PagesController < ApplicationController
def create
@item = Page.new(params[:page])
if @item.module_app.key == 'page_content'
if @item.module_app && @item.module_app.key == 'page_content'
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
end
@ -99,14 +99,16 @@ class Admin::PagesController < ApplicationController
format.html {
redirect_to admin_items_url( :parent_id => @item.parent_id )
}
format.js {}
format.js { redirect_to admin_items_url }
end
end
def delete
@item = Page.find(params[:id])
@item.destroy
respond_to do |format|
format.html {}
format.js { destroy }
format.js { @item = @item.parent }
end
end

View File

@ -157,7 +157,7 @@ class ApplicationController < ActionController::Base
end
def get_homepage
Item.first(:conditions => {:parent_id => nil})
Page.root
end
def layout_by_resource

View File

@ -11,14 +11,14 @@ module Admin::ItemHelper
no_nested = 'no-nest'
end
ret << "<li id='#{node.id}' class='#{no_nested}'>"
ret << "<i class='icons-moves'></i>"
ret << "<div class='with_action'>"
ret << (link_to node.i18n_variable[I18n.locale], dest)
# ret << "<i class='icons-moves'></i>"
ret << "<div class='with_action'><i class='icons-moves'></i>"
ret << (link_to node.i18n_variable[I18n.locale], dest, :class => 'js_history')
ret << "<div class='quick-edit hide'>"
ret << (link_to t('admin.edit'), eval("edit_admin_#{node._type.downcase}_path(node)")) if node._type.eql?('Page')
ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page') if node._type.eql?('Page')
ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link') if node._type.eql?('Page')
ret << (link_to t(:delete), eval("delete_admin_#{node._type.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete')
ret << (link_to t('admin.edit'), eval("edit_admin_#{node._type.downcase}_path(node)"), :class => 'js_history') if node._type.eql?('Page')
ret << (link_to t('admin.new_page'), new_admin_page_path(:parent_id => node.id), :class => 'new_page js_history') if node._type.eql?('Page')
ret << (link_to t('admin.new_link'), new_admin_link_path(:parent_id => node.id), :class => 'new_link js_history') if node._type.eql?('Page')
ret << (link_to t(:delete), eval("delete_admin_#{node._type.downcase}_path(node, :authenticity_token => form_authenticity_token)"), :confirm => t('sure?'), :class => 'delete js_history')
ret << "</div>"
ret << "</div>"
ret << render_children(node)

View File

@ -1 +1,3 @@
<ol class="nav nav-list">
<%= render_node_and_children(Item.first(:conditions => {:parent_id => nil})) %>
</ol>

View File

@ -1,9 +1,7 @@
$('#back_main').empty();
switch ("<%= escape_javascript(@item._type)%>") {
case 'Link':
$('#back_main').append("<%= escape_javascript(render(:partial => 'admin/links/show')) %>");
break;
case 'Page':
<% case @item._type %>
<% when 'Page' %>
$('#back_main').append("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>");
break;
};
<% when 'Link' %>
$('#back_main').append("<%= escape_javascript(render(:partial => 'admin/links/show')) %>");
<% end %>

View File

@ -1 +1,3 @@
$('#back_sidebar').html("<%= escape_javascript(render(:partial => 'admin/items/site_map_left_bar')) %>");
$('#back_main').html("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>");
history.pushState(null, document.title, "<%= escape_javascript(admin_items_url) %>");

View File

@ -4,7 +4,7 @@
<%= form_for @item, :url => admin_pages_path, :html => { :class => 'form-horizontal edit_page' } do |f| %>
<%= render :partial => "form", :locals => { :f => f } %>
<div class="form-actions">
<%= f.submit t('update'), :class => 'btn btn-primary' %>
<%= f.submit t('create'), :class => 'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% end %>

View File

@ -1 +1,3 @@
$('#back_sidebar').html("<%= escape_javascript(render(:partial => 'admin/items/site_map_left_bar')) %>");
$('#back_main').html("<%= escape_javascript(render(:partial => 'admin/pages/show')) %>");
history.pushState(null, document.title, "<%= escape_javascript(admin_items_url) %>");

View File

@ -23,9 +23,7 @@
</div>
<div class="viewport">
<div id='back_sidebar' class="overview">
<ol class="nav nav-list">
<%= yield :sidebar %>
</ol>
</div>
</div>
</nav>

View File

@ -18,6 +18,6 @@
<%= link_to page_context.version, panel_page_content_back_end_view_path(page_context.page_id) %>
<%end -%>
</td>
<td><%= display_date_time(page_context) %></td>
<td><%= display_date_time(page_context.updated_at) %></td>
<td><%= User.find(page_context.create_user_id).name %></td>
</tr>