Skip to content

Commit

Permalink
fix(properties): do not submit res instance form by adding new value (D…
Browse files Browse the repository at this point in the history
  • Loading branch information
kilchenmann committed Oct 15, 2021
1 parent d7bec78 commit 99a3022
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
Expand Up @@ -137,8 +137,8 @@ <h3 class="label mat-title">
</div>
<!-- Add button -->
<div *ngIf="addValueIsAllowed(prop) && project?.status">
<button mat-icon-button class="value-action create"
(click)="showAddValueForm(prop)"
<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>
</button>
Expand Down
Expand Up @@ -356,7 +356,8 @@ export class PropertiesComponent implements OnInit, OnChanges, OnDestroy {
/**
* called from the template when the user clicks on the add button
*/
showAddValueForm(prop: PropertyInfoValues) {
showAddValueForm(prop: PropertyInfoValues, ev: Event) {
ev.preventDefault();
this.propID = prop.propDef.id;
this.addValueFormIsVisible = true;
}
Expand Down
Expand Up @@ -50,9 +50,10 @@
<div class="buttons">
<button mat-icon-button
*ngIf="propertyValuesKeyValuePair[prop.id + '-filtered'].length !== 1"
type="button"
class="value-action delete"
title="Delete this value"
(click)="deleteValue(prop, i)">
(click)="deleteValue(prop, i, $event)">
<mat-icon>delete</mat-icon>
</button>
</div>
Expand All @@ -61,9 +62,10 @@
<!-- Add button -->
<div *ngIf="addValueIsAllowed(prop)">
<button mat-icon-button
type="button"
class="value-action create"
title="Add a new value"
(click)="addNewValueFormToProperty(prop)">
(click)="addNewValueFormToProperty(prop, $event)">
<mat-icon>add_box</mat-icon>
</button>
</div>
Expand Down
Expand Up @@ -111,7 +111,9 @@ export class SelectPropertiesComponent implements OnInit {
/**
* called from the template when the user clicks on the add button
*/
addNewValueFormToProperty(prop: ResourcePropertyDefinition) {
addNewValueFormToProperty(prop: ResourcePropertyDefinition, ev: Event) {
ev.preventDefault();

// get the length of the corresponding property values array
const length = this.propertyValuesKeyValuePair[prop.id].length;

Expand All @@ -124,7 +126,8 @@ export class SelectPropertiesComponent implements OnInit {
this.propertyValuesKeyValuePair[prop.id + '-filtered'].push(length);
}

deleteValue(prop: ResourcePropertyDefinition, index: number) {
deleteValue(prop: ResourcePropertyDefinition, index: number, ev: Event) {
ev.preventDefault();
// don't actually remove the item from the property values array, just set it to undefined.
// this is because if we actually modify the indexes of the array, the template will re-evaluate
// and recreate components for any elements after the deleted index, effectively erasing entered data if any was entered
Expand Down

0 comments on commit 99a3022

Please sign in to comment.