Merge pull request #6515 from opf/fix/28187/query-default-names

[28187] Fix showing default query names

[ci skip]
pull/6518/head
Oliver Günther 6 years ago committed by GitHub
commit b9857d6959
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      frontend/src/app/components/angular/tracking-functions.ts
  2. 6
      frontend/src/app/components/filters/filter-container/filter-container.directive.ts
  3. 4
      frontend/src/app/components/filters/query-filter/query-filter.component.html
  4. 8
      frontend/src/app/components/filters/query-filter/query-filter.component.ts
  5. 2
      frontend/src/app/components/filters/query-filters/query-filters.component.html
  6. 2
      frontend/src/app/components/filters/query-filters/query-filters.component.ts
  7. 17
      frontend/src/app/components/routing/wp-list/wp-list.component.ts
  8. 5
      frontend/src/app/components/wp-fast-table/handlers/state/rows-transformer.ts
  9. 4
      frontend/src/app/components/wp-list/wp-list-checksum.service.ts
  10. 12
      frontend/src/app/components/wp-query-select/wp-query-select-dropdown.component.ts
  11. 5
      frontend/src/app/components/wp-table/wp-table.directive.ts
  12. 4
      frontend/src/app/helpers/debug_output.ts

@ -10,6 +10,10 @@ export namespace AngularTrackingHelpers {
return bothNil || (!!a && !!b && a.name === b.name);
}
export function trackByName(i:number, item:any) {
return _.get(item, 'name');
}
export function compareByHref<T extends HalResource>(a:T|undefined|null, b:T|undefined|null):boolean {
const bothNil = !a && !b;
return bothNil || (!!a && !!b && a.$href === b.$href);

@ -26,7 +26,7 @@
// See doc/COPYRIGHT.rdoc for more details.
// ++
import {Component, Inject, OnDestroy} from '@angular/core';
import {Component, OnDestroy} from '@angular/core';
import {WorkPackageTableFiltersService} from 'core-components/wp-fast-table/state/wp-table-filters.service';
import {WorkPackageTableFilters} from 'core-components/wp-fast-table/wp-table-filters';
import {componentDestroyed} from 'ng2-rx-componentdestroyed';
@ -43,7 +43,9 @@ export class WorkPackageFilterContainerComponent implements OnDestroy {
readonly wpFiltersService:WorkPackageFiltersService) {
this.wpTableFilters
.observeUntil(componentDestroyed(this))
.subscribe(() => this.filters = this.wpTableFilters.currentState);
.subscribe(() => {
this.filters = this.wpTableFilters.currentState;
});
}
ngOnDestroy() {

@ -31,8 +31,8 @@
</div>
<!-- Values -->
<ng-container *ngIf="showValuesInput">
<div class="advanced-filters--filter-value" [ngSwitch]="filter.currentSchema!.values!.type">
<ng-container *ngIf="showValuesInput && valueType">
<div class="advanced-filters--filter-value" [ngSwitch]="valueType">
<filter-integer-value *ngSwitchCase="'[1]Integer'"
(filterChanged)="onFilterUpdated($event)"
[filter]="filter"></filter-integer-value>

@ -73,6 +73,14 @@ export class QueryFilterComponent implements OnInit, OnDestroy {
this.deactivateFilter.emit(this.filter);
}
public get valueType():string|undefined {
if (this.filter.currentSchema && this.filter.currentSchema.values) {
return this.filter.currentSchema.values.type;
}
return undefined;
}
ngOnInit() {
this.eeShowBanners = jQuery('body').hasClass('ee-banners-visible');
this.availableOperators = this.filter.schema.availableOperators;

@ -8,7 +8,7 @@
</a>
<ul class="advanced-filters--filters">
<ng-container *ngFor="let filter of filters.current; trackBy: compareByName ; let index = index">
<ng-container *ngFor="let filter of filters.current; trackBy: trackByName ; let index = index">
<li id="filter_{{filter.id}}"
query-filter
[filter]="filter"

@ -55,7 +55,7 @@ export class QueryFiltersComponent implements OnInit, OnChanges, OnDestroy {
public remainingFilters:any[] = [];
public eeShowBanners:boolean = false;
public focusElementIndex:number = 0;
public compareByName = AngularTrackingHelpers.compareByName;
public compareByName = AngularTrackingHelpers.trackByName;
public text = {
open_filter: this.I18n.t('js.filter.description.text_open_filter'),

@ -114,7 +114,13 @@ export class WorkPackagesListComponent implements OnInit, OnDestroy {
this.setupRefreshObserver();
// Listen for param changes
this.$transitions.onSuccess({}, (transition) => {
this.$transitions.onSuccess({}, (transition):any => {
let options = transition.options();
// Avoid performing any changes when we're going to reload
if (options.reload || (options.custom && options.custom.notify === false)) {
return true;
}
const params = transition.params('to');
let newChecksum = this.wpListService.getCurrentQueryProps(params);
@ -162,15 +168,6 @@ export class WorkPackagesListComponent implements OnInit, OnDestroy {
this.currentQuery = query;
});
// Update the checksum and url query params whenever a new query is loaded
this.states.query.resource.values$().pipe(
untilComponentDestroyed(this),
distinctUntilChanged((query, formerQuery) => query.id === formerQuery.id),
withLatestFrom(this.wpTablePagination.state.values$())
).subscribe(([query, pagination]) => {
this.wpListChecksumService.setToQuery(query, pagination);
});
this.tableState.ready.fireOnStateChange(this.wpTablePagination.state,
'Query loaded').values$().pipe(
untilComponentDestroyed(this),

@ -21,12 +21,7 @@ export class RowsTransformer {
takeUntil(this.tableState.stopAllSubscriptions)
)
.subscribe((rows:WorkPackageResource[]) => {
var t0 = performance.now();
table.initialSetup(rows);
var t1 = performance.now();
debugLog('[RowTransformer] Reinitialized in ' + (t1 - t0) + ' milliseconds.');
});
// Refresh a single row if it exists

@ -87,7 +87,7 @@ export class WorkPackagesListChecksumService {
public executeIfOutdated(newId:number,
newChecksum:string | null,
callback:Function) {
if (this.isOutdated(newId, newChecksum)) {
if (this.isUninitialized() || this.isOutdated(newId, newChecksum)) {
this.set(newId, newChecksum);
callback();
@ -146,6 +146,6 @@ export class WorkPackagesListChecksumService {
private maintainUrlQueryState(id:string | number | null, checksum:string | null) {
this.visibleChecksum = checksum;
this.$state.go('.', {query_props: checksum, query_id: id}, {notify: false});
this.$state.go('.', {query_props: checksum, query_id: id}, {custom: { notify: false } });
}
}

@ -399,10 +399,18 @@ export class WorkPackageQuerySelectDropdownComponent implements OnInit, OnDestro
private loadQuery(item:IAutocompleteItem) {
const params = this.getQueryParams(item);
const currentId = _.toString(this.$state.params.query_id);
let opts = {reload: false};
let opts = { reload: false };
if (item.identifier || params.query_id && params.query_id === currentId.toString()) {
const isStaticItem = !!item.identifier;
const isSameItem = params.query_id && params.query_id === currentId.toString();
// Ensure we're loading the query
if (isStaticItem || isSameItem) {
this.wpListChecksumService.clear();
}
if (isSameItem) {
opts.reload = true;
}

@ -172,17 +172,12 @@ export class WorkPackagesTableController implements OnInit, OnDestroy {
}
public registerTimeline(controller:WorkPackageTimelineTableController, body:HTMLElement) {
let t0 = performance.now();
const tbody = this.$element.find('.work-package--results-tbody');
this.workPackageTable = new WorkPackageTable(this.injector, this.$element[0], tbody[0], body, controller, this.configuration);
this.tbody = tbody;
controller.workPackageTable = this.workPackageTable;
new TableHandlerRegistry(this.injector).attachTo(this.workPackageTable);
this.cdRef.detectChanges();
let t1 = performance.now();
debugLog('Render took ', t1 - t0, ' milliseconds.');
}
public openTableConfigurationModal() {

@ -25,7 +25,7 @@ export function timeOutput(msg:string, cb:() => void):any {
var results = cb();
var t1 = performance.now();
console.log(`%c${msg} [completed in ${(t1 - t0)} milliseconds.`, 'color:#00A093;');
console.log(`%c${msg} completed in ${(t1 - t0)} milliseconds.`, 'color:#00A093;');
return results;
} else {
@ -39,7 +39,7 @@ export function asyncTimeOutput(msg:string, promise:Promise<any>):any {
return promise.then(() => {
var t1 = performance.now();
console.log(`%c${msg} [completed in ${(t1 - t0)} milliseconds.`, 'color:#00A093;');
console.log(`%c${msg} completed in ${(t1 - t0)} milliseconds.`, 'color:#00A093;');
});
} else {
return promise;

Loading…
Cancel
Save