Skip to content

Commit

Permalink
fixed key and set element as required in component when is required #273
Browse files Browse the repository at this point in the history
  • Loading branch information
Shayan1375 committed Nov 11, 2024
1 parent fcc4be6 commit 076ccfe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class EditFieldsModalComponent implements OnInit {
tree: TreeNode[];
profileName: DisplayData;

removeFieldDisabled = false;
arrayOfSelectedFields: ProfileFields[] = [];

constructor(
Expand Down Expand Up @@ -55,7 +56,7 @@ export class EditFieldsModalComponent implements OnInit {

public setSelectedChildrenFields(fields: ProfileFields[]) {
fields.forEach((field) => {
if (field.getIsSelected()) {
if (field.getIsSelected() || field.getIsRequired() || field.getRecommended()) {
this.selectedDataSelectionProfileFieldsService.addToSelection(field);
}
this.setSelectedChildrenFields(field.getChildren());
Expand All @@ -82,19 +83,22 @@ export class EditFieldsModalComponent implements OnInit {

private addNodeToSelectedFields(node: ProfileFields): void {
this.selectedDataSelectionProfileFieldsService.addToSelection(node);
node.setRecommended(false);
node.setIsSelected(true);
}

private removeNodeFromSelectedFields(node: ProfileFields): void {
this.selectedDataSelectionProfileFieldsService.removeFromSelection(node);
node.setIsSelected(false);
const fieldToUpdate = this.dataSelectionProfileProfileNode.find(
(field) => field.getId() === node.getId()
);
if (fieldToUpdate) {
fieldToUpdate.setIsSelected(false);
if (!node.getIsRequired()) {
this.selectedDataSelectionProfileFieldsService.removeFromSelection(node);
node.setIsSelected(false);
const fieldToUpdate = this.dataSelectionProfileProfileNode.find(
(field) => field.getId() === node.getId()
);
if (fieldToUpdate) {
fieldToUpdate.setIsSelected(false);
}
this.tree = FieldsTreeAdapter.fromTree(this.dataSelectionProfileProfileNode);
}
this.tree = FieldsTreeAdapter.fromTree(this.dataSelectionProfileProfileNode);
}

public saveFields() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class CreateDataSelectionProfileService {
this.instantiateDisplayData(node.description),
children,
node.isSelected || false,
node.isRequired || false,
node.required,
node.recommended
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/shared/components/tree/tree.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { TreeNode } from '../../models/TreeNode/TreeNodeInterface';

@Component({
Expand Down Expand Up @@ -52,7 +52,7 @@ export class TreeComponent implements OnInit {
}
}
public checkboxSelected(node: TreeNode): void {
if (node.data.selectable) {
if (node.data.selectable && node.data.isDisabled) {
node.data.isCheckboxSelected = !node.data.isCheckboxSelected;
this.selectedCheckbox.emit(node);
}
Expand Down

0 comments on commit 076ccfe

Please sign in to comment.