@filter.shared=(params[:shared]=='true')
@filter.data=URI.unescape(params[:data])
if @filter.save
- current_user.favourited_measure_filters<<@filter
+ current_user.favourited_measure_filters<<@filter if add_to_favourites
render :text => @filter.id.to_s, :status => 200
else
render :partial => 'measures/save_form', :status => 400
end
end
+ # GET /measures/copy_form/<filter id>
+ def copy_form
+ require_parameters :id
+ @filter = find_filter(params[:id])
+ render :partial => 'measures/copy_form'
+ end
+
+ # POST /measures/copy/<filter id>?name=<copy name>&description=<copy description>
+ def copy
+ verify_post_request
+ access_denied unless logged_in?
+ require_parameters :id
+
+ to_clone = find_filter(params[:id])
+ @filter = MeasureFilter.new
+ @filter.name = params[:name]
+ @filter.description = params[:description]
+ @filter.user_id = current_user.id
+ @filter.shared = to_clone.shared
+ @filter.data = to_clone.data
+ @filter.shared = false
+ if @filter.save
+ render :text => @filter.id.to_s, :status => 200
+ else
+ render :partial => 'measures/copy_form', :status => 400
+ end
+ end
+
# POST /measures/delete/<filter id>
def delete
verify_post_request
has_many :filters, :dependent => :destroy
has_many :active_dashboards, :dependent => :destroy, :order => 'order_index'
has_many :dashboards, :dependent => :destroy
- has_many :measure_filters, :class_name => 'MeasureFilter', :dependent => :delete_all
+ has_many :measure_filters, :class_name => 'MeasureFilter', :dependent => :delete_all, :order => 'name asc'
# measure filters that are marked as favourites
- has_many :favourited_measure_filters, :class_name => 'MeasureFilter', :through => :measure_filter_favourites, :source => :measure_filter
+ has_many :favourited_measure_filters, :class_name => 'MeasureFilter', :through => :measure_filter_favourites, :source => :measure_filter, :order => 'name asc'
# the join table MEASURE_FILTER_FAVOURITES
has_many :measure_filter_favourites, :class_name => 'MeasureFilterFavourite', :dependent => :delete_all
--- /dev/null
+<form id="copy-filter-form" method="post" action="<%= ApplicationController.root_context -%>/measures/copy">
+ <input type="hidden" name="id" value="<%= @filter.id -%>">
+ <fieldset>
+ <div class="form-head">
+ <h2>Copy Filter: <%= h @filter.name -%></h2>
+ </div>
+ <div class="form-body">
+ <% @filter.errors.each do |attr, msg| %>
+ <p class="error"><%= h msg -%></p>
+ <% end %>
+ <div class="form-field">
+ <label for="name">Name <em class="mandatory">*</em></label>
+ <input id="name" name="name" type="text" size="50" maxlength="100" value="<%= h @filter.name -%>"/>
+ </div>
+ <div class="form-field">
+ <label for="description">Description</label>
+ <input id="description" name="description" type="text" size="50" maxlength="4000" value="<%= h @filter.description -%>"/>
+ </div>
+ </div>
+ <div class="form-foot">
+ <input type="submit" value="<%= h message('copy') -%>" id="copy-submit"/>
+ <a href="#" onclick="return closeModalWindow()" id="copy-cancel"><%= h message('cancel') -%></a>
+ </div>
+ </fieldset>
+</form>
+<script>
+ $j("#copy-filter-form").modalForm();
+ $j('#name').select();
+</script>
\ No newline at end of file
size_measure=result.measure(@filter.display.size_metric)
if size_measure && size_measure.value
color_measure=result.measure(@filter.display.color_metric)
- if result.snapshot.source_code?
- link="of(#{result.snapshot.project_id})"
- else
- link="ov(#{result.snapshot.project_id})"
- end
title="#{result.snapshot.resource.long_name} | #{@filter.display.size_metric.short_name}: #{size_measure.formatted_value}"
if color_measure && color_measure.value
title += " | #{@filter.display.color_metric.short_name}: #{color_measure.formatted_value}"
end
%>
- <a href="#" onclick="<%= link -%>" title="<%= title -%>"><span style="font-size: <%= cloud_font_size(size_measure.value, min_size_value, max_size_value) -%>%;color: <%= MeasureColor.color(color_measure, color_options).html -%>"><%= result.snapshot.resource.name %></span></a>
+ <a href="<%= ApplicationController.root_context -%>/dashboard/index/<%= result.snapshot.resource_id -%>" title="<%= title -%>"><span style="font-size: <%= cloud_font_size(size_measure.value, min_size_value, max_size_value) -%>%;color: <%= MeasureColor.color(color_measure, color_options).html -%>"><%= result.snapshot.resource.name %></span></a>
<% end
end %>
</div>
\ No newline at end of file
</form>
<script>
$j("#edit-filter-form").modalForm();
- $j('#name').focus();
+ $j('#name').select();
</script>
\ No newline at end of file
$j("#save-filter-form").modalForm({success:function (data) {
window.location = baseUrl + '/measures/filter/' + data;
}});
- $j('#name').focus();
+ $j('#name').select();
</script>
\ No newline at end of file
var filterId = $j(this).attr('filter-id');
var star = $j(this);
$j.ajax({
- type: 'POST',
+ type:'POST',
url:baseUrl + "/measures/toggle_fav",
- data:{id: filterId},
+ data:{id:filterId},
success:function (data) {
- if (data=='true') {
+ if (data == 'true') {
star.removeClass('notfav').addClass('fav');
star.attr('title', '<%= escape_javascript message('click_to_remove_from_favourites') -%>');
} else {
<% end %>
<h2>My Measure Filters</h2>
-<table class="data" id="my-filters">
+<table class="data marginbottom10" id="my-filters">
<thead>
<tr>
<th class="thin"></th>
<td class="thin nowrap right">
<a id="edit_<%= filter.name.parameterize -%>" href="<%= ApplicationController.root_context -%>/measures/edit_form/<%= filter.id -%>" class="link-action open-modal"><%= message('edit') -%></a>
+ <a id="copy-<%= filter.name.parameterize -%>" href="<%= ApplicationController.root_context -%>/measures/copy_form/<%= filter.id -%>" class="link-action open-modal"><%= message('copy') -%></a>
+
<%= link_to_action message('delete'), "#{ApplicationController.root_context}/measures/delete/#{filter.id}",
:class => 'link-action link-red',
:id => "delete_#{filter.name.parameterize}",
</tbody>
</table>
-<br>
+<br/>
<h2>Shared Measure Filters</h2>
<table class="data" id="shared-filters">
<th class="thin"></th>
<th><%= message('name') -%></th>
<th><%= message('shared_by') -%></th>
+ <th class="right"><%= message('operations') -%></th>
</tr>
</thead>
<tbody>
<% if @shared_filters.empty? %>
<tr class="even">
- <td colspan="3"><%= message('filters.no_filters') -%></td>
+ <td colspan="4"><%= message('filters.no_filters') -%></td>
</tr>
<% else %>
<% @shared_filters.each do |filter| %>
<td>
<%= h filter.user.name -%>
</td>
+ <td class="thin nowrap right">
+ <a id="copy-<%= filter.name.parameterize -%>" href="<%= ApplicationController.root_context -%>/measures/copy_form/<%= filter.id -%>" class="link-action open-modal"><%= message('copy') -%></a>
+ </td>
</tr>
<% end %>
Display as:
<% MeasureFilter::DISPLAYS.each do |display_class| %>
- <%= link_to_if display_class::KEY!=@filter.display.class::KEY, display_class::KEY, params.merge(:action => 'search', :display => display_class::KEY, :id => nil) -%>
+ <%= link_to_if display_class::KEY!=@filter.display.class::KEY, display_class::KEY, params.merge(:action => 'search', :display => display_class::KEY, :id => @filter.id) -%>
<% end %>
<% if logged_in? && (@filter.user_id==nil || @filter.user_id==current_user.id) %>
</form>
<script>
$j("#copy-profile-form").modalForm();
- $j('#copy-name').focus();
+ $j('#copy-name').select();
</script>
\ No newline at end of file
</form>
<script>
$j("#rename-profile-form").modalForm();
- $j('#new-name').focus();
+ $j('#new-name').select();
</script>
\ No newline at end of file