diff --git a/app/assets/stylesheets/admins/forum_moderators.scss b/app/assets/stylesheets/admins/forum_moderators.scss new file mode 100644 index 00000000..47f1f2ce --- /dev/null +++ b/app/assets/stylesheets/admins/forum_moderators.scss @@ -0,0 +1,11 @@ +.admins-forum-moderators-index-page { + .df{ + display: flex; + } + .flex1 { + flex: 1; +} +.text-center { + text-align: center; +} +} \ No newline at end of file diff --git a/app/assets/stylesheets/admins/forum_sections.scss b/app/assets/stylesheets/admins/forum_sections.scss index 61ec5cce..c5d66216 100644 --- a/app/assets/stylesheets/admins/forum_sections.scss +++ b/app/assets/stylesheets/admins/forum_sections.scss @@ -21,4 +21,108 @@ .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; +} } \ No newline at end of file diff --git a/app/controllers/admins/base_controller.rb b/app/controllers/admins/base_controller.rb index fbfc3fc4..56ce082b 100644 --- a/app/controllers/admins/base_controller.rb +++ b/app/controllers/admins/base_controller.rb @@ -43,4 +43,30 @@ class Admins::BaseController < ApplicationController def setup_laboratory Laboratory.current = Laboratory.find_by_subdomain(request.subdomain) || Laboratory.find(1) 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 diff --git a/app/controllers/admins/forum_moderators_controller.rb b/app/controllers/admins/forum_moderators_controller.rb index 0356952b..969ea477 100644 --- a/app/controllers/admins/forum_moderators_controller.rb +++ b/app/controllers/admins/forum_moderators_controller.rb @@ -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 ? )", "%#{user_name}%","%#{user_name}%","%#{user_name}%") users.each do |u| - check_html = "" + check_html = "
" return_html << check_html end end diff --git a/app/controllers/admins/forum_sections_controller.rb b/app/controllers/admins/forum_sections_controller.rb index 2531cb0d..e2dc0193 100644 --- a/app/controllers/admins/forum_sections_controller.rb +++ b/app/controllers/admins/forum_sections_controller.rb @@ -33,26 +33,26 @@ class Admins::ForumSectionsController < Admins::BaseController attachment_id = params[:attachments]&.first positions = ForumSection.pluck(:position).select { |a| a.is_a? Integer } positions = positions.max.to_i - if params[:parent_id].present? - @parent_forum = ForumSection.find_by_id(params[:parent_id]) + if params[:forum_section][:parent_id].present? + @parent_forum = ForumSection.find_by_id(params[:forum_section][:parent_id]) end - if params[:title].blank? + if params[:forum_section][:title].blank? forum_status = 0 - forum_msg = "不能为空" - elsif params[:title].strip.length > 20 + forum_msg = "标题不能为空" + elsif params[:forum_section][:title].strip.length > 20 forum_status = 0 forum_msg = "不能超过最大限制:20个字符" - elsif ForumSection.exists?(title: params[:title].strip) + elsif ForumSection.exists?(title: params[:forum_section][:title].strip) forum_status = 0 forum_msg = "不能重名" else forum_section_params = { user_id: current_user.id, - title: params[:title].strip, + title: params[:forum_section][:title].strip, position: positions + 1, - parent_id: params[:parent_id], + parent_id: params[:forum_section][:parent_id], 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) if @forum_section.save @@ -80,18 +80,18 @@ class Admins::ForumSectionsController < Admins::BaseController def update attachment_id = params[:attachments]&.first - if params[:title].blank? + if params[:forum_section][:title].blank? forum_status = 0 - forum_msg = "不能为空" - elsif params[:title].strip.length > 20 + forum_msg = "名称不能为空" + elsif params[:forum_section][:title].strip.length > 20 forum_status = 0 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_msg = "不能重名" 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 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.save 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_msg = "更新成功" else @@ -151,6 +139,7 @@ class Admins::ForumSectionsController < Admins::BaseController else @c_msg = "移动失败" end + redirect_to admins_forum_sections_path end private @@ -159,4 +148,6 @@ class Admins::ForumSectionsController < Admins::BaseController @forum_section = ForumSection.find_by_id(params[:id]) end + + end diff --git a/app/controllers/admins/upload_images_controller.rb b/app/controllers/admins/upload_images_controller.rb deleted file mode 100644 index 802ea306..00000000 --- a/app/controllers/admins/upload_images_controller.rb +++ /dev/null @@ -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 \ No newline at end of file diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 16842fb5..f052a873 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -92,6 +92,44 @@ class AttachmentsController < ApplicationController 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 begin @file_path = absolute_path(local_path(@file)) diff --git a/app/views/admins/forum_moderators/_forum_moderator_item.html.erb b/app/views/admins/forum_moderators/_forum_moderator_item.html.erb index 79764db7..8bffb62f 100644 --- a/app/views/admins/forum_moderators/_forum_moderator_item.html.erb +++ b/app/views/admins/forum_moderators/_forum_moderator_item.html.erb @@ -1,9 +1,12 @@ <% if users.present? && users.size > 0 %> <% users.each do |u| %> <% user = u.user %> + <%= link_to user.try(:show_real_name), user_path(user) %> - <%= link_to "".html_safe,admin_forum_section_forum_moderator_path(forum, u), method: :delete, data:{confirm: "确认删除吗?"}, remote: true, class: "color-grey-9" %> + <%= link_to "".html_safe,admins_forum_section_forum_moderator_path(forum, u), method: :delete, data:{confirm: "确认删除吗?"}, remote: true, class: "color-grey-9" %> + + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/admins/forum_moderators/create.js.erb b/app/views/admins/forum_moderators/create.js.erb index 5a4630df..8d82b337 100644 --- a/app/views/admins/forum_moderators/create.js.erb +++ b/app/views/admins/forum_moderators/create.js.erb @@ -1,6 +1,4 @@ <% 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} %>") -op_know("添加成功") -<% else %> -op_know("没有选择版主") +$('#admin-managers-modal').modal("hide") <% end %> \ No newline at end of file diff --git a/app/views/admins/forum_moderators/new.js.erb b/app/views/admins/forum_moderators/new.js.erb index 9ca23dcc..ba6b10ab 100644 --- a/app/views/admins/forum_moderators/new.js.erb +++ b/app/views/admins/forum_moderators/new.js.erb @@ -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) { var t_value = $("#"+ target).val() $.ajax({ 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', success: function (data) { if(data.html.length > 0){ diff --git a/app/views/admins/forum_moderators/shared/_form.html.erb b/app/views/admins/forum_moderators/shared/_form.html.erb new file mode 100644 index 00000000..16825ec6 --- /dev/null +++ b/app/views/admins/forum_moderators/shared/_form.html.erb @@ -0,0 +1,26 @@ + +<%= simple_form_for(ForumModerator.new, url: admins_forum_section_forum_moderators_path(@forum_section), html: { remote: true}) do |f|%> + + +<% end %> diff --git a/app/views/admins/forum_sections/_children_forum_detail.html.erb b/app/views/admins/forum_sections/_children_forum_detail.html.erb index c8ade8be..2eb1b0c5 100644 --- a/app/views/admins/forum_sections/_children_forum_detail.html.erb +++ b/app/views/admins/forum_sections/_children_forum_detail.html.erb @@ -1,6 +1,6 @@ <%= children_forum.try(:title) %> - +
<%= 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 %> diff --git a/app/views/admins/forum_sections/_forums_plateSetting.html.erb b/app/views/admins/forum_sections/_forums_plateSetting.html.erb index 0d3e31bd..feed20b6 100644 --- a/app/views/admins/forum_sections/_forums_plateSetting.html.erb +++ b/app/views/admins/forum_sections/_forums_plateSetting.html.erb @@ -43,6 +43,7 @@ } function first_menu_action(that) { + console.log('ddddd') var target = $(that); var target_action = target.find(".operateList"); if(target_action.hasClass("active")){ diff --git a/app/views/admins/forum_sections/_td_forum_section.html.erb b/app/views/admins/forum_sections/_td_forum_section.html.erb index b4d67d74..4351b341 100644 --- a/app/views/admins/forum_sections/_td_forum_section.html.erb +++ b/app/views/admins/forum_sections/_td_forum_section.html.erb @@ -1,22 +1,21 @@ -
  • +
    <%= forum.try(:title) %> - - +
    <%= 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 "新增子版块".html_safe, new_admins_forum_section_path(parent_id: forum.id),remote: true %> <% 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 %> <% 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 %>
    @@ -24,7 +23,7 @@
    <%= render partial: "admins/forum_sections/children_forum_sections", locals: {children_forums: forum.get_children_section("desc")} %>
    -
  • +
    <%= render partial: "admins/forum_sections/recommend_forum_sections", locals: {forum: forum} %> diff --git a/app/views/admins/forum_sections/_upload_logo.html.erb b/app/views/admins/forum_sections/_upload_logo.html.erb index ea6b8d25..33b125a6 100644 --- a/app/views/admins/forum_sections/_upload_logo.html.erb +++ b/app/views/admins/forum_sections/_upload_logo.html.erb @@ -1,20 +1,27 @@ <%= file_field_tag 'attachments[dummy][file]', :id => "_file_section_picture", :class => 'file_selector', - :onchange => "addInputFiles_board(this);", + :onchange => "addInputFiles_board()", :style =>'display:none', accept: 'image/png,image/gif,image/jpeg,image/jpg,image/bmp', :data => { :max_file_size => 5120.kilobytes, :max_concurrent_uploads => 1, - :upload_path => admins_upload_images_path(:format => 'js'), + :upload_path => attachments_upload_images_path(:format => 'js'), } %> \ No newline at end of file diff --git a/app/views/admins/forum_sections/create.js.erb b/app/views/admins/forum_sections/create.js.erb index a4c94579..6d2bb3f3 100644 --- a/app/views/admins/forum_sections/create.js.erb +++ b/app/views/admins/forum_sections/create.js.erb @@ -1,14 +1,12 @@ <% if @forum_status[:status] == 0 %> - $("#new_forum_section_notice").removeClass("none").html("<%= @forum_status[:msg] %>") - $("#new_forum_section_notice").siblings("input").addClass("error_tip"); -<% elsif @forum_status[:status] > 0 %> - op_know("<%= @forum_status[:msg] %>") - <% if params[:parent_id].present? %> - $("#forum-section-detail-<%= params[:parent_id] %>").html("<%= j render partial: "admins/forum_sections/td_forum_section", locals: {forum: @parent_forum} %>") + $("#add-section-forum").removeClass("none").html("<%= j render partial: "admins/forum_sections/shared/error_section", locals: {error_messages: @forum_status[:msg] } %>") +<% else %> + $("#add-section-forum").addClass("none") + <% if @forum_section.parent_id.present? %> + $("#forum-section-detail-<%= @forum_section.parent_id %>").html("<%= j render partial: "admins/forum_sections/td_forum_section", locals: {forum: @parent_forum} %>") <% else %> $("#forum-section-contents").prepend("<%= j render partial: "admins/forum_sections/forum_section_detail", locals: {forum: @forum_section} %>") <% end %> + $('#admin-forum-section-modal').modal("hide") +<% end %> -<% else %> - op_know("<%= @forum_status[:msg] %>") -<% end %> \ No newline at end of file diff --git a/app/views/admins/forum_sections/destroy.js.erb b/app/views/admins/forum_sections/destroy.js.erb index 4502d31a..060573b8 100644 --- a/app/views/admins/forum_sections/destroy.js.erb +++ b/app/views/admins/forum_sections/destroy.js.erb @@ -1,10 +1,7 @@ <% if @delete_status[:status] > 0 %> -op_know("<%= @delete_status[:msg] %>") -<% if params[:children_forum].present? %> -$("#children-forum-detail-<%= @forum_section.id %>").remove() -<% else %> -$("#forum-section-detail-<%= @forum_section.id %>").remove() -<% end %> -<% else %> -op_know("<%= @delete_status[:msg] %>") + <% if params[:children_forum] %> + $("#children-forum-detail-<%= @forum_section.id %>").remove() + <% else %> + $("#forum-section-detail-<%= @forum_section.id %>").remove() + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/admins/forum_sections/edit.js.erb b/app/views/admins/forum_sections/edit.js.erb index 27f507a3..fa336267 100644 --- a/app/views/admins/forum_sections/edit.js.erb +++ b/app/views/admins/forum_sections/edit.js.erb @@ -1,2 +1,4 @@ -var htmlvalue = "<%= j render :partial => 'admins/forum_sections/edit_forum' %>"; -pop_box_new(htmlvalue, 520, 400); \ No newline at end of file + +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') \ No newline at end of file diff --git a/app/views/admins/forum_sections/index.html.erb b/app/views/admins/forum_sections/index.html.erb index d9ce73c8..e8a4e0c5 100644 --- a/app/views/admins/forum_sections/index.html.erb +++ b/app/views/admins/forum_sections/index.html.erb @@ -8,4 +8,5 @@ -<%= render partial: 'admins/forum_sections/shared/add_section' %> \ No newline at end of file +<%= render partial: 'admins/forum_sections/shared/add_section' %> +<%= render partial: 'admins/forum_sections/shared/add_managers' %> \ No newline at end of file diff --git a/app/views/admins/forum_sections/shared/_add_managers.html.erb b/app/views/admins/forum_sections/shared/_add_managers.html.erb new file mode 100644 index 00000000..6a3e316a --- /dev/null +++ b/app/views/admins/forum_sections/shared/_add_managers.html.erb @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/app/views/admins/forum_sections/shared/_new_forum.html.erb b/app/views/admins/forum_sections/shared/_new_forum.html.erb index b985b5a1..a41ea823 100644 --- a/app/views/admins/forum_sections/shared/_new_forum.html.erb +++ b/app/views/admins/forum_sections/shared/_new_forum.html.erb @@ -1,5 +1,5 @@ -<%= 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 %>