Class: LcpRuby::SavedFiltersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- LcpRuby::SavedFiltersController
- Includes:
- DialogRendering
- Defined in:
- app/controllers/lcp_ruby/saved_filters_controller.rb
Constant Summary
Constants included from DialogRendering
DialogRendering::DIALOG_PASS_THROUGH_KEYS
Constants included from Controller::BearerAuthentication
Controller::BearerAuthentication::BASIC_PREFIX_LENGTH, Controller::BearerAuthentication::BEARER_PREFIX_LENGTH
Instance Method Summary collapse
-
#create ⇒ Object
POST /:lcp_slug/saved-filters Creates a new saved filter.
-
#destroy ⇒ Object
DELETE /:lcp_slug/saved-filters/:id Deletes a saved filter.
-
#index ⇒ Object
GET /:lcp_slug/saved-filters Returns visible saved filters for the current user and presenter.
-
#update ⇒ Object
PATCH /:lcp_slug/saved-filters/:id Updates an existing saved filter.
Methods included from DialogRendering
#composite_dialog?, #defaults_from_params, #dialog_context?, #dialog_form_url, #dialog_locals, #dialog_pass_through_params, #partial_for_dialog_result_style, #render_composite_dialog_form, #render_dialog_form, #render_dialog_form_with_errors, #render_dialog_result, #render_dialog_success, #resolved_dialog_config, #resolved_dialog_page
Methods included from Controller::Authorization
Instance Method Details
#create ⇒ Object
POST /:lcp_slug/saved-filters Creates a new saved filter.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/lcp_ruby/saved_filters_controller.rb', line 23 def create return create_from_dialog if dialog_context? record = build_saved_filter limit_error = check_limits(record) if limit_error render json: { error: limit_error }, status: :unprocessable_content return end if record.save render json: serialize_filter(record), status: :created else render json: { errors: record.errors. }, status: :unprocessable_content end end |
#destroy ⇒ Object
DELETE /:lcp_slug/saved-filters/:id Deletes a saved filter.
58 59 60 61 62 |
# File 'app/controllers/lcp_ruby/saved_filters_controller.rb', line 58 def destroy (@saved_filter) @saved_filter.destroy! render json: { success: true } end |
#index ⇒ Object
GET /:lcp_slug/saved-filters Returns visible saved filters for the current user and presenter.
10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/lcp_ruby/saved_filters_controller.rb', line 10 def index filters = SavedFilters::Resolver.visible_filters( presenter_name: current_presenter.name, user: current_user, evaluator: current_evaluator ) render json: filters.map { |f| serialize_filter(f) } end |
#update ⇒ Object
PATCH /:lcp_slug/saved-filters/:id Updates an existing saved filter.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/lcp_ruby/saved_filters_controller.rb', line 43 def update (@saved_filter) @saved_filter.assign_attributes(saved_filter_params) sync_ql_text!(@saved_filter) if @saved_filter.save render json: serialize_filter(@saved_filter) else render json: { errors: @saved_filter.errors. }, status: :unprocessable_content end end |