Skip to content

Commit

Permalink
fix(geo): eliminate 300 ppp resolution from mobile devices (#1498)
Browse files Browse the repository at this point in the history
* fix(geo/print): use array instead of strEnum

---------

Co-authored-by: Alexandre Caron <[email protected]>
  • Loading branch information
aziz-access and alecarn authored Nov 16, 2023
1 parent 1b3d96b commit 4ed5e3e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,8 @@
formControlName="resolution"
placeholder="{{ 'igo.geo.printForm.resolution' | translate }}"
>
<mat-option
*ngFor="let resolution of resolutions | keyvalue"
[value]="resolution.key"
>
{{ resolution.value }}
<mat-option *ngFor="let resolution of resolutions" [value]="resolution">
{{ resolution }}
</mat-option>
</mat-select>
</mat-form-field>
Expand Down
16 changes: 13 additions & 3 deletions packages/geo/src/lib/print/print-form/print-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
Validators
} from '@angular/forms';

import { MediaService } from '@igo2/core';

import { BehaviorSubject } from 'rxjs';

import { PrintOptions } from '../shared/print.interface';
Expand All @@ -28,7 +30,7 @@ export class PrintFormComponent implements OnInit {
public outputFormats = PrintOutputFormat;
public paperFormats = PrintPaperFormat;
public orientations = PrintOrientation;
public resolutions = PrintResolution;
public resolutions = [...PrintResolution];
public imageFormats = PrintSaveImageFormat;
public legendPositions = PrintLegendPosition;
public isPrintService = true;
Expand Down Expand Up @@ -80,7 +82,7 @@ export class PrintFormComponent implements OnInit {
return this.resolutionField.value;
}
set resolution(value: PrintResolution) {
this.resolutionField.setValue(value || PrintResolution['96'], {
this.resolutionField.setValue(value || ('96' satisfies PrintResolution), {
onlySelf: true
});
}
Expand Down Expand Up @@ -202,7 +204,10 @@ export class PrintFormComponent implements OnInit {

maxLength: number = 180;

constructor(private formBuilder: UntypedFormBuilder) {
constructor(
private formBuilder: UntypedFormBuilder,
private mediaService: MediaService
) {
this.form = this.formBuilder.group({
title: ['', [Validators.minLength(0), Validators.maxLength(130)]],
subtitle: ['', [Validators.minLength(0), Validators.maxLength(120)]],
Expand All @@ -225,6 +230,11 @@ export class PrintFormComponent implements OnInit {

ngOnInit() {
this.doZipFileField.setValue(false);
if (this.mediaService.isMobile()) {
this.resolutions = this.resolutions.filter(
(resolution) => resolution !== '300'
);
}
}

handleFormSubmit(data: PrintOptions, isValid: boolean) {
Expand Down
4 changes: 2 additions & 2 deletions packages/geo/src/lib/print/shared/print.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export type PrintPaperFormat = keyof typeof PrintPaperFormat;
export const PrintOrientation = strEnum(['landscape', 'portrait']);
export type PrintOrientation = keyof typeof PrintOrientation;

export const PrintResolution = strEnum(['72', '96', '150']); // For now, we remove the 300 dpi because there is too much instability on iOS and slow device.
export type PrintResolution = keyof typeof PrintResolution;
export const PrintResolution = ['72', '96', '150', '300'] as const;
export type PrintResolution = (typeof PrintResolution)[number];

export const PrintSaveImageFormat = strEnum([
'Bmp',
Expand Down

0 comments on commit 4ed5e3e

Please sign in to comment.