-
Notifications
You must be signed in to change notification settings - Fork 2
Create module
florianInfo edited this page Feb 21, 2019
·
18 revisions
HOME > DOCUMENTATION > CREATE MODULE
- Go in src/api/core/demo/input
- Create a folder called : type-input where type is the type of the input (ex: image-input, sound-input, ...)
- Create 2 typescript files inside : type-input.component.ts and type-input.presenter.ts
- Write this code in the type-input.component.ts file:
import {InputComponent} from '../input.component';
import { TypeInputPresenter } from './type-input.presenter';
export interface TypeInputComponent extends InputComponent{
getPresenter():TypeInputPresenter;
//some methods to implements
}
Replace Type by the name given before.
- Write this code in the type-input.presenter.ts file :
import {InputPresenter} from '../input.presenter';
export interface TypeInputPresenter extends InputPresenter{
//some methods to implements
}
Replace Type by the name given before.
- In the folder src/api/core/demo/input create a file type-input.d.ts
- Write this code inside (export new interfaces created just before) :
export * from './type-input/type-input.presenter'
export * from './type-input/type-input.component'
- Open cmd
- Go in src/app/demo/input
- Generate a new component with the command : ng generate component type-input where type is the name as in the API
- A folder called type-input is created, create a new file inside : type-input.presenter.ts
- In the file type-input.component.ts :
- rename the class (add the suffix Impl )
- implement the interface of the component
- implement the method of the API ( getPresenter() )
- import interfaces from the API (created brefore TypeInputComponent and TypeInputPresenter)
- import the implementation of the presenter (created just after this part)
import { Component, OnInit } from '@angular/core';
import { TypeInputComponent } from '@api/core/demo/input/type-input';
import { TypeInputPresenter } from '@api/core/demo/input/type-input/type-input.presenter'
import { TypeInputPresenterImpl } from './type-input.presenter';
@Component({
selector: 'app-type-input',
templateUrl: './type-input.component.html',
styleUrls: ['./type-input.component.css']
})
export class TypeInputComponentImpl implements OnInit, TypeInputComponent {
private presenter:TypeInputPresenter;
constructor() {
}
ngOnInit() {
}
getPresenter():TypeInputPresenter {
return this.presenter;
}
}
Replace Type by the name given brefore. Don't forget the type in imports and in selector, template and style
- In the file type-input.presenter.ts paste this code and rename Type by the name givn before :
import {TypeInputPresenter} from '@api/core/demo/input/type-input';;
export class TypeInputPresenterImpl implements TypeInputPresenter {
}
- In the file src/app/demo/input/input-container.component :
- import the new component :
import {TypeInputComponentImpl} from './type-input/type-input.component';
- add it to the map to make it available :
private mapSons = new Map()
.set("image", ImageInputComponentImpl)
.set("json", JsonInputComponentImpl)
.set("type", TypeInputComponentImpl);
- In the file src/app/app.module.ts :
- add the new component in the list entryComponents:
entryComponents: [JsonInputComponentImpl, ImageInputComponentImpl, JSONModelComponentImpl, TSModelComponentImpl, TypeInputComponentImpl],
- Go in src/api/core/model
- Create a folder called : type-model where type is the type of the model(ex: text-model, form-model, ...)
- Create 2 typescript files inside : type-model.component.ts and type-model.presenter.ts
- Write this code in the type-model.component.ts file:
import {ModelComponent} from '../model.component';
import { TypeModelPresenter } from './type-model.presenter';
export interface TypeModelComponent extends ModelComponent{
getPresenter():TypeModelPresenter;
//some methods to implements
}
Replace Type by the name given before.
- Write this code in the type-model.presenter.ts file :
import {ModelPresenter} from '../model.presenter';
export interface TypeModelPresenter extends ModelPresenter{
//some methods to implements
}
Replace Type by the name given before.
- In the folder src/api/core/model create a file type-model.d.ts
- Write this code inside (export new interfaces created just before) :
export * from './type-model/type-model.presenter'
export * from './type-model/type-model.component'
- Open cmd
- Go in src/app/demo/model
- Generate a new component with the command : ng generate component type-model where type is the name as in the API
- A folder called type-model is created, create a new file inside : type-model.presenter.ts
- In the file type-model.component.ts :
- rename the class (add the suffix Impl )
- implement the interface of the component
- implement the method of the API ( getPresenter() )
- import interfaces from the API (created brefore TypeModelComponent and TypeModelPresenter)
- import the implementation of the presenter (created just after this part)
import { Component, OnInit } from '@angular/core';
import { TypeModelComponent } from '@api/core/model/type-model';
import { TypeModelPresenter } from '@api/core/model/type-model/type-model.presenter'
import { TypeModelPresenterImpl } from './type-model.presenter';
@Component({
selector: 'app-type-model',
templateUrl: './type-model.component.html',
styleUrls: ['./type-model.component.css']
})
export class TypeModelComponentImpl implements OnInit, TypeModelComponent {
private presenter:TypeModelPresenter;
constructor() {
}
ngOnInit() {
}
getPresenter():TypeModelPresenter {
return this.presenter;
}
}
Replace Type by the name given brefore. Don't forget the type in imports and in selector, template and style
- In the file type-model.presenter.ts paste this code and rename Type by the name given before :
import {TypeModelPresenter} from '@api/core/model/type-model';
export class TypeModelPresenterImpl implements TypeModelPresenter {
}
- In the file src/app/demo/model/model-container.component :
- import the new component :
import {TypeModelComponentImpl} from './type-model/type-model.component';
- add it to the map to make it available :
private mapSons = new Map()
.set("json", JSONModelComponentImpl)
.set("typescript", TSModelComponentImpl)
.set("type", TypeModelComponentImpl);
- In the file src/app/app.module.ts :
- add the new component in the list entryComponents:
entryComponents: [JsonInputComponentImpl, ImageInputComponentImpl, JSONModelComponentImpl, TSModelComponentImpl, TypeModelComponentImpl],