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
Switch view select to actually work with views instead of queries
Henriette Darged2dd116a1008
diff --git a/app/views/work_packages/_menu_query_select.html.erb b/app/views/work_packages/_menu_query_select.html.erbindex 991c4722598..990489d403d 100644--- a/app/views/work_packages/_menu_query_select.html.erb+++ b/app/views/work_packages/_menu_query_select.html.erb@@ -1,8 +1,9 @@<%=angular_component_tag 'op-view-select',inputs: {- projectIdentifier: (@project ? @project.identifier : ''),+ projectId: (@project ? @project.id.to_s : ''),menuItems: [parent_name, name],- baseRoute: 'work-packages'+ baseRoute: 'work-packages',+ viewType: 'WorkPackagesTable',}%>diff --git a/frontend/src/app/core/state/views/view.model.ts b/frontend/src/app/core/state/views/view.model.tsindex 5341e4c7ac1..09089326b84 100644--- a/frontend/src/app/core/state/views/view.model.ts+++ b/frontend/src/app/core/state/views/view.model.ts@@ -10,6 +10,8 @@ export interface ViewLinks extends HalResourceLinks {export interface View {id:ID;+ starred:boolean;+ public:boolean;_links:ViewLinks;}diff --git a/frontend/src/app/shared/components/op-view-select/op-view-select.component.ts b/frontend/src/app/shared/components/op-view-select/op-view-select.component.tsindex 8100f2bb64e..d91a3973004 100644--- a/frontend/src/app/shared/components/op-view-select/op-view-select.component.ts+++ b/frontend/src/app/shared/components/op-view-select/op-view-select.component.ts@@ -47,8 +47,13 @@ import { DatasetInputs } from 'core-app/shared/components/dataset-inputs.decoratimport { MainMenuNavigationService } from 'core-app/core/main-menu/main-menu-navigation.service';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { IOpSidemenuItem } from 'core-app/shared/components/sidemenu/sidemenu.component';-import { QueryResource } from 'core-app/features/hal/resources/query-resource';import { StaticQueriesService } from 'core-app/shared/components/op-view-select/op-static-queries.service';+import { ViewsResourceService } from 'core-app/core/state/views/views.service';+import { Apiv3ListParameters } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';+import { View } from 'core-app/core/state/views/view.model';+import idFromLink from 'core-app/features/hal/helpers/id-from-link';++export type ViewType = 'WorkPackagesTable'|'BCF'|'TeamPlanner';export const opViewSelectSelector = 'op-view-select';@@ -69,15 +74,19 @@ export class ViewSelectComponent extends UntilDestroyedMixin implements OnInit {no_results: this.I18n.t('js.work_packages.query.text_no_results'),};- public $queries:Observable<IOpSidemenuItem[]>;+ public $views:Observable<IOpSidemenuItem[]>;@Input() menuItems:string[] = [];- @Input() projectIdentifier:string;+ @Input() projectId:string|undefined;@Input() baseRoute:string;- private $queryCategories = new BehaviorSubject<IOpSidemenuItem[]>([]);+ @Input() viewType:ViewType;++ private apiViewType:string;++ private $viewCategories = new BehaviorSubject<IOpSidemenuItem[]>([]);private $search = new BehaviorSubject<string>('');@@ -91,6 +100,7 @@ export class ViewSelectComponent extends UntilDestroyedMixin implements OnInit {readonly opStaticQueries:StaticQueriesService,readonly mainMenuService:MainMenuNavigationService,readonly cdRef:ChangeDetectorRef,+ readonly viewsService:ViewsResourceService,) {super();}@@ -102,15 +112,17 @@ export class ViewSelectComponent extends UntilDestroyedMixin implements OnInit {}ngOnInit():void {+ this.apiViewType = `Views::${this.viewType}`;+// When activating the work packages submenu,// either initially or through click on the toggle, load the resultsthis.mainMenuService.onActivate(...this.menuItems).subscribe(() => this.initializeAutocomplete());- this.$queries = combineLatest(+ this.$views = combineLatest(this.$search,- this.$queryCategories,+ this.$viewCategories,).pipe(map(([searchText, categories]) => categories@@ -141,7 +153,7 @@ export class ViewSelectComponent extends UntilDestroyedMixin implements OnInit {}this.updateMenuOnChanges();- this.initializeQueries();+ this.initializeViews();this.initialized = true;}@@ -149,7 +161,7 @@ export class ViewSelectComponent extends UntilDestroyedMixin implements OnInit {return text.toLowerCase().includes(searchText.toLowerCase());}- private initializeQueries():void {+ private initializeViews():void {const categories:{ [category:string]:IOpSidemenuItem[] } = {starred: [],default: [],@@ -157,26 +169,38 @@ export class ViewSelectComponent extends UntilDestroyedMixin implements OnInit {private: [],};- // TODO: use global query store- this.apiV3Service- .queries- .filterNonHidden(this.projectIdentifier)+ const params:Apiv3ListParameters = {+ filters: [+ ['type', '=', [this.apiViewType]],+ ],+ };++ if (this.projectId) {+ params.filters?.push(+ ['project', '=', [this.projectId]],+ );+ }++ this.viewsService+ .fetchViews(params).pipe(this.untilDestroyed()).subscribe((queryCollection) => {- queryCollection.elements.forEach((query) => {+ queryCollection._embedded.elements.forEach((view) => {let cat = 'private';- if (query.public) {+ if (view.public) {cat = 'public';}- if (query.starred) {+ if (view.starred) {cat = 'starred';}- categories[cat].push(this.toOpSideMenuItem(query));+ categories[cat].push(this.toOpSideMenuItem(view));});- const staticQueries = this.opStaticQueries.getStaticQueries(this.baseRoute);- this.$queryCategories.next([+ // TODO+ // this.opStaticQueries.getStaticQueries(this.baseRoute);+ const staticQueries = [] as IOpSidemenuItem[];+ this.$viewCategories.next([{ title: this.text.scope_starred, children: categories.starred, collapsible: true },{ title: this.text.scope_default, children: staticQueries, collapsible: true },{ title: this.text.scope_global, children: categories.public, collapsible: true },@@ -185,11 +209,12 @@ export class ViewSelectComponent extends UntilDestroyedMixin implements OnInit {});}- private toOpSideMenuItem(query:QueryResource):IOpSidemenuItem {+ private toOpSideMenuItem(view:View):IOpSidemenuItem {+ const query = view._links.query;return {- title: query.name,+ title: query.title,uiSref: this.baseRoute,- uiParams: { query_id: query.id, query_props: '' },+ uiParams: { query_id: idFromLink(query.href), query_props: '' },};}@@ -197,6 +222,6 @@ export class ViewSelectComponent extends UntilDestroyedMixin implements OnInit {private updateMenuOnChanges() {this.states.changes.queries.pipe(this.untilDestroyed())- .subscribe(() => this.initializeQueries());+ .subscribe(() => this.initializeViews());}}diff --git a/frontend/src/app/shared/components/op-view-select/op-view-select.template.html b/frontend/src/app/shared/components/op-view-select/op-view-select.template.htmlindex 7668ac34fe7..9ce874ed6d6 100644--- a/frontend/src/app/shared/components/op-view-select/op-view-select.template.html+++ b/frontend/src/app/shared/components/op-view-select/op-view-select.template.html@@ -1,4 +1,4 @@-<div id="querySelect" class="searchable-menu">+<div id="viewSelect" class="searchable-menu"><div class="searchable-menu--search-container"><div class="searchable-menu--search-bar"><label for="query-title-filter"@@ -14,12 +14,12 @@</div><p class="searchable-menu--no-results-container"- [hidden]="($queries | async).length > 0"+ [hidden]="($views | async).length > 0"[textContent]="text.no_results"></p><op-sidemenuclass="op-view-select--search-results"- [items]="$queries | async"+ [items]="$views | async"[collapsible]="true"[searchable]="true">diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.tsindex c5f6b65e419..04a62e7d559 100644--- a/frontend/src/app/shared/shared.module.ts+++ b/frontend/src/app/shared/shared.module.ts@@ -85,6 +85,7 @@ import { OpFormFieldComponent } from './components/forms/form-field/form-field.cimport { OpFormBindingDirective } from './components/forms/form-field/form-binding.directive';import { OpOptionListComponent } from './components/option-list/option-list.component';import { OpSidemenuComponent } from './components/sidemenu/sidemenu.component';+import { ViewsResourceService } from 'core-app/core/state/views/views.service';export function bootstrapModule(injector:Injector) {// Ensure error reporter is run@@ -190,6 +191,7 @@ export function bootstrapModule(injector:Injector) {],providers: [StaticQueriesService,+ ViewsResourceService,],declarations: [OpDateTimeComponent,diff --git a/modules/bim/app/views/bim/ifc_models/ifc_models/_panels.html.erb b/modules/bim/app/views/bim/ifc_models/ifc_models/_panels.html.erbindex c9408a151b2..b973b67987f 100644--- a/modules/bim/app/views/bim/ifc_models/ifc_models/_panels.html.erb+++ b/modules/bim/app/views/bim/ifc_models/ifc_models/_panels.html.erb@@ -2,9 +2,10 @@<%=angular_component_tag 'op-view-select',inputs: {- projectIdentifier: (@project ? @project.identifier : ''),+ projectId: (@project ? @project.id.to_s : ''),menuItems: [parent_name, name],- baseRoute: 'bim.partitioned.split'+ baseRoute: 'bim.partitioned.split',+ viewType: 'BCF',}%>diff --git a/spec/support/pages/work_packages/work_packages_table.rb b/spec/support/pages/work_packages/work_packages_table.rbindex 49c0e8c5256..c13af3755da 100644--- a/spec/support/pages/work_packages/work_packages_table.rb+++ b/spec/support/pages/work_packages/work_packages_table.rb@@ -123,7 +123,7 @@ module Pagesdef expect_query_in_select_dropdown(name)page.find('.title-container').click- page.within('#querySelect') do+ page.within('#viewSelect') doexpect(page).to have_selector('.op-sidemenu--item-action', text: name)endend