|
|
@ -53,65 +53,45 @@ import {WorkPackageQueryStateService} from "core-components/wp-fast-table/state/ |
|
|
|
import {debugLog} from "core-app/helpers/debug_output"; |
|
|
|
import {debugLog} from "core-app/helpers/debug_output"; |
|
|
|
import {WorkPackageFiltersService} from "core-components/filters/wp-filters/wp-filters.service"; |
|
|
|
import {WorkPackageFiltersService} from "core-components/filters/wp-filters/wp-filters.service"; |
|
|
|
|
|
|
|
|
|
|
|
export class WorkPackagesSetComponent implements OnInit, OnDestroy { |
|
|
|
export abstract class WorkPackagesViewBase implements OnInit, OnDestroy { |
|
|
|
|
|
|
|
|
|
|
|
projectIdentifier = this.$state.params['projectPath'] || null; |
|
|
|
readonly $state:StateService = this.injector.get(StateService); |
|
|
|
|
|
|
|
readonly states:States = this.injector.get(States); |
|
|
|
tableInformationLoaded = false; |
|
|
|
readonly querySpace:IsolatedQuerySpace = this.injector.get(IsolatedQuerySpace); |
|
|
|
|
|
|
|
readonly authorisationService:AuthorisationService = this.injector.get(AuthorisationService); |
|
|
|
private removeTransitionSubscription:Function; |
|
|
|
readonly wpTableRefresh:WorkPackageTableRefreshService = this.injector.get(WorkPackageTableRefreshService); |
|
|
|
|
|
|
|
readonly wpTableColumns:WorkPackageTableColumnsService = this.injector.get(WorkPackageTableColumnsService); |
|
|
|
constructor(readonly injector:Injector, |
|
|
|
readonly wpTableHighlighting:WorkPackageTableHighlightingService = this.injector.get(WorkPackageTableHighlightingService); |
|
|
|
readonly states:States, |
|
|
|
readonly wpTableSortBy:WorkPackageTableSortByService = this.injector.get(WorkPackageTableSortByService); |
|
|
|
readonly querySpace:IsolatedQuerySpace, |
|
|
|
readonly wpTableGroupBy:WorkPackageTableGroupByService = this.injector.get(WorkPackageTableGroupByService); |
|
|
|
readonly authorisationService:AuthorisationService, |
|
|
|
readonly wpTableFilters:WorkPackageTableFiltersService = this.injector.get(WorkPackageTableFiltersService); |
|
|
|
readonly wpTableRefresh:WorkPackageTableRefreshService, |
|
|
|
readonly wpTableSum:WorkPackageTableSumService = this.injector.get(WorkPackageTableSumService); |
|
|
|
readonly wpTableColumns:WorkPackageTableColumnsService, |
|
|
|
readonly wpTableTimeline:WorkPackageTableTimelineService = this.injector.get(WorkPackageTableTimelineService); |
|
|
|
readonly wpTableHighlighting:WorkPackageTableHighlightingService, |
|
|
|
readonly wpTableHierarchies:WorkPackageTableHierarchiesService = this.injector.get(WorkPackageTableHierarchiesService); |
|
|
|
readonly wpTableSortBy:WorkPackageTableSortByService, |
|
|
|
readonly wpTablePagination:WorkPackageTablePaginationService = this.injector.get(WorkPackageTablePaginationService); |
|
|
|
readonly wpTableGroupBy:WorkPackageTableGroupByService, |
|
|
|
readonly wpListService:WorkPackagesListService = this.injector.get(WorkPackagesListService); |
|
|
|
readonly wpTableFilters:WorkPackageTableFiltersService, |
|
|
|
readonly wpListChecksumService:WorkPackagesListChecksumService = this.injector.get(WorkPackagesListChecksumService); |
|
|
|
readonly wpTableSum:WorkPackageTableSumService, |
|
|
|
readonly loadingIndicatorService:LoadingIndicatorService = this.injector.get(LoadingIndicatorService); |
|
|
|
readonly wpTableTimeline:WorkPackageTableTimelineService, |
|
|
|
readonly $transitions:TransitionService = this.injector.get(TransitionService); |
|
|
|
readonly wpTableHierarchies:WorkPackageTableHierarchiesService, |
|
|
|
readonly I18n:I18nService = this.injector.get(I18nService); |
|
|
|
readonly wpTablePagination:WorkPackageTablePaginationService, |
|
|
|
readonly wpStaticQueries:WorkPackageStaticQueriesService = this.injector.get(WorkPackageStaticQueriesService); |
|
|
|
readonly wpListService:WorkPackagesListService, |
|
|
|
|
|
|
|
readonly wpFilters:WorkPackageFiltersService, |
|
|
|
constructor(protected injector:Injector) { |
|
|
|
readonly wpListChecksumService:WorkPackagesListChecksumService, |
|
|
|
|
|
|
|
readonly loadingIndicator:LoadingIndicatorService, |
|
|
|
|
|
|
|
readonly $transitions:TransitionService, |
|
|
|
|
|
|
|
readonly $state:StateService, |
|
|
|
|
|
|
|
readonly I18n:I18nService, |
|
|
|
|
|
|
|
readonly wpStaticQueries:WorkPackageStaticQueriesService) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
ngOnInit() { |
|
|
|
// Listen to changes on the query state objects
|
|
|
|
// Listen to changes on the query state objects
|
|
|
|
this.setupQueryObservers(); |
|
|
|
this.setupQueryObservers(); |
|
|
|
|
|
|
|
|
|
|
|
this.initialQueryLoading(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Listen for refresh changes
|
|
|
|
// Listen for refresh changes
|
|
|
|
this.setupRefreshObserver(); |
|
|
|
this.setupRefreshObserver(); |
|
|
|
|
|
|
|
|
|
|
|
this.updateQueryOnParamsChanges(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ngOnDestroy():void { |
|
|
|
ngOnDestroy():void { |
|
|
|
if (this.removeTransitionSubscription) { |
|
|
|
|
|
|
|
this.removeTransitionSubscription(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.wpTableRefresh.clear('Table controller scope destroyed.'); |
|
|
|
this.wpTableRefresh.clear('Table controller scope destroyed.'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private setupQueryObservers() { |
|
|
|
private setupQueryObservers() { |
|
|
|
this.querySpace.tableRendering.onQueryUpdated.values$() |
|
|
|
|
|
|
|
.pipe( |
|
|
|
|
|
|
|
take(1) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.subscribe(() => this.tableInformationLoaded = true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.querySpace.ready.fireOnStateChange(this.wpTablePagination.state, |
|
|
|
this.querySpace.ready.fireOnStateChange(this.wpTablePagination.state, |
|
|
|
'Query loaded').values$().pipe( |
|
|
|
'Query loaded').values$().pipe( |
|
|
|
untilComponentDestroyed(this), |
|
|
|
untilComponentDestroyed(this), |
|
|
@ -119,7 +99,7 @@ export class WorkPackagesSetComponent implements OnInit, OnDestroy { |
|
|
|
).subscribe(([pagination, query]) => { |
|
|
|
).subscribe(([pagination, query]) => { |
|
|
|
if (this.wpListChecksumService.isQueryOutdated(query, pagination)) { |
|
|
|
if (this.wpListChecksumService.isQueryOutdated(query, pagination)) { |
|
|
|
this.wpListChecksumService.update(query, pagination); |
|
|
|
this.wpListChecksumService.update(query, pagination); |
|
|
|
this.updateResultsVisibly(); |
|
|
|
this.refresh(true, false); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -133,13 +113,23 @@ export class WorkPackagesSetComponent implements OnInit, OnDestroy { |
|
|
|
this.setupChangeObserver(this.wpTableHighlighting); |
|
|
|
this.setupChangeObserver(this.wpTableHighlighting); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setupChangeObserver(service:WorkPackageQueryStateService, firstPage:boolean = false) { |
|
|
|
/** |
|
|
|
|
|
|
|
* Listen to changes in the given service and reload the query / results if |
|
|
|
|
|
|
|
* the service requests that. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param service Work package query state service to listento |
|
|
|
|
|
|
|
* @param firstPage If the service requests a change, load the first page |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
protected setupChangeObserver(service:WorkPackageQueryStateService, firstPage:boolean = false) { |
|
|
|
const queryState = this.querySpace.query; |
|
|
|
const queryState = this.querySpace.query; |
|
|
|
|
|
|
|
|
|
|
|
this.querySpace.ready.fireOnStateChange(service.state, 'Query loaded').values$().pipe( |
|
|
|
this.querySpace.ready |
|
|
|
untilComponentDestroyed(this), |
|
|
|
.fireOnStateChange(service.state, 'Query loaded') |
|
|
|
filter(() => queryState.hasValue() && service.hasChanged(queryState.value!)) |
|
|
|
.values$() |
|
|
|
).subscribe(() => { |
|
|
|
.pipe( |
|
|
|
|
|
|
|
untilComponentDestroyed(this), |
|
|
|
|
|
|
|
filter(() => queryState.hasValue() && service.hasChanged(queryState.value!)) |
|
|
|
|
|
|
|
).subscribe(() => { |
|
|
|
const newQuery = queryState.value!; |
|
|
|
const newQuery = queryState.value!; |
|
|
|
const triggerUpdate = service.applyToQuery(newQuery); |
|
|
|
const triggerUpdate = service.applyToQuery(newQuery); |
|
|
|
this.querySpace.query.putValue(newQuery); |
|
|
|
this.querySpace.query.putValue(newQuery); |
|
|
@ -158,68 +148,30 @@ export class WorkPackagesSetComponent implements OnInit, OnDestroy { |
|
|
|
* Setup the listener for members of the table to request a refresh of the entire table |
|
|
|
* Setup the listener for members of the table to request a refresh of the entire table |
|
|
|
* through the refresh service. |
|
|
|
* through the refresh service. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
setupRefreshObserver() { |
|
|
|
protected setupRefreshObserver() { |
|
|
|
this.wpTableRefresh.state.values$('Refresh listener in wp-list.controller').pipe( |
|
|
|
this.wpTableRefresh.state.values$('Refresh listener in wp-set.component').pipe( |
|
|
|
untilComponentDestroyed(this), |
|
|
|
untilComponentDestroyed(this), |
|
|
|
auditTime(20) |
|
|
|
auditTime(20) |
|
|
|
).subscribe(([refreshVisibly, firstPage]) => { |
|
|
|
).subscribe(([refreshVisibly, firstPage]) => { |
|
|
|
if (refreshVisibly) { |
|
|
|
debugLog('Refreshing work package results.'); |
|
|
|
debugLog('Refreshing work package results visibly.'); |
|
|
|
this.refresh(refreshVisibly, firstPage); |
|
|
|
this.updateResultsVisibly(firstPage); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
debugLog('Refreshing work package results in the background.'); |
|
|
|
|
|
|
|
this.updateResults(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
updateResults():Promise<WorkPackageCollectionResource> { |
|
|
|
|
|
|
|
return this.wpListService.reloadCurrentResultsList(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateResultsVisibly(firstPage:boolean = false) { |
|
|
|
|
|
|
|
if (firstPage) { |
|
|
|
|
|
|
|
this.loadingIndicator.table.promise = this.updateToFirstResultsPage(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.loadingIndicator.table.promise = this.updateResults(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateToFirstResultsPage():Promise<WorkPackageCollectionResource> { |
|
|
|
|
|
|
|
return this.wpListService.loadCurrentResultsListFirstPage(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private updateQueryOnParamsChanges() { |
|
|
|
/** |
|
|
|
// Listen for param changes
|
|
|
|
* Refresh the set of results, |
|
|
|
this.removeTransitionSubscription = this.$transitions.onSuccess({}, (transition):any => { |
|
|
|
* showing the loading indicator if visibly is set. |
|
|
|
let options = transition.options(); |
|
|
|
* |
|
|
|
|
|
|
|
* @param visibly Set true when desiring the loading indicator |
|
|
|
// Avoid performing any changes when we're going to reload
|
|
|
|
* @param firstPage Reload the page to first page. |
|
|
|
if (options.reload || (options.custom && options.custom.notify === false)) { |
|
|
|
*/ |
|
|
|
return true; |
|
|
|
public abstract refresh(visibly:boolean, firstPage:boolean):Promise<unknown>; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const params = transition.params('to'); |
|
|
|
|
|
|
|
let newChecksum = this.wpListService.getCurrentQueryProps(params); |
|
|
|
|
|
|
|
let newId = params.query_id && parseInt(params.query_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.wpListChecksumService |
|
|
|
|
|
|
|
.executeIfOutdated(newId, |
|
|
|
|
|
|
|
newChecksum, |
|
|
|
|
|
|
|
() => this.loadCurrentQuery()); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected initialQueryLoading() { |
|
|
|
|
|
|
|
this.wpTableRefresh.clear('Impending query loading.'); |
|
|
|
|
|
|
|
this.loadCurrentQuery(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected loadCurrentQuery():Promise<any> { |
|
|
|
|
|
|
|
let loadingPromise = this.wpListService.loadCurrentQueryFromParams(this.projectIdentifier); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.loadingIndicator.table.promise = loadingPromise; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return loadingPromise; |
|
|
|
/** |
|
|
|
} |
|
|
|
* Set the loading indicator for this set instance |
|
|
|
|
|
|
|
* @param promise |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
protected abstract set loadingIndicator(promise:Promise<unknown>); |
|
|
|
} |
|
|
|
} |