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

fix(geo): Layer color picker do not change the fill/stroke color #1509

Merged
merged 1 commit into from
Nov 20, 2023
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Component, Input, forwardRef } from '@angular/core';
import {
Component,
EventEmitter,
Input,
Output,
forwardRef
} from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';

import { ColorEvent } from 'ngx-color';
Expand Down Expand Up @@ -35,6 +41,12 @@ export class ColorPickerFormFieldComponent implements ControlValueAccessor {

@Input() outputFormat: ColorFormat = 'rgba';

/**
* The emitted value represent the current chosen color in the picker
* The value is emitted by default in RGBA, or based on the input 'outputFormat' value.
*/
@Output() colorChange: EventEmitter<string> = new EventEmitter<string>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cette composante est une variant d'un FormField elle fonctionne avec le ReactiveForm d'Angular. Lorsqu'on lui passe un FormControl, on peut s'abonner au changement au niveau du FormControl. Voir l'exemple dans le prochain commentaire

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui sauf que dans ce cas la, pour setter le form, il faut cliquer sur ok ou appliquer, donc le changement n'est pas dynamique.


colorPicker: string;

onChange: any = () => {};
Expand All @@ -61,6 +73,7 @@ export class ColorPickerFormFieldComponent implements ControlValueAccessor {

handleChange($event: ColorEvent) {
this.colorPicker = this.formatColor($event.color.rgb, 'rgba');
this.colorChange.emit(this.formatColor(this.colorPicker));
}

private formatColor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ <h2 mat-dialog-title class="mat-typography">
</span>
<igo-color-picker-form-field
formControlName="fill"
(colorChange)="setLayerFillColor($event)"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On pourrait avoir les changements de valeurs ainsi dans le Typescript de la composante:

Suggested change
(colorChange)="setLayerFillColor($event)"
this.form
.get('fill')
.valueChanges.subscribe((color) => this.handleFillColor(color));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il faut cliquer sur Appliquer/OK pour récupérer la couleur

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chrome_2023-11-20_16-24-49

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vraiment plus convivial pour choisir une couleur, surtout si des superpositions/conflits visuel de couleur sont possible.

></igo-color-picker-form-field>
</div>

Expand All @@ -25,6 +26,7 @@ <h2 mat-dialog-title class="mat-typography">
</span>
<igo-color-picker-form-field
formControlName="stroke"
(colorChange)="setLayerStrokeColor($event)"
></igo-color-picker-form-field>
</div>
</form>
Expand Down