almost complete
Oleg
committed Aug 24, 2011
commit 9da3ee780ea2a349f458c5e170500ef13da5aa40
Showing 9
changed files with
53 additions
and 14 deletions
app/assets/javascripts/comfortable_mexican_sofa/application.js
+20
-3
| @@ | @@ -16,9 +16,10 @@ $.CMS = function(){ |
| $.CMS.enable_date_picker(); | |
| $.CMS.enable_sortable_list(); | |
| if($('form#page_edit, form#page_new').get(0)) $.CMS.enable_page_save_form(); | |
| - | if($('#mirrors').get(0)) $.CMS.enable_mirrors_widget(); |
| - | if($('#page_save').get(0)) $.CMS.enable_page_save_widget(); |
| - | if($('#uploader_button').get(0)) $.CMS.enable_uploader(); |
| + | if($('#mirrors').get(0)) $.CMS.enable_mirrors_widget(); |
| + | if($('#page_save').get(0)) $.CMS.enable_page_save_widget(); |
| + | if($('#uploader_button').get(0)) $.CMS.enable_uploader(); |
| + | if($('.categories_widget').get(0)) $.CMS.enable_categories_widget(); |
| }); | |
| return { | |
| @@ | @@ -163,6 +164,22 @@ $.CMS = function(){ |
| xhr.send(file); | |
| }); | |
| }); | |
| + | }, |
| + | |
| + | enable_categories_widget : function(){ |
| + | $('.categories_widget a.action_link').click(function(){ |
| + | if($(this).data('state') == 'edit'){ |
| + | $('.categories.read').hide(); |
| + | $('.categories.editable').show(); |
| + | $(this).hide(); |
| + | $('a.action_link.done').show(); |
| + | } else { |
| + | $('.categories.editable').hide(); |
| + | $('.categories.read').show(); |
| + | $(this).hide(); |
| + | $('a.action_link.edit').show(); |
| + | } |
| + | }); |
| } | |
| } | |
| }(); | |
| \ No newline at end of file | |
app/assets/stylesheets/comfortable_mexican_sofa/content.css
+1
-1
| @@ | @@ -82,7 +82,7 @@ |
| font: 12px 'Lucida Grande', Tahoma, sans-serif; | |
| width: 100px; | |
| } | |
| - | #cms_body .categories_widget a.action_link.edit { |
| + | #cms_body .categories_widget a.action_link { |
| float: right; | |
| margin-left: 10px; | |
| padding: 2px 4px; | |
app/views/cms_admin/categories/_index.html.erb
+11
-3
| @@ | @@ -3,12 +3,20 @@ |
| <div class='categories_widget'> | |
| <div class='label'><%= t('.label') %></div> | |
| - | <%= link_to t('.edit'), '#', :class => 'action_link edit' %> |
| - | <div class='categories'> |
| + | <%= link_to t('.edit'), '#', :class => 'action_link edit', 'data-state' => 'edit' %> |
| + | <%= link_to t('.done'), '#', :class => 'action_link done', 'data-state' => 'done', :style => 'display:none' %> |
| + | |
| + | <div class='categories read'> |
| <div class='category all'> | |
| - | <%= link_to t('.all'), '' %> |
| + | <%= link_to t('.all'), :category => nil %> |
| </div> | |
| + | <% Cms::Category.of_type(type).each do |category| %> |
| + | <%= render :partial => 'cms_admin/categories/show', :object => category, :locals => { :read => true } %> |
| + | <% end %> |
| + | </div> |
| + | |
| + | <div class='categories editable' style='display:none'> |
| <% Cms::Category.of_type(type).each do |category| %> | |
| <%= render :partial => 'cms_admin/categories/show', :object => category %> | |
| <% end %> | |
app/views/cms_admin/categories/_show.html.erb
+9
-2
| @@ | @@ -1,5 +1,12 @@ |
| <% category ||= show %> | |
| + | <% read ||= false %> |
| <div class='category' id="<%= dom_id(category)%>"> | |
| - | <%= link_to category.label, edit_cms_admin_site_category_path(@site, category), :remote => true %> |
| - | <%= link_to 'x', cms_admin_site_category_path(@site, category), :method => :delete, :remote => true, :confirm => t('.are_you_sure'), :class => 'delete' %> |
| + | |
| + | <% if read %> |
| + | <%= link_to category.label, :category => category.label %> |
| + | <% else %> |
| + | <%= link_to category.label, edit_cms_admin_site_category_path(@site, category), :remote => true %> |
| + | <%= link_to 'x', cms_admin_site_category_path(@site, category), :method => :delete, :remote => true, :confirm => t('.are_you_sure'), :class => 'delete' %> |
| + | <% end %> |
| + | |
| </div> | |
| \ No newline at end of file | |
app/views/cms_admin/categories/create.js.erb
+5
-2
| @@ | @@ -1,4 +1,7 @@ |
| - | $('.categories_widget .category.new').before( |
| + | $('.categories_widget .categories.editable .category.new').before( |
| '<%= escape_javascript(render :partial => "show", :object => @category ) %>' | |
| ); | |
| - | $('.categories_widget .category.new form input#category_label').val(''); |
| \ No newline at end of file | |
| + | $('.categories_widget .categories.read').append( |
| + | '<%= escape_javascript(render :partial => "show", :object => @category, :locals => { :read => true }) %>' |
| + | ); |
| + | $('.categories_widget .categories.editable .category.new form input#category_label').val(''); |
| \ No newline at end of file | |
app/views/cms_admin/categories/destroy.js.erb
+1
-1
| @@ | @@ -1,3 +1,3 @@ |
| - | $('.category#<%= dom_id(@category) %>').fadeOut('slow', function(){ |
| + | $('.categories .category#<%= dom_id(@category) %>').fadeOut('slow', function(){ |
| $(this).remove() | |
| }) | |
| \ No newline at end of file | |
app/views/cms_admin/categories/edit.js.erb
+1
-1
| @@ | @@ -1,3 +1,3 @@ |
| - | $('.category#<%= dom_id(@category) %>').replaceWith( |
| + | $('.categories.editable .category#<%= dom_id(@category) %>').replaceWith( |
| '<%= escape_javascript(render :partial => "edit", :object => @category ) %>' | |
| ); | |
| \ No newline at end of file | |
app/views/cms_admin/categories/update.js.erb
+4
-1
| @@ | @@ -1,3 +1,6 @@ |
| - | $('.category#<%= dom_id(@category) %>').replaceWith( |
| + | $('.categories.editable .category#<%= dom_id(@category) %>').replaceWith( |
| '<%= escape_javascript(render :partial => "show", :object => @category ) %>' | |
| + | ); |
| + | $('.categories.read .category#<%= dom_id(@category) %>').replaceWith( |
| + | '<%= escape_javascript(render :partial => "show", :object => @category, :locals => { :read => true } ) %>' |
| ); | |
| \ No newline at end of file | |
config/locales/en.yml
+1
-0
| @@ | @@ -201,6 +201,7 @@ en: |
| index: | |
| label: Categories | |
| edit: Edit | |
| + | done: Done |
| all: All | |
| add: add | |
| show: | |