更改贴吧描述

This commit is contained in:
daiao 2016-12-30 16:12:25 +08:00
parent 44acf1a383
commit f332307cae
3 changed files with 24 additions and 9 deletions

View File

@ -271,6 +271,19 @@ class ForumsController < ApplicationController
end end
end end
# 更新贴吧描述
def update_memo_description
@forum = Forum.find(params[:id])
if @forum.blank?
result = { :result => false }
else
forum_decription = params[:forum][:description]
@forum.update_attributes(:description => forum_decription )
result = { :result => true }
end
render :json => result
end
def search_forum def search_forum
# @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'") # @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'")
q = "%#{params[:name].strip}%" q = "%#{params[:name].strip}%"

View File

@ -5,7 +5,8 @@
</div> </div>
<div class="fl" style="width: 120px;"> <div class="fl" style="width: 120px;">
<% user_name = @forum.creator.show_name.empty? ? @forum.creator.name : @forum.creator.show_name %> <% user_name = @forum.creator.show_name.empty? ? @forum.creator.name : @forum.creator.show_name %>
<div class="fl mb8 mt10">吧主:</div><a href="<%= user_path(@forum.creator)%>" class="linkBlue w80 fl mb8 mt10" style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis; "><%= user_name %></a> <div class="fl mb8 mt10">吧主:</div>
<a href="<%= user_path(@forum.creator)%>" target="_blank" class="linkBlue w80 fl mb8 mt10" style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis; "><%= user_name %></a>
<div class="fontGrey3 fl">回答:<a href="javascript:void(0);" class="linkOrange mr5" style="cursor: default"><%= @my_replies_count %></a> 帖子:<a href="javascript:void(0);" class="linkOrange" style="cursor: default"><%= @my_topic_count %></a></div> <div class="fontGrey3 fl">回答:<a href="javascript:void(0);" class="linkOrange mr5" style="cursor: default"><%= @my_replies_count %></a> 帖子:<a href="javascript:void(0);" class="linkOrange" style="cursor: default"><%= @my_topic_count %></a></div>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
@ -13,8 +14,9 @@
<%= link_to @forum.name, forum_path(@forum), :class => "f16 fontBlue", :style => "word-break: break-all; word-wrap:break-word;white-space:pre-wrap;" %> <%= link_to @forum.name, forum_path(@forum), :class => "f16 fontBlue", :style => "word-break: break-all; word-wrap:break-word;white-space:pre-wrap;" %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="fontGrey2 mt10"><span id="forum_desc_span" style="word-break:normal; width:auto; display:block; white-space:pre-wrap;word-wrap : break-word ;overflow: hidden ;"><%= @forum.description.html_safe%></span> <div class="fontGrey2 mt10">
<%if @forum.creator.id == User.current.id%> <span id="forum_desc_span" style="word-break:normal; width:auto; display:block; white-space:pre-wrap;word-wrap : break-word ;overflow: hidden ;"><%= h @forum.description.html_safe%></span>
<% if @forum.creator.id == User.current.id %>
<a href="javascript:void(0);" onclick="edit_desc();"> <a href="javascript:void(0);" onclick="edit_desc();">
<%= image_tag('signature_edit.png',{:width => 12,:height => 12}) %> <%= image_tag('signature_edit.png',{:width => 12,:height => 12}) %>
</a> </a>
@ -49,23 +51,22 @@
<script> <script>
var desc; var desc;
function edit_desc(){ function edit_desc(){
if(<%= @forum.creator.id == User.current.id %>) {
desc = $("#forum_desc_span").html(); desc = $("#forum_desc_span").html();
$("#forum_desc_span").html("<textarea id='forum_desc_input' onblur='change_forum_desc();' style='width: 200px;height: 80px; max-width: 207px; max-height: 80px; border: 1px solid #d9d9d9;outline: none;margin: 0px 0px 12px 0px;'>" + desc + "</textarea>"); $("#forum_desc_span").html("<textarea id='forum_desc_input' onblur='change_forum_desc();' style='width: 200px;height: 80px; max-width: 207px; max-height: 80px; border: 1px solid #d9d9d9;outline: none;margin: 0px 0px 12px 0px;'>" + desc + "</textarea>");
$("#forum_desc_input").focus(); $("#forum_desc_input").focus();
}
} }
function change_forum_desc(){ function change_forum_desc(){
$.ajax({ $.ajax({
url: '<%= forums_path + '/'+@forum.id.to_s+".js" %>', url: '<%= update_memo_description_forum_path(@forum) %>',
type: 'PUT', type: 'post',
dataType: 'json',
data:{"forum[description]":$("#forum_desc_input").val().trim()}, data:{"forum[description]":$("#forum_desc_input").val().trim()},
success:function(data){ success:function(data){
if(data == true){ if(data.result == true){
$("#forum_desc_input").hide();
$("#forum_desc_span").html($("#forum_desc_input").val().trim()); $("#forum_desc_span").html($("#forum_desc_input").val().trim());
}else{ }else{
alert("失败");
$("#forum_desc_span").html(desc); $("#forum_desc_span").html(desc);
} }
} }

View File

@ -457,6 +457,7 @@ RedmineApp::Application.routes.draw do
member do member do
post 'create_memo' post 'create_memo'
post 'create_feedback' post 'create_feedback'
post 'update_memo_description'
match 'search_memo', :via => [:get, :post] match 'search_memo', :via => [:get, :post]
match 'delete_forum_tag',:via =>[:get] match 'delete_forum_tag',:via =>[:get]
match 'add_forum_tag',:via=>[:get] match 'add_forum_tag',:via=>[:get]