2 Copyright 2020 TATA ELXSI
4 Licensed under the Apache License, Version 2.0 (the 'License');
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
16 Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
20 * @file PagePerRow Model
22 import { Component, EventEmitter, Injector, Output } from '@angular/core';
23 import { TranslateService } from '@ngx-translate/core';
24 import { PAGERSMARTTABLE } from 'CommonModel';
25 import { SharedService } from 'SharedService';
29 * @Component takes PagePerRow.html as template url
32 // eslint-disable-next-line @angular-eslint/component-selector
33 selector: 'page-per-row',
34 templateUrl: './PagePerRow.html',
35 styleUrls: ['./PagePerRow.scss']
37 /** Exporting a class @exports PagePerRow */
38 // eslint-disable-next-line @angular-eslint/component-class-suffix
39 export class PagePerRow {
40 /** To inject services @public */
41 public injector: Injector;
43 /** handle translate @public */
44 public translateService: TranslateService;
46 /** get the pagaintion default select value @public */
47 public getDefaultSelected: number;
49 /** Controls the pagination List Count form @public */
50 public pageCount: { value: number; viewValue: number; }[] =
52 { value: 10, viewValue: 10 },
53 { value: 25, viewValue: 25 },
54 { value: 50, viewValue: 50 },
55 { value: 100, viewValue: 100 }
58 /** Contains all methods related to shared @private */
59 public sharedService: SharedService;
61 /** Event emitter to emit selected page number @public */
62 @Output() public pagePerRow: EventEmitter<number> = new EventEmitter();
64 constructor(injector: Injector) {
65 this.injector = injector;
66 this.translateService = this.injector.get(TranslateService);
67 this.sharedService = this.injector.get(SharedService);
71 * Lifecyle Hooks the trigger before component is instantiate
73 public ngOnInit(): void {
74 const getPaginationValues: PAGERSMARTTABLE = this.sharedService.paginationPagerConfig();
75 this.getDefaultSelected = getPaginationValues.perPage;
78 /** Handles select event @public */
79 public onSelectRow(e: number): void {
80 this.pagePerRow.emit(e);