Skip to content

Commit

Permalink
annunciate
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmingyuan committed Dec 4, 2023
1 parent 63a6320 commit 82deb5e
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 19 deletions.
11 changes: 0 additions & 11 deletions app/controllers/notice/admin/annunciations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,7 @@ def options
@tags = UserTag.default_where(default_params)
end

def edit_member
q_params = {}
q_params.merge! default_params

@departments = Org::Department.default_where(q_params)
end

def update_member
params[:department_ids].reject(&:blank?).each do |department_id|
@annunciation.annunciates.find_or_create_by(department_id: department_id)
end
end

private
def set_annunciation
Expand Down
30 changes: 29 additions & 1 deletion app/controllers/notice/admin/member_annunciates_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
class Notice::Admin::MemberAnnunciatesController < Notice::Admin::BaseController
module Notice
class Admin::MemberAnnunciatesController < Admin::BaseController
before_action :set_annunciation
before_action :set_departments, only: [:new, :create]
before_action :set_new_member_annunciate, only: [:new, :create]

def index
@member_annunciates = @annunciation.annunciates
end

private
def set_annunciation
@annunciation = Annunciation.find params[:annunciation_id]
end

def set_departments
@departments = Org::Department.default_where(default_params)
end

def set_new_member_annunciate
@member_annunciate = @annunciation.annunciates.build(member_annunciate_params)
end

def member_annunciate_params
params.fetch(:member_annunciate, {}).permit(
:department_id
)
end

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<%= button_to({ action: 'edit_user', id: model.id }, aria: { label: t('.edit_user.title') }, class: 'button is-small is-rounded') do %>
<i class="fa-solid fa-bullhorn has-text-danger"></i>
<% end if model.is_a?(Notice::UserAnnunciation) %>
<%= button_to({ action: 'edit_member', id: model.id }, aria: { label: t('.edit_member.title') }, class: 'button is-small is-rounded') do %>
<%= button_to({ controller: 'member_annunciates', action: 'new', annunciation_id: model.id }, aria: { label: t('.member_annunciates.new.title') }, class: 'button is-small is-rounded') do %>
<i class="fa-solid fa-bullhorn has-text-primary"></i>
<% end if model.is_a?(Notice::MemberAnnunciation) %>
</td>

This file was deleted.

This file was deleted.

12 changes: 12 additions & 0 deletions app/views/notice/admin/member_annunciates/_new_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%= form_with model: @member_annunciate, url: { action: 'create' }, class: 'modal-card' do |f| %>
<header class="modal-card-head">
<p class="modal-card-title"><%= t('.title') %></p>
<button type="button" data-action="modal#close" class="delete"></button>
</header>
<section class="modal-card-body">
<%= f.collection_select :department_ids, @departments, :id, :name, { label: Notice::Annunciation.human_attribute_name(:user_tags) }, { multiple: true, data: { controller: 'choice' } } %>
</section>
<footer class="modal-card-foot">
<%= f.submit %>
</footer>
<% end %>
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
match :edit_user, via: [:get, :post]
patch 'user' => :update_user
match :edit_member, via: [:get, :post]
patch 'member' => :update_member
get 'publish/options' => :options
match :publish, via: [:get, :post]
end
Expand Down

0 comments on commit 82deb5e

Please sign in to comment.