Add ForumSection admin manages
This commit is contained in:
parent
8ad3160ab7
commit
20dd1aeedf
|
@ -0,0 +1,11 @@
|
||||||
|
.admins-forum-moderators-index-page {
|
||||||
|
.df{
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.flex1 {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.text-center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,4 +21,108 @@
|
||||||
.pointer {
|
.pointer {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
.avatar100{
|
||||||
|
height: 100px;
|
||||||
|
width: 100px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
.upload-image-100:hover .admin-show-again-upload{display: block;}
|
||||||
|
.admin-show-again-upload {
|
||||||
|
bottom: 0;
|
||||||
|
width: 100px;
|
||||||
|
height: 100%;
|
||||||
|
line-height: 100px;
|
||||||
|
/* top: 0; */
|
||||||
|
background: rgba(0,0,0,0.6);
|
||||||
|
color: #fff;
|
||||||
|
position: absolute;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
.menu_operate {
|
||||||
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
|
.operateList {
|
||||||
|
position: absolute;
|
||||||
|
right: -110px;
|
||||||
|
top: 9px;
|
||||||
|
background: #fff;
|
||||||
|
width: 100px;
|
||||||
|
color: #999;
|
||||||
|
box-shadow: 0px 0px 9px rgba(0,0,0,0.2);
|
||||||
|
z-index: 100;
|
||||||
|
display: none;
|
||||||
|
a {
|
||||||
|
display: block;
|
||||||
|
height: 30px;
|
||||||
|
line-height: 30px;
|
||||||
|
padding: 0px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
.operateList.active {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.color-grey-6 {
|
||||||
|
color: #666!important;
|
||||||
|
}
|
||||||
|
.set_l_submenu {
|
||||||
|
padding-left: 50px;
|
||||||
|
display: none;
|
||||||
|
width: 180px;
|
||||||
|
list-style-type: none;
|
||||||
|
li{
|
||||||
|
padding: 4px 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.set_l_submenu.active {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.set_l_premenu {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
height: 30px;
|
||||||
|
line-height: 30px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.df{
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.flex1 {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
.text-center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.grid-item-left {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns:1fr max-content;
|
||||||
|
align-self: start;
|
||||||
|
}
|
||||||
|
.ml20{margin-left: 20px;}
|
||||||
|
|
||||||
|
.forum-moderators-items {
|
||||||
|
padding: 10px 30px;
|
||||||
|
max-height: 175px;
|
||||||
|
overflow-y: auto;
|
||||||
|
background: #F4FAFF;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
.mr4 {margin-right: 4px;}
|
||||||
|
.blue-user-btn {
|
||||||
|
margin: 0 5px;
|
||||||
|
padding: 2px 8px;
|
||||||
|
background: #F4F8FA!important;
|
||||||
|
color: #fff!important;
|
||||||
|
border: 1px solid #4CACFF;
|
||||||
|
border-radius: 4px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.mr5 {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
.moderator-list-content{
|
||||||
|
display: inline-block;
|
||||||
|
margin: 5px 0;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -43,4 +43,30 @@ class Admins::BaseController < ApplicationController
|
||||||
def setup_laboratory
|
def setup_laboratory
|
||||||
Laboratory.current = Laboratory.find_by_subdomain(request.subdomain) || Laboratory.find(1)
|
Laboratory.current = Laboratory.find_by_subdomain(request.subdomain) || Laboratory.find(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def up_and_down(opr,current_target,position,model_name)
|
||||||
|
modal_target = model_name.capitalize.classify.constantize
|
||||||
|
if model_name == "forum_section" #只有root才能移动
|
||||||
|
modal_target = modal_target.roots
|
||||||
|
end
|
||||||
|
if opr.to_s == "up"
|
||||||
|
last_target = modal_target.where("position > ?",position)&.first
|
||||||
|
if last_target.present?
|
||||||
|
current_target.update_attribute(:position, last_target.position)
|
||||||
|
last_target.update_attribute(:position, position) # 重新获取当前问题的位置
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return -1
|
||||||
|
end
|
||||||
|
elsif opr.to_s == "down"
|
||||||
|
next_target = modal_target.where("position < ?",position)&.last
|
||||||
|
if next_target.present?
|
||||||
|
current_target.update_attribute(:position, next_target.position)
|
||||||
|
next_target.update_attribute(:position, position)
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return -1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Admins::ForumModeratorsController < Admins::BaseController
|
||||||
users = User.where("( LOWER(login) LIKE ? or LOWER(concat(lastname, firstname)) LIKE ? or LOWER(mail) LIKE ? )",
|
users = User.where("( LOWER(login) LIKE ? or LOWER(concat(lastname, firstname)) LIKE ? or LOWER(mail) LIKE ? )",
|
||||||
"%#{user_name}%","%#{user_name}%","%#{user_name}%")
|
"%#{user_name}%","%#{user_name}%","%#{user_name}%")
|
||||||
users.each do |u|
|
users.each do |u|
|
||||||
check_html = "<input id='check_user_#{u.login}' class='magic-checkbox' type='checkbox' name='member_ids[]' value=""#{u.id}"" checked='false'><label for='check_user_#{u.login}'>#{u.try(:show_real_name)}</label>"
|
check_html = "<div class='search-user-check'><input id='check_user_#{u.login}' class='magic-checkbox mr4' type='checkbox' name='member_ids[]' value=""#{u.id}"" checked='false'><label for='check_user_#{u.login}'>#{u.try(:show_real_name)}</label></div>"
|
||||||
return_html << check_html
|
return_html << check_html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,26 +33,26 @@ class Admins::ForumSectionsController < Admins::BaseController
|
||||||
attachment_id = params[:attachments]&.first
|
attachment_id = params[:attachments]&.first
|
||||||
positions = ForumSection.pluck(:position).select { |a| a.is_a? Integer }
|
positions = ForumSection.pluck(:position).select { |a| a.is_a? Integer }
|
||||||
positions = positions.max.to_i
|
positions = positions.max.to_i
|
||||||
if params[:parent_id].present?
|
if params[:forum_section][:parent_id].present?
|
||||||
@parent_forum = ForumSection.find_by_id(params[:parent_id])
|
@parent_forum = ForumSection.find_by_id(params[:forum_section][:parent_id])
|
||||||
end
|
end
|
||||||
if params[:title].blank?
|
if params[:forum_section][:title].blank?
|
||||||
forum_status = 0
|
forum_status = 0
|
||||||
forum_msg = "不能为空"
|
forum_msg = "标题不能为空"
|
||||||
elsif params[:title].strip.length > 20
|
elsif params[:forum_section][:title].strip.length > 20
|
||||||
forum_status = 0
|
forum_status = 0
|
||||||
forum_msg = "不能超过最大限制:20个字符"
|
forum_msg = "不能超过最大限制:20个字符"
|
||||||
elsif ForumSection.exists?(title: params[:title].strip)
|
elsif ForumSection.exists?(title: params[:forum_section][:title].strip)
|
||||||
forum_status = 0
|
forum_status = 0
|
||||||
forum_msg = "不能重名"
|
forum_msg = "不能重名"
|
||||||
else
|
else
|
||||||
forum_section_params = {
|
forum_section_params = {
|
||||||
user_id: current_user.id,
|
user_id: current_user.id,
|
||||||
title: params[:title].strip,
|
title: params[:forum_section][:title].strip,
|
||||||
position: positions + 1,
|
position: positions + 1,
|
||||||
parent_id: params[:parent_id],
|
parent_id: params[:forum_section][:parent_id],
|
||||||
is_recommend: false,
|
is_recommend: false,
|
||||||
description: params[:description].to_s.truncate(200)
|
description: params[:forum_section][:description].to_s.truncate(200)
|
||||||
}
|
}
|
||||||
@forum_section = ForumSection.new(forum_section_params)
|
@forum_section = ForumSection.new(forum_section_params)
|
||||||
if @forum_section.save
|
if @forum_section.save
|
||||||
|
@ -80,18 +80,18 @@ class Admins::ForumSectionsController < Admins::BaseController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
attachment_id = params[:attachments]&.first
|
attachment_id = params[:attachments]&.first
|
||||||
if params[:title].blank?
|
if params[:forum_section][:title].blank?
|
||||||
forum_status = 0
|
forum_status = 0
|
||||||
forum_msg = "不能为空"
|
forum_msg = "名称不能为空"
|
||||||
elsif params[:title].strip.length > 20
|
elsif params[:forum_section][:title].strip.length > 20
|
||||||
forum_status = 0
|
forum_status = 0
|
||||||
forum_msg = "不能超过最大限制:20个字符"
|
forum_msg = "不能超过最大限制:20个字符"
|
||||||
elsif params[:title].strip != @forum_section.title && ForumSection.exists?(title: params[:title].strip)
|
elsif params[:forum_section][:title].strip != @forum_section.title && ForumSection.exists?(title: params[:forum_section][:title].strip)
|
||||||
forum_status = 0
|
forum_status = 0
|
||||||
forum_msg = "不能重名"
|
forum_msg = "不能重名"
|
||||||
else
|
else
|
||||||
|
|
||||||
if @forum_section.update_attributes(title: params[:title].strip, description: params[:description].to_s.truncate(200))
|
if @forum_section.update_attributes(title: params[:forum_section][:title].strip, description: params[:forum_section][:description].to_s.truncate(200))
|
||||||
|
|
||||||
unless attachment_id.blank? || @forum_section.attachment_id.to_i == attachment_id.to_i
|
unless attachment_id.blank? || @forum_section.attachment_id.to_i == attachment_id.to_i
|
||||||
Attachment.where(id: @forum_section.attachment_id.to_i).destroy_all if @forum_section.attachment_id.present?
|
Attachment.where(id: @forum_section.attachment_id.to_i).destroy_all if @forum_section.attachment_id.present?
|
||||||
|
@ -101,18 +101,6 @@ class Admins::ForumSectionsController < Admins::BaseController
|
||||||
@forum_section.attachment_id = attachment_id
|
@forum_section.attachment_id = attachment_id
|
||||||
@forum_section.save
|
@forum_section.save
|
||||||
end
|
end
|
||||||
# if attachment_id.present?
|
|
||||||
# unless @forum_section.attachment_id.to_i == attachment_id.to_i
|
|
||||||
# if @forum_section.attachment_id.to_i != attachment_id.to_i
|
|
||||||
# Attachment.where(id: @forum_section.attachment_id.to_i).destroy_all
|
|
||||||
# end
|
|
||||||
# attachment = Attachment.find(attachment_id)
|
|
||||||
# attachment.container = @forum_section
|
|
||||||
# attachment.save
|
|
||||||
# @forum_section.attachment_id = attachment_id
|
|
||||||
# @forum_section.save
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
forum_status = 1
|
forum_status = 1
|
||||||
forum_msg = "更新成功"
|
forum_msg = "更新成功"
|
||||||
else
|
else
|
||||||
|
@ -151,6 +139,7 @@ class Admins::ForumSectionsController < Admins::BaseController
|
||||||
else
|
else
|
||||||
@c_msg = "移动失败"
|
@c_msg = "移动失败"
|
||||||
end
|
end
|
||||||
|
redirect_to admins_forum_sections_path
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -159,4 +148,6 @@ class Admins::ForumSectionsController < Admins::BaseController
|
||||||
@forum_section = ForumSection.find_by_id(params[:id])
|
@forum_section = ForumSection.find_by_id(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
class Admins::UploadImagesController < Admins::BaseController
|
|
||||||
def create
|
|
||||||
@attachment = Attachment.new(:file => request.raw_post)
|
|
||||||
@attachment.author = User.current
|
|
||||||
@attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16)
|
|
||||||
if @attachment.save
|
|
||||||
@status = 1
|
|
||||||
else
|
|
||||||
@status = -1
|
|
||||||
end
|
|
||||||
respond_to do |format|
|
|
||||||
format.js
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -92,6 +92,44 @@ class AttachmentsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#后台上传图片
|
||||||
|
def upload_images
|
||||||
|
upload_file = params["file"] || params["#{params[:file_param_name]}"]# 这里的file_param_name是为了方便其他插件名称
|
||||||
|
raise "未上传文件" unless upload_file
|
||||||
|
|
||||||
|
folder = edu_setting('attachment_folder')
|
||||||
|
raise "存储目录未定义" unless folder.present?
|
||||||
|
month_folder = current_month_folder
|
||||||
|
save_path = File.join(folder, month_folder)
|
||||||
|
|
||||||
|
ext = SecureRandom.urlsafe_base64
|
||||||
|
|
||||||
|
local_path, digest = file_save_to_local(save_path, upload_file.tempfile, ext)
|
||||||
|
|
||||||
|
content_type = upload_file.content_type.presence || 'application/octet-stream'
|
||||||
|
|
||||||
|
disk_filename = local_path[save_path.size + 1, local_path.size]
|
||||||
|
|
||||||
|
@attachment = Attachment.where(disk_filename: disk_filename,author_id: current_user.id).first
|
||||||
|
if @attachment.blank?
|
||||||
|
@attachment = Attachment.new
|
||||||
|
@attachment.filename = upload_file.original_filename
|
||||||
|
@attachment.disk_filename = disk_filename
|
||||||
|
@attachment.filesize = upload_file.tempfile.size
|
||||||
|
@attachment.content_type = content_type
|
||||||
|
@attachment.digest = digest
|
||||||
|
@attachment.author_id = current_user.id
|
||||||
|
@attachment.disk_directory = month_folder
|
||||||
|
@attachment.save!
|
||||||
|
@status = 1
|
||||||
|
else
|
||||||
|
@status = -1
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
begin
|
begin
|
||||||
@file_path = absolute_path(local_path(@file))
|
@file_path = absolute_path(local_path(@file))
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
<% if users.present? && users.size > 0 %>
|
<% if users.present? && users.size > 0 %>
|
||||||
<% users.each do |u| %>
|
<% users.each do |u| %>
|
||||||
<% user = u.user %>
|
<% user = u.user %>
|
||||||
|
<span class="moderator-list-content">
|
||||||
<span class="blue-user-btn" id="forum_section_moderator_user_<%= u.id %>">
|
<span class="blue-user-btn" id="forum_section_moderator_user_<%= u.id %>">
|
||||||
<span class="mr5"><%= link_to user.try(:show_real_name), user_path(user) %></span>
|
<span class="mr5"><%= link_to user.try(:show_real_name), user_path(user) %></span>
|
||||||
<span><%= link_to "<i class='fa fa-close font16'></i>".html_safe,admin_forum_section_forum_moderator_path(forum, u), method: :delete, data:{confirm: "确认删除吗?"}, remote: true, class: "color-grey-9" %></span>
|
<span><%= link_to "<i class='fa fa-close font16'></i>".html_safe,admins_forum_section_forum_moderator_path(forum, u), method: :delete, data:{confirm: "确认删除吗?"}, remote: true, class: "color-grey-9" %></span>
|
||||||
</span>
|
</span>
|
||||||
|
</span>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
|
@ -1,6 +1,4 @@
|
||||||
<% if @forum_status > 0 %>
|
<% if @forum_status > 0 %>
|
||||||
$("#forum_sections_moderators_<%= @forum_section.id %>").html("<%= j render partial: "admins/forum_moderators/forum_moderator_item", locals: {users: @forum_moderators, forum: @forum_section} %>")
|
$("#forum_sections_moderators_<%= @forum_section.id %>").html("<%= j render partial: "admins/forum_moderators/forum_moderator_item", locals: {users: @forum_moderators, forum: @forum_section} %>")
|
||||||
op_know("添加成功")
|
$('#admin-managers-modal').modal("hide")
|
||||||
<% else %>
|
|
||||||
op_know("没有选择版主")
|
|
||||||
<% end %>
|
<% end %>
|
|
@ -1,11 +1,13 @@
|
||||||
var htmlvalue = "<%= j render :partial => 'admins/forum_moderators/new_forum_moderators' %>";
|
|
||||||
pop_box_new(htmlvalue, 520, 400);
|
var htmlvalue = "<%= j render :partial => 'admins/forum_moderators/shared/form'%>";
|
||||||
|
$("#admin-forum-managers-content").html(htmlvalue)
|
||||||
|
$('#admin-managers-modal').modal('show')
|
||||||
|
|
||||||
function search_forum_users(target) {
|
function search_forum_users(target) {
|
||||||
var t_value = $("#"+ target).val()
|
var t_value = $("#"+ target).val()
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url:'/admin/forum_sections/<%= @forum_section.id %>/forum_moderators/search_user?user_name='+t_value,
|
url:'/admins/forum_sections/<%= @forum_section.id %>/forum_moderators/search_user?user_name='+t_value,
|
||||||
dataType:'JSON',
|
dataType:'JSON',
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if(data.html.length > 0){
|
if(data.html.length > 0){
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">
|
||||||
|
添加版主
|
||||||
|
</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<%= simple_form_for(ForumModerator.new, url: admins_forum_section_forum_moderators_path(@forum_section), html: { remote: true}) do |f|%>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="task-popup-content mt10">
|
||||||
|
<div class="grid-item-left">
|
||||||
|
<%= text_field_tag :user_name,nil,class: "form-control input-lg" ,id: "search-forum-moderators",placeholder: "请输入用户的名称搜索" %>
|
||||||
|
<%= link_to "搜索", "javascript:void(0)", class: "btn btn-primary btn-sm ml20", onclick: "search_forum_users('search-forum-moderators')", disable_with: '搜索中...' %>
|
||||||
|
</div>
|
||||||
|
<div id="has-none-moderators" class="none forum-moderators-items">
|
||||||
|
</div>
|
||||||
|
<div id="forum-moderators-show" class="none forum-moderators-items">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||||
|
<%= f.submit "确定", disable_with: '提交中...', class: "btn btn-primary submit-btn" %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -1,6 +1,6 @@
|
||||||
<a href="javascript:void(0)" class="fl" ><%= children_forum.try(:title) %></a>
|
<a href="javascript:void(0)" class="fl" ><%= children_forum.try(:title) %></a>
|
||||||
<span href="javascript:void(0)" class="menu_operate ml20 fr" onclick="first_menu_action(this)">
|
<span href="javascript:void(0)" class="menu_operate ml20 fr" onclick="first_menu_action(this)">
|
||||||
<i class="iconfont icon-sandian color-grey-6 font-12"> </i>
|
<i class="fa fa-ellipsis-v color-grey-6"></i>
|
||||||
<div class="operateList">
|
<div class="operateList">
|
||||||
<%= link_to "重命名", edit_admins_forum_section_path(children_forum, children_forum: true), remote: true %>
|
<%= link_to "重命名", edit_admins_forum_section_path(children_forum, children_forum: true), remote: true %>
|
||||||
<%= link_to "删除", admins_forum_section_path(children_forum, children_forum: true),method: :delete, data:{confirm: "确认删除吗?"}, remote: true %>
|
<%= link_to "删除", admins_forum_section_path(children_forum, children_forum: true),method: :delete, data:{confirm: "确认删除吗?"}, remote: true %>
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function first_menu_action(that) {
|
function first_menu_action(that) {
|
||||||
|
console.log('ddddd')
|
||||||
var target = $(that);
|
var target = $(that);
|
||||||
var target_action = target.find(".operateList");
|
var target_action = target.find(".operateList");
|
||||||
if(target_action.hasClass("active")){
|
if(target_action.hasClass("active")){
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
<td>
|
<td>
|
||||||
<li class="set_l_main">
|
<div class="set_l_main">
|
||||||
<div class="set_l_premenu">
|
<div class="set_l_premenu">
|
||||||
<span class="ml10 max-width-300" onclick="first_menu_click(this)">
|
<span class="ml10 max-width-300" onclick="first_menu_click(this)">
|
||||||
<i class="fa fa-plus-square-o color-grey-6"></i>
|
<i class="fa fa-plus-square-o color-grey-6"></i>
|
||||||
<span class="ml5"><%= forum.try(:title) %></span>
|
<span class="ml5"><%= forum.try(:title) %></span>
|
||||||
</span>
|
</span>
|
||||||
<span href="javascript:void(0)" class="menu_operate ml20" onclick="first_menu_action(this)">
|
<span href="javascript:void(0)" class="menu_operate ml20" onclick="first_menu_action(this)">
|
||||||
<i class="iconfont icon-sandian color-grey-6 font-12">
|
<i class="fa fa-ellipsis-v color-grey-6"></i>
|
||||||
</i>
|
|
||||||
<div class="operateList">
|
<div class="operateList">
|
||||||
<%= link_to "重命名", edit_admins_forum_section_path(forum), remote: true %>
|
<%= link_to "重命名", edit_admins_forum_section_path(forum), remote: true %>
|
||||||
<%= link_to "删除", admins_forum_section_path(forum),method: :delete, data:{confirm: "确认删除吗?"}, remote: true %>
|
<%= link_to "删除", admins_forum_section_path(forum),method: :delete, data:{confirm: "确认删除吗?"}, remote: true %>
|
||||||
<%= link_to "新增子版块".html_safe, new_admins_forum_section_path(parent_id: forum.id),remote: true %>
|
<%= link_to "新增子版块".html_safe, new_admins_forum_section_path(parent_id: forum.id),remote: true %>
|
||||||
<% if forum&.position.to_i != @min_position %>
|
<% if forum&.position.to_i != @min_position %>
|
||||||
<%= link_to "下移",move_admin_forum_section_path(forum,opr:"down"), method: :post, remote: true %>
|
<%= link_to "下移",move_admins_forum_section_path(forum,opr:"down"), method: :post, remote: true %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if forum&.position.to_i != @max_position %>
|
<% if forum&.position.to_i != @max_position %>
|
||||||
<%= link_to "上移",move_admin_forum_section_path(forum,opr:"up"), method: :post, remote: true %>
|
<%= link_to "上移",move_admins_forum_section_path(forum,opr:"up"), method: :post, remote: true %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
|
@ -24,7 +23,7 @@
|
||||||
<div id="children-forum-section-<%= forum.id %>">
|
<div id="children-forum-section-<%= forum.id %>">
|
||||||
<%= render partial: "admins/forum_sections/children_forum_sections", locals: {children_forums: forum.get_children_section("desc")} %>
|
<%= render partial: "admins/forum_sections/children_forum_sections", locals: {children_forums: forum.get_children_section("desc")} %>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td id="forum-section-recommend-<%= forum.id %>">
|
<td id="forum-section-recommend-<%= forum.id %>">
|
||||||
<%= render partial: "admins/forum_sections/recommend_forum_sections", locals: {forum: forum} %>
|
<%= render partial: "admins/forum_sections/recommend_forum_sections", locals: {forum: forum} %>
|
||||||
|
|
|
@ -1,20 +1,27 @@
|
||||||
<%= file_field_tag 'attachments[dummy][file]',
|
<%= file_field_tag 'attachments[dummy][file]',
|
||||||
:id => "_file_section_picture",
|
:id => "_file_section_picture",
|
||||||
:class => 'file_selector',
|
:class => 'file_selector',
|
||||||
:onchange => "addInputFiles_board(this);",
|
:onchange => "addInputFiles_board()",
|
||||||
:style =>'display:none',
|
:style =>'display:none',
|
||||||
accept: 'image/png,image/gif,image/jpeg,image/jpg,image/bmp',
|
accept: 'image/png,image/gif,image/jpeg,image/jpg,image/bmp',
|
||||||
:data => {
|
:data => {
|
||||||
:max_file_size => 5120.kilobytes,
|
:max_file_size => 5120.kilobytes,
|
||||||
:max_concurrent_uploads => 1,
|
:max_concurrent_uploads => 1,
|
||||||
:upload_path => admins_upload_images_path(:format => 'js'),
|
:upload_path => attachments_upload_images_path(:format => 'js'),
|
||||||
} %>
|
} %>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function addInputFiles_board(file) {
|
function addInputFiles_board() {
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append('file', $('input[name="attachments[dummy][file]"]')[0].files[0]);
|
||||||
|
$.ajax({
|
||||||
|
url: "<%= attachments_upload_images_path %>",
|
||||||
|
type: 'POST',
|
||||||
|
data: formData,
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
|
@ -1,14 +1,12 @@
|
||||||
<% if @forum_status[:status] == 0 %>
|
<% if @forum_status[:status] == 0 %>
|
||||||
$("#new_forum_section_notice").removeClass("none").html("<%= @forum_status[:msg] %>")
|
$("#add-section-forum").removeClass("none").html("<%= j render partial: "admins/forum_sections/shared/error_section", locals: {error_messages: @forum_status[:msg] } %>")
|
||||||
$("#new_forum_section_notice").siblings("input").addClass("error_tip");
|
<% else %>
|
||||||
<% elsif @forum_status[:status] > 0 %>
|
$("#add-section-forum").addClass("none")
|
||||||
op_know("<%= @forum_status[:msg] %>")
|
<% if @forum_section.parent_id.present? %>
|
||||||
<% if params[:parent_id].present? %>
|
$("#forum-section-detail-<%= @forum_section.parent_id %>").html("<%= j render partial: "admins/forum_sections/td_forum_section", locals: {forum: @parent_forum} %>")
|
||||||
$("#forum-section-detail-<%= params[:parent_id] %>").html("<%= j render partial: "admins/forum_sections/td_forum_section", locals: {forum: @parent_forum} %>")
|
|
||||||
<% else %>
|
<% else %>
|
||||||
$("#forum-section-contents").prepend("<%= j render partial: "admins/forum_sections/forum_section_detail", locals: {forum: @forum_section} %>")
|
$("#forum-section-contents").prepend("<%= j render partial: "admins/forum_sections/forum_section_detail", locals: {forum: @forum_section} %>")
|
||||||
<% end %>
|
<% end %>
|
||||||
|
$('#admin-forum-section-modal').modal("hide")
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% else %>
|
|
||||||
op_know("<%= @forum_status[:msg] %>")
|
|
||||||
<% end %>
|
|
|
@ -1,10 +1,7 @@
|
||||||
<% if @delete_status[:status] > 0 %>
|
<% if @delete_status[:status] > 0 %>
|
||||||
op_know("<%= @delete_status[:msg] %>")
|
<% if params[:children_forum] %>
|
||||||
<% if params[:children_forum].present? %>
|
$("#children-forum-detail-<%= @forum_section.id %>").remove()
|
||||||
$("#children-forum-detail-<%= @forum_section.id %>").remove()
|
<% else %>
|
||||||
<% else %>
|
$("#forum-section-detail-<%= @forum_section.id %>").remove()
|
||||||
$("#forum-section-detail-<%= @forum_section.id %>").remove()
|
<% end %>
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
op_know("<%= @delete_status[:msg] %>")
|
|
||||||
<% end %>
|
<% end %>
|
|
@ -1,2 +1,4 @@
|
||||||
var htmlvalue = "<%= j render :partial => 'admins/forum_sections/edit_forum' %>";
|
|
||||||
pop_box_new(htmlvalue, 520, 400);
|
var htmlvalue = "<%= j render :partial => 'admins/forum_sections/shared/new_forum', locals: {parent_id: @forum_section.parent_id, is_create: "2", forum_section: @forum_section} %>";
|
||||||
|
$("#admin-forum-section-content").html(htmlvalue)
|
||||||
|
$('#admin-forum-section-modal').modal('show')
|
|
@ -8,4 +8,5 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= render partial: 'admins/forum_sections/shared/add_section' %>
|
<%= render partial: 'admins/forum_sections/shared/add_section' %>
|
||||||
|
<%= render partial: 'admins/forum_sections/shared/add_managers' %>
|
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
<div class="modal fade admins-add-managers-modal" tabindex="-1" role="dialog" aria-hidden="true" id="admin-managers-modal">
|
||||||
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content" id="admin-forum-managers-content">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title">
|
<h5 class="modal-title">
|
||||||
<%= is_create === "1" ? "新建" : "编辑" %>
|
<%= is_create === "1" ? "新建" : "编辑" %>
|
||||||
<%= parent_id.present? ? "二级版块" : "一级版块" %>
|
<%= parent_id.present? ? "二级版块" : "一级版块" %>
|
||||||
</h5>
|
</h5>
|
||||||
|
@ -7,31 +7,32 @@
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<%= form_tag(admins_forum_sections_path, method: :post, class: "", remote: true) do %>
|
<%= simple_form_for(forum_section, url: forum_section.id.present? ? admins_forum_section_path(forum_section.id) : admins_forum_sections_path,method: forum_section.id.present? ? "put" : "post", html: { remote: true}) do |f|%>
|
||||||
|
<%= f.hidden_field :parent_id, value: parent_id %>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<%= hidden_field_tag :parent_id,parent_id %>
|
|
||||||
<div>
|
<div>
|
||||||
<div class="grid-item-top">
|
<div class="grid-item-top">
|
||||||
<span class="mr10 color-grey">名称:</span>
|
<span class="mr10 color-grey">名称:</span>
|
||||||
<div>
|
<div>
|
||||||
<%= text_field_tag :title, nil,class: "form-control input-lg", placeholder: "请输入名称,最大限制20个字符", maxlength: 20 %>
|
<%= f.text_field :title,class: "form-control input-lg", placeholder: "请输入名称,最大限制20个字符", maxlength: 20 %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid-item-top mt20">
|
<div class="grid-item-top mt20">
|
||||||
<span class="mr10 color-grey">描述:</span>
|
<span class="mr10 color-grey">描述:</span>
|
||||||
<div>
|
<div>
|
||||||
<%= text_area_tag :description,nil,class: "form-control input-lg", placeholder: "请输入描述", maxlength: 200, rows: 4 %>
|
<%= f.text_area :description,class: "form-control input-lg", placeholder: "请输入描述", maxlength: 200, rows: 4 %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid-item-top mt20">
|
<div class="grid-item-top mt20">
|
||||||
<span class="mr10 color-grey">封面:</span>
|
<span class="mr10 color-grey">封面:</span>
|
||||||
<div>
|
<div>
|
||||||
<div class="upload-image-100 pointer" onclick="$('#_file_section_picture').click();" id="admin-logo-upload">
|
<div class="upload-image-100 pointer" onclick="$('#_file_section_picture').click();" id="admin-logo-upload">
|
||||||
<div style="line-height: 100px;">上传封面</div>
|
<% if forum_section&.id && forum_section.attachment_id.present? %>
|
||||||
</div>
|
<% attachment = forum_section.image_attachment %>
|
||||||
<div class="none poa top-bottom-0">
|
<%= render partial: "admins/forum_sections/show_image_forum", locals: {logo_url: download_url(attachment), attachment: attachment, image_type: 'image' } %>
|
||||||
<input type="file" name="attachments[dummy][file]" id="_file_section_picture">
|
<% else %>
|
||||||
<%# <%=render partial: "admins/forum_sections/upload_logo"> %>
|
<div style="line-height: 100px;">上传封面</div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="font-12 color-grey">
|
<div class="font-12 color-grey">
|
||||||
尺寸 100*100,支持.jpg .jpeg .bmp .gif .png格式照片。
|
尺寸 100*100,支持.jpg .jpeg .bmp .gif .png格式照片。
|
||||||
|
@ -45,6 +46,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||||
<%= submit_tag "确定", class: "btn btn-primary submit-btn" %>
|
<%= f.submit "确定", disable_with: '提交中...', class: "btn btn-primary submit-btn" %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<div class="none poa top-bottom-0">
|
||||||
|
<%= render partial: "admins/forum_sections/upload_logo" %>
|
||||||
|
</div>
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
<% if @edit_forum_status[:status] == 0 %>
|
<% if @edit_forum_status[:status] == 0 %>
|
||||||
$("#edit_forum_section_notice").removeClass("none").html("<%= @edit_forum_status[:msg] %>")
|
$("#add-section-forum").removeClass("none").html("<%= j render partial: "admins/forum_sections/shared/error_section", locals: {error_messages: @edit_forum_status[:msg] } %>")
|
||||||
$("#edit_forum_section_notice").siblings("input").addClass("error_tip");
|
|
||||||
<% elsif @edit_forum_status[:status] > 0 %>
|
|
||||||
op_know("<%= @edit_forum_status[:msg] %>")
|
|
||||||
<% if params[:children_forum].present? %>
|
|
||||||
$("#children-forum-detail-<%= @forum_section.id %>").html("<%= j render partial: "admins/forum_sections/children_forum_detail", locals: {children_forum: @forum_section} %>")
|
|
||||||
<% else %>
|
|
||||||
$("#forum-section-detail-<%= @forum_section.id %>").html("<%= j render partial: "admins/forum_sections/td_forum_section", locals: {forum: @forum_section} %>")
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
op_know("<%= @edit_forum_status[:msg] %>")
|
$("#add-section-forum").addClass("none")
|
||||||
<% end %>
|
<% if @forum_section.parent_id.present? %>
|
||||||
|
$("#children-forum-detail-<%= @forum_section.id %>").html("<%= j render partial: "admins/forum_sections/children_forum_detail", locals: {children_forum: @forum_section} %>")
|
||||||
|
<% else %>
|
||||||
|
$("#forum-section-detail-<%= @forum_section.id %>").html("<%= j render partial: "admins/forum_sections/td_forum_section", locals: {forum: @forum_section} %>")
|
||||||
|
<% end %>
|
||||||
|
$('#admin-forum-section-modal').modal("hide")
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
<% if @status > 0 %>
|
|
||||||
$("#admin-logo-upload").html("<%= j render partial: "admins/forum_sections/show_image_forum", locals: {logo_url: download_named_attachment_path(@attachment, @attachment.filename), attachment: @attachment, image_type: params[:image_type] || 'image' } %>")
|
|
||||||
<% end %>
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<% if @status > 0 %>
|
||||||
|
$("#admin-logo-upload").html("<%= j render partial: "admins/forum_sections/show_image_forum", locals: {logo_url: download_url(@attachment), attachment: @attachment, image_type: params[:image_type] || 'image' } %>")
|
||||||
|
<% end %>
|
|
@ -33,7 +33,8 @@ Rails.application.routes.draw do
|
||||||
get 'attachments/entries/get_file', to: 'attachments#get_file'
|
get 'attachments/entries/get_file', to: 'attachments#get_file'
|
||||||
get 'attachments/download/:id', to: 'attachments#show'
|
get 'attachments/download/:id', to: 'attachments#show'
|
||||||
get 'attachments/download/:id/:filename', to: 'attachments#show'
|
get 'attachments/download/:id/:filename', to: 'attachments#show'
|
||||||
|
post 'attachments/upload_images', to: 'attachments#upload_images'
|
||||||
|
# get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
|
||||||
get 'auth/qq/callback', to: 'oauth/qq#create'
|
get 'auth/qq/callback', to: 'oauth/qq#create'
|
||||||
get 'auth/failure', to: 'oauth/base#auth_failure'
|
get 'auth/failure', to: 'oauth/base#auth_failure'
|
||||||
get 'auth/cas/callback', to: 'oauth/cas#create'
|
get 'auth/cas/callback', to: 'oauth/cas#create'
|
||||||
|
@ -492,7 +493,6 @@ Rails.application.routes.draw do
|
||||||
# post :confirm_banned
|
# post :confirm_banned
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
resources :upload_images, only: :create
|
|
||||||
resources :forum_sections do
|
resources :forum_sections do
|
||||||
member do
|
member do
|
||||||
get "order_forums"
|
get "order_forums"
|
||||||
|
|
Loading…
Reference in New Issue