Last Batch before Release (#2899)

This commit is contained in:
Joe Milazzo 2024-04-21 10:53:40 -05:00 committed by GitHub
parent 8d77b398b2
commit 32bedb4e06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 3302 additions and 124 deletions

View file

@ -64,16 +64,26 @@ export class EditListComponent implements OnInit {
}
remove(index: number) {
const tokens = this.combinedItems.split(',');
const tokenToRemove = tokens[index];
this.combinedItems = tokens.filter(t => t != tokenToRemove).join(',');
for (const [index, [key, value]] of Object.entries(Object.entries(this.form.controls))) {
if (key.startsWith('link') && this.form.get(key)?.value === tokenToRemove) {
this.form.removeControl('link' + index, {emitEvent: true});
}
const initialControls = Object.keys(this.form.controls)
.filter(key => key.startsWith('link'));
if (index == 0 && initialControls.length === 1) {
this.form.get(initialControls[0])?.setValue('', {emitEvent: true});
this.emit();
this.cdRef.markForCheck();
return;
}
// Remove the form control explicitly then rebuild the combinedItems
this.form.removeControl('link' + index, {emitEvent: true});
this.combinedItems = Object.keys(this.form.controls)
.filter(key => key.startsWith('link'))
.map(key => this.form.get(key)?.value)
.join(',');
this.emit();
this.cdRef.markForCheck();
}