Admin template editor. Fix invalid visibility rules case.
This commit is contained in:
parent
9ccae4d2c7
commit
c157ecc4e7
|
@ -23,7 +23,7 @@ export class RuleEditorModel extends BaseFormModel {
|
||||||
// sourceField: [this.sourceField],
|
// sourceField: [this.sourceField],
|
||||||
target: [{ value: this.target, disabled: (disabled && !skipDisable.includes('RuleEditorModel.target')) }, [Validators.required]],
|
target: [{ value: this.target, disabled: (disabled && !skipDisable.includes('RuleEditorModel.target')) }, [Validators.required]],
|
||||||
ruleStyle: [{ value: this.ruleStyle, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleStyle')) }],
|
ruleStyle: [{ value: this.ruleStyle, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleStyle')) }],
|
||||||
value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('RuleEditorModel.value')) }],
|
value: [{ value: this.value, disabled: (disabled && !skipDisable.includes('RuleEditorModel.value')) }, [Validators.required]],
|
||||||
ruleType: [{ value: this.ruleType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleType')) }],
|
ruleType: [{ value: this.ruleType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.ruleType')) }],
|
||||||
valueType: [{ value: this.valueType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.valueType')) }]
|
valueType: [{ value: this.valueType, disabled: (disabled && !skipDisable.includes('RuleEditorModel.valueType')) }]
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,13 +34,14 @@ import { AutoCompleteFieldDataEditorModel } from '../../../admin/field-data/auto
|
||||||
import { DatasetsAutoCompleteFieldDataEditorModel } from '../../../admin/field-data/datasets-autocomplete-field-data-editor-mode';
|
import { DatasetsAutoCompleteFieldDataEditorModel } from '../../../admin/field-data/datasets-autocomplete-field-data-editor-mode';
|
||||||
import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type';
|
import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type';
|
||||||
import { Guid } from '@common/types/guid';
|
import { Guid } from '@common/types/guid';
|
||||||
import { ErrorStateMatcher, MatSlideToggleChange } from '@angular/material';
|
import { ErrorStateMatcher, MatDialog, MatSlideToggleChange } from '@angular/material';
|
||||||
import { DefaultValueEditorModel } from '../../../admin/default-value-editor-model';
|
import { DefaultValueEditorModel } from '../../../admin/default-value-editor-model';
|
||||||
import { EditorCustomValidators } from '../../custom-validators/editor-custom-validators';
|
import { EditorCustomValidators } from '../../custom-validators/editor-custom-validators';
|
||||||
import { Field } from '@app/core/model/admin/dataset-profile/dataset-profile';
|
import { Field } from '@app/core/model/admin/dataset-profile/dataset-profile';
|
||||||
import { DatasetProfileInternalDmpEntitiesType } from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type';
|
import { DatasetProfileInternalDmpEntitiesType } from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type';
|
||||||
import { FieldEditorModel } from '../../../admin/field-editor-model';
|
import { FieldEditorModel } from '../../../admin/field-editor-model';
|
||||||
import { AutoCompleteFieldData, BooleanDecisionFieldData, CheckBoxFieldData, CurrencyFieldData, DataRepositoriesFieldData, DatasetIdentifierFieldData, DatePickerFieldData, DmpsAutoCompleteFieldData, ExternalDatasetsFieldData, FieldDataOption, FreeTextFieldData, OrganizationsFieldData, RadioBoxFieldData, RegistriesFieldData, ResearchersAutoCompleteFieldData, ServicesFieldData, TagsFieldData, TextAreaFieldData, ValidationFieldData, WordListFieldData } from '@app/core/model/dataset-profile-definition/field-data/field-data';
|
import { AutoCompleteFieldData, BooleanDecisionFieldData, CheckBoxFieldData, CurrencyFieldData, DataRepositoriesFieldData, DatasetIdentifierFieldData, DatePickerFieldData, DmpsAutoCompleteFieldData, ExternalDatasetsFieldData, FieldDataOption, FreeTextFieldData, OrganizationsFieldData, RadioBoxFieldData, RegistriesFieldData, ResearchersAutoCompleteFieldData, ServicesFieldData, TagsFieldData, TextAreaFieldData, ValidationFieldData, WordListFieldData } from '@app/core/model/dataset-profile-definition/field-data/field-data';
|
||||||
|
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-profile-editor-field-component',
|
selector: 'app-dataset-profile-editor-field-component',
|
||||||
|
@ -69,7 +70,8 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public enumUtils: EnumUtils,
|
public enumUtils: EnumUtils,
|
||||||
public datasetProfileService: DatasetProfileService
|
public datasetProfileService: DatasetProfileService,
|
||||||
|
private dialog: MatDialog
|
||||||
) { super();
|
) { super();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -97,7 +99,8 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if(this.form.get('viewStyle').get('renderStyle').value){
|
const renderStyle = this.form.get('viewStyle').get('renderStyle').value;
|
||||||
|
if(renderStyle){
|
||||||
|
|
||||||
// this.matcher.setReference(this.form);
|
// this.matcher.setReference(this.form);
|
||||||
const type = this.form.get('viewStyle').get('renderStyle').value;
|
const type = this.form.get('viewStyle').get('renderStyle').value;
|
||||||
|
@ -390,8 +393,6 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
|
||||||
case this.viewTypeEnum.Select:
|
case this.viewTypeEnum.Select:
|
||||||
case this.viewTypeEnum.CheckBox:
|
case this.viewTypeEnum.CheckBox:
|
||||||
case this.viewTypeEnum.DatePicker:
|
case this.viewTypeEnum.DatePicker:
|
||||||
case this.viewTypeEnum.DataRepositories://TODO FURTHER NOTICE
|
|
||||||
case this.viewTypeEnum.ExternalDatasets://TODO FURTHER NOTICE
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,7 +280,95 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
|
||||||
}, 400);
|
}, 400);
|
||||||
// this._initializeFormValidity(tocentries);
|
// this._initializeFormValidity(tocentries);
|
||||||
|
|
||||||
|
//Checking invalid visibilty RULES
|
||||||
|
const fieldsetEntries = this._getAllFieldSets(this.toCEntries);
|
||||||
|
const fieldSetHavingInvalidVisibilityRules:ToCEntry[] = fieldsetEntries
|
||||||
|
.filter(entry=>{
|
||||||
|
const fieldsFormGroup = entry.form.get('fields');
|
||||||
|
const invalid = (fieldsFormGroup as FormArray).controls.filter(field=>{
|
||||||
|
return this.hasInvalidVisibilityRule(field as FormGroup);
|
||||||
|
|
||||||
|
});
|
||||||
|
if(invalid && invalid.length){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if(fieldSetHavingInvalidVisibilityRules.length){
|
||||||
|
const occurences = fieldSetHavingInvalidVisibilityRules.map(record=>record.numbering).join(' , ');
|
||||||
|
this.dialog.open(ConfirmationDialogComponent, {
|
||||||
|
data:{
|
||||||
|
message: this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.MESSAGE-START')+occurences+ this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.MESSAGE-END'),
|
||||||
|
confirmButton: this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.CONFIRM-YES'),
|
||||||
|
cancelButton: this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.CONFIRM-NO')
|
||||||
|
},
|
||||||
|
maxWidth:'30em'
|
||||||
|
})
|
||||||
|
.afterClosed()
|
||||||
|
.subscribe(confirm=>{
|
||||||
|
if(confirm){
|
||||||
|
this.removeFieldSetVisibilityRules(fieldSetHavingInvalidVisibilityRules);
|
||||||
|
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-PROFILE-EDITOR.ERRORS.INVALID-VISIBILITY-RULES.REMOVE-SUCCESS'), SnackBarNotificationLevel.Success);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
console.log('User not confirmed');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private removeFieldSetVisibilityRules(fieldsets:ToCEntry[]){
|
||||||
|
|
||||||
|
if(!fieldsets || !fieldsets.length) return;
|
||||||
|
|
||||||
|
fieldsets.forEach(fieldset=>{
|
||||||
|
if(fieldset.type != ToCEntryType.FieldSet){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const fields = fieldset.form.get('fields') as FormArray;
|
||||||
|
|
||||||
|
fields.controls.forEach(fieldControl=>{
|
||||||
|
if(this.hasInvalidVisibilityRule(fieldControl as FormGroup)){
|
||||||
|
try{
|
||||||
|
(fieldControl.get('visible').get('rules') as FormArray).clear();
|
||||||
|
}catch{}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private hasInvalidVisibilityRule(field: FormGroup):boolean{
|
||||||
|
const renderStyle = field.get('viewStyle').get('renderStyle').value;
|
||||||
|
if(renderStyle && ![
|
||||||
|
DatasetProfileFieldViewStyle.TextArea,
|
||||||
|
DatasetProfileFieldViewStyle.FreeText,
|
||||||
|
DatasetProfileFieldViewStyle.BooleanDecision,
|
||||||
|
DatasetProfileFieldViewStyle.RadioBox,
|
||||||
|
DatasetProfileFieldViewStyle.CheckBox,
|
||||||
|
DatasetProfileFieldViewStyle.DatePicker,
|
||||||
|
DatasetProfileFieldViewStyle.ComboBox,
|
||||||
|
].includes(renderStyle)){
|
||||||
|
if(((renderStyle === DatasetProfileFieldViewStyle) && (field.get('data').get('type').value === DatasetProfileComboBoxType.WordList))){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
if(field.get('visible').get('rules').value.length){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}catch{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -532,6 +532,15 @@
|
||||||
},
|
},
|
||||||
"FEEDBACK-MESSAGES":{
|
"FEEDBACK-MESSAGES":{
|
||||||
"SAVE-SUCCESS":"Changes were saved successfully."
|
"SAVE-SUCCESS":"Changes were saved successfully."
|
||||||
|
},
|
||||||
|
"ERRORS":{
|
||||||
|
"INVALID-VISIBILITY-RULES":{
|
||||||
|
"MESSAGE-START": "There were invalid visibilty rules detected in ",
|
||||||
|
"MESSAGE-END": ". Would you like to fix them?",
|
||||||
|
"CONFIRM-YES": "Yes, remove invalid rules",
|
||||||
|
"CONFIRM-NO": "No, keep them.",
|
||||||
|
"REMOVE-SUCCESS":"Invalid visibility rules were removed successfully."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"GRANT-LISTING": {
|
"GRANT-LISTING": {
|
||||||
|
|
|
@ -532,6 +532,15 @@
|
||||||
},
|
},
|
||||||
"FEEDBACK-MESSAGES":{
|
"FEEDBACK-MESSAGES":{
|
||||||
"SAVE-SUCCESS":"Changes were saved successfully."
|
"SAVE-SUCCESS":"Changes were saved successfully."
|
||||||
|
},
|
||||||
|
"ERRORS":{
|
||||||
|
"INVALID-VISIBILITY-RULES":{
|
||||||
|
"MESSAGE-START": "There were invalid visibilty rules detected in ",
|
||||||
|
"MESSAGE-END": ". Would you like to fix them?",
|
||||||
|
"CONFIRM-YES": "Yes, remove invalid rules",
|
||||||
|
"CONFIRM-NO": "No, keep them.",
|
||||||
|
"REMOVE-SUCCESS":"Invalid visibility rules were removed successfully."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"GRANT-LISTING": {
|
"GRANT-LISTING": {
|
||||||
|
|
|
@ -532,6 +532,15 @@
|
||||||
},
|
},
|
||||||
"FEEDBACK-MESSAGES":{
|
"FEEDBACK-MESSAGES":{
|
||||||
"SAVE-SUCCESS":"Changes were saved successfully."
|
"SAVE-SUCCESS":"Changes were saved successfully."
|
||||||
|
},
|
||||||
|
"ERRORS":{
|
||||||
|
"INVALID-VISIBILITY-RULES":{
|
||||||
|
"MESSAGE-START": "There were invalid visibilty rules detected in ",
|
||||||
|
"MESSAGE-END": ". Would you like to fix them?",
|
||||||
|
"CONFIRM-YES": "Yes, remove invalid rules",
|
||||||
|
"CONFIRM-NO": "No, keep them.",
|
||||||
|
"REMOVE-SUCCESS":"Invalid visibility rules were removed successfully."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"GRANT-LISTING": {
|
"GRANT-LISTING": {
|
||||||
|
|
|
@ -532,6 +532,15 @@
|
||||||
},
|
},
|
||||||
"FEEDBACK-MESSAGES":{
|
"FEEDBACK-MESSAGES":{
|
||||||
"SAVE-SUCCESS":"Changes were saved successfully."
|
"SAVE-SUCCESS":"Changes were saved successfully."
|
||||||
|
},
|
||||||
|
"ERRORS":{
|
||||||
|
"INVALID-VISIBILITY-RULES":{
|
||||||
|
"MESSAGE-START": "There were invalid visibilty rules detected in ",
|
||||||
|
"MESSAGE-END": ". Would you like to fix them?",
|
||||||
|
"CONFIRM-YES": "Yes, remove invalid rules",
|
||||||
|
"CONFIRM-NO": "No, keep them.",
|
||||||
|
"REMOVE-SUCCESS":"Invalid visibility rules were removed successfully."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"GRANT-LISTING": {
|
"GRANT-LISTING": {
|
||||||
|
|
|
@ -532,6 +532,15 @@
|
||||||
},
|
},
|
||||||
"FEEDBACK-MESSAGES":{
|
"FEEDBACK-MESSAGES":{
|
||||||
"SAVE-SUCCESS":"Changes were saved successfully."
|
"SAVE-SUCCESS":"Changes were saved successfully."
|
||||||
|
},
|
||||||
|
"ERRORS":{
|
||||||
|
"INVALID-VISIBILITY-RULES":{
|
||||||
|
"MESSAGE-START": "There were invalid visibilty rules detected in ",
|
||||||
|
"MESSAGE-END": ". Would you like to fix them?",
|
||||||
|
"CONFIRM-YES": "Yes, remove invalid rules",
|
||||||
|
"CONFIRM-NO": "No, keep them.",
|
||||||
|
"REMOVE-SUCCESS":"Invalid visibility rules were removed successfully."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"GRANT-LISTING": {
|
"GRANT-LISTING": {
|
||||||
|
|
|
@ -532,6 +532,15 @@
|
||||||
},
|
},
|
||||||
"FEEDBACK-MESSAGES":{
|
"FEEDBACK-MESSAGES":{
|
||||||
"SAVE-SUCCESS":"Changes were saved successfully."
|
"SAVE-SUCCESS":"Changes were saved successfully."
|
||||||
|
},
|
||||||
|
"ERRORS":{
|
||||||
|
"INVALID-VISIBILITY-RULES":{
|
||||||
|
"MESSAGE-START": "There were invalid visibilty rules detected in ",
|
||||||
|
"MESSAGE-END": ". Would you like to fix them?",
|
||||||
|
"CONFIRM-YES": "Yes, remove invalid rules",
|
||||||
|
"CONFIRM-NO": "No, keep them.",
|
||||||
|
"REMOVE-SUCCESS":"Invalid visibility rules were removed successfully."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"GRANT-LISTING": {
|
"GRANT-LISTING": {
|
||||||
|
|
|
@ -532,6 +532,15 @@
|
||||||
},
|
},
|
||||||
"FEEDBACK-MESSAGES":{
|
"FEEDBACK-MESSAGES":{
|
||||||
"SAVE-SUCCESS":"Changes were saved successfully."
|
"SAVE-SUCCESS":"Changes were saved successfully."
|
||||||
|
},
|
||||||
|
"ERRORS":{
|
||||||
|
"INVALID-VISIBILITY-RULES":{
|
||||||
|
"MESSAGE-START": "There were invalid visibilty rules detected in ",
|
||||||
|
"MESSAGE-END": ". Would you like to fix them?",
|
||||||
|
"CONFIRM-YES": "Yes, remove invalid rules",
|
||||||
|
"CONFIRM-NO": "No, keep them.",
|
||||||
|
"REMOVE-SUCCESS":"Invalid visibility rules were removed successfully."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"GRANT-LISTING": {
|
"GRANT-LISTING": {
|
||||||
|
|
|
@ -532,6 +532,15 @@
|
||||||
},
|
},
|
||||||
"FEEDBACK-MESSAGES":{
|
"FEEDBACK-MESSAGES":{
|
||||||
"SAVE-SUCCESS":"Changes were saved successfully."
|
"SAVE-SUCCESS":"Changes were saved successfully."
|
||||||
|
},
|
||||||
|
"ERRORS":{
|
||||||
|
"INVALID-VISIBILITY-RULES":{
|
||||||
|
"MESSAGE-START": "There were invalid visibilty rules detected in ",
|
||||||
|
"MESSAGE-END": ". Would you like to fix them?",
|
||||||
|
"CONFIRM-YES": "Yes, remove invalid rules",
|
||||||
|
"CONFIRM-NO": "No, keep them.",
|
||||||
|
"REMOVE-SUCCESS":"Invalid visibility rules were removed successfully."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"GRANT-LISTING": {
|
"GRANT-LISTING": {
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.cancel-btn {
|
.cancel-btn {
|
||||||
width: 101px;
|
min-width: 101px;
|
||||||
height: 43px;
|
height: 43px;
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
border: 1px solid #b5b5b5;
|
border: 1px solid #b5b5b5;
|
||||||
|
|
Loading…
Reference in New Issue