# HG changeset patch # User luisf # Date 1300713512 0 # Node ID c09865a48f4e5cb33c07eb97c56d3aee85073120 # Parent f89f7331fc006721e88689ef3d8368b0ebb117d8 TEST DEV commit: creates the repository automatically; diff -r f89f7331fc00 -r c09865a48f4e app/controllers/projects_controller.rb --- a/app/controllers/projects_controller.rb Thu Mar 17 17:44:19 2011 +0000 +++ b/app/controllers/projects_controller.rb Mon Mar 21 13:18:32 2011 +0000 @@ -190,6 +190,13 @@ @trackers = Tracker.all @repository ||= @project.repository @wiki ||= @project.wiki + + # luisf. change + if !@repository + @repository = Repository.factory(params[:repository_scm]) + @repository.project = @project if @repository + end + end def edit diff -r f89f7331fc00 -r c09865a48f4e app/controllers/repositories_controller.rb --- a/app/controllers/repositories_controller.rb Thu Mar 17 17:44:19 2011 +0000 +++ b/app/controllers/repositories_controller.rb Mon Mar 21 13:18:32 2011 +0000 @@ -34,6 +34,21 @@ rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed + def ssamr_edit + @repository = @project.repository + + if !@repository + @repository = Repository.factory(params[:repository_scm]) + @repository.project = @project if @repository + end + if request.post? && @repository + @repository.attributes = params[:repository] + @repository.save + end + end + + + def edit @repository = @project.repository diff -r f89f7331fc00 -r c09865a48f4e app/helpers/repositories_helper.rb --- a/app/helpers/repositories_helper.rb Thu Mar 17 17:44:19 2011 +0000 +++ b/app/helpers/repositories_helper.rb Mon Mar 21 13:18:32 2011 +0000 @@ -145,13 +145,19 @@ send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) && method != 'repository_field_tags' end + + def ssamr_scm_update(repository) + check_box_tag('repository_scm', value = "1", checked = false, onchange => remote_function(:url => { :controller => 'repositories', :action => 'ssamr_edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)")) + + end + def scm_select_tag(repository) scm_options = [["--- #{l(:actionview_instancetag_blank_option)} ---", '']] Redmine::Scm::Base.all.each do |scm| scm_options << ["Repository::#{scm}".constantize.scm_name, scm] if Setting.enabled_scm.include?(scm) || (repository && repository.class.name.demodulize == scm) end - select_tag('repository_scm', + select_tag('repository_scm', options_for_select(scm_options, repository.class.name.demodulize), :disabled => (repository && !repository.new_record?), :onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)") diff -r f89f7331fc00 -r c09865a48f4e app/views/projects/settings/_repository.rhtml --- a/app/views/projects/settings/_repository.rhtml Thu Mar 17 17:44:19 2011 +0000 +++ b/app/views/projects/settings/_repository.rhtml Mon Mar 21 13:18:32 2011 +0000 @@ -9,13 +9,13 @@ <%= error_messages_for 'repository' %>
-<% if !@repository || !@repository.url %> +<% if !@repository %> + + + <% end %> -

<%= label_tag('repository_scm', l(:label_scm)) %> -<%= scm_select_tag(@repository) %> -

<%= label_tag('repository_is_external', l(:label_is_external_repository)) %> <%= check_box :repository, :is_external, :onclick => "toggle_ext_url()" %> @@ -38,5 +38,5 @@ <% end %>

-<%= submit_tag((@repository.nil? || @repository.new_record?) ? l(:button_create) : l(:button_save), :disabled => @repository.nil?) %> +<%= submit_tag((@repository.nil? || @repository.new_record?) ? l(:button_create) : l(:button_save), :onclick => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)")) %> <% end %>