module Dhatu class SectionsController < ResourceController private def permitted_params params.require("dhatu/section").permit(:page_id, :name, :title, :sub_title, :code, :short_description, :long_description, :button_one_text, :button_two_text, :button_one_link, :button_two_link, :category_id, :priority, :enable_title, :enable_sub_title, :enable_short_description, :enable_long_description, :enable_button_one, :enable_button_two, :enable_cover_image, :enable_gallery_images) end def get_collections @relation = Dhatu::Section.includes(:cover_image).where("") parse_filters apply_filters @sections = @r_objects = @relation.page(@current_page).per(@per_page) return true end def apply_filters @relation = @relation.search(@query) if @query @relation = @relation.status(@status) if @status @order_by = "priority ASC, created_at desc" unless @order_by @relation = @relation.order(@order_by) 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: "Filter by Status", display_hash: Dhatu::Section::STATUS, current_value: @status, values: Dhatu::Section::STATUS_REVERSE, current_filters: @filters, filters_to_remove: [], filters_to_add: {}, url_method_name: 'sections_url', show_all_filter_on_top: true } } end def resource_controller_configuration { page_title: "Manage Sections", current_nav: "dhatu/pages", # Resource Names class: Dhatu::Section, collection_name: :sections, item_name: :section, # 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: :feed, # Mention all checkbox fields so that it will resource controller will set that value to be false when the update action is called # if @resource_options[:checkbox_fields] && @resource_options[:checkbox_fields].any? # @resource_options[:checkbox_fields].each do |field| # @r_object.write_attribute(field, false) # end # end # This is a tricky solution to update bolean fields which are shown as checkbox. checkbox_fields: [ :enable_title, :enable_sub_title, :enable_short_description, :enable_long_description, :enable_button_one, :enable_button_two, :enable_cover_image, :enable_gallery_images ], # "/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/sections", js_view_path: "dhatu/sections", # Additional Configurations load_rich_text_editor: true, tagsinput: false } end def breadcrumbs_configuration { heading: "Manage Sections", icon: "fa-reorder", description: "Listing all Sections", links: [{name: "Dashboard", link: breadcrumb_home_path, icon: 'fa-dashboard'}, {name: "Manage Sections", link: dhatu.sections_path, icon: 'fa-calendar', active: true}] } end def set_navs set_nav("section") end end end