roles fully implemented for the page / content sections + uniformize drag n drop in the contents section + add the missing selected value for the has_one field
This commit is contained in:
parent
09171555a7
commit
1be92e0db4
@ -5,13 +5,14 @@ module Admin
|
||||
|
||||
before_filter :set_content_type
|
||||
|
||||
respond_to :json, :only => :update
|
||||
respond_to :json, :only => [:update, :sort]
|
||||
|
||||
# before_filter :authorize
|
||||
skip_load_and_authorize_resource
|
||||
|
||||
before_filter :authorize_content
|
||||
|
||||
def index
|
||||
@contents = @content_type.list_or_group_contents
|
||||
authorize! :index, ContentInstance
|
||||
end
|
||||
|
||||
def create
|
||||
@ -23,7 +24,7 @@ module Admin
|
||||
end
|
||||
|
||||
def sort
|
||||
@content_type.sort_contents!(params[:order])
|
||||
@content_type.sort_contents!(params[:children])
|
||||
|
||||
respond_with(@content_type, :location => admin_contents_url(@content_type.slug))
|
||||
end
|
||||
@ -42,5 +43,9 @@ module Admin
|
||||
set_content_type
|
||||
end
|
||||
|
||||
def authorize_content
|
||||
authorize! params[:action].to_sym, ContentInstance
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -107,8 +107,8 @@ class ContentType
|
||||
self.asc_order? ? list : list.reverse
|
||||
end
|
||||
|
||||
def sort_contents!(order)
|
||||
order.split(',').each_with_index do |id, position|
|
||||
def sort_contents!(ids)
|
||||
ids.each_with_index do |id, position|
|
||||
self.contents.find(BSON::ObjectId(id))._position_in_list = position
|
||||
end
|
||||
self.save
|
||||
|
@ -1,7 +1,7 @@
|
||||
- if contents.empty?
|
||||
%p.no-items!= t('.no_items', :url => new_admin_content_url(@content_type.slug))
|
||||
- else
|
||||
%ul{ :id => 'contents-list', :class => "list #{'sortable' if @content_type.order_by == '_position_in_list'}" }
|
||||
%ul{ :id => 'contents-list', :class => "list #{'sortable' if @content_type.order_by == '_position_in_list'}", :'data-url' => sort_admin_contents_path(@content_type.slug, :json) }
|
||||
- contents.each do |content|
|
||||
%li.content{ :id => "content-#{content._id}" }
|
||||
%em
|
||||
|
@ -1,13 +1,15 @@
|
||||
- title t('.title', :type => @content_type.name.capitalize)
|
||||
|
||||
|
||||
- content_for :submenu do
|
||||
= render 'admin/shared/menu/contents'
|
||||
|
||||
|
||||
- content_for :actions do
|
||||
= render 'admin/shared/actions/contents'
|
||||
|
||||
- content_for :buttons do
|
||||
= admin_button_tag t('admin.contents.index.edit'), edit_admin_content_type_url(@content_type), :class => 'edit'
|
||||
- if can?(:manage, ContentType)
|
||||
= admin_button_tag t('admin.contents.index.edit'), edit_admin_content_type_url(@content_type), :class => 'edit'
|
||||
|
||||
= admin_button_tag t('admin.contents.index.new'), new_admin_content_url(@content_type.slug), :class => 'new'
|
||||
|
||||
%p= @content_type.description
|
||||
|
@ -10,7 +10,9 @@
|
||||
= include_javascripts :contents
|
||||
|
||||
- content_for :buttons do
|
||||
= admin_button_tag :edit, edit_admin_content_type_url(@content_type), :class => 'edit'
|
||||
- if can?(:manage, ContentType)
|
||||
= admin_button_tag :edit, edit_admin_content_type_url(@content_type), :class => 'edit'
|
||||
|
||||
= admin_button_tag :new, new_admin_content_url(@content_type.slug), :class => 'new'
|
||||
|
||||
- if @content_type.description.present?
|
||||
@ -24,7 +26,7 @@
|
||||
- else
|
||||
= render 'list', :contents => @contents
|
||||
|
||||
= form_tag sort_admin_contents_path(@content_type.slug), :method => :put, :class => 'formtastic' do
|
||||
= hidden_field_tag :order
|
||||
|
||||
= render 'admin/shared/form_actions', :delete_button => link_to(content_tag(:em, escape_once(' ')) + t('.destroy'), admin_content_type_url(@content_type), :confirm => t('admin.messages.confirm'), :method => :delete, :class => 'button small remove'), :button_label => :update
|
||||
- if can?(:manage, ContentType)
|
||||
#local-actions-bottom-bar
|
||||
%p.tleft
|
||||
= link_to(content_tag(:em, escape_once(' ')) + t('.destroy'), admin_content_type_url(@content_type), :confirm => t('admin.messages.confirm'), :method => :delete, :class => 'button small remove')
|
||||
|
@ -6,8 +6,9 @@
|
||||
- content_for :actions do
|
||||
= render 'admin/shared/actions/contents'
|
||||
|
||||
- content_for :buttons do
|
||||
= admin_button_tag t('admin.contents.index.edit'), edit_admin_content_type_url(@content_type), :class => 'edit'
|
||||
- if can?(:manage, ContentType)
|
||||
- content_for :buttons do
|
||||
= admin_button_tag t('admin.contents.index.edit'), edit_admin_content_type_url(@content_type), :class => 'edit'
|
||||
|
||||
%p= @content_type.description
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
- field.target.constantize.reload_parent! # to make sure all the contents from the parent are loaded
|
||||
|
||||
= form.input field._alias.to_sym, :label => field.label, :hint => field.hint, :input_html => { :class => 'has_one' }, :as => :select, :collection => options_for_has_one(field, form.object.send(field._alias.to_sym).try(:_id))
|
||||
- selected_id = form.object.send(field._alias.to_sym).try(:_id)
|
||||
|
||||
= form.input field._alias.to_sym, :label => field.label, :hint => field.hint, :input_html => { :class => 'has_one' }, :as => :select, :collection => options_for_has_one(field, selected_id), :selected => selected_id
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
- if not @page.index? and not @page.not_found?
|
||||
= f.input :parent_id, :as => :select, :collection => parent_pages_options, :include_blank => false
|
||||
|
||||
= f.input :slug, :required => false, :hint => @page.slug.blank? ? ' ' : page_url(@page), :input_html => { :data_url => get_path_admin_pages_url, :disabled => @page.index? || @page.not_found? }, :wrapper_html => { :style => "#{'display: none' if @page.templatized?}; height: 50px" }
|
||||
= f.input :slug, :required => false, :hint => @page.slug.blank? ? ' ' : page_url(@page), :input_html => { :'data-url' => get_path_admin_pages_url, :disabled => @page.index? || @page.not_found? }, :wrapper_html => { :style => "#{'display: none' if @page.templatized?}; height: 50px" }
|
||||
|
||||
= render 'editable_elements', :page => @page
|
||||
|
||||
|
@ -17,6 +17,6 @@
|
||||
= link_to image_tag('admin/list/icons/trash.png'), admin_page_url(page), :class => 'remove', :confirm => t('admin.messages.confirm'), :method => :delete
|
||||
|
||||
- if with_children
|
||||
%ul{ :id => "folder-#{page._id}", :class => "folder depth-#{(page.depth || 0) + 1}", :data_url => sort_admin_page_url(page), :style => "display: #{cookies["folder-#{page._id}"] || 'block'}" }
|
||||
%ul{ :id => "folder-#{page._id}", :class => "folder depth-#{(page.depth || 0) + 1}", :'data-url' => sort_admin_page_url(page), :style => "display: #{cookies["folder-#{page._id}"] || 'block'}" }
|
||||
|
||||
= render children
|
@ -1,4 +1,4 @@
|
||||
.actions
|
||||
#local-actions-bottom-bar
|
||||
.span-12
|
||||
%p
|
||||
- if defined?(back_url)
|
||||
|
6
doc/TODO
6
doc/TODO
@ -35,9 +35,9 @@ x better hints:
|
||||
x model
|
||||
x ui
|
||||
- controllers / views:
|
||||
- page
|
||||
- asset
|
||||
- content type
|
||||
x page
|
||||
x content / content type
|
||||
x asset
|
||||
- site
|
||||
- account
|
||||
- snippet
|
||||
|
@ -1,18 +1,20 @@
|
||||
$(document).ready(function() {
|
||||
var updateContentsOrder = function() {
|
||||
var lists = $('ul#contents-list.sortable');
|
||||
var ids = jQuery.map(lists, function(list) {
|
||||
return(jQuery.map($(list).sortable('toArray'), function(el) {
|
||||
return el.match(/content-(\w+)/)[1];
|
||||
}).join(','));
|
||||
}).join(',');
|
||||
$('#order').val(ids || '');
|
||||
}
|
||||
|
||||
// sortable items
|
||||
$('ul#contents-list.sortable').sortable({
|
||||
handle: 'em',
|
||||
items: 'li.content',
|
||||
stop: function(event, ui) { updateContentsOrder(); }
|
||||
'handle': 'em',
|
||||
'items': 'li.content',
|
||||
'axis': 'y',
|
||||
'update': function(event, ui) {
|
||||
var params = $(this).sortable('serialize', { 'key': 'children[]' });
|
||||
params += '&_method=put';
|
||||
params += '&' + $('meta[name=csrf-param]').attr('content') + '=' + $('meta[name=csrf-token]').attr('content');
|
||||
|
||||
$.post($(this).attr('data-url'), params, function(data) {
|
||||
var error = typeof(data.error) != 'undefined';
|
||||
$.growl((error ? 'error' : 'success'), (error ? data.error : data.notice));
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
|
@ -26,7 +26,7 @@ $(document).ready(function() {
|
||||
params += '&_method=put';
|
||||
params += '&' + $('meta[name=csrf-param]').attr('content') + '=' + $('meta[name=csrf-token]').attr('content');
|
||||
|
||||
$.post($(this).attr('data_url'), params, function(data) {
|
||||
$.post($(this).attr('data-url'), params, function(data) {
|
||||
var error = typeof(data.error) != 'undefined';
|
||||
$.growl((error ? 'error' : 'success'), (error ? data.error : data.notice));
|
||||
}, 'json');
|
||||
@ -82,7 +82,7 @@ $(document).ready(function() {
|
||||
|
||||
var lookForSlugAndUrl = function() {
|
||||
params = 'parent_id=' + $('#page_parent_id').val() + "&slug=" + $('#page_slug').val();
|
||||
$.get($('#page_slug').attr('data_url'), params, function(data) {
|
||||
$.get($('#page_slug').attr('data-url'), params, function(data) {
|
||||
$('#page_slug_input .inline-hints').html(data.url).effect('highlight');
|
||||
}, 'json');
|
||||
};
|
||||
|
@ -165,38 +165,6 @@ form.formtastic fieldset ol .more { text-align: right; width: auto; margin: 10px
|
||||
form.formtastic fieldset ol .more a { text-decoration: none; color: #787A89; font-size: 0.7em; }
|
||||
form.formtastic fieldset ol .more a:hover { text-decoration: underline; }
|
||||
|
||||
/*form.formtastic hr { border-top: 2px solid #ccc; }*/
|
||||
|
||||
/*form.formtastic fieldset.buttons { padding-left: 28%; padding-bottom: 20px; }*/
|
||||
|
||||
form.formtastic div.actions {
|
||||
position: relative;
|
||||
top: 27px;
|
||||
left: -15px;
|
||||
width: 950px;
|
||||
background: #8b8d9a;
|
||||
}
|
||||
|
||||
form.formtastic div.actions p {
|
||||
padding: 15px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
form.formtastic div.actions a {
|
||||
color: #fff !important;
|
||||
text-decoration: none;
|
||||
font-size: 0.8em;
|
||||
position: relative;
|
||||
top: 4px;
|
||||
}
|
||||
|
||||
form.formtastic div.actions a.remove { color: #ff092c !important; }
|
||||
|
||||
form.formtastic div.actions p a:hover { text-decoration: underline; }
|
||||
|
||||
form.formtastic div.actions .last p { text-align: right; }
|
||||
|
||||
|
||||
/* ___ pages ___ */
|
||||
|
||||
form.formtastic fieldset ol li.path em {
|
||||
|
@ -151,6 +151,33 @@ body {
|
||||
|
||||
#content #local-actions-bar a:hover { text-decoration: none; color: #333; }
|
||||
|
||||
#content #local-actions-bottom-bar {
|
||||
position: relative;
|
||||
top: 27px;
|
||||
left: -15px;
|
||||
width: 950px;
|
||||
background: #8b8d9a;
|
||||
}
|
||||
|
||||
#content #local-actions-bottom-bar p {
|
||||
padding: 15px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#content #local-actions-bottom-bar a {
|
||||
color: #fff !important;
|
||||
text-decoration: none;
|
||||
font-size: 0.8em;
|
||||
position: relative;
|
||||
top: 4px;
|
||||
}
|
||||
|
||||
#content #local-actions-bottom-bar a.remove { color: #ff092c !important; }
|
||||
|
||||
#content #local-actions-bottom-bar p a:hover { text-decoration: underline; }
|
||||
|
||||
#content #local-actions-bottom-bar .last p { text-align: right; }
|
||||
|
||||
/* ___ footer ___ */
|
||||
|
||||
#footer {
|
||||
|
Loading…
Reference in New Issue
Block a user