Commit e5d4a803 authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

update button in edit

parent 176ab9ac
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Boilerplate } from 'src/app/models/boilerplate.model';
import { Sections } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { MainService } from 'src/app/services/main.service';
import {MainDetailsComponent} from 'src/app/components/main-details/main-details.component'
import {PrefixDetailsComponent} from 'src/app/components/prefix-details/prefix-details.component'
import {SuffixDetailsComponent} from 'src/app/components/suffix-details/suffix-details.component'
import { NotifierService } from "angular-notifier";
......@@ -14,7 +18,6 @@ import { MainService } from 'src/app/services/main.service';
styleUrls: ['./boilerplate-details.component.scss']
})
export class BoilerplateDetailsComponent implements OnInit {
panelOpenState = false;
subjects:string[] = [];
......@@ -31,12 +34,18 @@ export class BoilerplateDetailsComponent implements OnInit {
message = '';
searchText = '';
searchTextinstances = '';
private readonly notifier: NotifierService;
constructor(
private mainService: MainService,
private boilerplateService: BoilerplateService,
private route: ActivatedRoute,
private router: Router) { }
notifierService: NotifierService,
private router: Router) { this.notifier = notifierService; }
@ViewChild(MainDetailsComponent) mainchild!: MainDetailsComponent;
@ViewChild(PrefixDetailsComponent) prefchild!: PrefixDetailsComponent;
@ViewChild(SuffixDetailsComponent) sufchild!: SuffixDetailsComponent;
ngOnInit(): void {
this.message = '';
......@@ -57,16 +66,19 @@ export class BoilerplateDetailsComponent implements OnInit {
});
}
updateBoilerplate(): void {
updateBoilerplate(): any {
if (this.currentboilerplate.has_prefix){this.prefchild.updatePrefix()};
if (this.currentboilerplate.has_main){this.mainchild.updateMain();};
if (this.currentboilerplate.has_suffix){this.sufchild.updateSuffix();};
this.boilerplateService.update(this.route.snapshot.params.gb, this.currentboilerplate.id, this.currentboilerplate)
.subscribe(
response => {
console.log(response);
this.message = response.message;
window.location.reload();
this.notifier.notify("success",(JSON.stringify("Requirement " + this.currentboilerplate.title + " updated")));
this.router.navigate(['/groupboilerplates/'+this.route.snapshot.params.gb+'/boilerplates']);
},
error => {
console.log(error);
this.notifier.notify("warning",(JSON.stringify(error)));
});
}
......
......@@ -57,8 +57,8 @@
</form>
</div>
</div>
<div class="form-row">
<div class="col">
<div class="form-row" >
<div class="col" style="width: 100px;">
<form class="form-group form-inline">
<mat-form-field class="example-full-width">
<mat-label>Shall/shall not</mat-label>
......@@ -69,7 +69,7 @@
[formControl]="shallControl"
[matAutocomplete]="autoshall"
>
<mat-autocomplete autoActiveFirstOption #autoshall ="matAutocomplete">
<mat-autocomplete autoActiveFirstOption #autoshall ="matAutocomplete" >
<mat-option *ngFor="let option of shallfilteredOptions | async" [value]="option">
{{option}}
</mat-option>
......@@ -186,10 +186,4 @@
</mat-form-field>
</form>
</div>
<div class="col">
<input class="btn btn-success"
type="button"
value="Update Main"
(click)="updateMain()"/>
</div>
</div>
\ No newline at end of file
.example-full-width {
width: 100%;
}
.example-mid-width {
width: 50%;
}
.mat-autocomplete {
width: 100%;
}
.mat-autocomplete-mid {
width: 50%;
}
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, Output, EventEmitter} from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Main } from 'src/app/models/main.model';
import { Mainsyntax } from 'src/app/models/main.model';
......@@ -47,7 +47,7 @@ export class MainDetailsComponent implements OnInit {
verb:string[] = [];
verbfilteredOptions: Observable<string[]>;
quantifierControl = new FormControl();
quantifierControl = new FormControl( );
quantifier:string[] = [];
quantifierfilteredOptions: Observable<string[]>;
quantifierControlisDivVisible = false
......@@ -154,14 +154,14 @@ export class MainDetailsComponent implements OnInit {
//console.log("Verb okk")
for (let a=0; a < this.mainsyntax[x].Attributes.length; a++ ){
if (this.mainsyntax[x].Attributes[a] == (this.fifuintsysstatsetControl.value.slice(0, this.fifuintsysstatsetControl.value.indexOf(':'))).replace(/\s/g, "")){
console.log("Attribute okk", this.mainsyntax[x].Id)
//console.log("Attribute okk", this.mainsyntax[x].Id)
if (this.mainsyntax[x].Related_to_Subject.length > 0 ){
this.stateitemControlisDivVisible = true
for (let r=0; r < this.mainsyntax[x].Related_to_Subject.length; r++ ){
if (this.mainsyntax[x].Related_to_Subject[r] == "StateValue"){this.statevalueControlisDivVisible = true; }
}
}
console.log(this.mainsyntax[x].Quantifier)
//console.log(this.mainsyntax[x].Quantifier)
if (this.mainsyntax[x].Quantifier){
//this.quantifierControl.enable();
this.quantifierControlisDivVisible = true;
......@@ -247,7 +247,6 @@ export class MainDetailsComponent implements OnInit {
});
}
updateMain(): void {
this.currentmain.sys_fun_inter = this.subjectsControl.value;
if( this.stateitemControlisDivVisible){this.currentmain.state_item_before_verb = this.stateitemControl.value;}
......@@ -263,13 +262,13 @@ export class MainDetailsComponent implements OnInit {
this.mainService.update(this.route.snapshot.params.id, MainDetailsComponent.id[i], this.currentmain)
.subscribe(
response => {
this.notifier.notify("success",JSON.stringify("Prefix updated"));
this.message = response.message;
},
error => {
console.log(error);
this.notifier.notify("warning",(JSON.stringify(error["error"])));
});}
}
......
......@@ -100,12 +100,6 @@
</fieldset>
</form>
</div>
<div class="col">
<input class="btn btn-success"
type="button"
value="Update Prefix"
(click)="updatePrefix()"/>
</div>
</div>
......
......@@ -133,7 +133,7 @@ export class PrefixDetailsComponent implements OnInit {
}
updatePrefix(): void {
updatePrefix(): any {
this.currentprefix.prefix = this.simpleprefixControl.value;
this.currentprefix.system_fun_item = this.subjectsControl.value;
this.currentprefix.state_or_verb = this.verbsControl.value;
......@@ -143,11 +143,9 @@ export class PrefixDetailsComponent implements OnInit {
this.prefixService.update(this.route.snapshot.params.id, PrefixDetailsComponent.id[i], this.currentprefix)
.subscribe(
response => {
this.notifier.notify("success",JSON.stringify("Prefix updated"));
this.message = response.message;
},
error => {
console.log(error);
this.notifier.notify("warning",(JSON.stringify(error["error"])));
});}
}
......
......@@ -65,10 +65,4 @@
</mat-form-field>
</form>
</div>
<div class="col">
<input class="btn btn-success"
type="button"
value="Update Suffix"
(click)="updateSuffix()"/>
</div>
</div>
\ No newline at end of file
......@@ -122,11 +122,9 @@ export class SuffixDetailsComponent implements OnInit {
this.suffixService.update(this.route.snapshot.params.id, SuffixDetailsComponent.id[i], this.currentsuffix)
.subscribe(
response => {
this.notifier.notify("success",JSON.stringify("Suffix updated"));
this.message = response.message;
},
error => {
console.log(error);
this.notifier.notify("warning",(JSON.stringify(error["error"])));
});}
}
......
......@@ -45,11 +45,11 @@ FUNCTION_SUBCLASSES_COMMENTS = get_dmo_classes_of_classes_and_comment("SAO#Funct
FUNCTION_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Function")
#
SHALL_CHOICES = ( ("shall", "shall"), ("shall not", "shall not"))
QUANTIFIER_CHOICES = ( ("none","NONE"), ("all", "ALL"), ("only", "ONLY"),
("more than", "MORE THAN"), ("less than", "LESS THAN"), ("exactly","EXACTLY"),
("at least", "AT LEAST"), ("at most", "AT MOST")
QUANTIFIER_CHOICES = ( ("NONE","NONE"), ("ALL", "ALL"), ("ONLY", "ONLY"),
("MORE THAN", "MORE THAN"), ("LESS THAN", "LESS THAN"), ("EXACTLY","EXACTLY"),
("AT LEAST", "AT LEAST"), ("AT MOST", "AT MOST")
)
NUMBER_UNITS_CHOICES = (("",""), ("meters","METERS"), ("kilometers","KILOMETERS"), ("volt","VOLT"))
NUMBER_UNITS_CHOICES = (("",""), ("METERS","METERS"), ("KILOMETERS","KILOMETERS"), ("VOLT","VOLT"))
#ITEM
ITEM_CHOICES = get_instances("SAO#Item")
ITEM_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Item")
......
......@@ -141,13 +141,13 @@ class Prefix(models.Model):
prefix_boilerplate = models.ForeignKey(Boilerplate, related_name='prefix_boilerplate', on_delete=models.CASCADE)
prefix = models.CharField(choices=PREFIX_CHOICES, max_length=100)
#state value constraint
system_fun_item = models.CharField(choices= (ITEM_CHOICES + SYSTEM_CHOICES + FUNCTION_CHOICES), max_length=100, blank=True)
state_or_verb = models.CharField(choices=STATE_CHOICES + VERB_CHOICES, max_length=100, blank=True)
system_fun_item = models.CharField(choices= (ITEM_CHOICES + SYSTEM_CHOICES + FUNCTION_CHOICES), max_length=100)
state_or_verb = models.CharField(choices=STATE_CHOICES + VERB_CHOICES, max_length=100)
#state_value = models.CharField(choices=STATE_VALUE_CHOICES, max_length=100, blank=True)
#occuring functionality
#sys_fun = models.CharField(choices=, max_length=100, blank=True)
#verb = models.CharField(choices=VERB_CHOICES, max_length=100, blank=True)
item_function_flow_statevalue = models.CharField(choices=ITEM_CHOICES + FLOW_CHOICES + FUNCTION_CHOICES + STATE_VALUE_CHOICES, max_length=100, blank=True)
item_function_flow_statevalue = models.CharField(choices=ITEM_CHOICES + FLOW_CHOICES + FUNCTION_CHOICES + STATE_VALUE_CHOICES, max_length=100)
#Prefix value P1/P2/P3
logical_expression = models.CharField(choices=LOGICAL_EXPRESSION, max_length=100, blank=True)
#Info for prefix
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment