From 1d6fb6849a9691fb4fd4209f7de752a396a78b89 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 7 Mar 2017 11:12:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8C=E7=A8=8B=E7=A2=91=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=8C=E6=8A=A5=E5=90=8D=E7=A7=B0=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/versions_controller.rb | 4 +++- app/views/versions/_edit.html.erb | 3 ++- app/views/versions/edit.js.erb | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index ad5f5b9d4..fcbdb2921 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -202,6 +202,7 @@ class VersionsController < ApplicationController @is_setting = params[:is_setting] @is_create = params[:is_create] @is_index = params[:is_index] + @version_id = params[:id] end def update @@ -276,10 +277,11 @@ class VersionsController < ApplicationController end # 判断里程碑是否重名 + # 项目内的里程碑不能重名,项目之间的里程碑能重名 def judge_version_title begin version = Version.where(:name => params[:version_name], :project_id => @project.id).first - if version.blank? + if version.blank? || version.id == params[:version_id].to_i result = {:result => true} else result = {:result => false} diff --git a/app/views/versions/_edit.html.erb b/app/views/versions/_edit.html.erb index 42a42b739..f218550b0 100644 --- a/app/views/versions/_edit.html.erb +++ b/app/views/versions/_edit.html.erb @@ -75,7 +75,8 @@ url:"<%= judge_version_title_project_versions_path(:project_id => @project) %>", type: "GET", data: { - version_name: $.trim($("#popub_setting_version_name").val()) + version_name: $.trim($("#popub_setting_version_name").val()), + version_id: <%= version_id %> }, success:function(data){ if(data.result == true) { diff --git a/app/views/versions/edit.js.erb b/app/views/versions/edit.js.erb index baa20b6cd..b574d7d5b 100644 --- a/app/views/versions/edit.js.erb +++ b/app/views/versions/edit.js.erb @@ -1,4 +1,4 @@ -var htmlvalue = "<%= escape_javascript(render :partial => 'versions/edit') %>"; +var htmlvalue = "<%= escape_javascript(render :partial => 'versions/edit', :locals => {:version_id => @version_id}) %>"; pop_box_new(htmlvalue,820,316); var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: 0, showOn: 'button', buttonImageOnly: true, buttonImage: '/images/public_icon.png', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true}; $(function() { $('#version_effective_date2').datepicker(datepickerOptions);