module Dhatu class ServicesController < ResourceController private def permitted_params params.require("dhatu/service").permit(:name, :meta_description, :permalink, :description, :price, :duration, :category_id, :priority) end def get_collections category_ids = Dhatu::Service.distinct.pluck(:category_id) @categories = Dhatu::Category.where(id: category_ids).to_a @categories.unshift(Dhatu::Category.new(id: -1, name: "All")) @relation = Dhatu::Service.includes(:cover_image).where("") # params[:st] = "published" if params[:st].nil? parse_filters apply_filters @services = @r_objects = @relation.page(@current_page).per(@per_page) return true end def apply_filters @category = Dhatu::Category.find_by_id(params[:ct]) || Dhatu::Category.new(id: -1, name: "All") if @category && @category.id != -1 @relation = @relation.where("category_id = ?", @category.id) end @relation = @relation.search(@query) if @query @relation = @relation.status(@status) if @status @relation = @relation.order("priority ASC, name ASC") end def configure_filter_settings @filter_settings = { string_filters: [ { filter_name: :query }, { filter_name: :status } ], boolean_filters: [], reference_filters: [], variable_filters: [], } end def configure_filter_ui_settings @filter_ui_settings = { status: { object_filter: false, select_label: "Select Status", display_hash: Dhatu::Service::STATUS, current_value: @status, values: Dhatu::Service::STATUS_REVERSE, current_filters: @filters, filters_to_remove: [], filters_to_add: {}, url_method_name: 'services_url', show_all_filter_on_top: true } } end def resource_controller_configuration { page_title: "Services", js_view_path: "/kuppayam/workflows/peacock", view_path: "dhatu/services", collection_name: :services, item_name: :service, class: Dhatu::Service } end def breadcrumbs_configuration { heading: "Manage Services", icon: "fa-glass", description: "Listing all Services", links: [{name: "Dashboard", link: breadcrumb_home_path, icon: 'fa-dashboard'}, {name: "Manage Services", link: dhatu.services_path, icon: 'fa-glass', active: true}] } end def set_navs set_nav("service") end end end