Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom edit paging for all tables - for Egor #563

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/app/core/config/config.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export interface Config {
enableStructureFeatures?: boolean;
StructureFeaturePriority?: Array<string>;
structureEditSearch?: boolean;
editPagingOptionSettings?: PagingOptionSettings;
}

export interface StagingAreaSettings {
Expand Down Expand Up @@ -159,3 +160,15 @@ export interface ExternalSiteWarning {
dialogTitle: string;
dialogMessage: string;
}

export interface PagingOptionSettings {
names?: PagingOptions;
codes?: PagingOptions;
relationships?: PagingOptions;
references?: PagingOptions;
}

export interface PagingOptions {
pageSizeOptions?: Array<number>;
pageSizeDefault?: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
Add code <mat-icon svgIcon="add_circle_outline"></mat-icon>
</button> -->
</div>
<mat-paginator *ngIf="codes && codes.length > 5" [length]="filtered && filtered.length || 0" [pageIndex]="page" [pageSize]="10" showFirstLastButtons="true"
(page)="pageChange($event, analyticsEventCategory)" [pageSizeOptions]="[5, 10, 25, 100]">
<mat-paginator *ngIf="codes && codes.length > 5" [length]="filtered && filtered.length || 0" [pageIndex]="page" [pageSize]="pageSize" showFirstLastButtons="true"
(page)="pageChange($event, analyticsEventCategory)" [pageSizeOptions]="pageSizeOptions">
</mat-paginator>
<div class="code" *ngFor="let code of paged; last as isLast; index as index" appScrollToTarget
[id]="'substance-code-' + index">
<app-code-form [code]="code" (codeDeleted)="deleteCode($event)" [show] = "expanded"></app-code-form>
<mat-divider class="form-divider" [inset]="true" *ngIf="!isLast"></mat-divider>
</div>
<mat-paginator *ngIf="codes && codes.length > 5" [length]="filtered && filtered.length || 0" [pageIndex]="page" [pageSize]="10" showFirstLastButtons="true"
(page)="pageChange($event, analyticsEventCategory)" [pageSizeOptions]="[5, 10, 25, 100]">
<mat-paginator *ngIf="codes && codes.length > 5" [length]="filtered && filtered.length || 0" [pageIndex]="page" [pageSize]="pageSize" showFirstLastButtons="true"
(page)="pageChange($event, analyticsEventCategory)" [pageSizeOptions]="pageSizeOptions">
</mat-paginator>

<div *ngIf = "codes && codes.length > 0" style = "display: flex;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ScrollToService } from '../../scroll-to/scroll-to.service';
import { GoogleAnalyticsService } from '../../google-analytics/google-analytics.service';
import { Subscription } from 'rxjs';
import { SubstanceFormCodesService } from './substance-form-codes.service';
import { ConfigService } from '@gsrs-core/config';

@Component({
selector: 'app-substance-form-codes-card',
Expand All @@ -20,19 +21,33 @@ export class SubstanceFormCodesCardComponent extends SubstanceCardBaseFilteredLi
pageSize = 10;
expanded = true;
validate = false;
pageSizeOptions = [5, 10, 25, 100];


constructor(
private substanceFormCodesService: SubstanceFormCodesService,
private substanceFormService: SubstanceFormService,
private scrollToService: ScrollToService,
public gaService: GoogleAnalyticsService
public gaService: GoogleAnalyticsService,
private configService: ConfigService,

) {
super(gaService);
this.analyticsEventCategory = 'substance form codes';
}

ngOnInit() {
this.menuLabelUpdate.emit('Codes');

if (this.configService && this.configService.configData && this.configService.configData.editPagingOptionSettings && this.configService.configData.editPagingOptionSettings.codes ){
let pagingSettings = this.configService.configData.editPagingOptionSettings.codes;
if(pagingSettings.pageSizeDefault) {
this.pageSize = pagingSettings.pageSizeDefault
}
if(pagingSettings.pageSizeOptions) {
this.pageSizeOptions = pagingSettings.pageSizeOptions;
}
}
}

collapse() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,25 @@ export class SubstanceFormNamesCardComponent
this.menuLabelUpdate.emit('Names');
this.appId = this.configService.environment.appId;
this.standardizeButton = this.configService.configData.showNameStandardizeButton || false;
//temp while switching to newer config system
if (this.configService && this.configService.configData && this.configService.configData.nameFormPageSizeOptions) {
this.pageSizeOptions = this.configService.configData.nameFormPageSizeOptions;
}
if (this.configService && this.configService.configData && this.configService.configData.nameFormPageSizeDefault) {
this.pageSize = this.configService.configData.nameFormPageSizeDefault;
}


if (this.configService && this.configService.configData && this.configService.configData.editPagingOptionSettings && this.configService.configData.editPagingOptionSettings.names ){
let pagingSettings = this.configService.configData.editPagingOptionSettings.names;
if(pagingSettings.pageSizeDefault) {
this.pageSize = pagingSettings.pageSizeDefault
}
if(pagingSettings.pageSizeOptions) {
this.pageSizeOptions = pagingSettings.pageSizeOptions;
}
}

const definitionSubscription = this.substanceFormService.definition.subscribe( level => {
if (level.definitionType && level.definitionType === 'ALTERNATIVE') {
// this.canAddItemUpdate.emit(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
Add reference <mat-icon svgIcon="add_circle_outline"></mat-icon>
</button> -->
</div>
<mat-paginator *ngIf="references && references.length > 5" [length]="filtered && filtered.length || 0" [pageIndex]="page" [pageSize]="5" showFirstLastButtons="true" (page)="pageChange($event, analyticsEventCategory)"
[pageSizeOptions]="[5, 10, 25, 100]">
<mat-paginator *ngIf="references && references.length > 5" [length]="filtered && filtered.length || 0" [pageIndex]="page" [pageSize]="pageSize" showFirstLastButtons="true" (page)="pageChange($event, analyticsEventCategory)"
[pageSizeOptions]="pageSizeOptions">
</mat-paginator>
<div class="reference" *ngFor="let reference of paged; last as isLast" [id]="reference.uuid" appScrollToTarget>
<app-reference-form [reference]="reference" (referenceDeleted)="deleteReference($event)"></app-reference-form>
<mat-divider class="form-divider" [inset]="true" *ngIf="!isLast"></mat-divider>
</div>
<mat-paginator *ngIf="references && references.length > 5" [length]="filtered && filtered.length || 0" [pageIndex]="page" [pageSize]="5" showFirstLastButtons="true" (page)="pageChange($event, analyticsEventCategory)"
[pageSizeOptions]="[5, 10, 25, 100]">
<mat-paginator *ngIf="references && references.length > 5" [length]="filtered && filtered.length || 0" [pageIndex]="page" [pageSize]="pageSize" showFirstLastButtons="true" (page)="pageChange($event, analyticsEventCategory)"
[pageSizeOptions]="pageSizeOptions">
</mat-paginator>

<div *ngIf = "references && references.length > 0" style = "display: flex;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { GoogleAnalyticsService } from '../../google-analytics/google-analytics.
import { Subscription } from 'rxjs';
import { OverlayContainer } from '@angular/cdk/overlay';
import { SubstanceFormReferencesService } from './substance-form-references.service';
import { ConfigService } from '@gsrs-core/config';

@Component({
selector: 'app-substance-form-references-card',
Expand All @@ -20,13 +21,17 @@ export class SubstanceFormReferencesCardComponent extends SubstanceCardBaseFilte
references: Array<SubstanceReference>;
private subscriptions: Array<Subscription> = [];
private overlayContainer: HTMLElement;
pageSizeOptions = [5, 10, 25, 100];
pageSize = 10;


constructor(
private substanceFormReferencesService: SubstanceFormReferencesService,
private dialog: MatDialog,
private scrollToService: ScrollToService,
public gaService: GoogleAnalyticsService,
private overlayContainerService: OverlayContainer
private overlayContainerService: OverlayContainer,
private configService: ConfigService,
) {
super(gaService);
this.analyticsEventCategory = 'substance form references';
Expand All @@ -36,6 +41,15 @@ export class SubstanceFormReferencesCardComponent extends SubstanceCardBaseFilte
this.canAddItemUpdate.emit(true);
this.menuLabelUpdate.emit('References');
this.overlayContainer = this.overlayContainerService.getContainerElement();
if (this.configService && this.configService.configData && this.configService.configData.editPagingOptionSettings && this.configService.configData.editPagingOptionSettings.references ){
let pagingSettings = this.configService.configData.editPagingOptionSettings.references;
if(pagingSettings.pageSizeDefault) {
this.pageSize = pagingSettings.pageSizeDefault
}
if(pagingSettings.pageSizeOptions) {
this.pageSizeOptions = pagingSettings.pageSizeOptions;
}
}
}

ngAfterViewInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
Add relationship <mat-icon svgIcon="add_circle_outline"></mat-icon>
</button> -->
</div>
<mat-paginator *ngIf="relationships && relationships.length > 5" [length]="filtered && filtered.length || 0" [pageIndex]="page" [pageSize]="5" showFirstLastButtons="true"
(page)="pageChange($event, analyticsEventCategory)" [pageSizeOptions]="[5, 10, 25, 100]">
<mat-paginator *ngIf="relationships && relationships.length > 5" [length]="filtered && filtered.length || 0" [pageIndex]="page" [pageSize]="pageSize" showFirstLastButtons="true"
(page)="pageChange($event, analyticsEventCategory)" [pageSizeOptions]="pageSizeOptions">
</mat-paginator>
<div class="relationship" *ngFor="let relationship of paged; last as isLast; index as index" appScrollToTarget
[id]="'substance-relationship-' + index">
<app-relationship-form [relationship]="relationship" (relationshipDeleted)="deleteRelationship($event)" [show] = "expanded">
</app-relationship-form>
<mat-divider class="form-divider" [inset]="true" *ngIf="!isLast"></mat-divider>
</div>
<mat-paginator *ngIf="relationships && relationships.length > 5" [length]="filtered && filtered.length || 0" [pageIndex]="page" [pageSize]="5" showFirstLastButtons="true"
(page)="pageChange($event, analyticsEventCategory)" [pageSizeOptions]="[5, 10, 25, 100]">
<mat-paginator *ngIf="relationships && relationships.length > 5" [length]="filtered && filtered.length || 0" [pageIndex]="page" [pageSize]="pageSize" showFirstLastButtons="true"
(page)="pageChange($event, analyticsEventCategory)" [pageSizeOptions]="pageSizeOptions">
</mat-paginator>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ScrollToService } from '../../scroll-to/scroll-to.service';
import { GoogleAnalyticsService } from '../../google-analytics/google-analytics.service';
import { Subscription } from 'rxjs';
import { SubstanceFormRelationshipsService } from './substance-form-relationships.service';
import { ConfigService } from '@gsrs-core/config';

@Component({
selector: 'app-substance-form-relationships-card',
Expand All @@ -16,11 +17,16 @@ export class SubstanceFormRelationshipsCardComponent extends SubstanceCardBaseFi
relationships: Array<SubstanceRelationship>;
private subscriptions: Array<Subscription> = [];
expanded = true;
pageSize = 10;
pageSizeOptions = [5, 10, 25, 100];


constructor(
private substanceFormRelationshipsService: SubstanceFormRelationshipsService,
private scrollToService: ScrollToService,
public gaService: GoogleAnalyticsService
public gaService: GoogleAnalyticsService,
private configService: ConfigService,

) {
super(gaService);
}
Expand All @@ -29,6 +35,16 @@ export class SubstanceFormRelationshipsCardComponent extends SubstanceCardBaseFi
this.canAddItemUpdate.emit(true);
this.menuLabelUpdate.emit('Relationships');
this.analyticsEventCategory = 'substance form relationships';

if (this.configService && this.configService.configData && this.configService.configData.editPagingOptionSettings && this.configService.configData.editPagingOptionSettings.relationships ){
let pagingSettings = this.configService.configData.editPagingOptionSettings.relationships;
if(pagingSettings.pageSizeDefault) {
this.pageSize = pagingSettings.pageSizeDefault
}
if(pagingSettings.pageSizeOptions) {
this.pageSizeOptions = pagingSettings.pageSizeOptions;
}
}
}

ngAfterViewInit() {
Expand Down
Loading