end
+ def copy_form
+ @profile = Profile.find(params[:id])
+ render :partial => 'profiles/copy_form'
+ end
#
#
#
#
def copy
- profile = Profile.find(params[:id])
- name = params['copy_' + profile.id.to_s]
+ render :text => 'Not an ajax request', :status => '400' unless request.xhr?
- validation_errors = profile.validate_copy(name)
+ @profile = Profile.find(params[:id])
+ name = params['name']
+
+ validation_errors = @profile.validate_copy(name)
if validation_errors.empty?
- java_facade.copyProfile(profile.id, name)
+ java_facade.copyProfile(@profile.id, name)
flash[:notice]= message('quality_profiles.profile_x_not_activated', :params => name)
+ render :text => 'ok', :status => 200
else
- flash[:error] = validation_errors.full_messages.first
+ @error = validation_errors.full_messages.first
+ render :partial => 'profiles/copy_form', :status => 400
end
-
- redirect_to :action => 'index'
end
url = "#{ApplicationController.root_context}/confirm?url=#{u post_url}"
if message_key
url += "&k=#{message_key}&"
- url += message_params.map{|p| "p=#{p}"}.join('&') if message_params
+ url += message_params.map{|p| "p=#{u p}"}.join('&') if message_params
end
"<a href='#{url}' modal-width='#{width}' class='open-modal button #{clazz}' #{id}>#{label}</a>"
<fieldset>
<div class="form-head">
<img src="<%= ApplicationController.root_context -%>/images/warning.png" style="vertical-align: text-bottom"/>
- <%= message(message_key, :params => message_params) -%>
+ <%= h message(message_key, :params => message_params) -%>
</div>
<div class="form-foot">
<input type="submit" value="Confirm"/>
--- /dev/null
+<form id="form-copy-profile" method="post" action="profiles/copy">
+ <input type="hidden" name="id" value="<%= @profile.id -%>"/>
+ <fieldset>
+ <div class="form-head">
+ <h2>Copy Profile: <%= h @profile.name -%></h2>
+ </div>
+ <div class="form-body">
+ <% if @error %>
+ <div class="form-field">
+ <p class="error"><%= h @error -%></p>
+ </div>
+ <% end %>
+ <div class="form-field">
+ <label for="name">New name</label>
+ <input id="new-name" name="name" type="text" size="50" maxlength="100"/>
+ </div>
+ </div>
+ <div class="form-foot">
+ <input type="submit" value="Copy"/>
+ <a href="#" onclick="return closeModalWindow()"><%= message('cancel') -%></a>
+ </div>
+ </fieldset>
+</form>
+<script>
+ $j("#form-copy-profile").modalForm();
+ $j('#new-name').focus();
+</script>
\ No newline at end of file
</fieldset>
</form>
<script>
+ $j("#form-rename-profile").modalForm();
$j('#new-name').focus();
- $j("#form-rename-profile").submit(function (event) {
- $j('input[type=submit]', this).attr('disabled', 'disabled');
- $j.ajax({type:"POST", data:$j(this).serialize(), url:$j(this).attr('action'),
- success:function (data) {
- location.reload();
- },
- error:function (xhr, textStatus, errorThrown) {
- $j("#modal").html(xhr.responseText);
- }
- });
- return false;
- });
</script>
\ No newline at end of file
<td align="right">
<% if !profile.provided? %>
- <a id="rename-<%= profile.key.parameterize -%>" href="profiles/rename_form?id=<%= profile.id -%>" class="button open-modal"><%= message('rename') -%></a>
+ <a id="rename-<%= profile.key.parameterize -%>" href="profiles/rename_form/<%= profile.id -%>" class="button open-modal"><%= message('rename') -%></a>
<% end %>
</td>
<td align="right">
- <% form_tag(:action => 'copy', :id => profile.id) do -%>
- <%= hidden_field_tag 'copy_' + profile.id.to_s %>
- <input type="button" name="button_copy" id="copy_<%= u profile.key %>" value="<%= message('copy') -%>" onClick='var name=prompt("<%= message('quality_profiles.name_for_new_profile') -%>"); if (name!=null) {$("copy_<%= profile.id %>").value=name; submit();} else {return false;}'>
- <% end %>
+ <a id="copy-<%= profile.key.parameterize -%>" href="profiles/copy_form/<%= profile.id -%>" class="button open-modal"><%= message('copy') -%></a>
</td>
<td>
}
new Ajax.Request(
- baseUrl + '/treemap/index?id=' + this.id + '&width=' + width + '&height=' + height + '&size_metric=' + this.sizeMetric + '&color_metric=' + this.colorMetric + '&' + context.type + '=' + context.id,
- {
- asynchronous:true,
- evalScripts:true
- });
+ baseUrl + '/treemap/index?id=' + this.id + '&width=' + width + '&height=' + height + '&size_metric=' + this.sizeMetric + '&color_metric=' + this.colorMetric + '&' + context.type + '=' + context.id,
+ {
+ asynchronous:true,
+ evalScripts:true
+ });
};
Treemap.prototype.htmlNode = function (nodeId) {
return $('tm-node-' + this.id + '-' + nodeId);
$j.get($link.attr('href'), {}, function (html) {
$dialog.html(html);
$dialog
- .dialog({
- width:($link.attr('modal-width')||540),
- draggable:false,
- autoOpen:false,
- modal:true,
- minHeight: 50,
- resizable:false,
- close: function() {
- $j('#modal').remove();
- }
- });
+ .dialog({
+ width:($link.attr('modal-width') || 540),
+ draggable:false,
+ autoOpen:false,
+ modal:true,
+ minHeight:50,
+ resizable:false,
+ close:function () {
+ $j('#modal').remove();
+ }
+ });
$dialog.dialog("open");
});
return false;
});
+ return false;
+ });
+ });
+ },
+ modalForm:function () {
+ return this.each(function () {
+ var obj = $j(this);
+ obj.submit(function (event) {
+ $j('input[type=submit]', this).attr('disabled', 'disabled');
+ $j.ajax({
+ type:'POST',
+ url:obj.attr('action'),
+ data:obj.serialize(),
+ success:function (data) {
+ location.reload();
+ },
+ error:function (xhr, textStatus, errorThrown) {
+ $j("#modal").html(xhr.responseText);
+ }
+ });
return false;
});
});