Class: Pattana::RegionsController
- Inherits:
-
ResourceController
- Object
- Kuppayam::BaseController
- ApplicationController
- ResourceController
- Pattana::RegionsController
- Defined in:
- app/controllers/pattana/regions_controller.rb
Instance Method Summary collapse
- #cities ⇒ Object
- #hide_in_api ⇒ Object
- #mark_as_operational ⇒ Object
- #remove_operational ⇒ Object
- #show_in_api ⇒ Object
Instance Method Details
#cities ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/pattana/regions_controller.rb', line 4 def cities @region = Region.find_by_id(params[:id]) @relation = @region.cities.limit(50) parse_filters apply_filters @filter_ui_settings[:operational][:drop_down_options] = {remote: true} @filter_ui_settings[:operational][:url_method_name] = "cities_region_url" @filter_ui_settings[:show_in_api][:drop_down_options] = {remote: true} @filter_ui_settings[:show_in_api][:url_method_name] = "cities_region_url" @cities = @relation.page(@current_page).per(@per_page) end |
#hide_in_api ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/pattana/regions_controller.rb', line 35 def hide_in_api @region = @r_object = Region.find(params[:id]) if @region @region.show_in_api = false if @region.valid? @region.save set_notification(true, I18n.t('regions.hide_in_api.heading'), I18n.t('regions.hide_in_api.message')) else set_notification(false, I18n.t('status.error'), I18n.translate("error"), @region.errors..join("<br>")) end else set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize)) end render_row end |
#mark_as_operational ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/pattana/regions_controller.rb', line 51 def mark_as_operational @region = @r_object = Region.find(params[:id]) if @region @region.operational = true if @region.valid? @region.save set_notification(true, I18n.t('regions.marked_as_operational.heading'), I18n.t('regions.marked_as_operational.message')) else set_notification(false, I18n.t('status.error'), I18n.translate("error"), @region.errors..join("<br>")) end else set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize)) end render_row end |
#remove_operational ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/controllers/pattana/regions_controller.rb', line 67 def remove_operational @region = @r_object = Region.find(params[:id]) if @region @region.operational = false if @region.valid? @region.save set_notification(true, I18n.t('regions.removed_operational.heading'), I18n.t('regions.removed_operational.message')) else set_notification(false, I18n.t('status.error'), I18n.translate("error"), @region.errors..join("<br>")) end else set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize)) end render_row end |
#show_in_api ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/pattana/regions_controller.rb', line 19 def show_in_api @region = @r_object = Region.find(params[:id]) if @region @region.show_in_api = true if @region.valid? @region.save set_notification(true, I18n.t('regions.show_in_api.heading'), I18n.t('regions.show_in_api.message')) else set_notification(false, I18n.t('status.error'), I18n.translate("error"), @region.errors..join("<br>")) end else set_notification(false, I18n.t('status.error'), I18n.t('status.error', item: default_item_name.titleize)) end render_row end |