CMS Sorting: Add in ability to sort CMS list pages#76
CMS Sorting: Add in ability to sort CMS list pages#76ricocynthia merged 9 commits intoordercloud-api:masterfrom
Conversation
ricocynthia
left a comment
There was a problem hiding this comment.
Instead of doing a drop down for sorting, we should handle the sorting in the CMS like we are doing for non-ecommerce products, ecommerce products, and goldbook. You'll see that when you click on Name in the list of ecomm products, it will sort by Name ascending and then the top arrow on the icon will be highlighted (vice versa for descending). Could you do that here as well please?
ricocynthia
left a comment
There was a problem hiding this comment.
also is there a reason you excluded "Created By" from being sorted?
|
No reason in particular, it seems that we auto generate most pages to begin with (making it limited with that field) but I guess adding it in is the better option |
| ASSET_TYPES, | ||
| } from '../../constants/asset-types.constants'; | ||
| import { PageContentDoc } from '../../models/page-content-doc.interface'; | ||
| import { FormBuilder, FormGroup } from '@angular/forms'; |
There was a problem hiding this comment.
it look these are no longer being used in this component, can you remove this line please?
| faSortDown = faSortDown; | ||
|
|
||
| constructor(private spinner: NgxSpinnerService) { } | ||
| constructor(private spinner: NgxSpinnerService, private formBuilder: FormBuilder) { } |
There was a problem hiding this comment.
it looks like formBuilder is no longer being used in this component, can you remove it please?
| sortBy = "!" + this.sortBy; | ||
| this.sortBy = sortBy; | ||
| } | ||
| else {this.sortBy = sortBy} |
There was a problem hiding this comment.
you don't need this else statement here. if you move this.sortBy = sortBy; out of the if and remove the else it will work the same way
| this.sortBy = sortBy; | ||
| } | ||
| else {this.sortBy = sortBy} | ||
| switch (sortBy){ |
There was a problem hiding this comment.
this can be simplified by removing the switch statement and doing something like this return this.list.sort((a, b) => (a.Doc[sortBy] > b.Doc[sortBy] ? 1 : -1)) since it looks like the sortBy value is the name of the property you need to get from the doc. you'll just need to add some logic to remove the ! if it exists in sortBy. let me know if you have any question about this, i'd be happy to walk you through a solution!
| ></fa-icon> | ||
| </fa-layers> | ||
| </th> | ||
| <th (click)="changeSortStrategy('DateUpdated')">Last Updated |
There was a problem hiding this comment.
in order to simplify the logic in changeSortStrategy(), we'll need to update the parameter to 'DateLastUpdated'
| <fa-layers class="fa-fw"> | ||
| <fa-icon | ||
| [icon]="faSortUp" | ||
| [ngClass]="{ inactive: sortBy != 'DateUpdated' }" |
There was a problem hiding this comment.
this will also need to be updated
| ></fa-icon> | ||
| <fa-icon | ||
| [icon]="faSortDown" | ||
| [ngClass]="{ inactive: sortBy != '!DateUpdated' }" |
There was a problem hiding this comment.
this will also need to be updated
| ></fa-icon> | ||
| </fa-layers> | ||
| </th> | ||
| <th (click)="changeSortStrategy('CreatedBy')">Created By |
There was a problem hiding this comment.
in order to simplify the logic in changeSortStrategy(), we'll need to update the parameter to 'Author'
| <fa-layers class="fa-fw"> | ||
| <fa-icon | ||
| [icon]="faSortUp" | ||
| [ngClass]="{ inactive: sortBy != 'CreatedBy' }" |
There was a problem hiding this comment.
this will also need to be updated
| ></fa-icon> | ||
| <fa-icon | ||
| [icon]="faSortDown" | ||
| [ngClass]="{ inactive: sortBy != '!CreatedBy' }" |
There was a problem hiding this comment.
this will also need to be updated
| changes[propertyName].previousValue !== changes[propertyName].currentValue; | ||
| } | ||
|
|
||
| changeSortStrategy(sortBy: string) { |
There was a problem hiding this comment.
can you add what this method is expected to return as well please?
This adds in the ability for users on a page-list to sort the docs by the following: Title, Date Created and Date Updated