Merge pull request #11587 from AllForNothing/sort-name

Fix repo list sorting and filtering bug
This commit is contained in:
Will Sun 2020-04-14 17:34:39 +08:00 committed by GitHub
commit faf554f642
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 6 deletions

View File

@ -21,7 +21,13 @@ import {
UserPermissionService, USERSTATICPERMISSION UserPermissionService, USERSTATICPERMISSION
} from "../../../../../lib/services"; } from "../../../../../lib/services";
import { ClrDatagridStateInterface } from '@clr/angular'; import { ClrDatagridStateInterface } from '@clr/angular';
import { DEFAULT_PAGE_SIZE, calculatePage, dbEncodeURIComponent } from '../../../../../lib/utils/utils'; import {
DEFAULT_PAGE_SIZE,
calculatePage,
dbEncodeURIComponent,
doFiltering,
doSorting
} from '../../../../../lib/utils/utils';
import { AppConfigService } from "../../../../services/app-config.service"; import { AppConfigService } from "../../../../services/app-config.service";
class InitTag { class InitTag {
@ -130,6 +136,9 @@ export class ArtifactTagComponent implements OnInit, OnDestroy {
} }
} }
this.currentTags = res.body; this.currentTags = res.body;
// Do customising filtering and sorting
this.currentTags = doFiltering<Tag>(this.currentTags, state);
this.currentTags = doSorting<Tag>(this.currentTags, state);
}, error => { }, error => {
this.errorHandlerService.error(error); this.errorHandlerService.error(error);
}); });

View File

@ -25,11 +25,9 @@
<div *ngIf="!isCardView" class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div *ngIf="!isCardView" class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<clr-datagrid (clrDgRefresh)="clrLoad($event)" [clrDgLoading]="loading" [(clrDgSelected)]="selectedRow"> <clr-datagrid (clrDgRefresh)="clrLoad($event)" [clrDgLoading]="loading" [(clrDgSelected)]="selectedRow">
<clr-dg-action-bar> <clr-dg-action-bar>
<!-- <button *ngIf="withAdmiral" type="button" class="btn btn-secondary" (click)="provisionItemEvent($event, selectedRow[0])" [disabled]="!(selectedRow.length===1 && hasProjectAdminRole)"><clr-icon shape="times" size="16"></clr-icon>&nbsp;{{'REPOSITORY.DEPLOY' | translate}}</button>
<button *ngIf="withAdmiral" type="button" class="btn btn-secondary" (click)="itemAddInfoEvent($event, selectedRow[0])" [disabled]="!(selectedRow.length===1 && hasProjectAdminRole)"><clr-icon shape="times" size="16"></clr-icon>&nbsp;{{'REPOSITORY.ADDITIONAL_INFO' | translate}}</button> -->
<button type="button" class="btn btn-secondary" (click)="deleteRepos(selectedRow)" [disabled]="!(selectedRow.length)|| !hasDeleteRepositoryPermission"><clr-icon shape="times" size="16"></clr-icon>&nbsp;{{'REPOSITORY.DELETE' | translate}}</button> <button type="button" class="btn btn-secondary" (click)="deleteRepos(selectedRow)" [disabled]="!(selectedRow.length)|| !hasDeleteRepositoryPermission"><clr-icon shape="times" size="16"></clr-icon>&nbsp;{{'REPOSITORY.DELETE' | translate}}</button>
</clr-dg-action-bar> </clr-dg-action-bar>
<clr-dg-column [clrDgField]="'q'" [clrDgSortBy]="'name'">{{'REPOSITORY.NAME' | translate}}</clr-dg-column> <clr-dg-column [clrDgField]="'name'">{{'REPOSITORY.NAME' | translate}}</clr-dg-column>
<clr-dg-column>{{'REPOSITORY.ARTIFACTS_COUNT' | translate}}</clr-dg-column> <clr-dg-column>{{'REPOSITORY.ARTIFACTS_COUNT' | translate}}</clr-dg-column>
<clr-dg-column [clrDgSortBy]="'pull_count'">{{'REPOSITORY.PULL_COUNT' | translate}}</clr-dg-column> <clr-dg-column [clrDgSortBy]="'pull_count'">{{'REPOSITORY.PULL_COUNT' | translate}}</clr-dg-column>
<clr-dg-placeholder>{{'REPOSITORY.PLACEHOLDER' | translate }}</clr-dg-placeholder> <clr-dg-placeholder>{{'REPOSITORY.PLACEHOLDER' | translate }}</clr-dg-placeholder>

View File

@ -24,7 +24,14 @@ import {
UserPermissionService, USERSTATICPERMISSION UserPermissionService, USERSTATICPERMISSION
} from "../../../lib/services"; } from "../../../lib/services";
import { FilterComponent } from "../../../lib/components/filter/filter.component"; import { FilterComponent } from "../../../lib/components/filter/filter.component";
import { calculatePage, clone, DEFAULT_PAGE_SIZE, dbEncodeURIComponent } from "../../../lib/utils/utils"; import {
calculatePage,
clone,
DEFAULT_PAGE_SIZE,
dbEncodeURIComponent,
doFiltering,
doSorting
} from "../../../lib/utils/utils";
import { IServiceConfig, SERVICE_CONFIG } from "../../../lib/entities/service.config"; import { IServiceConfig, SERVICE_CONFIG } from "../../../lib/entities/service.config";
import { ErrorHandler } from "../../../lib/utils/error-handler"; import { ErrorHandler } from "../../../lib/utils/error-handler";
import { ConfirmationButtons, ConfirmationState, ConfirmationTargets } from "../../../lib/entities/shared.const"; import { ConfirmationButtons, ConfirmationState, ConfirmationTargets } from "../../../lib/entities/shared.const";
@ -372,7 +379,9 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit, OnDestroy
this.totalCount = +repo.headers.get('x-total-count'); this.totalCount = +repo.headers.get('x-total-count');
this.repositories = repo.body; this.repositories = repo.body;
// Do customising filtering and sorting
this.repositories = doFiltering<NewRepository>(this.repositories, state);
this.repositories = doSorting<NewRepository>(this.repositories, state);
this.signedCon = {}; this.signedCon = {};
this.loading = false; this.loading = false;
}, error => { }, error => {