Ticket #27: status.diff

File status.diff, 3.5 kB (added by paul@vudmaska.com, 2 years ago)

Did no see how to attach diff.

  • test/functional/admin/page_controller_test.rb

    old new  
    171171    assert ! %r{<head>}.match(@response.body) 
    172172    assert_equal 'text/html;charset=utf-8', @response.headers['Content-Type'] 
    173173  end 
     174   
     175  def test_update_status 
     176    get :update_status, :id => 1, :value => 1 
     177    assert_response :success     
     178  end 
    174179end 
  • app/controllers/admin/page_controller.rb

    old new  
    6060    response.headers['Content-Type'] = 'text/html;charset=utf-8' 
    6161    render(:layout => false) 
    6262  end 
     63   
     64  def update_status#_with_ajax     
     65    @page = Page.update(params[:id], :status_id => params[:value]) 
     66    render :text => @page.status.name     
     67  end 
    6368 
    6469  private 
    6570    def announce_page_saved 
  • app/views/admin/page/_node.rhtml

    old new  
    3434        </span> 
    3535                        </td> 
    3636<% unless simple -%> 
    37                         <td class="status <%= page.status.name.downcase %>-status"><%= page.status.name %></td> 
     37                        <td id="td-status<%= page.id %>" class="status <%= page.status.name.downcase %>-status"> 
     38                                <span id="page-status<%= page.id %>"><%= page.status.name %></span> 
     39                                <script type="text/javascript"> 
     40                                  new Ajax.InPlaceCollectionEditor( 
     41                                     'page-status<%= page.id %>',  
     42                                     '/admin/pages/update_status/<%= page.id %>',  
     43                                     { oldPageStatus : '<%= page.status.name.downcase %>', 
     44                                        onComplete:function(rq){ 
     45                                                  if(!rq){return} // Don't do anything on cancel 
     46                                                  /* 
     47                                                         * Burying old page status class - so we can delete it before adding the new one 
     48                                                         * 
     49                                                         ****************************/ 
     50                                                        new Effect.Shake('page-status<%= page.id %>') 
     51                                                        new     Element.removeClassName('td-status<%= page.id %>',this.oldPageStatus + '-status') 
     52                                                        this.oldPageStatus = rq.responseText.toLowerCase()                                                       
     53                                                  new   Element.addClassName('td-status<%= page.id %>', this.oldPageStatus + '-status')  
     54                                                                                         
     55                                  },value:'<%= page.status_id %>',collection: [[1,'Draft'],[50,'Reviewed'],[100,'Published'],[101,'Hidden']]}); 
     56                                </script> 
     57                        </td> 
    3858                        <td class="add-child"><%= link_to image_tag('add-child', :alt => 'add child'), page_new_url(:parent_id => page) %></td> 
    3959                        <td class="remove"><%= link_to image_tag('remove', :alt => 'remove page'), page_remove_url(:id => page) %></td> 
    4060<% end -%> 
  • config/routes.rb

    old new  
    1616    page.homepage_new      'admin/pages/new/homepage',           :action => 'new',        :slug => '/', :breadcrumb => 'Home' 
    1717    page.page_remove       'admin/pages/remove/:id',             :action => 'remove' 
    1818    page.page_add_part     'admin/ui/pages/part/add',            :action => 'add_part' 
     19    page.page_update_status 'admin/pages/update_status/:id',     :action => 'update_status' 
    1920    page.page_children     'admin/ui/pages/children/:id/:level', :action => 'children',   :level => '1' 
    2021    page.clear_cache       'admin/pages/cache/clear',            :action => 'clear_cache'     
    2122  end