Browse Source

Bugfix/enable save button after editing tags in create or update activity dialog (#5561)

* Enable save button after editing tags in create or update activity dialog

* Update changelog
pull/5509/head^2
Germán Martín 3 weeks ago
committed by GitHub
parent
commit
cd40ce3679
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      CHANGELOG.md
  2. 4
      apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts
  3. 3
      apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html
  4. 59
      libs/ui/src/lib/tags-selector/tags-selector.component.ts

8
CHANGELOG.md

@ -11,6 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `settings` to the `Access` model - Added `settings` to the `Access` model
### Changed
- Extended the tags selector component to support form control
### Fixed
- Fixed an issue where the save button was not enabled after editing tags in the create or update activity dialog
## 2.201.0 - 2025-09-24 ## 2.201.0 - 2025-09-24
### Added ### Added

4
apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts

@ -573,10 +573,6 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy {
} }
} }
public onTagsChanged(tags: Tag[]) {
this.activityForm.get('tags').setValue(tags);
}
public ngOnDestroy() { public ngOnDestroy() {
this.unsubscribeSubject.next(); this.unsubscribeSubject.next();
this.unsubscribeSubject.complete(); this.unsubscribeSubject.complete();

3
apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.html

@ -322,10 +322,9 @@
</div> </div>
<div class="mb-3"> <div class="mb-3">
<gf-tags-selector <gf-tags-selector
formControlName="tags"
[hasPermissionToCreateTag]="hasPermissionToCreateOwnTag" [hasPermissionToCreateTag]="hasPermissionToCreateOwnTag"
[tags]="activityForm.get('tags')?.value"
[tagsAvailable]="tagsAvailable" [tagsAvailable]="tagsAvailable"
(tagsChanged)="onTagsChanged($event)"
/> />
</div> </div>
</div> </div>

59
libs/ui/src/lib/tags-selector/tags-selector.component.ts

@ -14,7 +14,13 @@ import {
signal, signal,
ViewChild ViewChild
} from '@angular/core'; } from '@angular/core';
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms'; import {
ControlValueAccessor,
FormControl,
FormsModule,
NG_VALUE_ACCESSOR,
ReactiveFormsModule
} from '@angular/forms';
import { import {
MatAutocompleteModule, MatAutocompleteModule,
MatAutocompleteSelectedEvent MatAutocompleteSelectedEvent
@ -40,12 +46,21 @@ import { BehaviorSubject, Subject, takeUntil } from 'rxjs';
MatInputModule, MatInputModule,
ReactiveFormsModule ReactiveFormsModule
], ],
providers: [
{
multi: true,
provide: NG_VALUE_ACCESSOR,
useExisting: GfTagsSelectorComponent
}
],
schemas: [CUSTOM_ELEMENTS_SCHEMA], schemas: [CUSTOM_ELEMENTS_SCHEMA],
selector: 'gf-tags-selector', selector: 'gf-tags-selector',
styleUrls: ['./tags-selector.component.scss'], styleUrls: ['./tags-selector.component.scss'],
templateUrl: 'tags-selector.component.html' templateUrl: 'tags-selector.component.html'
}) })
export class GfTagsSelectorComponent implements OnInit, OnChanges, OnDestroy { export class GfTagsSelectorComponent
implements ControlValueAccessor, OnChanges, OnDestroy, OnInit
{
@Input() hasPermissionToCreateTag = false; @Input() hasPermissionToCreateTag = false;
@Input() readonly = false; @Input() readonly = false;
@Input() tags: Tag[]; @Input() tags: Tag[];
@ -99,7 +114,10 @@ export class GfTagsSelectorComponent implements OnInit, OnChanges, OnDestroy {
return [...(tags ?? []), tag]; return [...(tags ?? []), tag];
}); });
this.tagsChanged.emit(this.tagsSelected()); const newTags = this.tagsSelected();
this.tagsChanged.emit(newTags);
this.onChange(newTags);
this.onTouched();
this.tagInput.nativeElement.value = ''; this.tagInput.nativeElement.value = '';
this.tagInputControl.setValue(undefined); this.tagInputControl.setValue(undefined);
} }
@ -111,7 +129,31 @@ export class GfTagsSelectorComponent implements OnInit, OnChanges, OnDestroy {
}); });
}); });
this.tagsChanged.emit(this.tagsSelected()); const newTags = this.tagsSelected();
this.tagsChanged.emit(newTags);
this.onChange(newTags);
this.onTouched();
this.updateFilters();
}
public registerOnChange(fn: (value: Tag[]) => void) {
this.onChange = fn;
}
public registerOnTouched(fn: () => void) {
this.onTouched = fn;
}
public setDisabledState(isDisabled: boolean) {
if (isDisabled) {
this.tagInputControl.disable();
} else {
this.tagInputControl.enable();
}
}
public writeValue(value: Tag[]) {
this.tagsSelected.set(value || []);
this.updateFilters(); this.updateFilters();
} }
@ -133,6 +175,15 @@ export class GfTagsSelectorComponent implements OnInit, OnChanges, OnDestroy {
}); });
} }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
private onChange = (_value: Tag[]): void => {
// ControlValueAccessor onChange callback
};
private onTouched = (): void => {
// ControlValueAccessor onTouched callback
};
private updateFilters() { private updateFilters() {
this.filteredOptions.next(this.filterTags()); this.filteredOptions.next(this.filterTags());
} }

Loading…
Cancel
Save