Skip to content

Commit c1c5c6a

Browse files
committed
formatting changes
1 parent f75b4b0 commit c1c5c6a

6 files changed

Lines changed: 11 additions & 31 deletions

File tree

src/app/courses/courses.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,7 @@ export class CoursesComponent implements OnInit, OnChanges, AfterViewInit, OnDes
307307

308308
/** Whether the number of selected elements matches the total number of rows. */
309309
isAllSelected() {
310-
const visibleItems = itemsShown(this.paginator);
311-
return this.selection.selected.length === visibleItems;
310+
return this.selection.selected.length === itemsShown(this.paginator);
312311
}
313312

314313
/** Selects all rows if they are not all selected; otherwise clear selection. */

src/app/manager-dashboard/manager-fetch.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ export class ManagerFetchComponent implements OnInit, AfterViewInit {
6262

6363
/** Whether the number of selected elements matches the total number of rows. */
6464
isAllSelected() {
65-
const visibleItems = itemsShown(this.paginator);
66-
return this.selection.selected.length === visibleItems;
65+
return this.selection.selected.length === itemsShown(this.paginator);
6766
}
6867

6968
/** Selects all rows if they are not all selected; otherwise clear selection. */

src/app/meetups/meetups.component.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { takeUntil } from 'rxjs/operators';
1313
import { MeetupService } from './meetups.service';
1414
import { StateService } from '../shared/state.service';
1515
import { DialogsLoadingService } from '../shared/dialogs/dialogs-loading.service';
16-
import { findByIdInArray, itemsShown } from '../shared/utils';
16+
import { findByIdInArray, itemsShown } from '../shared/utils';
1717

1818
@Component({
1919
templateUrl: './meetups.component.html',
@@ -87,10 +87,9 @@ export class MeetupsComponent implements OnInit, AfterViewInit, OnDestroy {
8787
this.meetups.sort = this.sort;
8888
}
8989

90-
isAllSelected() {
91-
const visibleItems = itemsShown(this.paginator);
92-
return this.selection.selected.length === visibleItems;
93-
}
90+
isAllSelected() {
91+
return this.selection.selected.length === itemsShown(this.paginator);
92+
}
9493
onPaginateChange(e: PageEvent) {
9594
this.selection.clear();
9695
}

src/app/resources/resources.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ export class ResourcesComponent implements OnInit, AfterViewInit, OnDestroy {
202202

203203
/** Whether the number of selected elements matches the total number of rows. */
204204
isAllSelected() {
205-
const visibleItems = itemsShown(this.paginator);
206-
return this.selection.selected.length === visibleItems;
205+
return this.selection.selected.length === itemsShown(this.paginator);
207206
}
208207

209208
applyResFilter(filterResValue: string) {

src/app/shared/utils.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export const styleVariables: any = {
4949

5050
export const filterById = (array = [], id: string) => array.filter(item => item._id !== id);
5151

52+
export const itemsShown = (paginator: any) => Math.min(paginator.length - (paginator.pageIndex * paginator.pageSize), paginator.pageSize);
53+
5254
export const isInMap = (tag: string, map: Map<string, boolean>) => map.get(tag);
5355

5456
export const mapToArray = (map: Map<string, boolean>, equalValue?) => {
@@ -79,26 +81,9 @@ export const urlToParamObject = (url: string) => url.split(';').reduce((params,
7981

8082
export const toProperCase = (string: string) => `${string.slice(0, 1).toUpperCase()}${string.slice(1)}`;
8183

82-
export const itemsShown = (paginator?: { length: number; pageIndex: number; pageSize: number }) => {
83-
if (!paginator) {
84-
return 0;
85-
}
86-
const remaining = paginator.length - (paginator.pageIndex * paginator.pageSize);
87-
return Math.min(Math.max(remaining, 0), paginator.pageSize);
88-
};
89-
9084
export const stringToHex = (string: string) => string.split('').map(char => char.charCodeAt(0).toString(16)).join('');
9185

92-
export const hexToString = (hex: string) => {
93-
if (!hex) {
94-
return '';
95-
}
96-
const matches = hex.match(/.{1,2}/g);
97-
if (!matches) {
98-
return '';
99-
}
100-
return matches.map(byte => String.fromCharCode(parseInt(byte, 16))).join('');
101-
};
86+
export const hexToString = (string: string) => string.match(/.{1,2}/g).map(hex => String.fromCharCode(parseInt(hex, 16))).join('');
10287

10388
export const ageFromBirthDate = (currentTime: number, birthDate: string) => {
10489
const now = new Date(currentTime);

src/app/users/users-table.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ export class UsersTableComponent implements OnInit, OnDestroy, AfterViewInit, On
158158
}
159159

160160
isAllSelected() {
161-
const visibleItems = itemsShown(this.paginator);
162-
return this.selection.selected.length === visibleItems;
161+
return this.selection.selected.length === itemsShown(this.paginator);
163162
}
164163

165164
onlyManagerSelected() {

0 commit comments

Comments
 (0)