Class: Decidim::Notify::Admin::ConversationsController
- Inherits:
-
ApplicationController
- Object
- Admin::Components::BaseController
- ApplicationController
- Decidim::Notify::Admin::ConversationsController
- Includes:
- Broadcasts, NeedsAjaxRescue
- Defined in:
- app/controllers/decidim/notify/admin/conversations_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/decidim/notify/admin/conversations_controller.rb', line 18 def create :update, :config @form = form(NotifyConfigForm).from_params(params) UpdateConfig.call(@form) do on(:ok) do |participants| flash[:notice] = I18n.t("decidim.notify.admin.conversations.success") broadcast_participants participants end on(:invalid) do || flash[:alert] = I18n.t("decidim.notify.admin.conversations.error", message: ) end end redirect_to EngineRouter.admin_proxy(current_component).conversations_path end |
#index ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/controllers/decidim/notify/admin/conversations_controller.rb', line 10 def index :index, :config @users = Author.for(current_component).map { |user| OpenStruct.new(text: format_user_name(user), id: user.decidim_user_id) } @note_takers = Author.for(current_component).note_takers.map { |user| OpenStruct.new(text: format_user_name(user), id: user.decidim_user_id) } @form = form(NotifyConfigForm).from_params(current_component.attributes["settings"]["global"]) end |
#users ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/decidim/notify/admin/conversations_controller.rb', line 34 def users :update, :config respond_to do |format| format.json do if (term = params[:term].to_s).present? query = current_organization.users.order(name: :asc) query = query.where("name ILIKE :term OR nickname ILIKE :term OR email ILIKE :term", term: "%#{term}%") render json: query.all.collect { |u| { id: u.id, text: format_user_name(u) } } else render json: [] end end end end |