项目配置各种局部刷新(新建编辑提示等)

This commit is contained in:
huang 2016-10-25 11:11:25 +08:00
parent 7a78bbdc45
commit a86ad7d99a
8 changed files with 125 additions and 69 deletions

View File

@ -380,6 +380,8 @@ class ProjectsController < ApplicationController
project_org_ids = "(" + project_org_ids.join(',') + ")"
@orgs_not_in_project = Organization.where("id not in #{project_org_ids} and is_public = 1")
end
# 里程碑
@versions = @project.shared_versions.sort
# 处理从新建版本库返回来的错误信息
if !params[:repository_error_message].to_s.blank?

View File

@ -185,44 +185,54 @@ class VersionsController < ApplicationController
end
def update
if request.put? && params[:version] && params[:flag].to_i == 1
@version.update_attribute(:status, params[:status])
if @version.save
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_update)
redirect_to settings_project_path(@project, :tab => 'versions')
}
format.js
format.api { render_api_ok }
end
else
respond_to do |format|
format.html { render :action => 'edit' }
format.api { render_validation_errors(@version) }
end
end
else if request.put? && params[:version]
attributes = params[:version].dup
attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing'])
@version.safe_attributes = attributes
if @version.save
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_update)
redirect_to settings_project_path(@project, :tab => 'versions')
}
format.api { render_api_ok }
if request.put? && params[:version]
# 处理里程碑里面的更新
if params[:flag].to_i == 1
@version.update_attribute(:status, params[:status])
if @version.save
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_update)
redirect_to settings_project_path(@project, :tab => 'versions')
}
format.js
format.api { render_api_ok }
end
else
respond_to do |format|
format.html { render :action => 'edit' }
format.api { render_validation_errors(@version) }
end
end
else
respond_to do |format|
format.html { render :action => 'edit' }
format.api { render_validation_errors(@version) }
attributes = params[:version].dup
attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing'])
@version.safe_attributes = attributes
@is_setting = params[:is_setting]
if @version.save
# 为了再setting里面局部刷新
if @is_setting
@versions = @version.project.shared_versions.sort
end
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_update)
redirect_to settings_project_path(@project, :tab => 'versions')
}
format.js
format.api { render_api_ok }
end
else
respond_to do |format|
format.html { render :action => 'edit' }
format.js
format.api { render_validation_errors(@version) }
end
end
end
end
end
end
end
def close_completed
if request.put?
@project.close_completed_versions

View File

@ -26,7 +26,7 @@
</li>
</ul>
<a href="javascript:void(0)" onclick="cancel_for_create();" class="fr sy_btn_grey"><%=l(:button_cancel)%></a>
<a href="" onclick="project_repository_commit();" class="fr sy_btn_blue mr5"><%=l(:lable_project_rep_create) %></a>
<a href="javascript:void(0)" onclick="project_repository_commit();" class="fr sy_btn_blue mr5"><%=l(:lable_project_rep_create) %></a>
<% end %>
</div>
<% else %>

View File

@ -44,7 +44,7 @@
</tr>
</thead>
<tbody>
<% @project.shared_versions.sort.each do |version| %>
<% @versions.each do |version| %>
<tr>
<th>
<a><%= 'shared' if version.project != @project %> <%= link_to_version version %></a>

View File

