text_field_tag definition.key(), val, :size => 10
elsif definition.type.name()==WidgetProperty::TYPE_FILTER
- user_filters = ::Filter.find(:all, :conditions => ['user_id=?', current_user.id]).sort_by(&:id).collect { |f| "<option value='#{f.id}'" + (value == f.id.to_s ? " selected='selected'" : "") + ">#{f.name}</option>" }
- shared_filters = ::Filter.find(:all, :conditions => ['(user_id<>? or user_id is null) and shared=?', current_user.id, true]).sort_by(&:id).collect { |f| "<option value='#{f.id}'" + (value == f.id.to_s ? " selected='selected'" : "") + ">#{f.name}</option>" }
- all_filters = '<optgroup label="My Filters">' + user_filters.to_s + '</optgroup>' + '<optgroup label="Shared Filters">' + shared_filters.to_s + '</optgroup>'
+ user_filters = options(value, ::Filter.find(:all, :conditions => ['user_id=?', current_user.id]).sort_by(&:id))
+ shared_filters = options(value, ::Filter.find(:all, :conditions => ['(user_id<>? or user_id is null) and shared=?', current_user.id, true]).sort_by(&:id))
- select_tag definition.key(), all_filters
+ select_tag definition.key(), option_group('My Filters', user_filters) + option_group('Shared Filters', shared_filters)
else
hidden_field_tag definition.key()
end
def resource_value_field(value)
- select_tag 'resource_id', Project.all(:conditions => {:scope => 'PRJ', :qualifier => 'TRK'}).collect { |f| "<option value='#{f.id}'" + (value == f.id ? " selected='selected'" : "") + ">#{f.name}</option>" }
+ select_tag 'resource_id', options(value, Project.all(:conditions => {:scope => 'PRJ', :qualifier => 'TRK'}))
+ end
+
+ def options(value, values)
+ values.collect { |f| "<option value='#{f.id}'" + (value.to_s == f.id.to_s ? " selected='selected'" : "") + ">#{f.name}</option>" }.to_s
+ end
+
+ def option_group(name, options)
+ options.empty? ? '' : "<optgroup label=\"#{name}\">" + options + "</optgroup>"
end
end
<% if widget.properties_as_hash['filter'] %>
<% filter = ::Filter.find_by_id(widget.properties_as_hash['filter']) %>
- <div class="widget-title"><%= filter.name if filter -%></div>
+ <div class="widget-title">
+ <% if filter %>
+ <%= filter.name -%>
+ <%= period_names[filter.period_index] if filter.period_index -%>
+ <% end %>
+ </div>
<% elsif @resource && !widget.java_definition.global %>
<div class="widget-title"><%= @resource.name -%></div>
<% end %>
<% filter=@filter_context.filter %>
<div>
-<% unless edit_mode %>
- <div class="line-block">
- <div class="operations">
- <form action="<%= url_for :overwrite_params => {:period => nil} -%>" style="display: inline" method="get">
- <select name="period" onchange="submit()" class="small">
- <option value=""><%= message('time_changes') -%>...</option>
- <% period_names.each_with_index do |name, index| %>
- <option value="<%= index+1 -%>" <%= 'selected' if @filter_context.period_index==index+1 -%>><%= name -%></value>
- <% end %>
- </select>
- <% if params[:did] %>
- <input type="hidden" name="did" value="<%= params[:did] %>">
- <% end %>
- </form>
- </div>
- </div>
-<% end %>
<table class="data nowrap width100" id="results">
<thead id="results-head">
<tr>