this.s3keyLabel = this.i18n('S3 Key');
this.capabilityLabel = this.i18n('capability');
this.createForm();
- this.listenToChanges();
}
createForm() {
});
}
- listenToChanges() {
- // Reset the validation status of various controls, especially those that are using
- // the 'requiredIf' validator. This is necessary because the controls itself are not
- // validated again if the status of their prerequisites have been changed.
- this.userForm.get('generate_key').valueChanges.subscribe(() => {
- ['access_key', 'secret_key'].forEach((path) => {
- this.userForm.get(path).updateValueAndValidity({ onlySelf: true });
- });
- });
- this.userForm.get('user_quota_enabled').valueChanges.subscribe(() => {
- ['user_quota_max_size', 'user_quota_max_objects'].forEach((path) => {
- this.userForm.get(path).updateValueAndValidity({ onlySelf: true });
- });
- });
- this.userForm.get('user_quota_max_size_unlimited').valueChanges.subscribe(() => {
- this.userForm.get('user_quota_max_size').updateValueAndValidity({ onlySelf: true });
- });
- this.userForm.get('user_quota_max_objects_unlimited').valueChanges.subscribe(() => {
- this.userForm.get('user_quota_max_objects').updateValueAndValidity({ onlySelf: true });
- });
- this.userForm.get('bucket_quota_enabled').valueChanges.subscribe(() => {
- ['bucket_quota_max_size', 'bucket_quota_max_objects'].forEach((path) => {
- this.userForm.get(path).updateValueAndValidity({ onlySelf: true });
- });
- });
- this.userForm.get('bucket_quota_max_size_unlimited').valueChanges.subscribe(() => {
- this.userForm.get('bucket_quota_max_size').updateValueAndValidity({ onlySelf: true });
- });
- this.userForm.get('bucket_quota_max_objects_unlimited').valueChanges.subscribe(() => {
- this.userForm.get('bucket_quota_max_objects').updateValueAndValidity({ onlySelf: true });
- });
- }
-
ngOnInit() {
this.editing = this.router.url.startsWith(`/rgw/user/${URLVerbs.EDIT}`);
this.action = this.editing ? this.actionLabels.EDIT : this.actionLabels.CREATE;
) {
this.resource = this.i18n('S3 Key');
this.createForm();
- this.listenToChanges();
}
createForm() {
});
}
- listenToChanges() {
- // Reset the validation status of various controls, especially those that are using
- // the 'requiredIf' validator. This is necessary because the controls itself are not
- // validated again if the status of their prerequisites have been changed.
- this.formGroup.get('generate_key').valueChanges.subscribe(() => {
- ['access_key', 'secret_key'].forEach((path) => {
- this.formGroup.get(path).updateValueAndValidity({ onlySelf: true });
- });
- });
- }
-
/**
* Set the 'viewing' flag. If set to TRUE, the modal dialog is in 'View' mode,
* otherwise in 'Add' mode. According to the mode the dialog and its controls
) {
this.resource = this.i18n('Subuser');
this.createForm();
- this.listenToChanges();
}
createForm() {
});
}
- listenToChanges() {
- // Reset the validation status of various controls, especially those that are using
- // the 'requiredIf' validator. This is necessary because the controls itself are not
- // validated again if the status of their prerequisites have been changed.
- this.formGroup.get('generate_secret').valueChanges.subscribe(() => {
- ['secret_key'].forEach((path) => {
- this.formGroup.get(path).updateValueAndValidity({ onlySelf: true });
- });
- });
- }
-
/**
* Validates whether the subuser already exists.
*/
* @return {ValidatorFn} Returns the validator function.
*/
static requiredIf(prerequisites: Object, condition?: Function | undefined): ValidatorFn {
+ let isWatched = false;
+
return (control: AbstractControl): ValidationErrors | null => {
+ if (!isWatched && control.parent) {
+ Object.keys(prerequisites).forEach((key) => {
+ control.parent.get(key).valueChanges.subscribe(() => {
+ control.updateValueAndValidity({ emitEvent: false });
+ });
+ });
+
+ isWatched = true;
+ }
+
// Check if all prerequisites matches.
if (
!Object.keys(prerequisites).every((key) => {