OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
generalize filters component and change base folders
Behrokh Satarnejadff1ce32d4f5b
diff --git a/app/components/_index.sass b/app/components/_index.sassindex 03df4c8193e..ec865cc19ae 100644--- a/app/components/_index.sass+++ b/app/components/_index.sass@@ -1,2 +1,3 @@@import "work_packages/share/modal_body_component"@import "work_packages/share/invite_user_form_component"+@import "filters_component"diff --git a/app/components/projects/filters_component.html.erb b/app/components/filters_component.html.erbsimilarity index 79%rename from app/components/projects/filters_component.html.erbrename to app/components/filters_component.html.erbindex 53ad58b0c0d..da3ef1d1e12 100644--- a/app/components/projects/filters_component.html.erb+++ b/app/components/filters_component.html.erb@@ -1,20 +1,19 @@-<div data-controller="project-filters"+<div data-controller="filters"data-application-target="dynamic"- data-project-filters-display-filters-value="<%= helpers.show_filters_section? %>">+ data-filters-display-filters-value="<%= helpers.show_filters_section? %>">-- <div class="project-filters-text">+ <div class="op-filters-header"><%= render(Primer::Beta::Button.new(scheme: :secondary,mb: 2,mr: 2,- data: { 'project-filters-target': 'filterFormToggle',- 'action': 'project-filters#toggleDisplayFilters',+ data: { 'filters-target': 'filterFormToggle',+ 'action': 'filters#toggleDisplayFilters','test-selector': 'project-filter-toggle' })) do %><%= t(:label_filter) %><%= render(Primer::Beta::Counter.new(count: query.filters.count, round: true, hide_if_zero: false, scheme: :default)) %><% end %>- <div class="project-filters-text-actions">+ <div class="op-filters-header-actions"><% buttons.each do |button| %><%= button %><% end %>@@ -22,16 +21,16 @@</div><%= form_tag({},method: :get,- class: "project-filters-box",+ class: "op-filters-form",data: {- 'project-filters-target': 'filterForm',- action: 'submit->project-filters#sendForm:prevent'+ 'filters-target': 'filterForm',+ action: 'submit->filters#sendForm:prevent'}) do %><% operators_without_values = %w[* !* t w] %><fieldset class="advanced-filters--container"><a title="<%= t('js.close_form_title') %>"class="advanced-filters--close icon-context icon-close"- data-action="project-filters#toggleFilterForm"></a>+ data-action="filters#toggleFilterForm"></a><legend><%= t(:label_filter_plural) %></legend><ul class="advanced-filters--filters"><% allowed_filters.each do |filter| %>@@ -41,7 +40,7 @@<li class="advanced-filters--filter <%= filter_active ? '' : 'hidden' %>"filter-name="<%= filter.name %>"filter-type="<%= filter.type %>"- data-project-filters-target="filter">+ data-filters-target="filter"><label class='advanced-filters--filter-name' for="<%= filter.name %>"><%= filter.human_name %></label>@@ -55,29 +54,29 @@selected_operator),class: 'advanced-filters--select',data: {- action: 'change->project-filters#setValueVisibility',- 'project-filters-filter-name-param': filter.name,- 'project-filters-target': 'operator',+ action: 'change->filters#setValueVisibility',+ 'filters-filter-name-param': filter.name,+ 'filters-target': 'operator','filter-name': filter.name} %><% end %><% value_visibility = operators_without_values.include?(selected_operator) ? 'hidden' : '' %><% if filter_boolean %>- <%= render partial: 'projects/filters/boolean',+ <%= render partial: 'filters/boolean',locals: { value_visibility: value_visibility,filter: filter } %><% elsif %i(list list_optional list_all).include? filter.type %>- <%= render partial: 'projects/filters/list/input_options',+ <%= render partial: 'filters/list/input_options',locals: { value_visibility: value_visibility,filter: filter } %><% elsif [:datetime_past, :date].include? filter.type %>- <%= render partial: 'projects/filters/date/input_options',+ <%= render partial: 'filters/date/input_options',locals: { value_visibility: value_visibility,filter: filter,selected_operator: selected_operator } %><% else %><%# All other simple types %>- <%= render partial: 'projects/filters/text',+ <%= render partial: 'filters/text',locals: { value_visibility: value_visibility,filter: filter } %><% end %>@@ -85,8 +84,8 @@<div class="advanced-filters--remove-filter"><a href="#"class="filter_rem"- data-action="click->project-filters#removeFilter"- data-project-filters-filter-name-param="<%= filter.name %>">+ data-action="click->filters#removeFilter"+ data-filters-filter-name-param="<%= filter.name %>"><%= helpers.op_icon("icon-close advanced-filters--remove-filter-icon", title: I18n.t('js.button_delete')) %></a></div>@@ -94,7 +93,7 @@<% end %><li class="advanced-filters--spacer <%= query.filters.blank? ? 'hidden' : '' %>"- data-project-filters-target="spacer"></li>+ data-filters-target="spacer"></li><li class="advanced-filters--add-filter"><!-- Add filters -->@@ -121,8 +120,8 @@focus: "false",'aria-invalid': "false",data: {- 'project-filters-target': 'addFilterSelect',- action: 'change->project-filters#addFilter:prevent'+ 'filters-target': 'addFilterSelect',+ action: 'change->filters#addFilter:prevent'} %></div></li>diff --git a/app/components/projects/filters_component.rb b/app/components/filters_component.rbsimilarity index 97%rename from app/components/projects/filters_component.rbrename to app/components/filters_component.rbindex 4815a91c1c0..bf2e8a3cb0e 100644--- a/app/components/projects/filters_component.rb+++ b/app/components/filters_component.rb@@ -28,7 +28,7 @@# See COPYRIGHT and LICENSE files for more details.# ++-class Projects::FiltersComponent < ApplicationComponent+class FiltersComponent < ApplicationComponentoptions :queryrenders_many :buttons, lambda { |**system_arguments|diff --git a/app/components/filters_component.sass b/app/components/filters_component.sassnew file mode 100644index 00000000000..cac2095766c--- /dev/null+++ b/app/components/filters_component.sass@@ -0,0 +1,48 @@+.op-filters+ &-form+ display: none+ &.-expanded+ display: block+ .advanced-filters--filter-value+ // visibility based on operator type+ &.hidden+ visibility: hidden+ height: 55px++ // visibility for list value selectors+ .multi-select+ display: none+ .single-select+ display: block+ &.multi-value+ .multi-select+ display: block+ .single-select+ display: none++ // visibility for datetime_past value selectors+ &.between-dates+ >.on-date,+ >.days+ display: none+ &.on-date+ >.between-dates,+ >.days+ display: none+ &.days+ >.on-date,+ >.between-dates+ display: none++ // Special input field styles+ &.between-dates+ input[type="text"]+ display: inline-block+ max-width: 6rem++ .advanced-filters--controls+ margin-top: 1rem++ &-header+ display: flex+ justify-content: space-between\ No newline at end of filediff --git a/app/views/projects/filters/_boolean.html.erb b/app/views/filters/_boolean.html.erbsimilarity index 89%rename from app/views/projects/filters/_boolean.html.erbrename to app/views/filters/_boolean.html.erbindex 60a16d53d34..b39e613b28b 100644--- a/app/views/projects/filters/_boolean.html.erb+++ b/app/views/filters/_boolean.html.erb@@ -1,5 +1,5 @@<label class="advanced-filters--filter-value"- data-project-filters-target="filterValueContainer"+ data-filters-target="filterValueContainer"data-filter-name="<%= filter.name %>"><%= angular_component_tag 'spot-switch',inputs: {diff --git a/app/views/projects/filters/_text.html.erb b/app/views/filters/_text.html.erbsimilarity index 82%rename from app/views/projects/filters/_text.html.erbrename to app/views/filters/_text.html.erbindex 25de867693b..6073072dffa 100644--- a/app/views/projects/filters/_text.html.erb+++ b/app/views/filters/_text.html.erb@@ -1,5 +1,5 @@<div class="advanced-filters--filter-value <%= value_visibility %>"- data-project-filters-target="filterValueContainer"+ data-filters-target="filterValueContainer"data-filter-name="<%= filter.name %>"><% if filter.type == :string %><div>@@ -7,7 +7,7 @@filter.values.first,class: 'advanced-filters--text-field -slim',data: {- 'project-filters-target': 'simpleValue',+ 'filters-target': 'simpleValue','filter-name': filter.name} %></div>@@ -17,7 +17,7 @@filter.values.first,class: 'advanced-filters--text-field -slim',data: {- 'project-filters-target': 'simpleValue',+ 'filters-target': 'simpleValue','filter-name': filter.name} %></div>@@ -28,7 +28,7 @@class: 'advanced-filters--text-field -slim',step: 'any',data: {- 'project-filters-target': 'simpleValue',+ 'filters-target': 'simpleValue','filter-name': filter.name}%></div>@@ -39,7 +39,7 @@class: 'advanced-filters--text-field -slim',step: 'any',data: {- 'project-filters-target': 'simpleValue',+ 'filters-target': 'simpleValue','filter-name': filter.name}%></div>diff --git a/app/views/projects/filters/date/_between_dates.html.erb b/app/views/filters/date/_between_dates.html.erbsimilarity index 100%rename from app/views/projects/filters/date/_between_dates.html.erbrename to app/views/filters/date/_between_dates.html.erbdiff --git a/app/views/projects/filters/date/_days.html.erb b/app/views/filters/date/_days.html.erbsimilarity index 87%rename from app/views/projects/filters/date/_days.html.erbrename to app/views/filters/date/_days.html.erbindex 208981ea11b..1e23e740fc9 100644--- a/app/views/projects/filters/date/_days.html.erb+++ b/app/views/filters/date/_days.html.erb@@ -5,7 +5,7 @@<%= number_field_tag :value,value,class: 'advanced-filters--text-field -slim',- 'data-project-filters-target': 'days',+ 'data-filters-target': 'days','data-filter-name': filter.name %><label for="value" class="form-label -transparent">days</label></span>diff --git a/app/views/projects/filters/date/_input_options.html.erb b/app/views/filters/date/_input_options.html.erbsimilarity index 79%rename from app/views/projects/filters/date/_input_options.html.erbrename to app/views/filters/date/_input_options.html.erbindex 2956a01d6fe..f7f1229cc6d 100644--- a/app/views/projects/filters/date/_input_options.html.erb+++ b/app/views/filters/date/_input_options.html.erb@@ -9,15 +9,15 @@end%><div class="advanced-filters--filter-value <%= value_visibility %> <%= value_format %>"- data-project-filters-target="filterValueContainer"+ data-filters-target="filterValueContainer"data-filter-name="<%= filter.name %>">- <%= render partial: 'projects/filters/date/days',+ <%= render partial: 'filters/date/days',locals: { filter: filter,value: value_format == 'days' ? filter.values.first : '' } %>- <%= render partial: 'projects/filters/date/on_date',+ <%= render partial: 'filters/date/on_date',locals: { filter: filter,value: value_format == 'on-date' ? filter.values.first : '' } %>- <%= render partial: 'projects/filters/date/between_dates',+ <%= render partial: 'filters/date/between_dates',locals: { filter: filter,from_value: value_format == 'between-dates' ? filter.values.first : '',to_value: value_format == 'between-dates' ? filter.values.second : ''} %>diff --git a/app/views/projects/filters/date/_on_date.html.erb b/app/views/filters/date/_on_date.html.erbsimilarity index 100%rename from app/views/projects/filters/date/_on_date.html.erbrename to app/views/filters/date/_on_date.html.erbdiff --git a/app/views/filters/list/_input_options.html.erb b/app/views/filters/list/_input_options.html.erbnew file mode 100644index 00000000000..19cc3a0ceca--- /dev/null+++ b/app/views/filters/list/_input_options.html.erb@@ -0,0 +1,8 @@+<% filter_values = filter.values || [] %>++<div class="advanced-filters--filter-value <%= value_visibility %> <%= filter_values.size > 1 ? 'multi-value' : '' %>"+ data-filters-target="filterValueContainer"+ data-filter-name="<%= filter.name %>">+ <%= render partial: 'filters/list/select', locals: { filter: filter, selected_values: filter_values.first, multi_value: false } %>+ <%= render partial: 'filters/list/select', locals: { filter: filter, selected_values: filter_values, multi_value: true } %>+</div>diff --git a/app/views/projects/filters/list/_select.html.erb b/app/views/filters/list/_select.html.erbsimilarity index 83%rename from app/views/projects/filters/list/_select.html.erbrename to app/views/filters/list/_select.html.erbindex d4be055ca68..495cda7f369 100644--- a/app/views/projects/filters/list/_select.html.erb+++ b/app/views/filters/list/_select.html.erb@@ -8,7 +8,7 @@selected_values),{class: 'form--select -slim',- 'data-project-filters-target': 'filterValueSelect',+ 'data-filters-target': 'filterValueSelect','data-filter-name': filter.name}]if multi_value@@ -18,8 +18,8 @@<a href=""class="form-label no-decoration-on-hover -transparent multi-select-toggle"tabindex="0"- data-action="click->project-filters#toggleMultiSelect"- data-project-filters-filter-name-param="<%= filter.name %>">+ data-action="click->filters#toggleMultiSelect"+ data-filters-filter-name-param="<%= filter.name %>"><span class="icon-context icon-button <%= multi_value ? 'icon-minus2' : 'icon-add' %> icon4" title="<%= t(:label_enable_multi_select) %>"><span class="hidden-for-sighted"><%= t(:label_enable_multi_select) %></span></span>diff --git a/app/views/projects/filters/list/_input_options.html.erb b/app/views/projects/filters/list/_input_options.html.erbdeleted file mode 100644index 4aba18e3233..00000000000--- a/app/views/projects/filters/list/_input_options.html.erb+++ /dev/null@@ -1,8 +0,0 @@-<% filter_values = filter.values || [] %>--<div class="advanced-filters--filter-value <%= value_visibility %> <%= filter_values.size > 1 ? 'multi-value' : '' %>"- data-project-filters-target="filterValueContainer"- data-filter-name="<%= filter.name %>">- <%= render partial: 'projects/filters/list/select', locals: { filter: filter, selected_values: filter_values.first, multi_value: false } %>- <%= render partial: 'projects/filters/list/select', locals: { filter: filter, selected_values: filter_values, multi_value: true } %>-</div>diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erbindex c0d966ca951..76d2acd8611 100644--- a/app/views/projects/index.html.erb+++ b/app/views/projects/index.html.erb@@ -37,7 +37,7 @@ See COPYRIGHT and LICENSE files for more details.current_user:) %>- <%= render (Projects::FiltersComponent.new(+ <%= render (FiltersComponent.new(query: @query,) ) do |component|diff --git a/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.html b/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.htmlindex bc9b2733e3c..349d7f98b7f 100644--- a/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.html+++ b/frontend/src/app/shared/components/datepicker/basic-single-date-picker/basic-single-date-picker.component.html@@ -3,7 +3,7 @@#inputtype="text"class="spot-input"- data-project-filters-target="singleDay"+ data-filters-target="singleDay"[ngClass]="inputClassNames"[attr.data-value]="value"[id]="id"@@ -20,7 +20,7 @@<inputtype="date"class="spot-input"- data-project-filters-target="singleDay"+ data-filters-target="singleDay"[ngClass]="inputClassNames"[attr.data-value]="value"[id]="id"diff --git a/frontend/src/global_styles/content/_projects_list.sass b/frontend/src/global_styles/content/_projects_list.sassindex 0d7c549ba06..064e67d29aa 100644--- a/frontend/src/global_styles/content/_projects_list.sass+++ b/frontend/src/global_styles/content/_projects_list.sass@@ -39,54 +39,6 @@ $project-table--description-indention: 9px// This does not work for big font-sizespadding-left: calc(#{$indentation} * #{$project-table--child-indentation} + #{$project-table--start-indentation} + #{$project-table--description-indention})-form.project-filters-box- display: none- &.-expanded- display: block- .advanced-filters--filter-value- // visibility based on operator type- &.hidden- visibility: hidden- height: 55px-- // visibility for list value selectors- .multi-select- display: none- .single-select- display: block- &.multi-value- .multi-select- display: block- .single-select- display: none-- // visibility for datetime_past value selectors- &.between-dates- >.on-date,- >.days- display: none- &.on-date- >.between-dates,- >.days- display: none- &.days- >.on-date,- >.between-dates- display: none-- // Special input field styles- &.between-dates- input[type="text"]- display: inline-block- max-width: 6rem-- .advanced-filters--controls- margin-top: 1rem--.project-filters-text- display: flex- justify-content: space-between-.projects-table--hierarchy-icondisplay: nonediff --git a/frontend/src/stimulus/controllers/dynamic/project-filters.controller.ts b/frontend/src/stimulus/controllers/dynamic/filters.controller.tssimilarity index 99%rename from frontend/src/stimulus/controllers/dynamic/project-filters.controller.tsrename to frontend/src/stimulus/controllers/dynamic/filters.controller.tsindex bdc36478cea..452602388a7 100644--- a/frontend/src/stimulus/controllers/dynamic/project-filters.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/filters.controller.ts@@ -38,7 +38,7 @@ interface Filter {};}-export default class ProjectFiltersController extends Controller {+export default class FiltersController extends Controller {static targets = ['filterFormToggle','filterForm',