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
turn draggable autocompleter into web component
ulfertse8b1ff3a98de
diff --git a/app/components/projects/configure_view_modal_component.html.erb b/app/components/projects/configure_view_modal_component.html.erbindex c57ed3e31b1..1dac6636ea2 100644--- a/app/components/projects/configure_view_modal_component.html.erb+++ b/app/components/projects/configure_view_modal_component.html.erb@@ -18,6 +18,7 @@options: all_columns,selected: selected_columns,name: COLUMN_HTML_NAME,+ id: 'columns-select',inputLabel: I18n.t(:'queries.configure_view.columns.input_label'),inputPlaceholder: I18n.t(:'queries.configure_view.columns.input_placeholder'),dragAreaLabel: I18n.t(:'queries.configure_view.columns.drag_area_label')diff --git a/app/models/queries/work_packages/selects/work_package_select.rb b/app/models/queries/work_packages/selects/work_package_select.rbindex 4f0412fa9d5..b38de55b9c6 100644--- a/app/models/queries/work_packages/selects/work_package_select.rb+++ b/app/models/queries/work_packages/selects/work_package_select.rb@@ -44,6 +44,24 @@ class Queries::WorkPackages::Selects::WorkPackageSelect:summable_select,:summable_work_packages_select+ def self.instances(_context = nil)+ new+ end++ def self.scoped_column_sum(scope, select, group_by)+ scope = scope+ .except(:order, :select)++ if group_by+ scope+ .group(group_by)+ .select("#{group_by} id", select)+ else+ scope+ .select(select)+ end+ end+def sortable_join_statement(_query)sortable_joinend@@ -102,26 +120,6 @@ class Queries::WorkPackages::Selects::WorkPackageSelectmodel.send nameend- def self.instances(_context = nil)- new- end-- protected-- def name_or_value_or_false(value)- # This is different from specifying value = nil in the signature- # in that it will also set the value to false if nil is provided.- value ||= false-- # Explicitly checking for true because apparently, we do not want- # truish values to count here.- if value == true- name.to_s- else- value- end- end-def initialize(name, options = {})self.name = name@@ -145,17 +143,19 @@ class Queries::WorkPackages::Selects::WorkPackageSelectWorkPackage.human_attribute_name(name)end- def self.scoped_column_sum(scope, select, group_by)- scope = scope- .except(:order, :select)+ protected- if group_by- scope- .group(group_by)- .select("#{group_by} id", select)+ def name_or_value_or_false(value)+ # This is different from specifying value = nil in the signature+ # in that it will also set the value to false if nil is provided.+ value ||= false++ # Explicitly checking for true because apparently, we do not want+ # truish values to count here.+ if value == true+ name.to_selse- scope- .select(select)+ valueendendenddiff --git a/app/models/query.rb b/app/models/query.rbindex a029ae9dbcf..da8f9faaea5 100644--- a/app/models/query.rb+++ b/app/models/query.rb@@ -221,7 +221,7 @@ class Query < ApplicationRecorddef self.available_columns(project = nil)Queries::Register- .columns[self]+ .selects[self].map { |col| col.instances(project) }.flattenenddiff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex f59f0998495..0b749379987 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -158,7 +158,6 @@ en:description_available_columns: "Available Columns"description_current_position: "You are here: "description_select_work_package: "Select work package #%{id}"- description_selected_columns: "Selected Columns"description_subwork_package: "Child of work package #%{id}"editor:preview: 'Toggle preview mode'diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.tsindex 3419e89d9d0..0f48578fe0c 100644--- a/frontend/src/app/app.module.ts+++ b/frontend/src/app/app.module.ts@@ -145,6 +145,9 @@ import {import {CkeditorAugmentedTextareaComponent,} from 'core-app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component';+import {+ DraggableAutocompleteComponent,+} from 'core-app/shared/components/autocompleter/draggable-autocomplete/draggable-autocomplete.component';export function initializeServices(injector:Injector) {return () => {@@ -326,5 +329,6 @@ export class OpenProjectModule {registerCustomElement('opce-macro-attribute-label', AttributeLabelMacroComponent, { injector });registerCustomElement('opce-macro-wp-quickinfo', WorkPackageQuickinfoMacroComponent, { injector });registerCustomElement('opce-ckeditor-augmented-textarea', CkeditorAugmentedTextareaComponent, { injector });+ registerCustomElement('opce-draggable-autocompleter', DraggableAutocompleteComponent, { injector });}}diff --git a/frontend/src/app/core/setup/global-dynamic-components.const.ts b/frontend/src/app/core/setup/global-dynamic-components.const.tsindex dd1be299c52..17d5cd5d452 100644--- a/frontend/src/app/core/setup/global-dynamic-components.const.ts+++ b/frontend/src/app/core/setup/global-dynamic-components.const.ts@@ -183,9 +183,6 @@ import {TimerAccountMenuComponent,timerAccountSelector,} from 'core-app/shared/components/time_entries/timer/timer-account-menu.component';-import {- DraggableAutocompleteComponent, opDraggableAutocompleteSelector,-} from 'core-app/shared/components/autocompleter/draggable-autocomplete/draggable-autocomplete.component';export const globalDynamicComponents:OptionalBootstrapDefinition[] = [{ selector: appBaseSelector, cls: ApplicationBaseComponent },@@ -246,6 +243,4 @@ export const globalDynamicComponents:OptionalBootstrapDefinition[] = [{ selector: remoteFieldUpdaterSelector, cls: RemoteFieldUpdaterComponent },{ selector: timerAccountSelector, cls: TimerAccountMenuComponent },-- { selector: opDraggableAutocompleteSelector, cls: DraggableAutocompleteComponent },];diff --git a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/columns-tab.component.html b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/columns-tab.component.htmlindex 7f623eca812..bdeec625841 100644--- a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/columns-tab.component.html+++ b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/columns-tab.component.html@@ -1,19 +1,12 @@<div class="columns-modal--content">- <label- [textContent]="text.selectedColumns"- class="hidden-for-sighted">- </label>-- <opce-draggable-autocompleter [options]="availableColumnsOptions"- [selected]="selectedColumns"- [inputLabel]="text.inputLabel"- [inputPlaceholder]="text.inputPlaceholder"- [dragAreaLabel]="text.inputDragLabel">- (onChange)="updateSelected($event)"-- </opce-draggable-autocompleter>-- <p class="form--inline-instructions" [textContent]="text.columnsHelp"></p>+ <op-draggable-autocompleter [options]="availableColumnsOptions"+ [selected]="selectedColumns"+ [inputLabel]="text.inputLabel"+ [inputPlaceholder]="text.inputPlaceholder"+ [dragAreaLabel]="text.inputDragLabel"+ [id]="'columns-select'"+ (onChange)="updateSelected($event)">+ </op-draggable-autocompleter></div><op-enterprise-banner class="ee-relation-columns-upsale"diff --git a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/columns-tab.component.ts b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/columns-tab.component.tsindex 6b956aaa0d8..4321dd1c079 100644--- a/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/columns-tab.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-table/configuration-modal/tabs/columns-tab.component.ts@@ -27,7 +27,6 @@ export class WpTableConfigurationColumnsTabComponent implements TabComponent, Onpublic text = {columnsHelp: this.I18n.t('js.work_packages.table_configuration.columns_help_text'),columnsLabel: this.I18n.t('js.label_columns'),- selectedColumns: this.I18n.t('js.description_selected_columns'),multiSelectLabel: this.I18n.t('js.work_packages.label_column_multiselect'),upsaleRelationColumns: this.I18n.t('js.work_packages.table_configuration.upsale.relation_columns'),@@ -40,10 +39,9 @@ export class WpTableConfigurationColumnsTabComponent implements TabComponent, On};constructor(-readonly injector:Injector,+ readonly injector:Injector,readonly I18n:I18nService,readonly wpTableColumns:WorkPackageViewColumnsService,- readonly ConfigurationService:ConfigurationService,readonly bannerService:BannersService,) {}diff --git a/frontend/src/app/shared/components/autocompleter/draggable-autocomplete/draggable-autocomplete.component.html b/frontend/src/app/shared/components/autocompleter/draggable-autocomplete/draggable-autocomplete.component.htmlindex de56c504286..6b20ea0f7b2 100644--- a/frontend/src/app/shared/components/autocompleter/draggable-autocomplete/draggable-autocomplete.component.html+++ b/frontend/src/app/shared/components/autocompleter/draggable-autocomplete/draggable-autocomplete.component.html@@ -2,7 +2,8 @@<div class="FormControl-spacingWrapper mb-3"><div class="FormControl width-full"><label class="FormControl-label"- [textContent]="inputLabel">+ [textContent]="inputLabel"+ [attr.for]="id"></label><ng-selectdiff --git a/frontend/src/app/shared/components/autocompleter/draggable-autocomplete/draggable-autocomplete.component.ts b/frontend/src/app/shared/components/autocompleter/draggable-autocomplete/draggable-autocomplete.component.tsindex 44f9d7b323d..77b3a2efad2 100644--- a/frontend/src/app/shared/components/autocompleter/draggable-autocomplete/draggable-autocomplete.component.ts+++ b/frontend/src/app/shared/components/autocompleter/draggable-autocomplete/draggable-autocomplete.component.ts@@ -25,10 +25,8 @@ export interface DraggableOption {id:string;}-export const opDraggableAutocompleteSelector = 'opce-draggable-autocompleter';-@Component({- selector: opDraggableAutocompleteSelector,+ selector: 'op-draggable-autocompleter',templateUrl: './draggable-autocomplete.component.html',styleUrls: ['./draggable-autocomplete.component.sass'],changeDetection: ChangeDetectionStrategy.OnPush,@@ -42,6 +40,9 @@ export class DraggableAutocompleteComponent extends UntilDestroyedMixin implemen@Input() name = '';+ /** Id of the autocompleter input */+ @Input() id = this.name;+/** Label to display above the autocompleter */@Input() inputLabel = '';@@ -65,6 +66,7 @@ export class DraggableAutocompleteComponent extends UntilDestroyedMixin implemenprivate columnsGroup:Group;@ViewChild('ngSelectComponent') public ngSelectComponent:NgSelectComponent;+ @ViewChild('input') inputElement:ElementRef;constructor(readonly I18n:I18nService,@@ -117,6 +119,12 @@ export class DraggableAutocompleteComponent extends UntilDestroyedMixin implemenif (this.autofocus) {this.ngSelectComponent.focus();}++ // Set the id of the input so that it matches the label.+ const input = this.ngSelectComponent.element.querySelector('input');+ if (input) {+ input.id = this.id;+ }}ngOnDestroy():void {diff --git a/lib/api/v3/queries/columns/query_columns_factory.rb b/lib/api/v3/queries/columns/query_columns_factory.rbindex 2ed94b2fc72..fcbdabc6f4a 100644--- a/lib/api/v3/queries/columns/query_columns_factory.rb+++ b/lib/api/v3/queries/columns/query_columns_factory.rb@@ -34,9 +34,9 @@ module APIdef self.representer(column)case columnwhen ::Queries::WorkPackages::Selects::RelationToTypeSelect- ::API::V3::Queries::Columns::QueryQueries::WorkPackages::Selects::RelationToTypeSelectRepresenter+ ::API::V3::Queries::Columns::QueryRelationToTypeColumnRepresenterwhen ::Queries::WorkPackages::Selects::RelationOfTypeSelect- ::API::V3::Queries::Columns::QueryQueries::WorkPackages::Selects::RelationOfTypeSelectRepresenter+ ::API::V3::Queries::Columns::QueryRelationOfTypeColumnRepresenterelse::API::V3::Queries::Columns::QueryPropertyColumnRepresenterenddiff --git a/lib/api/v3/queries/columns/query_relation_of_type_column_representer.rb b/lib/api/v3/queries/columns/query_relation_of_type_column_representer.rbindex 85e0d1c023b..f4fe9422039 100644--- a/lib/api/v3/queries/columns/query_relation_of_type_column_representer.rb+++ b/lib/api/v3/queries/columns/query_relation_of_type_column_representer.rb@@ -30,7 +30,7 @@ module APImodule V3module Queriesmodule Columns- class QueryQueries::WorkPackages::Selects::RelationOfTypeSelectRepresenter < QueryColumnRepresenter+ class QueryRelationOfTypeColumnRepresenter < QueryColumnRepresenterdef _type'QueryColumn::RelationOfType'enddiff --git a/lib/api/v3/queries/columns/query_relation_to_type_column_representer.rb b/lib/api/v3/queries/columns/query_relation_to_type_column_representer.rbindex cf6a57406a2..cc0524ef133 100644--- a/lib/api/v3/queries/columns/query_relation_to_type_column_representer.rb+++ b/lib/api/v3/queries/columns/query_relation_to_type_column_representer.rb@@ -30,7 +30,7 @@ module APImodule V3module Queriesmodule Columns- class QueryQueries::WorkPackages::Selects::RelationToTypeSelectRepresenter < QueryColumnRepresenter+ class QueryRelationToTypeColumnRepresenter < QueryColumnRepresenterlink :type do{href: api_v3_paths.type(represented.type.id),