Skip to content

Commit

Permalink
fix(admin-ui): Correctly sort assets
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed May 7, 2019
1 parent 1c543db commit e57450b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { PaginationInstance } from 'ngx-pagination';
import { combineLatest, Observable } from 'rxjs';
import { debounceTime, map, takeUntil } from 'rxjs/operators';
import { SortOrder } from 'shared/generated-shop-types';
import { GetAssetList } from 'shared/generated-types';

import { BaseListComponent } from '../../../common/base-list.component';
Expand Down Expand Up @@ -40,6 +41,9 @@ export class AssetListComponent extends BaseListComponent<GetAssetList.Query, Ge
contains: this.searchTerm.value,
},
},
sort: {
createdAt: SortOrder.DESC,
},
},
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FormControl } from '@angular/forms';
import { PaginationInstance } from 'ngx-pagination';
import { Observable, Subject } from 'rxjs';
import { debounceTime, map, takeUntil, tap } from 'rxjs/operators';
import { Asset, GetAssetList } from 'shared/generated-types';
import { Asset, GetAssetList, SortOrder } from 'shared/generated-types';

import { _ } from '../../../core/providers/i18n/mark-for-extraction';
import { NotificationService } from '../../../core/providers/notification/notification.service';
Expand All @@ -21,7 +21,7 @@ import { Dialog } from '../../../shared/providers/modal/modal.service';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AssetPickerDialogComponent implements OnInit, OnDestroy, Dialog<Asset[]> {
assets$: Observable<Asset[]>;
assets$: Observable<GetAssetList.Items[]>;
paginationConfig: PaginationInstance = {
currentPage: 1,
itemsPerPage: 25,
Expand Down Expand Up @@ -106,6 +106,9 @@ export class AssetPickerDialogComponent implements OnInit, OnDestroy, Dialog<Ass
contains: searchTerm,
},
},
sort: {
createdAt: SortOrder.DESC,
},
},
});
}
Expand Down
1 change: 1 addition & 0 deletions admin-ui/src/app/data/definitions/product-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import gql from 'graphql-tag';
export const ASSET_FRAGMENT = gql`
fragment Asset on Asset {
id
createdAt
name
fileSize
mimeType
Expand Down
4 changes: 4 additions & 0 deletions admin-ui/src/app/data/providers/product-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
GetProductWithVariants,
RemoveOptionGroupFromProduct,
SearchProducts,
SortOrder,
UpdateProduct,
UpdateProductInput,
UpdateProductVariantInput,
Expand Down Expand Up @@ -184,6 +185,9 @@ export class ProductDataService {
options: {
skip,
take,
sort: {
createdAt: SortOrder.DESC,
},
},
});
}
Expand Down

0 comments on commit e57450b

Please sign in to comment.