From a86ad7d99a1f2177b755221183ad1852ecff1381 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 25 Oct 2016 11:11:25 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=85=8D=E7=BD=AE=E5=90=84?= =?UTF-8?q?=E7=A7=8D=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0=EF=BC=88=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E7=BC=96=E8=BE=91=E6=8F=90=E7=A4=BA=E7=AD=89=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 2 + app/controllers/versions_controller.rb | 76 +++++++------ .../settings/_new_repositories.html.erb | 2 +- .../projects/settings/_new_versions.html.erb | 2 +- app/views/versions/_edit.html.erb | 101 ++++++++++++------ app/views/versions/edit.js.erb | 2 +- app/views/versions/update.js.erb | 7 +- public/stylesheets/css/moduel.css | 2 + 8 files changed, 125 insertions(+), 69 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index e0d65a111..9fad64ad3 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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? diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index 087e2adfd..89061a2a2 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -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 diff --git a/app/views/projects/settings/_new_repositories.html.erb b/app/views/projects/settings/_new_repositories.html.erb index ab4bec103..0a6e64750 100644 --- a/app/views/projects/settings/_new_repositories.html.erb +++ b/app/views/projects/settings/_new_repositories.html.erb @@ -26,7 +26,7 @@ <%=l(:button_cancel)%> - <%=l(:lable_project_rep_create) %> + <%=l(:lable_project_rep_create) %> <% end %> <% else %> diff --git a/app/views/projects/settings/_new_versions.html.erb b/app/views/projects/settings/_new_versions.html.erb index 0a2eaf329..94ae93614 100644 --- a/app/views/projects/settings/_new_versions.html.erb +++ b/app/views/projects/settings/_new_versions.html.erb @@ -44,7 +44,7 @@ - <% @project.shared_versions.sort.each do |version| %> + <% @versions.each do |version| %> <%= 'shared' if version.project != @project %> <%= link_to_version version %> diff --git a/app/views/versions/_edit.html.erb b/app/views/versions/_edit.html.erb index 999ab53d7..e05516f66 100644 --- a/app/views/versions/_edit.html.erb +++ b/app/views/versions/_edit.html.erb @@ -1,33 +1,70 @@ -
-

新建里程碑

- -
-
-
- <%= form_for :version, :url => project_versions_path(@project, :is_setting => true),:html=>{:id=>"new_project_version_form", :remote => true} do |f| %> -
-
    -
  • - - <%= f.text_field :name, :maxlength => 60, :class=>"w650 fl", :style=>"height: 28px;", :id => "setting_version_name" %> - -
  • -
  • - - <%= f.text_field :description, :maxlength => 60, :class=>"w650 fl", :style=>"height:28px;"%> -
  • -
  • - - <%= f.text_field :effective_date, :size => 10, :readonly => true,:class=>"issues_calendar_input fl", :placeholder=>"结束日期", :style=>"height:28px;" %> - <%= calendar_for('version_effective_date') %> -
  • -
  • - - <%= f.select :status, Version::VERSION_STATUSES.collect {|s| [l("version_status_#{s}"), s]},{},{:style=>"height:28px"} %> -
  • -
    -
- 取消保存 -
- <% end %> +
+
+

编辑里程碑

+ +
+
+ +
+
+ <%#= 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| %> +
    +
  • + + <%= f.text_field :name, :maxlength => 60, :class=>"w650 fl", :style=>"height: 28px;", :id => "popub_setting_version_name", :no_label => true %> + +
  • +
  • + + <%= f.text_field :description, :maxlength => 60, :class=>"w650 fl", :style=>"height:28px;", :no_label => true %> +
  • +
  • + + <%= 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') %> + + +
  • +
  • + + <%= f.select :status, Version::VERSION_STATUSES.collect {|s| [l("version_status_#{s}"), s]},{:no_label => true },{:style=>"height:28px;"} %> +
  • + +
+ 取消 + 保存 + <% end %> +
+ +
+ + + + diff --git a/app/views/versions/edit.js.erb b/app/views/versions/edit.js.erb index 9d0fb2c23..377dbeebd 100644 --- a/app/views/versions/edit.js.erb +++ b/app/views/versions/edit.js.erb @@ -1,3 +1,3 @@ var htmlvalue = "<%= escape_javascript(render :partial => 'versions/edit') %>"; -pop_box_new(htmlvalue,580,366); +pop_box_new(htmlvalue,820,316); diff --git a/app/views/versions/update.js.erb b/app/views/versions/update.js.erb index 8b5cb4967..1c8825b1a 100644 --- a/app/views/versions/update.js.erb +++ b/app/views/versions/update.js.erb @@ -1 +1,6 @@ -$('#version_status_con_id').html('<%= escape_javascript( render :partial => 'versions/type_ico', :locals => {:version => @version}) %>'); \ No newline at end of file +<%# @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 %> diff --git a/public/stylesheets/css/moduel.css b/public/stylesheets/css/moduel.css index 1e2250de8..dde26fbf2 100644 --- a/public/stylesheets/css/moduel.css +++ b/public/stylesheets/css/moduel.css @@ -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;}