Permalink
Browse files

[0.11.1] create relationship modal

  • Loading branch information...
dog-ears committed Feb 22, 2018
1 parent 311d734 commit 7295efacc56aa0c29f524bb4cffdddd817c591d3
@@ -20,6 +20,7 @@ import { SchemaComponent } from './schema/schema.component';
import { ModalDataComponent } from './modal-data/modal-data.component';
import { ModalModelComponent } from './modal-model/modal-model.component';
import { ModalSchemaComponent } from './modal-schema/modal-schema.component';
import { ModalRelationComponent } from './modal-relation/modal-relation.component';
@NgModule({
declarations: [
@@ -30,6 +31,7 @@ import { ModalSchemaComponent } from './modal-schema/modal-schema.component';
ModalDataComponent,
ModalModelComponent,
ModalSchemaComponent,
ModalRelationComponent,
],
imports: [
BrowserModule,
@@ -47,6 +49,7 @@ import { ModalSchemaComponent } from './modal-schema/modal-schema.component';
ModalDataComponent,
ModalModelComponent,
ModalSchemaComponent,
ModalRelationComponent,
]
})
export class AppModule { }
@@ -0,0 +1,52 @@
<div class="modal-header">
<h5 class="modal-title">New Relation <span *ngIf="source_model && target_model">({{source_model.name}} -> {{target_model.name}})</span></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close" (click)="bsModalRef.hide()">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="row">
<div class="col-sm-4 text-right">Type</div>
<div class="col-sm-8">
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="type" id="type1" value="one-to-many" [(ngModel)]="relation_type"> one-to-many
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="type" id="type2" value="many-to-many" [(ngModel)]="relation_type"> many-to-many
</label>
</div>
</div>
</div>
<div class="form-group row d-flex" *ngIf="source_model && target_model">
<label for="source_model_display_schema-field" class="col-sm-4 col-form-label text-right align-self-center">Source Model Display Schema</label>
<div class="col-sm-8 align-self-center" *ngIf="source_model.schemas">
<select id="source_model_display_schema-field" name="source_model_display_schema" class="form-control form-control-sm" [(ngModel)]="source_model_display_schema">
<option value="" selected disabled hidden>--- select display schema here ---</option>
<option *ngFor="let schema of source_model.schemas;" value="{{schema.name}}">{{schema.name}}</option>
</select>
</div>
</div>
<div class="form-group row d-flex" *ngIf="relation_type=='many-to-many'">
<label for="target_model_display_schema-field" class="col-sm-4 col-form-label text-right align-self-center">Target Model Display Schema</label>
<div class="col-sm-8 align-self-center" *ngIf="target_model.schemas">
<select id="target_model_display_schema-field" name="target_model_display_schema" class="form-control form-control-sm" [(ngModel)]="target_model_display_schema">
<option value="" selected disabled hidden>--- select display schema here ---</option>
<option *ngFor="let schema of target_model.schemas" value="{{schema.name}}">{{schema.name}}</option>
</select>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" (click)="create()">Create</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="bsModalRef.hide()">Close</button>
</div>
@@ -0,0 +1,44 @@
// core
import { Component } from '@angular/core';
// ngx-bootstrap
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
// service
import { DataService } from '../service/data.service';
// class
import { Model } from '../class/model';
import { Schema } from '../class/schema';
@Component({
selector: 'modal',
templateUrl: './modal-relation.component.html'
})
export class ModalRelationComponent {
public source_model: Model;
public target_model: Model;
public relation_type:string;
public source_model_display_schema: string;
public target_model_display_schema: string;
constructor( private bsModalRef: BsModalRef, private dataService: DataService ) {
console.log('ModalRelationComponent.constructor() is called!');
this.relation_type = 'one-to-many';
this.source_model_display_schema = '';
this.target_model_display_schema = '';
}
private create(){
console.log('ModalRelationComponent.create() is called!');
if(this.relation_type == 'one-to-many'){
this.dataService.addOneToManyRelation(this.source_model, this.target_model, this.source_model_display_schema, this.target_model_display_schema);
}else if(this.relation_type == 'many-to-many'){
this.dataService.addManyToManyRelation(this.source_model, this.target_model, this.source_model_display_schema, this.target_model_display_schema);
}
this.bsModalRef.hide();
}
}
@@ -61,4 +61,13 @@ export class DataService {
}
this.flg_repaint = true;
}
public addOneToManyRelation( source_model:Model, target_model:Model, source_model_display_schema:string, target_model_display_schema:string ):void{
console.log('DataService.addOneToManyRelation() is called!');
}
public addManyToManyRelation( source_model:Model, target_model:Model, source_model_display_schema:string, target_model_display_schema:string ):void{
console.log('DataService.addManyToManyRelation() is called!');
}
}

0 comments on commit 7295efa

Please sign in to comment.