Class: Nexo::ElementsController
- Inherits:
-
NexoController
- Object
- NexoController
- Nexo::ElementsController
- Defined in:
- app/controllers/nexo/elements_controller.rb
Instance Method Summary collapse
- #fetch_remote ⇒ Object
- #index ⇒ Object
- #modify ⇒ Object
- #modify_local ⇒ Object
- #resolve_conflict ⇒ Object
- #show ⇒ Object
- #update_status ⇒ Object
Instance Method Details
#fetch_remote ⇒ Object
47 48 49 50 51 |
# File 'app/controllers/nexo/elements_controller.rb', line 47 def fetch_remote FetchRemoteResourceJob.perform_later(@element) redirect_to @element, notice: "Enqueued FetchRemoteResourceJob" end |
#index ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/nexo/elements_controller.rb', line 8 def index @elements = Element.includes(:synchronizable).order(id: :desc) .page(params[:page]).per(params[:page_size] || 10) if params[:not_synced] @elements = @elements.where.not(ne_status: :synced) end if params[:without_synchronizable] @elements = @elements.where(synchronizable_id: nil) end I18n.locale = :en end |
#modify ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/nexo/elements_controller.rb', line 59 def modify case params[:operation] when "delete" DeleteRemoteResourceJob.perform_later(@element) redirect_to @element, notice: "Enqueued DeleteRemoteResourceJob" else redirect_to @element, alert: "Unknown action" end end |
#modify_local ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/nexo/elements_controller.rb', line 31 def modify_local unless Rails.env.local? redirect_to @element, alert: "Available only on local env" return end event = @element.synchronizable event.date_from = event.date_from + 1.day event.date_to = event.date_to + 1.day event.save! EventReceiver.new.synchronizable_updated(event) redirect_to @element, notice: "Modified" end |
#resolve_conflict ⇒ Object
53 54 55 56 57 |
# File 'app/controllers/nexo/elements_controller.rb', line 53 def resolve_conflict ElementService.new(element: @element).resolve_conflict! redirect_to @element, notice: "Conflict solved" end |
#show ⇒ Object
22 23 |
# File 'app/controllers/nexo/elements_controller.rb', line 22 def show end |
#update_status ⇒ Object
25 26 27 28 29 |
# File 'app/controllers/nexo/elements_controller.rb', line 25 def update_status ElementService.new(element: @element).update_ne_status! redirect_to @element, notice: "Updated status" end |