Skip to content

Commit

Permalink
fix(value): fix boolean value issue (#557)
Browse files Browse the repository at this point in the history
* fix(value): fix issue if boolean value does not exist

* chore(value): boolean value cannot be deleted

* test(value): fix tests

* fix(search): reactivate "exists" comparison operator for boolean value

* test(value): set correct comment
  • Loading branch information
kilchenmann committed Oct 20, 2021
1 parent 5f8213c commit 4d35cd2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
Expand Up @@ -47,11 +47,11 @@
(click)="toggleComment()">
<mat-icon>comment</mat-icon>
</button>
<span [matTooltip]="(canDelete ? 'delete' : 'This value cannot be deleted because at least one value is required')">
<span [matTooltip]="((canDelete && valueTypeOrClass != constants.BooleanValue ) ? 'delete' : 'This value cannot be deleted because at least one value is required')">
<button mat-button
class="delete"
*ngIf="!readOnlyValue && canModify && !editModeActive && projectStatus"
[disabled]="!canDelete"
[disabled]="!canDelete || valueTypeOrClass === constants.BooleanValue"
(click)="openDialog()">
<mat-icon>delete</mat-icon>
</button>
Expand Down
Expand Up @@ -137,11 +137,7 @@ <h3 class="label mat-title">
</div>
<!-- Add button -->
<div *ngIf="addValueIsAllowed(prop) && project?.status">
<!-- boolen value will always be displayed even if value is not defined (value = false) -->
<span *ngIf="prop.propDef.objectType === booleanValueTypeIri">
<app-boolean-value [mode]="'read'" class="boolean-value"></app-boolean-value>
</span>
<button *ngIf="prop.propDef.objectType !== booleanValueTypeIri" mat-icon-button type="button" class="value-action create"
<button mat-icon-button type="button" class="value-action create"
(click)="showAddValueForm(prop, $event)"
title="Add a new value">
<mat-icon>add_box</mat-icon>
Expand Down
Expand Up @@ -389,7 +389,6 @@ describe('PropertiesComponent', () => {
let addButtons = propertyViewComponentDe.queryAll(By.css('button.create'));

// current amount of buttons should equal 17
// because the boolean property shouldn't have an add button if it has a value
// standoff links value and has incoming link value are system props and cannot be added: -2
expect(addButtons.length).toEqual(17);

Expand All @@ -399,14 +398,9 @@ describe('PropertiesComponent', () => {
testHostFixture.detectChanges();

// now the boolean property should have an add button
// so the amount of add buttons on the page should increase by 1
// standoff links value and has incoming link value are system props and cannot be added: -2
addButtons = propertyViewComponentDe.queryAll(By.css('button.create'));
expect(addButtons.length).toEqual(17);

// in case of boolean value, we do not display the add button, but the boolean value itself
const booleanValue = propertyViewComponentDe.queryAll(By.css('.boolean-value'));
expect(booleanValue.length).toEqual(1);
expect(addButtons.length).toEqual(18);

});

Expand Down
Expand Up @@ -122,7 +122,7 @@ export class SpecifyPropertyValueComponent implements OnChanges, OnDestroy {
break;

case Constants.BooleanValue:
this.comparisonOperators = [new Equals()];
this.comparisonOperators = [new Equals(), new Exists()];
break;

case Constants.UriValue:
Expand Down

0 comments on commit 4d35cd2

Please sign in to comment.