mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-06-09 14:25:43 -04:00
fixed unlinked categories validation
This commit is contained in:
@@ -248,6 +248,7 @@
|
||||
>
|
||||
</p-autocomplete>
|
||||
</div>
|
||||
<small *ngIf="hasUnlinkedCategoriesError()" class="p-error">At least one category is required when unlinked download handling is enabled</small>
|
||||
<small class="form-helper-text">Categories to check for unlinked downloads</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -139,7 +139,7 @@ export class DownloadCleanerSettingsComponent implements OnDestroy, CanComponent
|
||||
unlinkedUseTag: [{ value: false, disabled: true }],
|
||||
unlinkedIgnoredRootDir: [{ value: '', disabled: true }],
|
||||
unlinkedCategories: [{ value: [], disabled: true }]
|
||||
});
|
||||
}, { validators: this.validateUnlinkedCategories });
|
||||
|
||||
// Load the current configuration
|
||||
effect(() => {
|
||||
@@ -199,6 +199,20 @@ export class DownloadCleanerSettingsComponent implements OnDestroy, CanComponent
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom validator for unlinked categories - requires categories when unlinked handling is enabled
|
||||
*/
|
||||
private validateUnlinkedCategories(group: FormGroup): ValidationErrors | null {
|
||||
const unlinkedEnabled = group.get('unlinkedEnabled')?.value;
|
||||
const unlinkedCategories = group.get('unlinkedCategories')?.value;
|
||||
|
||||
if (unlinkedEnabled && (!unlinkedCategories || unlinkedCategories.length === 0)) {
|
||||
return { unlinkedCategoriesRequired: true };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to get a category control as FormGroup for the template
|
||||
*/
|
||||
@@ -592,6 +606,13 @@ export class DownloadCleanerSettingsComponent implements OnDestroy, CanComponent
|
||||
return control ? control.touched && control.hasError(errorName) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the form has the unlinked categories validation error
|
||||
*/
|
||||
hasUnlinkedCategoriesError(): boolean {
|
||||
return this.downloadCleanerForm.touched && this.downloadCleanerForm.hasError('unlinkedCategoriesRequired');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get schedule value options based on the current schedule unit type
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user