Skip to content

Commit

Permalink
Implement saving functionality for editing
Browse files Browse the repository at this point in the history
This rolls back the extraction of an editor component from the previous
commit due to issues with data transfer between the components.
Additionally this corrects two minor bugs in the serialization of
PropertiesDefinitions around SchemaDefinitions.
  • Loading branch information
Vogel612 committed Jul 20, 2020
1 parent b7e8ab9 commit 296a66b
Show file tree
Hide file tree
Showing 11 changed files with 349 additions and 325 deletions.
Expand Up @@ -16,6 +16,7 @@ import { Visuals } from './visuals';
import { TPolicy } from './policiesModalData';
import { Interface } from '../../../../tosca-management/src/app/model/interfaces';
import { PropertiesDefinition } from '../../../../tosca-management/src/app/instance/sharedComponents/propertiesDefinition/propertiesDefinitionsResourceApiData';
import { Constraint } from '../../../../tosca-management/src/app/model/constraint';

export class AbstractTEntity {
constructor(public documentation?: any,
Expand Down Expand Up @@ -187,19 +188,19 @@ export class TDataType extends EntityType {
namespace: string,
properties: any,
public full: any,
public constraints: any,
public keySchema: SchemaDefinition,
public entrySchema: SchemaDefinition) {
public constraints: Constraint[] = [],
public keySchema: SchemaDefinition = undefined,
public entrySchema: SchemaDefinition = undefined) {
super(id, qName, name, namespace, properties, full);
}
}

export class SchemaDefinition {
constructor(public type: string,
public description: string,
public constraints: any,
public keySchema: SchemaDefinition,
public entrySchema: SchemaDefinition
public description: string = '',
public constraints: Constraint[] = [],
public keySchema: SchemaDefinition = undefined,
public entrySchema: SchemaDefinition = undefined,
) {}
}

Expand Down
Expand Up @@ -481,7 +481,6 @@ tr.row.col-sm-12 {
border-radius: 0.25rem;
/*color: #FFFFFF;*/
color: black;
//top: 102px;
z-index: 999;
position: relative;
box-shadow: 2px 2px 10px -2px rgba(0, 0, 0, 0.75);
Expand Down

This file was deleted.

This file was deleted.

Expand Up @@ -94,20 +94,110 @@
</div>

<ng-template #editorModal>
<winery-modal-header [modalRef]="editorModalRef" [title]="'Add a Property Definition'">
<winery-modal-header [modalRef]="editorModalRef" [title]="propertyOperation + ' a Property Definition'">
</winery-modal-header>
<winery-modal-body>
<winery-properties-definition-editor #editor
[editedProperty]="editedProperty"
[propertyData]="resourceApiData.propertiesDefinition || resourceApiData.winerysPropertiesDefinition">
</winery-properties-definition-editor>
<!-- editor is not a separate component to allow communication between it and this component -->
<form id="editPropertyForm">
<div class="form-group">
<label class="control-label" for="name">Name</label>
<input #nameInput
#propName="ngModel"
id="name"
class="form-control"
type="text"
[name]="isYaml ? 'name' : 'key'"
autocomplete=off
required
[(ngModel)]="isYaml ? editedProperty.name : editedProperty.key"
[wineryDuplicateValidator]="validatorObject"/>

<div *ngIf="propName.errors && (propName.dirty || propName.touched)"
class="alert alert-danger">
<div [hidden]="!propName.errors.wineryDuplicateValidator">
No duplicates allowed!
</div>
<div [hidden]="!propName.errors.required">
Name is required
</div>
</div>
</div>

<div class="form-group">
<label class="control-label" for="propType">Type</label>
<select #typeSelect name="type" class="form-control" id="propType"
[value]="editedProperty.type">
<option *ngFor="let type of availableTypes" value="{{ type }}">
{{ type }}
</option>
</select>
</div>
<div class="form-group" [hidden]="typeSelect.value !== 'map' && typeSelect.value !== 'list'">
<label class="control-label" for="entrySchema">Entry Schema</label>
<!-- for now we do not support or condone nesting maps or lists -->
<select #entrySchemaSelect name="entrySchema" class="form-control" id="entrySchema" [value]="editedProperty.entrySchema.type">
<option *ngFor="let type of availableTypes" value="{{ type }}">
{{ type }}
</option>
</select>
</div>
<div class="form-group" [hidden]="typeSelect.value !== 'map'">
<label class="control-label" for="keySchema">Key Schema</label>
<!-- for now we do not support or condone nesting maps or lists -->
<select #keySchemaSelect name="keySchema" class="form-control" id="keySchema" [value]="editedProperty.keySchema.type">
<option *ngFor="let type of availableTypes" value="{{ type }}">
{{ type }}
</option>
</select>
</div>
<div class="form-group">
<label class="control-label" for="defaultValue">Default Value</label>
<input #defaultValueInput id="defaultValue" class="form-control" type="text" [value]="editedProperty.defaultValue"/>
</div>
<div class="form-group">
<input #requiredCheckbox type="checkbox" id="isRequired" style="margin-right: 7px" [checked]="editedProperty.required"/>
<label class="control-label" for="isRequired">Is required</label>
</div>
<div class="form-group">
<label class="control-label" for="description">Description</label>
<input #descriptionInput id="description" class="form-control" type="text" [value]="editedProperty.description"/>
</div>
<div class="form-group">
<label class="control-label" for="constraints">Constraints</label>
<p>
<div *ngFor="let constraintClause of editedConstraints" id="constraints" class="constraintField">
<span><b>{{constraintClause.key}}</b>:
<span *ngIf="constraintClause.value != null">{{constraintClause.value}}</span>
<span *ngIf="constraintClause.list != null">{{constraintClause.list.toString()}}</span>
<button class="rightbutton btn btn-danger btn-xs" (click)="removeConstraint(constraintClause)">Delete</button>
</span>
</div>
</div>
<div class="form-group">
<label class="control-label" for="constraintKey">Add new constraint</label><br>
<select #selectedConstraintKey id="constraintKey">
<option *ngFor="let item of valid_constraint_keys">{{ item }}</option>
</select>
<div *ngIf="list_constraint_keys.includes(selectedConstraintKey.value)">
Please separate items by using ','
</div>
<div *ngIf="range_constraint_keys.includes(selectedConstraintKey.value)">
Only two items are allowed.
</div>
<input #constraintValue id="constraintVal" class="form-control" type="text"/>
<button type="button" class="btn btn-default"
(click)="addConstraint(selectedConstraintKey.value, constraintValue.value)">
Add Constraint
</button>
</div>
</form>
</winery-modal-body>
<winery-modal-footer
(onOk)="handleEditorSubmit()"
(onOk)="handleEditorSubmit(nameInput.value, typeSelect.value, entrySchemaSelect.value, keySchemaSelect.value, defaultValueInput.value, requiredCheckbox.checked, descriptionInput.value)"
[closeButtonLabel]="'Cancel'"
[okButtonLabel]="'Add'"
[okButtonLabel]="propertyOperation"
[modalRef]="editorModalRef"
[disableOkButton]="!editor.exposedForm?.form.valid">
[disableOkButton]="!propName.valid">
</winery-modal-footer>
</ng-template>

Expand Down

0 comments on commit 296a66b

Please sign in to comment.