Class: Admin::Restaurants::RestaurantPackagesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- ApplicationController
- BaseController
- Admin::Restaurants::RestaurantPackagesController
- Defined in:
- app/controllers/admin/restaurants/restaurant_packages_controller.rb
Overview
typed: ignore
Constant Summary
Constants inherited from BaseController
BaseController::INTERNAL_SERVER_ERROR_MESSAGE
Instance Method Summary collapse
- #featured ⇒ Object
- #hh_menu_link ⇒ Object
- #index ⇒ Object
-
#list ⇒ Object
for admin reservation form page.
- #update ⇒ Object
Methods inherited from BaseController
#destroy_session, #identity_cache_memoization, #sign_in_page, #user_developer_session
Methods included from LogrageCustomLogger
Methods included from AdminHelper
#dynamic_pricings_formatter, #link_to_admin_reservations_path_by_id, #link_to_admin_restaurants_path_by_id, #link_to_log, #optional_locales, #optional_locales_with_labels, #staff_signed_in?
Methods included from UpdateLocaleConcern
Methods inherited from ApplicationController
#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=
Methods included from ControllerHelpers
#check_boolean_param, #get_banners, #inventory_params, #reservation_params
Instance Method Details
#featured ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/admin/restaurants/restaurant_packages_controller.rb', line 49 def featured featured_params = params[:featured].to_s == 'true' = 'Success! Package is no longer featured.' if featured_params = 'Success! Package is now featured.' end if restaurant_package.update(featured: featured_params) render json: { success: true, message: } else render json: { success: false, message: restaurant_package.errors..to_sentence } end end |
#hh_menu_link ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/admin/restaurants/restaurant_packages_controller.rb', line 64 def case params[:view_type] when 'full_view', 'without_header_footer' extra_params = params[:view_type] == 'without_header_footer' ? { header_footer: 'false' } : {} handle_link_redirect(extra_params) else flash[:alert] = 'Invalid view type' redirect_back(fallback_location: admin_restaurant_restaurant_packages_path) end end |
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/admin/restaurants/restaurant_packages_controller.rb', line 7 def index sort_order = params[:order] || 'asc' # Restaurant packages @restaurant_packages = restaurant.all_restaurant_packages. includes(package: :translations). where(deleted_at: nil). order(index_sort_logic(sort_order)) if params[:id].present? && params[:kind] == 'restaurant_package' @restaurant_add_ons = [] @restaurant_packages = @restaurant_packages.where(id: params[:id]) return end # Restaurant add-ons @restaurant_add_ons = restaurant.restaurant_add_ons. includes(add_on: :translations). order(index_sort_logic(sort_order)) if params[:id].present? && params[:kind] == 'restaurant_add_on' @restaurant_packages = [] @restaurant_add_ons = @restaurant_add_ons.where(id: params[:id]) end end |
#list ⇒ Object
for admin reservation form page
34 35 36 37 |
# File 'app/controllers/admin/restaurants/restaurant_packages_controller.rb', line 34 def list render json: restaurant.all_restaurant_packages.where(deleted_at: nil), each_serializer: Websites::RestaurantPackageSerializer end |
#update ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/admin/restaurants/restaurant_packages_controller.rb', line 39 def update permitted_params = params.require(:hh_package_restaurant_package).permit(:rank_in_restaurant_scope) if restaurant_package.update permitted_params flash[:notice] = 'Updated restaurant package rank in restaurant scope successfully' else flash[:alert] = restaurant_package.errors..to_sentence end redirect_back fallback_location: back_fallback_location end |