Skip to content

Commit

Permalink
Merge pull request #88 from feup-infolab/Cidoc-&-Templates-experiments
Browse files Browse the repository at this point in the history
Full update done
  • Loading branch information
nunofreitas96 committed Jun 29, 2020
2 parents 009fad1 + 8ac08be commit d4a9764
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 25 deletions.
7 changes: 4 additions & 3 deletions frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
MatButtonModule,
MatExpansionModule,
MatFormFieldModule,
MatInputModule,
MatInputModule, MatListModule,
MatOptionModule,
MatSelectModule,
MatSliderModule
Expand All @@ -32,7 +32,7 @@ const appRoutes: Routes = [
{ path: ':uid', component: EditEntityComponent },
{ path: '', component: SearchComponent },
{ path: 'viewtemplate/:uid', component: ViewTemplateComponent },
{ path: 'eva/:uid', component: DocumentComponentComponent}
{ path: 'uidglab/:uid', component: DocumentComponentComponent}

];

Expand Down Expand Up @@ -69,7 +69,8 @@ const appRoutes: Routes = [
MatFormFieldModule,
MatInputModule,
MatOptionModule,
MatSelectModule
MatSelectModule,
MatListModule
],
providers: [MyServiceService],
bootstrap: [ AppComponent ],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<mat-accordion>

<mat-expansion-panel>
<mat-expansion-panel-header>
Expand All @@ -9,27 +8,20 @@

<mat-form-field>
<mat-label>Title Name</mat-label>
<input matInput [value]="titleName">
<input matInput [value]="titleName" [(ngModel)]="titleName">
</mat-form-field>

<mat-form-field>
<mat-label>Type</mat-label>
<input matInput [value]=titleType >
</mat-form-field>

<div>
<mat-form-field>
<mat-label>Change Type</mat-label>
<mat-select>
<mat-option *ngFor="let title of titleTypes" [value]="title.value">
<mat-select [(value)]=titleType >
<mat-option *ngFor="let title of titleTypes" [value]="title.option" >
{{title.option}}
</mat-option>
</mat-select>
</mat-form-field>
</div>

</mat-expansion-panel>

<mat-expansion-panel >
<mat-expansion-panel-header>
<mat-panel-title>
Expand All @@ -39,23 +31,18 @@

<mat-form-field>
<mat-label>Identifier</mat-label>
<input matInput [value]=identifierName>
<input matInput [value]=identifierName [(ngModel)]="identifierName">
</mat-form-field>

<mat-form-field>
<mat-label>Type</mat-label>
<input matInput [value]=identifierType>
</mat-form-field>

<div>
<mat-form-field>
<mat-label>Change Type</mat-label>
<mat-select>
<mat-option *ngFor="let identifier of identifierTypes" [value]="identifier .value">
{{identifier .option}}
<mat-select [(value)]=identifierType>
<mat-option *ngFor="let identifier of identifierTypes" [value]="identifier.option">
{{identifier.option}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</mat-expansion-panel>
</mat-accordion>

<button mat-raised-button disabled color="primary" [disabled]="checkChange()" (click)="submitUpdate()">Update</button>
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,35 @@ export class DocumentComponentComponent implements OnInit {

template = {};

ftitleType = '';
ftitleName = '';
fidentifierName = '';
fidentifierType = '';
titleType = '';
titleName = '';
identifierName = '';
identifierType = '';
titleTypeVal = '';
identifierTypeVal = '';

titleTypes = [];
identifierTypes = [];

id = {
value: '',
type: ''
};

titlef = {
value: '',
type: ''
};

deliveredJson = {
identifier : [],
title: []
};



ngOnInit() {
Expand All @@ -73,6 +94,10 @@ export class DocumentComponentComponent implements OnInit {
this.identifierName = returnedTemplate.identifier[0].value;
this.titleType = returnedTemplate.title[0].type;
this.titleName = returnedTemplate.title[0].value;
this.fidentifierType = returnedTemplate.identifier[0].type;
this.fidentifierName = returnedTemplate.identifier[0].value;
this.ftitleType = returnedTemplate.title[0].type;
this.ftitleName = returnedTemplate.title[0].value;
this.getTitleTypes();
});
}
Expand All @@ -95,4 +120,39 @@ export class DocumentComponentComponent implements OnInit {

}

submitUpdate() {
let j: any;
for (j in this.titleTypes) {
if (this.titleTypes[j].option === this.titleType) {
this.titleTypeVal = this.titleTypes[j].value;
console.log('this worked');
console.log(this.titleTypeVal);
}
}
for (j in this.identifierTypes) {
if (this.identifierTypes[j].option === this.identifierType) {
this.identifierTypeVal = this.identifierTypes[j].value;
console.log('this worked');
console.log(this.identifierTypeVal);
}
}
this.deliveredJson.identifier.push({value: this.identifierName, type: this.identifierTypeVal});
this.deliveredJson.title.push({value: this.titleName, type: this.titleTypeVal});

this.service.postDocTemplate(this.uid, this.deliveredJson)
.subscribe(returned => {
console.log('Delivered Json');
console.log(this.deliveredJson);
console.log('Returned');
console.log(returned);
});
}

checkChange() {

// tslint:disable-next-line:max-line-length
return this.ftitleName === this.titleName && this.fidentifierName === this.identifierName && this.fidentifierType === this.identifierType && this.ftitleType === this.titleType;

}

}
4 changes: 4 additions & 0 deletions frontend/src/app/service/my-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export class MyServiceService {
return this.http.get<any>(this.baseUrl + 'uidglab/' + uid);
}

postDocTemplate(uid, content): Observable<any> {
return this.http.post<any>(this.baseUrl + 'uidglab/' + uid, content);
}

getAllTitleTypes(): Observable<any> {
return this.http.get<any>(this.baseUrl + 'control_values/title_types');
}
Expand Down

0 comments on commit d4a9764

Please sign in to comment.