Skip to content

Commit

Permalink
Add listed results for home search
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorHugoDuranS committed Jun 6, 2024
1 parent c44fce9 commit 95645f5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/app/shared/object-list/object-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
(next)="goNext()">
<ul *ngIf="objects?.hasSucceeded" class="list-unstyled" [ngClass]="{'ml-4': selectable}">
<li *ngFor="let object of objects?.payload?.page; let i = index; let last = last" class="mt-4 mb-4 d-flex" [class.border-bottom]="hasBorder && !last" [attr.data-test]="'list-object' | dsBrowserOnly">
<div class="p-1" *ngIf="getNumber(i)">
<span class="badge">{{getNumber(i)}}</span>
</div>
<ds-selectable-list-item-control *ngIf="selectable" [index]="i"
[object]="object"
[selectionConfig]="selectionConfig"
Expand Down
6 changes: 6 additions & 0 deletions src/app/shared/object-list/object-list.component.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
ds-selectable-list-item-control {
z-index: 1
}
span {
font-size: small;
color: #207698;
border: #207698 2px solid;
background-color: white;
}
17 changes: 17 additions & 0 deletions src/app/shared/object-list/object-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { SelectableListService } from './selectable-list/selectable-list.service
import { ViewMode } from '../../core/shared/view-mode.model';
import { Context } from '../../core/shared/context.model';
import { CollectionElementLinkType } from '../object-collection/collection-element-link.type';
import {hasValue} from "../empty.util";

@Component({
changeDetection: ChangeDetectionStrategy.Default,
Expand Down Expand Up @@ -227,4 +228,20 @@ export class ObjectListComponent {
this.next.emit(true);
}

/**
* @Description check if it is valid to return the number
* */
get isValidForShowItemNumbered() {
return hasValue(this.objects?.payload?.currentPage) && hasValue(this.objects?.payload?.elementsPerPage);
}

/**
* @Description return the current position of the item in the search
* */
getNumber(index: number): number {
if (this.isValidForShowItemNumbered) {
return ((this.objects?.payload?.currentPage - 1) * this.objects?.payload?.elementsPerPage) + (index + 1);
}
return null;
}
}

0 comments on commit 95645f5

Please sign in to comment.