Commit 4e5cfb67 authored by oussamasic's avatar oussamasic Committed by Ro3034
Browse files

add more fixes

parent dc1d2e47
......@@ -37,6 +37,8 @@
package fr.gouv.vitamui.commons.vitam.api.config.converter;
import fr.gouv.vitam.common.model.administration.FileRulesModel;
import fr.gouv.vitam.common.model.administration.RuleMeasurementEnum;
import fr.gouv.vitam.common.model.administration.RuleType;
import fr.gouv.vitamui.commons.rest.dto.RuleDto;
import fr.gouv.vitamui.commons.utils.VitamUIUtils;
......@@ -47,13 +49,15 @@ public class RuleConverter {
public FileRulesModel convertDtoToVitam(final RuleDto dto) {
final FileRulesModel rule = VitamUIUtils.copyProperties(dto, new FileRulesModel());
rule.setRuleType(RuleType.getEnumFromName(dto.getRuleType()));
rule.setRuleMeasurement(RuleMeasurementEnum.getEnumFromType(dto.getRuleMeasurement()));
return rule;
}
public RuleDto convertVitamToDto(final FileRulesModel rule) {
final RuleDto dto = VitamUIUtils.copyProperties(rule, new RuleDto());
dto.setRuleMeasurement(rule.getRuleMeasurement().getType());
dto.setRuleType(rule.getRuleType().name());
return dto;
}
......
......@@ -42,7 +42,6 @@ import { cloneDeep } from 'lodash';
import { merge, Subscription } from 'rxjs';
import { debounceTime, filter, map } from 'rxjs/operators';
import { CriteriaDataType, CriteriaOperator, diff, Rule, RuleService } from 'ui-frontend-common';
import { isEmpty } from 'underscore';
import { ManagementRulesSharedDataService } from '../../../core/management-rules-shared-data.service';
import { ArchiveService } from '../../archive.service';
import { RuleTypeEnum } from '../../models/rule-type-enum';
......@@ -120,7 +119,7 @@ export class AddManagementRulesComponent implements OnInit, OnDestroy {
rule: [
null,
[Validators.required, this.managementRulesValidatorService.ruleIdPattern()],
[this.managementRulesValidatorService.uniqueRuleId(), , this.managementRulesValidatorService.checkRuleIdExistence()],
[this.managementRulesValidatorService.uniqueRuleId(), this.managementRulesValidatorService.checkRuleIdExistence()],
],
name: [{ value: null, disabled: true }, Validators.required],
startDate: [null, Validators.required],
......@@ -131,7 +130,7 @@ export class AddManagementRulesComponent implements OnInit, OnDestroy {
.pipe(
debounceTime(UPDATE_DEBOUNCE_TIME),
map(() => diff(this.ruleDetailsForm.value, this.previousRuleDetails)),
filter((formData) => !isEmpty(formData)),
filter((formData) => this.isEmpty(formData)),
filter((formData) => this.patchForm(formData))
)
.subscribe(() => {
......@@ -145,26 +144,29 @@ export class AddManagementRulesComponent implements OnInit, OnDestroy {
this.selectedStartDate = date;
});
this.ruleDetailsForm.get('rule').valueChanges.subscribe((ruleSelected) => {
if (this.ruleDetailsForm.get('rule').value !== this.previousRuleDetails.rule) {
this.getRuleSuscription = this.ruleService.get(ruleSelected).subscribe((ruleResponse) => {
this.ruleDetailsForm.get('rule').valueChanges.subscribe(() => {
this.cancelStep.emit();
});
}
isEmpty(formData: any): boolean {
if (formData) {
if (formData.rule) {
this.getRuleSuscription = this.ruleService.get(formData.rule.trim()).subscribe((ruleResponse) => {
this.rule = ruleResponse;
this.ruleDetailsForm.patchValue({ name: ruleResponse.ruleValue });
});
return true;
}
if (this.rule && this.rule.ruleValue) {
this.ruleDetailsForm.patchValue({ name: this.rule.ruleValue });
}
this.cancelStep.emit();
});
}
return false;
}
ngOnDestroy() {
this.showConfirmDeleteAddRuleSuscription?.unsubscribe();
this.managementRulesSubscription?.unsubscribe();
this.criteriaSearchDSLQuerySuscription?.unsubscribe();
this.getRuleSuscription.unsubscribe();
this.getRuleSuscription?.unsubscribe();
}
ngOnInit() {}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment