Class: Integral::Backend::ListsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Integral::Backend::ListsController
- Defined in:
- app/controllers/integral/backend/lists_controller.rb
Overview
List controller
Instance Method Summary collapse
-
#clone ⇒ Object
GET /:id/clone Clone a list.
-
#create ⇒ Object
POST / List creation.
-
#destroy ⇒ Object
DELETE /:id.
-
#edit ⇒ Object
GET /:id/edit List edit form.
-
#index ⇒ Object
GET / Lists all lists.
-
#new ⇒ Object
GET /new List creation form.
-
#show ⇒ Object
GET /:id.
-
#update ⇒ Object
PUT /:id Updating an list.
Instance Method Details
#clone ⇒ Object
GET /:id/clone Clone a list
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/integral/backend/lists_controller.rb', line 56 def clone title = params[:title].present? ? params[:title] : "#{@list.title} Copy" title = "#{title} #{SecureRandom.hex[1..5]}" if Integral::List.find_by_title(title).present? cloned_list = @list.dup(title) if cloned_list.save respond_successfully(('creation_success'), backend_list_path(cloned_list)) else respond_failure(('creation_failure'), @list, :edit) end end |
#create ⇒ Object
POST / List creation
37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/integral/backend/lists_controller.rb', line 37 def create @list = List.new(list_params) if @list.save respond_successfully(('creation_success'), backend_list_path(@list)) else respond_failure(('creation_failure'), @list, :new) end end |
#destroy ⇒ Object
DELETE /:id
80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/integral/backend/lists_controller.rb', line 80 def destroy if @list.destroy respond_successfully(('delete_success'), backend_lists_path) else = @list.errors..to_sentence flash[:error] = "#{notification_message('delete_failure')} - #{error_message}" redirect_to backend_lists_path end end |
#edit ⇒ Object
GET /:id/edit List edit form
49 50 51 52 |
# File 'app/controllers/integral/backend/lists_controller.rb', line 49 def edit @list.title, :backend_list_path I18n.t('integral.breadcrumbs.edit'), :edit_backend_list_path end |
#index ⇒ Object
GET / Lists all lists
11 12 13 14 15 16 17 18 |
# File 'app/controllers/integral/backend/lists_controller.rb', line 11 def index respond_to do |format| format.html format.json do render json: { content: render_to_string(partial: 'integral/backend/lists/grid', locals: { grid: @grid }) } end end end |
#new ⇒ Object
GET /new List creation form
30 31 32 33 |
# File 'app/controllers/integral/backend/lists_controller.rb', line 30 def new I18n.t('integral.breadcrumbs.new'), :new_backend_list_path @list = List.new end |
#show ⇒ Object
GET /:id
21 22 23 24 25 26 |
# File 'app/controllers/integral/backend/lists_controller.rb', line 21 def show @list = List.find(params[:id]) @list.list_items.order(:priority) @list.title, :backend_list_path end |
#update ⇒ Object
PUT /:id Updating an list
71 72 73 74 75 76 77 |
# File 'app/controllers/integral/backend/lists_controller.rb', line 71 def update if @list.update(list_params) respond_successfully(('edit_success'), backend_list_path(@list)) else respond_failure(('edit_failure'), @list, :show) end end |