forked from Trustie/forgeplus
fixed 小程序活动后台管理
This commit is contained in:
parent
dd7be1c392
commit
4ea60a5114
|
|
@ -1,5 +1,6 @@
|
|||
class Admins::PlatformCommunicatesController < Admins::BaseController
|
||||
class Admins::PlatformCommunicatesController < Admins::BaseController
|
||||
before_action :get_communicate, only: [:edit, :update, :destroy, :show]
|
||||
|
||||
def index
|
||||
params[:location] = "pc"
|
||||
sort_by = PlatformCommunicate.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'order_index'
|
||||
|
|
@ -40,46 +41,48 @@ class Admins::PlatformCommunicatesController < Admins::BaseController
|
|||
|
||||
def create
|
||||
@communicate = PlatformCommunicate.new(communicate_params)
|
||||
if @communicate.save
|
||||
redirect_to admins_platform_communicates_path
|
||||
if @communicate.save
|
||||
redirect_to @communicate.location == 'pc' ? "/admins/platform_communicates?location=pc" : "/admins/platform_communicates/applet?location=applet"
|
||||
flash[:success] = '创建社区动态成功'
|
||||
else
|
||||
redirect_to admins_platform_communicates_path
|
||||
redirect_to @communicate.location == 'pc' ? "/admins/platform_communicates?location=pc" : "/admins/platform_communicates/applet?location=applet"
|
||||
flash[:danger] = "创建社区动态失败"
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
def edit
|
||||
|
||||
end
|
||||
|
||||
def update
|
||||
def update
|
||||
@communicate.attributes = communicate_params
|
||||
if @communicate.save
|
||||
redirect_to admins_platform_communicates_path
|
||||
redirect_to @communicate.location == 'pc' ? "/admins/platform_communicates?location=pc" : "/admins/platform_communicates/applet?location=applet"
|
||||
flash[:success] = '更新社区动态成功'
|
||||
else
|
||||
redirect_to admins_platform_communicates_path
|
||||
else
|
||||
redirect_to @communicate.location == 'pc' ? "/admins/platform_communicates?location=pc" : "/admins/platform_communicates/applet?location=applet"
|
||||
flash[:danger] = '更新社区动态失败'
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @communicate.destroy
|
||||
redirect_to admins_platform_communicates_path
|
||||
def destroy
|
||||
location = @communicate.location
|
||||
if @communicate.destroy
|
||||
redirect_to location == 'pc' ? "/admins/platform_communicates?location=pc" : "/admins/platform_communicates/applet?location=applet"
|
||||
flash[:success] = '删除社区动态成功'
|
||||
else
|
||||
redirect_to admins_platform_communicates_path
|
||||
redirect_to location == 'pc' ? "/admins/platform_communicates?location=pc" : "/admins/platform_communicates/applet?location=applet"
|
||||
flash[:danger] = '删除社区动态失败'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def get_communicate
|
||||
private
|
||||
|
||||
def get_communicate
|
||||
@communicate = PlatformCommunicate.find_by_id(params[:id])
|
||||
end
|
||||
|
||||
def communicate_params
|
||||
def communicate_params
|
||||
params.require(:platform_communicate).permit!
|
||||
end
|
||||
end
|
||||
|
|
@ -40,12 +40,12 @@
|
|||
</label>
|
||||
<%= p.number_field :order_index,class: "form-control input-lg",required: true%>
|
||||
</div>
|
||||
<%if @communicate&.tag_field.to_s.include?("活动") %>
|
||||
<%if @communicate&.tag_field.to_s.include?("活动") && @communicate.location =='applet' %>
|
||||
<div class="form-group">
|
||||
<label>
|
||||
报名字段(多个请用,隔开)
|
||||
报名字段(多个请用,隔开)<span class="ml10 color-orange mr20">*</span>
|
||||
</label>
|
||||
<%= p.text_field :enroll_field,class: "form-control input-lg"%>
|
||||
<%= p.text_field :enroll_field,class: "form-control input-lg", required: true%>
|
||||
</div>
|
||||
<%end %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('社区动态管理') %>
|
||||
<% add_admin_breadcrumb('小程序动态管理') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container platform-communicate-list-form">
|
||||
|
|
|
|||
Loading…
Reference in New Issue