From 3080c8ff0916c4eba2a495643166c386edda21f0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 26 Oct 2016 18:04:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8C=E7=A8=8B=E7=A2=91=E5=88=97=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=BB=BA=E5=BC=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/versions_controller.rb | 14 ++-- .../projects/settings/_new_versions.html.erb | 27 +------- .../settings/_new_versions_form.html.erb | 31 +++++++++ app/views/versions/_new_milestone.html.erb | 69 +++++++++++++++++++ app/views/versions/index.html.erb | 3 +- app/views/versions/new.js.erb | 5 ++ 6 files changed, 116 insertions(+), 33 deletions(-) create mode 100644 app/views/projects/settings/_new_versions_form.html.erb create mode 100644 app/views/versions/_new_milestone.html.erb diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index f8118c796..e15edf86a 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -143,11 +143,14 @@ class VersionsController < ApplicationController # @version = @project.versions.build # @version.safe_attributes = params[:version] # - # respond_to do |format| - # format.html - # format.js - # end - redirect_to settings_project_url(@project, :tab => 'versions') + respond_to do |format| + @is_create = params[:is_create] + format.js{ + unless @is_create + redirect_to settings_project_url(@project, :tab => 'versions') + end + } + end end def create @@ -157,7 +160,6 @@ class VersionsController < ApplicationController attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing']) @version.safe_attributes = attributes end - if request.post? if @version.save respond_to do |format| diff --git a/app/views/projects/settings/_new_versions.html.erb b/app/views/projects/settings/_new_versions.html.erb index c6ca489bf..a67b2f91e 100644 --- a/app/views/projects/settings/_new_versions.html.erb +++ b/app/views/projects/settings/_new_versions.html.erb @@ -3,32 +3,7 @@ <% end %>
新建里程碑 - <%= form_for :version, :url => project_versions_path(@project, :is_setting => true),:html=>{:id=>"new_project_version_form", :remote => true} do |f| %> - - <% end %> + <%= render :partial => 'projects/settings/new_versions_form', :locals => {:project => @project} %>
<% if @project.shared_versions.any? %> diff --git a/app/views/projects/settings/_new_versions_form.html.erb b/app/views/projects/settings/_new_versions_form.html.erb new file mode 100644 index 000000000..cc61b1993 --- /dev/null +++ b/app/views/projects/settings/_new_versions_form.html.erb @@ -0,0 +1,31 @@ +<%= form_for :version, :url => project_versions_path(@project, :is_setting => true),:html=>{:id=>"new_project_version_form", :remote => true} do |f| %> + +<% end %> + \ No newline at end of file diff --git a/app/views/versions/_new_milestone.html.erb b/app/views/versions/_new_milestone.html.erb new file mode 100644 index 000000000..2a7a88511 --- /dev/null +++ b/app/views/versions/_new_milestone.html.erb @@ -0,0 +1,69 @@ +
+
+

新建里程碑

+ +
+
+ +
+
+ <%#= form_tag( url_for(:controller => 'versions', :action => 'update', :is_setting => true, :is_index => @is_index), :remote => true, :id => 'project_applied_form') do %> + <%= form_for :version, :url => project_versions_path(@project, :is_setting => true),:html => {:id=>"popub_new_project_version_form", :remote => true} do |f| %> + <%#= labelled_form_for @version, :html => {:id => "popub_new_project_version_form", :remote => true, :is_setting => true, :is_index => params[:is_index] } 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_datex", :placeholder=>"结束日期", :style=>"height:28px;", :no_label => true %> + <%= calendar_for('version_effective_datex') %> + + +
  • +
  • + + <%= 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/index.html.erb b/app/views/versions/index.html.erb index 478d983e4..e53925ed7 100644 --- a/app/views/versions/index.html.erb +++ b/app/views/versions/index.html.erb @@ -15,7 +15,8 @@ <%= link_to "关闭#{@versions_closed_count}".html_safe, project_roadmap_path(@project, :type => "4"), :remote => true, :class => "new_roadmap_type_nomal", :id => "new_roadmap_type_1", :id => "new_roadmap_type_4" %> - 新建 + + <%= link_to "新建", new_project_version_path(@project, :is_create => true), :class => 'btn btn-green fr mr15 mt10', :remote => true %>
<%= render :partial => "versions/list" %> diff --git a/app/views/versions/new.js.erb b/app/views/versions/new.js.erb index 114b9c7c5..20992a66f 100644 --- a/app/views/versions/new.js.erb +++ b/app/views/versions/new.js.erb @@ -1,2 +1,7 @@ +<% if @is_create %> +var htmlvalue = "<%= escape_javascript(render :partial => 'versions/new_milestone') %>"; +pop_box_new(htmlvalue,820,316); +<% else %> $('#ajax-modal').html('<%= escape_javascript(render :partial => 'versions/new_modal') %>'); showModal('ajax-modal', '600px'); +<% end %> \ No newline at end of file