Skip to content

Commit

Permalink
adjusts
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Jan 31, 2024
1 parent 4c0c70a commit c83e3c6
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class <%= componentName %> implements OnInit {
if (query && <%= componentName %>.NOT_SORTABLE_FIELDS_AFTER_SEARCH.includes(this.predicate)) {
<%_ if (notSortableFieldsAfterSearchFieldNames.includes(primaryKey.name)) { _%>
this.predicate = '';
<%_ } else { _%>
<%_ } else if (primaryKey.typeLong && primaryKey.autoGenerate) { _%>
this.predicate = '<%- primaryKey.name %>';
this.ascending = true;
<%_ } _%>
Expand Down Expand Up @@ -254,9 +254,12 @@ export class <%= componentName %> implements OnInit {
this.page = +(page ?? 1);
<%_ } _%>
const sort = (params.get(SORT) ?? data[ DEFAULT_SORT_DATA ])?.split(',');
if (sort) {
if (sort && sort.length > 1) {
this.predicate = sort[ 0 ];
this.ascending = sort[ 1 ] === ASC;
} else {
this.predicate = '';
this.ascending = undefined;
}
<%_ if (jpaMetamodelFiltering && paginationPagination) { _%>
this.filters.initializeFromParams(params);
Expand Down Expand Up @@ -396,11 +399,10 @@ export class <%= componentName %> implements OnInit {
}

protected getSortQueryParam(predicate = this.predicate, ascending = this.ascending): string[] {
const ascendingQueryParam = ascending ? ASC : DESC;
if (predicate === '' || ascending === undefined) {
return [];
} else {
return [predicate + ',' + ascendingQueryParam];
return [`${predicate},${ascending ? ASC : DESC}`];
}
}
}

0 comments on commit c83e3c6

Please sign in to comment.