module Dhatu class PromotionEnquiriesController < ResourceController def show @promotion_enquiry = @r_object = Dhatu::PromotionEnquiry.find_by_id(params[:id]) if @promotion_enquiry @promotion_enquiry.read! if @promotion_enquiry.new? || @promotion_enquiry.unread? else set_notification(false, I18n.t('status.error'), I18n.t('status.not_found', item: default_item_name.titleize)) end end private def get_collections @new_promotion_enquiries_count = Dhatu::PromotionEnquiry.new_ones.count @unread_promotion_enquiries_count = Dhatu::PromotionEnquiry.unread.count @read_promotion_enquiries_count = Dhatu::PromotionEnquiry.read.count @relation = Dhatu::PromotionEnquiry.where("") params[:st] = "new" if params[:st].nil? && params[:q].nil? parse_filters apply_filters @promotion_enquiries = @r_objects = @relation.page(@current_page).per(@per_page) return true end def apply_filters if @promotion @relation = @relation.where("promotion_id = ?", @promotion.id) end @relation = @relation.search(@query) if @query @relation = @relation.status(@status) if @status @relation = @relation.order("created_at DESC") end def configure_filter_settings @filter_settings = { string_filters: [ { filter_name: :query }, { filter_name: :status } ], boolean_filters: [], reference_filters: [ { filter_name: :promotion, filter_class: Dhatu::Promotion }, ], variable_filters: [], } end def configure_filter_ui_settings @filter_ui_settings = { status: { object_filter: false, select_label: "Filter by Status", display_hash: Dhatu::PromotionEnquiry::STATUS_REVERSE, current_value: @status, values: Dhatu::PromotionEnquiry::STATUS, current_filters: @filters, filters_to_remove: [], filters_to_add: {}, url_method_name: 'promotion_enquiries_url', show_all_filter_on_top: false }, promotion: { object_filter: true, select_label: 'Filter by Promotion', current_value: @promotion, values: Dhatu::Promotion.order("priority ASC, title ASC").all, current_filters: @filters, url_method_name: 'promotion_enquiries_url', filters_to_remove: [], filters_to_add: {}, show_null_filter_on_top: false, show_all_filter_on_top: true } } end def resource_controller_configuration { page_title: "Promotional Enquiries", current_nav: "dhatu/promotion_enquiries", # Resource Names class: Dhatu::PromotionEnquiry, collection_name: :promotion_enquiries, item_name: :promotion_enquiry, # Conditions get_collections_after_save_resource: false, show_modal_after_create: false, show_modal_after_update: false, # Model Size can be large or generic form_model_size: :generic, show_model_size: :generic, # 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/promotion_enquiries", js_view_path: "/kuppayam/workflows/default", # Additional Configurations load_rich_text_editor: false, tagsinput: false } end def breadcrumbs_configuration { heading: "Manage Promotional Enquiries", icon: "fa-calendar", description: "Listing all Promotional Enquiries", links: [{name: "Dashboard", link: breadcrumb_home_path, icon: 'fa-dashboard'}, {name: "Manage Promotional Enquiries", link: dhatu.promotion_enquiries_path, icon: 'fa-email', active: true}] } end def set_navs set_nav("dhatu/promotion_enquiries") end end end