Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | 20x 60x 60x 60x 60x 60x 60x 60x 60x 20x 19x 26x 23x 25x 8x 8x 9x 9x 8x 9x 9x 9x 3x 3x 20x 10x 10x 1x 1x 9x 9x 10x 10x 10x 3x 3x 7x 7x 10x 20x | import { JobStatus, JobStatusMeta } from "./job.interface"; export class JobsListOptions { private page: number = 0; private itemsPerPage: number = 10; private jobStatus: keyof typeof JobStatus | null = null; private jobStatusMeta: keyof typeof JobStatusMeta | null = null; private currentSort: string; private mustReload: boolean | null = null; constructor(jobsStatus: string | null = null, jobStatusMeta: string | null = null, sort: string | null = null) { this.jobStatus = jobsStatus as keyof typeof JobStatus; this.jobStatusMeta = jobStatusMeta as keyof typeof JobStatusMeta; this.currentSort = sort ?? 'createdAt,desc'; } getCurrentPage(): number { return this.page; } getItemsPerPage(): number { return this.itemsPerPage; } getStatus() :string | null{ return this.jobStatus; } getStatusMeta() :string | null{ return this.jobStatusMeta; } getSort(): string { return this.currentSort; } getMustReload(): boolean | null { return this.mustReload; } equals(jobsListOptions: JobsListOptions) :boolean { return this.page === jobsListOptions.getCurrentPage() && this.itemsPerPage === jobsListOptions.getItemsPerPage() && this.jobStatus === jobsListOptions.getStatus() && this.jobStatusMeta === jobsListOptions.getStatusMeta() && this.currentSort == jobsListOptions.getSort(); } changePagination(page: number, itemsPerPage: number |null): this { this.page = page; if(itemsPerPage !== null) { this.itemsPerPage = itemsPerPage; } return this; } forceReload(force: boolean | null): this { this.mustReload = force; return this; } sort(sort: string): this { this.currentSort = sort; return this; } /** * * @param status the new job status as a string (keyof JobStatus) * @param statusMeta the new job "meta" status as a string (keyof JobStatusMeta) * @returns true if changed, false otherwise */ filter(status: string | null, statusMeta: string | null): this { // having two properties to handle status or statusMeta filters may seem unclean, as they are exclusive at the moment // but it actually allow us to change our mind in the future and use both filters cumulatively if(status !== null) { const newStatus: keyof typeof JobStatus = status as keyof typeof JobStatus; // clicking on the current status removes the filter if(newStatus === this.jobStatus) { this.jobStatus = null; console.log('removing current status'); } else { this.jobStatus = status as keyof typeof JobStatus; console.log('setting currentstatus ', this.jobStatus); } this.jobStatusMeta = null; } else { const newStatusFilter: keyof typeof JobStatusMeta = statusMeta as keyof typeof JobStatusMeta; // clicking on the current status filter removes the filter if(newStatusFilter === this.jobStatusMeta) { this.jobStatusMeta = null; console.log('removing current status filter'); } else { this.jobStatusMeta = statusMeta as keyof typeof JobStatusMeta; console.log('setting currentstatus filter ', this.jobStatusMeta); } this.jobStatus = null; } return this; } } |