Allow for filtering on latest_activity_at, while not yet resolving timezone difficulties.

pull/5981/head
Wieland Lindenthal 7 years ago committed by Jens Ulferts
parent 1d865b50ae
commit b83e15a8fa
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 4
      app/assets/javascripts/project/filters.js
  2. 4
      app/helpers/projects_helper.rb
  3. 2
      app/models/queries/filters/strategies/date_time_past.rb
  4. 1
      app/models/queries/projects.rb
  5. 57
      app/models/queries/projects/filters/latest_activity_at_filter.rb
  6. 14
      app/views/projects/index.html.erb

@ -110,9 +110,9 @@ jQuery(function($) {
filters.push(filterParam);
}
} else if ($valueBlock.hasClass('between-dates')) {
let fromValue = $('.between-dates #between-dates-from-value',
let fromValue = $('.between-dates input[name="from_value"]',
$valueBlock).val();
let toValue = $('.between-dates #between-dates-to-value',
let toValue = $('.between-dates input[name="to_value"]',
$valueBlock).val();
if (value.length > 0) {
filterParam[filterName] = {

@ -133,7 +133,7 @@ module ProjectsHelper
end
def allowed_filters(query)
filters_static = %i(status name_and_identifier created_on)
filters_static = %i(status name_and_identifier created_on latest_activity_at)
filters_dynamic = []
if EnterpriseToken.allows_to?(:custom_fields_in_projects_list)
filters_dynamic = ProjectCustomField
@ -159,6 +159,6 @@ module ProjectsHelper
end
def admin_only_filters
%i(created_on)
%i(created_on latest_activity_at)
end
end

@ -31,7 +31,7 @@ module Queries::Filters::Strategies
class DateTimePast < BaseStrategy
supported_operator_list ['>t-', '<t-', 't-', 't', 'w', '=d', '<>d']
default_operator '<t-'
default_operator '>t-'
def validate
if operator == Queries::Operators::OnDateTime ||

@ -37,4 +37,5 @@ module Queries::Projects
register.filter query, filters::NameAndIdentifierFilter
register.filter query, filters::CustomFieldFilter
register.filter query, filters::CreatedOnFilter
register.filter query, filters::LatestActivityAtFilter
end

@ -0,0 +1,57 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
class Queries::Projects::Filters::LatestActivityAtFilter < Queries::Projects::Filters::ProjectFilter
self.model = Project.with_latest_activity
def type
:datetime_past
end
def self.key
:latest_activity_at
end
def name
:latest_activity_at
end
def human_name
I18n.t('activerecord.attributes.project.latest_activity_at')
end
def where
operator_strategy.sql_for_field(values, "activity", self.class.key)
end
def order
9
end
end

@ -56,7 +56,7 @@ See doc/COPYRIGHT.rdoc for more details.
<% end %>
<%= form_tag({}, method: :get, class: "project-filters #{filter_set? ? '-expanded' : ''}") do %>
<% operators_without_values = ['*', '!*'] %>
<% operators_without_values = ['*', '!*', 't', 'w'] %>
<fieldset class="advanced-filters--container">
<a id="projects-filter-close-button" title="{{ ::I18n.t('js.close_form_title') }}" class="simple-filters--close icon-context icon-close"></a>
<legend><%= t(:label_filter_plural) %></legend>
@ -153,18 +153,18 @@ See doc/COPYRIGHT.rdoc for more details.
<div class="on-date">
<div class="form--field-container">
<div class="form--text-field-container -slim">
<%= text_field_tag :value, value_format == 'on-date' ? filter.values.first : '', id: "on-date-value", class: 'advanced-filters--text-field -slim', size: '10' %>
<%= calendar_for('on-date-value') %>
<%= text_field_tag :value, value_format == 'on-date' ? filter.values.first : '', id: "on-date-value-#{filter.name}", class: 'advanced-filters--text-field -slim', size: '10' %>
<%= calendar_for("on-date-value-#{filter.name}") %>
</div>
</div>
</div>
<div class="between-dates">
<span>From:</span>
<%= text_field_tag :value, value_format == 'between-dates' ? filter.values.first : '', id: "between-dates-from-value", class: 'advanced-filters--text-field -slim', size: '10' %>
<%= calendar_for('between-dates-from-value') %>
<%= text_field_tag :from_value, value_format == 'between-dates' ? filter.values.first : '', id: "between-dates-from-value-#{filter.name}", class: 'advanced-filters--text-field -slim', size: '10' %>
<%= calendar_for("between-dates-from-value-#{filter.name}") %>
<span>To:</span>
<%= text_field_tag :value, value_format == 'between-dates' ? filter.values.second : '', id: "between-dates-to-value", class: 'advanced-filters--text-field -slim', size: '10' %>
<%= calendar_for('between-dates-to-value') %>
<%= text_field_tag :to_value, value_format == 'between-dates' ? filter.values.second : '', id: "between-dates-to-value-#{filter.name}", class: 'advanced-filters--text-field -slim', size: '10' %>
<%= calendar_for("between-dates-to-value-#{filter.name}") %>
</div>
</div>
<% else %>

Loading…
Cancel
Save