Bug #2101
Plugin does not (fully) work on Redmine 2.1.x
100%
Description
In particular the Javascript code in the repositories helper patch does not work because that is Prototype style javascript where Redmine 2.1.x uses Rails 3.2.8 which uses JQuery.
Stuff like $("#id").value = 'something’ needs to change to $("#id").val('something’) and more like that.
The changes are actually pretty trivial. Below are patches I made to make it work (not taking cross-version support into account ).
@@ -34,12 +38,12 @@ module ScmRepositoriesHelperPatch
if interface && (interface < SCMCreator) && interface.enabled? && repository.new_record?
button_disabled = true
end
- end
- if request.xhr?
- reptags << javascript_tag("$('repository_save')." + (button_disabled ? 'disable' : 'enable') + "();")
- else
- reptags << javascript_tag("Event.observe(window, 'load', function() { $('repository_save')." + (button_disabled ? 'disable' : 'enable') + "(); });")
+ if request.xhr?
+ reptags << javascript_tag("$('#repository_save')." + (button_disabled ? "attr('disabled','disabled')" : "removeAttr('enable')") + "();")
+ else
+ reptags << javascript_tag("$(document).ready(function() { $('#repository_save')." + (button_disabled ? "attr('disabled','disabled')" : "removeAttr('enable')") + "(); });")
+ end
end
return reptags
@@ -54,7 +58,7 @@ module ScmRepositoriesHelperPatch
end
if repository.new_record? && SubversionCreator.enabled?
- add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').value = 'add';")
+ add = submit_tag(l(:button_create_new_repository), :onclick => "$('#repository_operation').val('add');")
svntags['<br />'] = ' ' + add + '<br />'
svntags << hidden_field_tag(:operation, '', :id => 'repository_operation')
unless request.post?
@@ -62,7 +66,7 @@ module ScmRepositoriesHelperPatch
if SubversionCreator.repository_exists?(@project.identifier) && @project.respond_to?(:repositories)
path << '.' + @project.repositories.select{ |r| r.created_with_scm }.size.to_s
end
- svntags << javascript_tag("$('repository_url').value = '#{escape_javascript(path)}';")
+ svntags << javascript_tag("$('#repository_url').val('#{escape_javascript(path)}');")
end
elsif !repository.new_record? && repository.created_with_scm &&
@@ -85,7 +89,7 @@ module ScmRepositoriesHelperPatch
end
if repository.new_record? && MercurialCreator.enabled?
- add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').value = 'add';")
+ add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').val('add');")
if hgtags.include?('<br />')
hgtags['<br />'] = ' ' + add + '<br />'
else
@@ -97,7 +101,7 @@ module ScmRepositoriesHelperPatch
if MercurialCreator.repository_exists?(@project.identifier) && @project.respond_to?(:repositories)
path << '.' + @project.repositories.select{ |r| r.created_with_scm }.size.to_s
end
- hgtags << javascript_tag("$('repository_url').value = '#{escape_javascript(path)}';")
+ hgtags << javascript_tag("$('repository_url').val('#{escape_javascript(path)}');")
end
elsif !repository.new_record? && repository.created_with_scm &&
@@ -126,7 +130,7 @@ module ScmRepositoriesHelperPatch
end
Associated revisions
History
#1 Updated by Andriy Lesyuk about 12 years ago
- Status changed from New to Open
- Assignee set to Andriy Lesyuk
Thanks, Martin!
#2 Updated by Andriy Lesyuk about 12 years ago
- Target version set to 0.4.2
#3 Updated by Takashi Okamoto about 12 years ago
I also hope supporting Redmine 2.1.x.
#4 Updated by Takashi Okamoto about 12 years ago
- File support_redmine2.1.x.patch View added
#5 Updated by Andriy Lesyuk about 12 years ago
- Status changed from Open to In Progress
- % Done changed from 0 to 100
#6 Updated by Andriy Lesyuk about 12 years ago
- Due date set to 28 Nov 2012
- Status changed from In Progress to Closed