Remove templated filters when accessing query page

pull/6272/head
Oliver Günther 7 years ago
parent 31fe2373bc
commit 39d63a0835
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 3
      app/helpers/types_helper.rb
  2. 7
      app/models/queries/filters/base.rb
  3. 2
      app/views/types/form/_query_group.html.erb
  4. 25
      spec/features/types/form_configuration_query_spec.rb

@ -106,6 +106,9 @@ module ::TypesHelper
end
def query_to_query_props(query)
# Remove the templated filter since we can't yet handle it in the frontend
query.filters.delete_if(&:templated?)
::API::V3::Queries::QueryParamsRepresenter.new(query).to_h
end

@ -98,6 +98,13 @@ class Queries::Filters::Base
true
end
##
# Return whether this filter is templated
# and must be substituted by the frontend.
def templated?
values == %w[templated]
end
def available_operators
type_strategy.supported_operator_classes
end

@ -17,7 +17,7 @@
<%= content_tag :div,
class: 'type-form-query',
data: { query: JSON.dump(query) } do %>
<span ng-click="editQuery($event)">
<span class="type-form-query-group--edit-button" ng-click="editQuery($event)">
<%= op_icon('button--icon icon-edit') %>
<%= t('types.edit.edit_query') %>
</span>

@ -90,18 +90,31 @@ describe 'form subelements configuration', type: :feature, js: true do
embedded_table.expect_work_package_not_listed subbug
# Go back to type configuration
# visit edit_type_tab_path(id: type.id, tab: "form_configuration")
visit edit_type_tab_path(id: type_bug.id, tab: "form_configuration")
# Edit query to remove filters
# TODO error due to templated filter
# form.edit_query_group('Subtasks')
form.edit_query_group('Subtasks')
# Expect filter still there
modal.expect_open
filters.expect_filter_count 2
filters.expect_filter_by 'Type', 'is', type_task.name
# Remove the filter again
filters.remove_filter 'type'
filters.save
# Save changes
# form.save_changes
form.save_changes
# Visit wp_page again, expect both listed
# embedded_table = Pages::EmbeddedWorkPackagesTable.new(find('.work-packages-embedded-view--container'))
# embedded_table.expect_work_package_listed subtask, subbug
wp_page.visit!
wp_page.ensure_page_loaded
wp_page.expect_group('Subtasks') do
embedded_table = Pages::EmbeddedWorkPackagesTable.new(find('.work-packages-embedded-view--container'))
embedded_table.expect_work_package_listed subtask, subbug
end
end
end
end

Loading…
Cancel
Save