module Dhatu class CareerOpportunitiesController < ResourceController private def permitted_params params.require("dhatu/career_opportunity").permit(:title, :sub_title, :short_description, :description, :priority, :category_id) end def get_collections @relation = Dhatu::CareerOpportunity.includes(:cover_image, :category).where("") parse_filters apply_filters @career_opportunities = @r_objects = @relation.page(@current_page).per(@per_page) return true end def apply_filters if @category.is_a?(String) @category = Dhatu::Category.new(id: -2, name: "IS NOT SET") elsif @category.blank? @category = Dhatu::Category.new(id: -1, name: "All") end if @category if @category.persisted? @relation = @relation.where("category_id = ?", @category.id) elsif @category.id == -2 @relation = @relation.where("category_id IS NULL") end end @relation = @relation.search(@query) if @query @relation = @relation.status(@status) if @status @relation = @relation.order("priority ASC, title ASC") end def configure_filter_settings @filter_settings = { string_filters: [ { filter_name: :query }, { filter_name: :status } ], boolean_filters: [], reference_filters: [ { filter_name: :category, filter_class: Dhatu::Category }, ], variable_filters: [], } end def configure_filter_ui_settings @filter_ui_settings = { status: { object_filter: false, select_label: "Filter by Status", display_hash: Dhatu::CareerOpportunity::STATUS_REVERSE, current_value: @status, values: Dhatu::CareerOpportunity::STATUS, current_filters: @filters, filters_to_remove: [], filters_to_add: {}, url_method_name: 'career_opportunities_url', show_all_filter_on_top: true }, category: { object_filter: true, select_label: 'Select Category Type', current_value: @category, values: [], #Dhatu::Category.filter_by_category_type("Dhatu::CareerOpportunity").published.order("priority ASC, name ASC").all, current_filters: @filters, url_method_name: 'career_opportunities_url', filters_to_remove: [], filters_to_add: {}, show_null_filter_on_top: true, show_all_filter_on_top: true } } end def resource_controller_configuration { page_title: "Manage Career Opportunities", current_nav: "dhatu/career_opportunities", # Resource Names class: Dhatu::CareerOpportunity, collection_name: :career_opportunities, item_name: :career_opportunity, # Conditions get_collections_after_save_resource: false, show_modal_after_create: true, show_modal_after_update: true, # Model Size can be large or generic form_model_size: :large, show_model_size: :large, # Layout can be table or feed # table uses html tables and feed uses div based boxes layout: :table, # "/kuppayam/workflows/default" # # Default partial opens show and form partial according to the model_size configuration # It also respect the configuration layout and refresh the page element on both cases - i.e layout is table or feed # "/kuppayam/workflows/peacock" # "/kuppayam/workflows/parrot" # # Peacock & Parrot are old ways of doing things and it respects certail configurations # Peacock opens show and form partials in large popup where as Parrot opens it in small # Both Peacock and Parrot expect table based layout and will reload a single row after create / update # Rendering Paths view_path: "dhatu/career_opportunities", js_view_path: "/kuppayam/workflows/default", # Additional Configurations load_rich_text_editor: true, tagsinput: false } end def breadcrumbs_configuration { heading: "Manage Career Opportunities", icon: "fa-gift", description: "Listing all Career Opportunities", links: [{name: "Dashboard", link: breadcrumb_home_path, icon: 'fa-dashboard'}, {name: "Manage CareerOpportunities", link: dhatu.career_opportunities_path, icon: 'fa-gift', active: true}] } end def set_navs set_nav("dhatu/career_opportunities") end end end