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 { ActivatedRoute, Router } from '@angular/router';
import { Boilerplate } from 'src/app/models/boilerplate.model'; import { Boilerplate } from 'src/app/models/boilerplate.model';
import { Sections } from 'src/app/models/boilerplate.model'; import { Sections } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service'; import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { MainService } from 'src/app/services/main.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'; ...@@ -14,7 +18,6 @@ import { MainService } from 'src/app/services/main.service';
styleUrls: ['./boilerplate-details.component.scss'] styleUrls: ['./boilerplate-details.component.scss']
}) })
export class BoilerplateDetailsComponent implements OnInit { export class BoilerplateDetailsComponent implements OnInit {
panelOpenState = false; panelOpenState = false;
subjects:string[] = []; subjects:string[] = [];
...@@ -31,12 +34,18 @@ export class BoilerplateDetailsComponent implements OnInit { ...@@ -31,12 +34,18 @@ export class BoilerplateDetailsComponent implements OnInit {
message = ''; message = '';
searchText = ''; searchText = '';
searchTextinstances = ''; searchTextinstances = '';
private readonly notifier: NotifierService;
constructor( constructor(
private mainService: MainService, private mainService: MainService,
private boilerplateService: BoilerplateService, private boilerplateService: BoilerplateService,
private route: ActivatedRoute, 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 { ngOnInit(): void {
this.message = ''; this.message = '';
...@@ -57,16 +66,19 @@ export class BoilerplateDetailsComponent implements OnInit { ...@@ -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) this.boilerplateService.update(this.route.snapshot.params.gb, this.currentboilerplate.id, this.currentboilerplate)
.subscribe( .subscribe(
response => { response => {
console.log(response); this.notifier.notify("success",(JSON.stringify("Requirement " + this.currentboilerplate.title + " updated")));
this.message = response.message; this.router.navigate(['/groupboilerplates/'+this.route.snapshot.params.gb+'/boilerplates']);
window.location.reload();
}, },
error => { error => {
console.log(error); this.notifier.notify("warning",(JSON.stringify(error)));
}); });
} }
......
...@@ -57,8 +57,8 @@ ...@@ -57,8 +57,8 @@
</form> </form>
</div> </div>
</div> </div>
<div class="form-row"> <div class="form-row" >
<div class="col"> <div class="col" style="width: 100px;">
<form class="form-group form-inline"> <form class="form-group form-inline">
<mat-form-field class="example-full-width"> <mat-form-field class="example-full-width">
<mat-label>Shall/shall not</mat-label> <mat-label>Shall/shall not</mat-label>
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
[formControl]="shallControl" [formControl]="shallControl"
[matAutocomplete]="autoshall" [matAutocomplete]="autoshall"
> >
<mat-autocomplete autoActiveFirstOption #autoshall ="matAutocomplete"> <mat-autocomplete autoActiveFirstOption #autoshall ="matAutocomplete" >
<mat-option *ngFor="let option of shallfilteredOptions | async" [value]="option"> <mat-option *ngFor="let option of shallfilteredOptions | async" [value]="option">
{{option}} {{option}}
</mat-option> </mat-option>
...@@ -186,10 +186,4 @@ ...@@ -186,10 +186,4 @@
</mat-form-field> </mat-form-field>
</form> </form>
</div> </div>
<div class="col">
<input class="btn btn-success"
type="button"
value="Update Main"
(click)="updateMain()"/>
</div>
</div> </div>
\ No newline at end of file
.example-full-width { .example-full-width {
width: 100%; width: 100%;
} }
.example-mid-width {
width: 50%;
}
.mat-autocomplete { .mat-autocomplete {
width: 100%; 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 { ActivatedRoute, Router } from '@angular/router';
import { Main } from 'src/app/models/main.model'; import { Main } from 'src/app/models/main.model';
import { Mainsyntax } from 'src/app/models/main.model'; import { Mainsyntax } from 'src/app/models/main.model';
...@@ -47,7 +47,7 @@ export class MainDetailsComponent implements OnInit { ...@@ -47,7 +47,7 @@ export class MainDetailsComponent implements OnInit {
verb:string[] = []; verb:string[] = [];
verbfilteredOptions: Observable<string[]>; verbfilteredOptions: Observable<string[]>;
quantifierControl = new FormControl(); quantifierControl = new FormControl( );
quantifier:string[] = []; quantifier:string[] = [];
quantifierfilteredOptions: Observable<string[]>; quantifierfilteredOptions: Observable<string[]>;
quantifierControlisDivVisible = false quantifierControlisDivVisible = false
...@@ -154,14 +154,14 @@ export class MainDetailsComponent implements OnInit { ...@@ -154,14 +154,14 @@ export class MainDetailsComponent implements OnInit {
//console.log("Verb okk") //console.log("Verb okk")
for (let a=0; a < this.mainsyntax[x].Attributes.length; a++ ){ 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, "")){ 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 ){ if (this.mainsyntax[x].Related_to_Subject.length > 0 ){
this.stateitemControlisDivVisible = true this.stateitemControlisDivVisible = true
for (let r=0; r < this.mainsyntax[x].Related_to_Subject.length; r++ ){ 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; } 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){ if (this.mainsyntax[x].Quantifier){
//this.quantifierControl.enable(); //this.quantifierControl.enable();
this.quantifierControlisDivVisible = true; this.quantifierControlisDivVisible = true;
...@@ -247,7 +247,6 @@ export class MainDetailsComponent implements OnInit { ...@@ -247,7 +247,6 @@ export class MainDetailsComponent implements OnInit {
}); });
} }
updateMain(): void { updateMain(): void {
this.currentmain.sys_fun_inter = this.subjectsControl.value; this.currentmain.sys_fun_inter = this.subjectsControl.value;
if( this.stateitemControlisDivVisible){this.currentmain.state_item_before_verb = this.stateitemControl.value;} if( this.stateitemControlisDivVisible){this.currentmain.state_item_before_verb = this.stateitemControl.value;}
...@@ -263,13 +262,13 @@ export class MainDetailsComponent implements OnInit { ...@@ -263,13 +262,13 @@ export class MainDetailsComponent implements OnInit {
this.mainService.update(this.route.snapshot.params.id, MainDetailsComponent.id[i], this.currentmain) this.mainService.update(this.route.snapshot.params.id, MainDetailsComponent.id[i], this.currentmain)
.subscribe( .subscribe(
response => { response => {
this.notifier.notify("success",JSON.stringify("Prefix updated"));
this.message = response.message; this.message = response.message;
}, },
error => { error => {
console.log(error);
this.notifier.notify("warning",(JSON.stringify(error["error"]))); this.notifier.notify("warning",(JSON.stringify(error["error"])));
});} });}
} }
......
...@@ -100,12 +100,6 @@ ...@@ -100,12 +100,6 @@
</fieldset> </fieldset>
</form> </form>
</div> </div>
<div class="col">
<input class="btn btn-success"
type="button"
value="Update Prefix"
(click)="updatePrefix()"/>
</div>
</div> </div>
......
...@@ -133,7 +133,7 @@ export class PrefixDetailsComponent implements OnInit { ...@@ -133,7 +133,7 @@ export class PrefixDetailsComponent implements OnInit {
} }
updatePrefix(): void { updatePrefix(): any {
this.currentprefix.prefix = this.simpleprefixControl.value; this.currentprefix.prefix = this.simpleprefixControl.value;
this.currentprefix.system_fun_item = this.subjectsControl.value; this.currentprefix.system_fun_item = this.subjectsControl.value;
this.currentprefix.state_or_verb = this.verbsControl.value; this.currentprefix.state_or_verb = this.verbsControl.value;
...@@ -143,11 +143,9 @@ export class PrefixDetailsComponent implements OnInit { ...@@ -143,11 +143,9 @@ export class PrefixDetailsComponent implements OnInit {
this.prefixService.update(this.route.snapshot.params.id, PrefixDetailsComponent.id[i], this.currentprefix) this.prefixService.update(this.route.snapshot.params.id, PrefixDetailsComponent.id[i], this.currentprefix)
.subscribe( .subscribe(
response => { response => {
this.notifier.notify("success",JSON.stringify("Prefix updated"));
this.message = response.message; this.message = response.message;
}, },
error => { error => {
console.log(error);
this.notifier.notify("warning",(JSON.stringify(error["error"]))); this.notifier.notify("warning",(JSON.stringify(error["error"])));
});} });}
} }
......
...@@ -65,10 +65,4 @@ ...@@ -65,10 +65,4 @@
</mat-form-field> </mat-form-field>
</form> </form>
</div> </div>
<div class="col">
<input class="btn btn-success"
type="button"
value="Update Suffix"
(click)="updateSuffix()"/>
</div>
</div> </div>
\ No newline at end of file
...@@ -122,11 +122,9 @@ export class SuffixDetailsComponent implements OnInit { ...@@ -122,11 +122,9 @@ export class SuffixDetailsComponent implements OnInit {
this.suffixService.update(this.route.snapshot.params.id, SuffixDetailsComponent.id[i], this.currentsuffix) this.suffixService.update(this.route.snapshot.params.id, SuffixDetailsComponent.id[i], this.currentsuffix)
.subscribe( .subscribe(
response => { response => {
this.notifier.notify("success",JSON.stringify("Suffix updated"));
this.message = response.message; this.message = response.message;
}, },
error => { error => {
console.log(error);
this.notifier.notify("warning",(JSON.stringify(error["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 ...@@ -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") FUNCTION_INSTANCES_COMMENTS = get_dmo_instance_and_comment("SAO#Function")
# #
SHALL_CHOICES = ( ("shall", "shall"), ("shall not", "shall not")) SHALL_CHOICES = ( ("shall", "shall"), ("shall not", "shall not"))
QUANTIFIER_CHOICES = ( ("none","NONE"), ("all", "ALL"), ("only", "ONLY"), QUANTIFIER_CHOICES = ( ("NONE","NONE"), ("ALL", "ALL"), ("ONLY", "ONLY"),
("more than", "MORE THAN"), ("less than", "LESS THAN"), ("exactly","EXACTLY"), ("MORE THAN", "MORE THAN"), ("LESS THAN", "LESS THAN"), ("EXACTLY","EXACTLY"),
("at least", "AT LEAST"), ("at most", "AT MOST") ("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
ITEM_CHOICES = get_instances("SAO#Item") ITEM_CHOICES = get_instances("SAO#Item")
ITEM_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Item") ITEM_CLASSES_COMMENTS = get_dmo_classes_and_comment("SAO#Item")
......
...@@ -141,13 +141,13 @@ class Prefix(models.Model): ...@@ -141,13 +141,13 @@ class Prefix(models.Model):
prefix_boilerplate = models.ForeignKey(Boilerplate, related_name='prefix_boilerplate', on_delete=models.CASCADE) prefix_boilerplate = models.ForeignKey(Boilerplate, related_name='prefix_boilerplate', on_delete=models.CASCADE)
prefix = models.CharField(choices=PREFIX_CHOICES, max_length=100) prefix = models.CharField(choices=PREFIX_CHOICES, max_length=100)
#state value constraint #state value constraint
system_fun_item = models.CharField(choices= (ITEM_CHOICES + SYSTEM_CHOICES + FUNCTION_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, blank=True) 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) #state_value = models.CharField(choices=STATE_VALUE_CHOICES, max_length=100, blank=True)
#occuring functionality #occuring functionality
#sys_fun = models.CharField(choices=, max_length=100, blank=True) #sys_fun = models.CharField(choices=, max_length=100, blank=True)
#verb = models.CharField(choices=VERB_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 #Prefix value P1/P2/P3
logical_expression = models.CharField(choices=LOGICAL_EXPRESSION, max_length=100, blank=True) logical_expression = models.CharField(choices=LOGICAL_EXPRESSION, max_length=100, blank=True)
#Info for prefix #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