From 53be02f2aec40d6e95ceb96d8ab023075d03f659 Mon Sep 17 00:00:00 2001
From: Davis Qi <907225883wxl@gmail.com>
Date: Mon, 8 Jul 2024 18:39:55 -0700
Subject: [PATCH] feat/reset checkbox status when leaving the page
---
.../pagination/pagination.component.ts | 87 +++++++++++++++++++
.../ui/selectRow/selectRow.services.ts | 15 ++++
2 files changed, 102 insertions(+)
create mode 100644 docker/advocase-image/build-files/suitecrm/core/app/core/src/lib/components/pagination/pagination.component.ts
create mode 100644 docker/advocase-image/build-files/suitecrm/core/app/core/src/lib/services/ui/selectRow/selectRow.services.ts
diff --git a/docker/advocase-image/build-files/suitecrm/core/app/core/src/lib/components/pagination/pagination.component.ts b/docker/advocase-image/build-files/suitecrm/core/app/core/src/lib/components/pagination/pagination.component.ts
new file mode 100644
index 000000000..04a281cde
--- /dev/null
+++ b/docker/advocase-image/build-files/suitecrm/core/app/core/src/lib/components/pagination/pagination.component.ts
@@ -0,0 +1,87 @@
+/**
+ * SuiteCRM is a customer relationship management program developed by SalesAgility Ltd.
+ * Copyright (C) 2021 SalesAgility Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Affero General Public License version 3 as published by the
+ * Free Software Foundation with the addition of the following permission added
+ * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
+ * IN WHICH THE COPYRIGHT IS OWNED BY SALESAGILITY, SALESAGILITY DISCLAIMS THE
+ * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ * In accordance with Section 7(b) of the GNU Affero General Public License
+ * version 3, these Appropriate Legal Notices must retain the display of the
+ * "Supercharged by SuiteCRM" logo. If the display of the logos is not reasonably
+ * feasible for technical reasons, the Appropriate Legal Notices must display
+ * the words "Supercharged by SuiteCRM".
+ */
+
+import {Component, Input, OnInit} from '@angular/core';
+import {combineLatestWith, Observable} from 'rxjs';
+import {map} from 'rxjs/operators';
+import {PageSelection, PaginationCount, PaginationDataSource} from 'common';
+import {LanguageStore, LanguageStringMap} from '../../store/language/language.store';
+import {SelectionService} from '../../services/ui/selectRow/selectRow.service';
+
+export interface PaginationViewModel {
+ appStrings: LanguageStringMap;
+ pageCount: PaginationCount;
+}
+
+@Component({
+ selector: 'scrm-pagination',
+ templateUrl: 'pagination.component.html'
+})
+export class PaginationComponent implements OnInit {
+
+ @Input() allowPagination = true;
+ @Input() state: PaginationDataSource;
+ displayResponsiveTable: any;
+
+ appStrings$: Observable = this.languageStore.appStrings$;
+ vm$: Observable = null;
+
+ constructor(
+ protected languageStore: LanguageStore,
+ private selectionService: SelectionService,
+ ) {
+ }
+
+
+ ngOnInit(): void {
+ const pageCount$ = this.state.getPaginationCount();
+
+ this.vm$ = this.appStrings$.pipe(
+ combineLatestWith(pageCount$),
+ map(([appStrings, pageCount]: [LanguageStringMap, PaginationCount]) => ({appStrings, pageCount}))
+ );
+ }
+
+ first(): void {
+ this.selectionService.deselectAll();
+ this.state.changePage(PageSelection.FIRST);
+ }
+
+ previous(): void {
+ this.selectionService.deselectAll();
+ this.state.changePage(PageSelection.PREVIOUS);
+ }
+
+ next(): void {
+ this.selectionService.deselectAll();
+ this.state.changePage(PageSelection.NEXT);
+ }
+
+ last(): void {
+ this.selectionService.deselectAll();
+ this.state.changePage(PageSelection.LAST);
+ }
+}
diff --git a/docker/advocase-image/build-files/suitecrm/core/app/core/src/lib/services/ui/selectRow/selectRow.services.ts b/docker/advocase-image/build-files/suitecrm/core/app/core/src/lib/services/ui/selectRow/selectRow.services.ts
new file mode 100644
index 000000000..0bc8a274e
--- /dev/null
+++ b/docker/advocase-image/build-files/suitecrm/core/app/core/src/lib/services/ui/selectRow/selectRow.services.ts
@@ -0,0 +1,15 @@
+import { Injectable } from '@angular/core';
+import { Subject } from 'rxjs';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class SelectionService {
+ private deselectAllSubject = new Subject();
+
+ deselectAll$ = this.deselectAllSubject.asObservable();
+
+ deselectAll(): void {
+ this.deselectAllSubject.next();
+ }
+}