ActiveAdmin.register C80Estate::Area, as: 'Area' do # scope_to :current_admin_user, association_method: :sites_list menu :label => "Площади" permit_params :title, :desc, :owner_id, :owner_type, :assigned_person_id, :assigned_person_type, :atype_id, :property_id, :astatus_ids => [], :aphotos_attributes => [:id, :image, :_destroy], :item_props_attributes => [:value, :_destroy, :prop_name_id, :id] batch_action :destroy, false batch_action 'Задать цену', form: { # type: %w[Offensive Spam Other], val: :text, # notes: :textarea, # hide: :checkbox, # date: :datepicker } do |ids, inputs| # inputs is a hash of all the form fields you requested redirect_to collection_path, notice: [ids, inputs].to_s end batch_action 'Задать объём площади', form: { # type: %w[Offensive Spam Other], val: :text, # notes: :textarea, # hide: :checkbox, # date: :datepicker } do |ids, inputs| # inputs is a hash of all the form fields you requested redirect_to collection_path, notice: [ids, inputs].to_s end config.clear_action_items! action_item :new_model, :only => :index do if current_admin_user.can_create_areas? link_to I18n.t("active_admin.new_model"), '/admin/areas/new', method: :get end end action_item only: [:show] do if current_admin_user.can_edit_area?(resource) link_to I18n.t("active_admin.edit_model"), edit_admin_area_path(resource) end end action_item only: [:show] do if current_admin_user.can_delete_area? link_to I18n.t("active_admin.delete_model"), admin_area_path(resource), data: { confirm: 'Вы уверены, что хотите удалить это?', method: 'delete' } # Удалить end end config.sort_order = 'id_asc' filter :atype_id, :label => 'Тип площади', :as => :select, :collection => -> { C80Estate::Atype.all.map { |p| ["#{p.title}", p.id] } }, :input_html => {:class => 'selectpicker', 'data-size' => "10", 'data-width' => '100%'} filter :property_id, :label => 'Объект недвижимости', :as => :select, :collection => -> { C80Estate::Property.all.map { |p| ["#{p.title}", p.id] } }, :input_html => {:class => 'selectpicker', 'data-size' => "10", 'data-width' => '100%'} # filter :item_prop_square_val_in, # :as => :string, # :label => 'Площадь (м.кв.)' filter :item_prop_square_val_in, :as => :string, :label => 'Площадь (м.кв.)', :input_html => {data: { provide: 'slider', slider_ticks: C80Estate::ItemProp.all_uniq_values(9).to_json, #'[0, 1, 2, 3]', slider_labels: C80Estate::ItemProp.all_uniq_values(9).to_json, #'["none", short", "medium","long"]', slider_min: C80Estate::ItemProp.all_uniq_values(9).last, slider_max: C80Estate::ItemProp.all_uniq_values(9).first, slider_step: 1, slider_value: 0, slider_range: true }} filter :item_prop_price_val_in, :as => :string, :label => 'Цена (руб/м.кв в месяц)', :input_html => {data: { provide: 'slider', slider_ticks: C80Estate::ItemProp.all_uniq_values(1).to_json, #'[0, 1, 2, 3]', slider_labels: C80Estate::ItemProp.all_uniq_values(1).to_json, #'["none", short", "medium","long"]', slider_min: C80Estate::ItemProp.all_uniq_values(1).last, slider_max: C80Estate::ItemProp.all_uniq_values(1).first, slider_step: 1, slider_value: 0, slider_range: true }} filter :item_prop_oenter_in, :as => :select, :collection => [['Есть', 11], ['Нет', 10]], :label => 'Отдельный вход с улицы', :input_html => {:class => 'selectpicker', 'data-size' => "3", 'data-width' => '100%'} filter :item_prop_floor_val_in, :as => :select, :collection => -> { C80Estate::ItemProp.all_uniq_values(5) }, :label => 'Этаж', :input_html => {:class => 'selectpicker', 'data-size' => "3", 'data-width' => '100%'} # filter :title filter :assigned_person_id, :label => 'Назначенный пользователь', :as => :select, :collection => -> { AdminUser.all.map { |u| ["#{u.email}", u.id] } }, :input_html => {:class => 'selectpicker', 'data-size' => "10", 'data-width' => '100%'} filter :created_at filter :updated_at scope "All", :all_areas scope "Free", :free_areas scope "Busy", :busy_areas index do selectable_column column :title column :atype do |area| area.atype_title end column :property do |area| "