配置页面,里程碑编辑删除局部刷新以及标题为空JS判断

This commit is contained in:
huang 2016-10-24 16:36:08 +08:00
parent 38d30c1cca
commit 651ea5d189
4 changed files with 48 additions and 20 deletions

View File

@ -241,6 +241,7 @@ class VersionsController < ApplicationController
if @version.fixed_issues.empty?
@version.destroy
respond_to do |format|
format.js
format.html { redirect_back_or_default settings_project_path(@project, :tab => 'versions') }
format.api { render_api_ok }
end

View File

@ -1,25 +1,15 @@
<script>
function pro_st_show_ban1()
{
$("#pro_st_edit_ban1").toggle();
}
function pro_st_show_ban()
{
$("#pro_st_edit_ban").toggle();
}
</script>
<% if @project.shared_versions.empty? %>
<div class="pro_new_prompt ml15 mr15 mb10"><p><%= l(:milestone_no_data) %></p></div>
<% end %>
<div class=" sy_new_tchbox clear " >
<a href="javascript:void(0);" class=" sy_btn_green mb10" onclick="pro_st_show_ban1();">新建里程碑</a>
<%= form_for :version, :url => project_versions_path(@project),:html=>{:id=>"new_project_version_form"} do |f| %>
<%= 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" style="display:none;">
<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;" %>
<%= 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>
@ -36,7 +26,7 @@
</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="$('#new_project_version_form').submit();" class="fr sy_btn_blue mr5">保存</a>
<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>
@ -54,7 +44,7 @@
</tr>
</thead>
<tbody>
<% for version in @project.shared_versions.sort %>
<% @project.shared_versions.sort.each do |version| %>
<tr>
<th>
<a><%= 'shared' if version.project != @project %> <%= link_to_version version %></a>
@ -64,8 +54,8 @@
<th><%= l("version_status_#{version.status}") %></th>
<th>
<% if version.project == @project && User.current.allowed_to?(:manage_versions, @project) %>
<%= link_to l(:button_edit), edit_version_path(version), :class => 'sy_btn_blue mr5' %></a>
<a href="/versions/1" data-confirm="您确定要删除吗?" ><%= delete_link_version version_path(version), :class=>"sy_btn_grey mr5" %></a>
<%= link_to l(:button_edit), edit_version_path(version, :is_setting => true), :class => 'sy_btn_blue mr5' %></a>
<%= delete_link_version version_path(version, :is_setting => true), :class=>"sy_btn_grey mr5", :remote => true %>
<% end %>
</th>
</tr>
@ -75,4 +65,37 @@
</div>
<% end %>
<script>
// 新建版本
function project_version_commit()
{
if(regex_version_name())
{
$("#new_project_version_form").submit();
}
}
function regex_version_name()
{
var name = $.trim($("#setting_version_name").val());
if(name.length == 0)
{
$("#project_setting_version_title").show();
return false;
}
else
{
$("#project_setting_version_title").hide();
return true;
}
}
function pro_st_show_ban1()
{
$("#pro_st_edit_ban1").toggle();
}
function pro_st_show_ban()
{
$("#pro_st_edit_ban").toggle();
}
</script>

View File

@ -1,3 +1 @@
hideModal();
<% select = content_tag('select', content_tag('option') + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]') %>
$('#issue_fixed_version_id').replaceWith('<%= escape_javascript(select) %>');
$("#pro_st_tbc_04").html('<%= escape_javascript( render :partial => 'projects/settings/new_versions') %>');

View File

@ -0,0 +1,6 @@
<% if params[:is_setting] %>
$("#pro_st_tbc_04").html('<%= escape_javascript( render :partial => 'projects/settings/new_versions') %>');
<% else %>
$("#pro_st_tbc_04").html('<%= escape_javascript( render :partial => 'projects/settings/new_versions') %>');
<% end %>