@ -1,33 +1,70 @@
<div class="sy_popup_top">
<h3 class="fl">新建里程碑</h3>
<a href="javascript:void(0);" class="sy_icons_close fr" onclick="hideModal()"></a>
<div class="cl"></div>
</div>
<div class="sy_popup_con">
<%= form_for :version, :url => project_versions_path(@project, :is_setting => true),:html=>{:id=>"new_project_version_form", :remote => true} do |f| %>
<div id="pro_st_edit_ban1">
<ul class="pro_newsetting_con mb15">
<li class="mb10 clear">
<label class="label02"><span class="c_red f12">*</span>&nbsp;<%= l(:field_name) %>&nbsp;&nbsp;:&nbsp;</label>
<%= f.text_field :name, :maxlength => 60, :class=>"w650 fl", :style=>"height: 28px;", :id => "setting_version_name" %>
<p class="c_orange ml100 " style="display: none" id="project_setting_version_title">标题不能为空</p>
</li>
<li class="mb10 clear">
<label class="fl">&nbsp;<%= l(:label_version_description) %>&nbsp;&nbsp;:&nbsp;</label>
<%= f.text_field :description, :maxlength => 60, :class=>"w650 fl", :style=>"height:28px;"%>
</li>
<li class="mb10 clear">
<label class=" fl">&nbsp;<%= l(:milestone_date_closed) %>&nbsp;&nbsp;:&nbsp;</label>
<%= f.text_field :effective_date, :size => 10, :readonly => true,:class=>"issues_calendar_input fl", :placeholder=>"结束日期", :style=>"height:28px;" %>
<%= calendar_for('version_effective_date') %>
</li>
<li class="mb10 clear">
<label class="fl">&nbsp;<%= l(:field_status) %>&nbsp;&nbsp;:&nbsp;</label>
<%= f.select :status, Version::VERSION_STATUSES.collect {|s| [l("version_status_#{s}"), s]},{},{:style=>"height:28px"} %>
</li>
<div class="cl mb10"></div>
</ul>
<a href="javascript:void(0);" class="fr sy_btn_grey " onclick="pro_st_show_ban1();">取消</a><a href="javascript:void(0);" onclick="project_version_commit();" class="fr sy_btn_blue mr5">保存</a>
</div>
<% end %>
<div id="muban_popup_box" style="width:820px;">
<div class="muban_popup_top">
<h3 class="fl">编辑里程碑</h3>
<a href="javascript:void(0);" class="muban_icons_close fr" onclick="hideModal()"></a>
<div class="cl"></div>
</div>
<div class="muban_popup_con " >
<div class="clear mt30 ml20 " >
<%#= form_tag( url_for(:controller => 'versions', :action => 'update', :is_setting => true), :remote => true, :id => 'project_applied_form') do %>
<%= labelled_form_for @version, :html => {:id => "popub_new_project_version_form", :remote => true, :is_setting => true, } do |f| %>
<ul class="pro_newsetting_con mb15 ">
<li class="mb10 clear">
<label class=" fl"><span class="c_red f12">*</span>&nbsp;名称&nbsp;&nbsp;:&nbsp;</label>
<%= f.text_field :name, :maxlength => 60, :class=>"w650 fl", :style=>"height: 28px;", :id => "popub_setting_version_name", :no_label => true %>
<p class="c_orange ml100" style="display: none" id="pupub_project_setting_version_title">标题不能为空</p>
</li>
<li class="mb10 clear">
<label class=" fl">&nbsp;描述&nbsp;&nbsp;:&nbsp;</label>
<%= f.text_field :description, :maxlength => 60, :class=>"w650 fl", :style=>"height:28px;", :no_label => true %>
</li>
<li class="mb10 clear">
<label class=" fl"><span class="c_red f12">*</span>&nbsp;结束日期&nbsp;&nbsp;:&nbsp;</label>
<%= f.text_field :effective_date, :size => 10, :readonly => true,:class=>"issues_calendar_input fl", :id => "version_effective_date2", :placeholder=>"结束日期", :style=>"height:28px;", :no_label => true %>
<%= calendar_for('version_effective_date2') %>
<!--<input type="text" placeholder="结束日期" class="issues_calendar_input fl ">-->
<!--<a href="" class="issues_data_img fl"></a>-->
</li>
<li class="mb10 clear">
<label class=" fl">&nbsp;状态&nbsp;&nbsp;:&nbsp;</label>
<%= f.select :status, Version::VERSION_STATUSES.collect {|s| [l("version_status_#{s}"), s]},{:no_label => true },{:style=>"height:28px;"} %>
</li>
<input value="true" name="is_setting" type="hidden">
</ul>
<a href="javascript:void(0);" class="fr sy_btn_grey mr45" onclick="hideModal()">取消</a>
<a href="javascript:void(0);" class="fr sy_btn_blue mr5" onclick="popub_project_version_commit();">保存</a>
<% end %>
</div>
</div>
</div>
<script>
// 新建版本
function popub_project_version_commit()
{
if(popub_regex_version_name())
{
hideModal();
$("#popub_new_project_version_form").submit();
}
}
function popub_regex_version_name()
{
var name = $.trim($("#popub_setting_version_name").val());
if(name.length == 0)
{
$("#pupub_project_setting_version_title").show();
return false;
}
else
{
$("#pupub_project_setting_version_title").hide();
return true;
}
}
</script>

View File

@ -1,3 +1,3 @@
var htmlvalue = "<%= escape_javascript(render :partial => 'versions/edit') %>";
pop_box_new(htmlvalue,580,366);
pop_box_new(htmlvalue,820,316);

View File

@ -1 +1,6 @@
$('#version_status_con_id').html('<%= escape_javascript( render :partial => 'versions/type_ico', :locals => {:version => @version}) %>');
<%# @is_setting:如果是settings里面新建则直接局部刷新setting如果是列表则直接局部刷新列表 %>
<% if @is_setting %>
$("#pro_st_tbc_04").html('<%= escape_javascript( render :partial => 'projects/settings/new_versions') %>');
<% else %>
$('#version_status_con_id').html('<%= escape_javascript( render :partial => 'versions/type_ico', :locals => {:version => @version}) %>');
<% end %>

View File

@ -4,6 +4,8 @@
.muban_popup_top h3{ font-size:16px; color:#fff; font-weight:normal; line-height:40px; padding-left:10px; }
a.muban_icons_close{width:20px; height:20px;display:block;background: url(/images/sy/sy_icons_close.png) 0 0px no-repeat; margin:8px 10px 0 0;}
a:hover.muban_icons_close{background: url(/images/sy/sy_icons_close.png) -40px 0px no-repeat;}
#muban_popup_box input,#muban_popup_box select{ border:1px solid #c8c8c8; height: 28px; color: #888;}
#muban_popup_box label{width: 100px; text-align: right; display: inline-block;}
/*模板表格 20161013byLB*/
.muban_table{ width:100%; background:#fff; border:1px solid #e5e5e5; border-bottom: none; }
.muban_table thead tr{ height:40px; line-height:40px;}