Skip to content

Commit

Permalink
Use radio buttons
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Wurster <miwurster@googlemail.com>
  • Loading branch information
miwurster committed Mar 23, 2021
1 parent 39def08 commit 69546b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
</td>
<td class="table-td">
<div style="margin-left: 2px; margin-top: 4px;">
<input type="checkbox" id="isMemberCheckbox" [checked]="isMember(p)"
(change)="toggleMembership(p)">
<input type="radio" id="isMemberCheckbox"
[name]="node.id"
[value]="p.id"
(change)="toggleMembership(p)"
[checked]="isMember(p)">
<label for="isMemberCheckbox"></label>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,44 +48,12 @@ export class AssignDeploymentTechnologyComponent implements OnInit {

isMember(dt: DeploymentTechnology) {
const value = this.node.otherAttributes[AssignDeploymentTechnologyComponent.QNAME];
if (value) {
if (value.indexOf(',') > -1) {
return value.split(',').indexOf(dt.id) > -1;
} else {
return dt.id === value;
}
}
return false;
return value && dt.id === value;
}

toggleMembership(dt: DeploymentTechnology) {
const value = this.node.otherAttributes[AssignDeploymentTechnologyComponent.QNAME];
if (this.isMember(dt)) {
if (value.indexOf(',') > -1) {
const arr = value.split(',');
const index = arr.findIndex((p) => p === dt.id);
arr.splice(index, 1);
this.ngRedux.dispatch(this.ngActions.assignDeploymentTechnology(this.node, arr.join(',')));
} else {
this.ngRedux.dispatch(this.ngActions.assignDeploymentTechnology(this.node, ''));
}
} else {
if (value) {
if (value.indexOf(',') > -1) {
const arr = value.split(',');
arr.push(dt.id);
this.ngRedux.dispatch(this.ngActions.assignDeploymentTechnology(
this.node, arr.join(',')
));
} else {
this.ngRedux.dispatch(this.ngActions.assignDeploymentTechnology(
this.node, value + ',' + dt.id
));
}
} else {
this.ngRedux.dispatch(this.ngActions.assignDeploymentTechnology(this.node, dt.id));
}
}
console.log('toggleMembership', dt);
this.ngRedux.dispatch(this.ngActions.assignDeploymentTechnology(this.node, dt.id));
}

isEmpty(): boolean {
Expand Down

0 comments on commit 69546b2

Please sign in to comment.