Merge branch 'dev_tieba' of https://git.trustie.net/jacknudt/trustieforge into dev_tieba
Conflicts: config/routes.rb
This commit is contained in:
commit
baaaaf95d8
|
@ -282,6 +282,19 @@ class ForumsController < ApplicationController
|
|||
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
|
||||
# @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'")
|
||||
q = "%#{params[:name].strip}%"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class MemosController < ApplicationController
|
||||
default_search_scope :memos
|
||||
before_filter :find_forum, :only => [:new, :create, :preview]
|
||||
before_filter :find_forum, :only => [:new, :create, :preview, :update]
|
||||
before_filter :find_attachments, :only => [:preview]
|
||||
before_filter :find_memo, :except => [:new, :create, :preview]
|
||||
before_filter :authenticate_user_edit, :only => [:edit, :update]
|
||||
|
@ -47,7 +47,7 @@ class MemosController < ApplicationController
|
|||
end
|
||||
|
||||
@memo = Memo.new(params[:memo])
|
||||
@memo.forum_id = params[:forum_id]
|
||||
@memo.forum_id = @forum.id
|
||||
@memo.author_id = User.current.id
|
||||
|
||||
if params[:memo][:parent_id]
|
||||
|
@ -154,6 +154,8 @@ class MemosController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
# 注意,如果不需要
|
||||
|
||||
@flag = false
|
||||
respond_to do |format|
|
||||
if( #@memo.update_column(:subject, params[:memo][:subject]) &&
|
||||
|
@ -163,10 +165,11 @@ class MemosController < ApplicationController
|
|||
@memo.update_column(:subject,params[:memo][:subject]) &&
|
||||
@memo.update_column(:updated_at,Time.now))
|
||||
@memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads]))
|
||||
@memo.forum_id = @forum.id
|
||||
@flag = @memo.save
|
||||
# @memo.root.update_attribute(:updated_at, @memo.updated_at)
|
||||
format.js
|
||||
format.html {redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}"}
|
||||
format.html {redirect_to back_memo_url, notice: "#{l :label_memo_update_succ}"}
|
||||
else
|
||||
format.js
|
||||
format.html { render action: "edit" }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<li class="mb10 clear">
|
||||
<label class="fl" style="width: 90px;text-align: right;">贴吧名称 : </label>
|
||||
<!--<input maxlength="80" class="postCreateInput" onfocus="hideError();" onblur="check_forum_name();" placeholder="输入贴吧名称" >-->
|
||||
<%= f.text_field :name, :label => "", :name => "forum[name]", :id => "forum_name", :class => "issues_calendar_input fl", :style => "width:320px;height:28px;", :placeholder => "请输入贴吧名称,最多50个字符", :onfocus => "$('#forum_name_error_tips').hide();" %>
|
||||
<%= f.text_field :name, :label => "", :name => "forum[name]", :id => "forum_name", :onblur => "check_forum_name()", :class => "issues_calendar_input fl", :style => "width:320px;height:28px;", :placeholder => "请输入贴吧名称,最多50个字符", :onfocus => "$('#forum_name_error_tips').hide();" %>
|
||||
<!--<input type="text" name="forum[name]" id="forum_name" onfocus="$('#forum_name_error_tips').hide();" placeholder="请输入贴吧名称,最多50个字符" class="issues_calendar_input fl" style="width:320px;height:28px;">-->
|
||||
<div class="clear"></div>
|
||||
<p class="c_red ml90" style="display: none" id="forum_name_error_tips"></p>
|
||||
|
@ -22,12 +22,22 @@
|
|||
|
||||
|
||||
<script>
|
||||
function check_forum_name(){
|
||||
if ($("#forum_name").val().trim() == ""){
|
||||
$("#forum_name_error_tips").html("贴吧名称不能为空").show();
|
||||
}else if($("#forum_name").val().length > 50){
|
||||
$("#forum_name_error_tips").html("贴吧名称不能超过50个字符").show();
|
||||
}
|
||||
}
|
||||
function forums_commit(){
|
||||
$("#forum_name_error_tips").hide();
|
||||
$("#forum_description_error_tips").hide();
|
||||
if ($("#forum_name").val().trim() == ""){
|
||||
$("#forum_name_error_tips").html("贴吧名称不能为空").show();
|
||||
}
|
||||
else if($("#forum_name").val().length > 50){
|
||||
$("#forum_name_error_tips").html("贴吧名称不能超过50个字符").show();
|
||||
}
|
||||
else if($("#forum_desc").val().trim() == ""){
|
||||
$("#forum_description_error_tips").html("贴吧描述不能为空").show();
|
||||
}
|
||||
|
|
|
@ -1,19 +1,24 @@
|
|||
<div class="homepageLeft-new">
|
||||
<div class="postDetailContainer">
|
||||
<div class="fl mr10 pr"> <%= link_to image_tag(url_to_avatar(@forum.creator),:width=>75,:height => 75,:alt=>'贴吧图像' ), user_path( @forum.creator) %>
|
||||
<div class="fl mr10 pr"> <%= link_to image_tag(url_to_avatar(@forum.creator),:width => 75,:height => 75,:alt => '贴吧图像' ), user_path( @forum.creator) %>
|
||||
<!--<div class="homepageEditProfile"><a href="javascript:void(0);" class="homepageEditProfileIcon"></a></div>-->
|
||||
</div>
|
||||
<div class="fl">
|
||||
<%= link_to @forum.name, forum_path(@forum), :class => "f16 fontBlue", :style => "word-break: break-all; word-wrap:break-word;white-space:pre-wrap;" %>
|
||||
<div class="fl" style="width: 120px;">
|
||||
<% user_name = @forum.creator.show_name.empty? ? @forum.creator.name : @forum.creator.show_name %>
|
||||
<div class="fontGrey2 mb8 mt10">吧主:<a href="<%= user_path(@forum.creator)%>" class="linkBlue"><%= user_name %></a></div>
|
||||
<div class="fontGrey3">回答:<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="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>
|
||||
<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>
|
||||
<%if @forum.creator.id == User.current.id%>
|
||||
<div class="fl">
|
||||
<%= 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 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 ;"><%= h @forum.description.html_safe%></span>
|
||||
<% if @forum.creator.id == User.current.id %>
|
||||
<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>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -46,23 +51,22 @@
|
|||
<script>
|
||||
var desc;
|
||||
function edit_desc(){
|
||||
if(<%= @forum.creator.id == User.current.id %>) {
|
||||
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_input").focus();
|
||||
}
|
||||
}
|
||||
|
||||
function change_forum_desc(){
|
||||
$.ajax({
|
||||
url: '<%= forums_path + '/'+@forum.id.to_s+".js" %>',
|
||||
type: 'PUT',
|
||||
dataType: 'json',
|
||||
url: '<%= update_memo_description_forum_path(@forum) %>',
|
||||
type: 'post',
|
||||
data:{"forum[description]":$("#forum_desc_input").val().trim()},
|
||||
success:function(data){
|
||||
if(data == true){
|
||||
if(data.result == true){
|
||||
$("#forum_desc_input").hide();
|
||||
$("#forum_desc_span").html($("#forum_desc_input").val().trim());
|
||||
}else{
|
||||
alert("失败");
|
||||
$("#forum_desc_span").html(desc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<%= @memo.subject %>
|
||||
</div>
|
||||
|
||||
<%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo),:html=>{:id=>'edit_memo'}) do |f| %>
|
||||
<%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo),:html=>{:id => 'new_memo'}) do |f| %>
|
||||
<%= render :partial => "memos/form", :locals => {:f => f} %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -1758,6 +1758,7 @@ zh:
|
|||
label_borad_org_subfield: 资源栏目讨论区
|
||||
view_borad_course: 课程讨论
|
||||
label_memo_create_succ: 发布成功
|
||||
label_memo_update_succ: 更新成功
|
||||
label_memo_create_fail: 发布失败
|
||||
label_forum_create_succ: 贴吧新建成功
|
||||
label_forum_create_fail: 贴吧新建失败
|
||||
|
|
|
@ -458,6 +458,7 @@ RedmineApp::Application.routes.draw do
|
|||
post 'create_memo'
|
||||
post 'create_feedback'
|
||||
post 'mail_feedback'
|
||||
post 'update_memo_description'
|
||||
match 'search_memo', :via => [:get, :post]
|
||||
match 'delete_forum_tag',:via =>[:get]
|
||||
match 'add_forum_tag',:via=>[:get]
|
||||
|
|
Loading…
Reference in New Issue