-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix core and angular template
- Loading branch information
Showing
8 changed files
with
101 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 14 additions & 8 deletions
22
packages/cli/frameworks/angular/template/src/components/series/create/component.angular.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
import { Component } from '@angular/core'; | ||
import { ApplicationRef, Component, Inject } from '@angular/core'; | ||
import { GenericComponent } from '@leanup/lib'; | ||
|
||
import { CreateSerieController } from './controller'; | ||
|
||
@Component({ | ||
selector: 'create-serie', | ||
template: ` | ||
<form (ngSubmit)="onSubmit()"> | ||
<form (ngSubmit)="ctrl.onSubmit()"> | ||
<h2>Create a new measuring serie</h2> | ||
<editor-serie [editorForm]="editorForm"></editor-serie> | ||
<editor-serie [editorForm]="ctrl.editorForm"></editor-serie> | ||
<button class="primary" type="submit" id="submit">Add</button> | ||
<button class="secondary" type="reset" id="cancel" (click)="onCancel()">Abbrechen</button> | ||
<button class="secondary" type="reset" id="cancel" (click)="ctrl.onCancel()">Abbrechen</button> | ||
</form> | ||
`, | ||
}) | ||
export class CreateSerieComponent extends CreateSerieController { | ||
// Den Overhead braucht nur Angular?! | ||
public constructor() { | ||
super(); | ||
export class CreateSerieComponent implements GenericComponent { | ||
public readonly ctrl: CreateSerieController; | ||
|
||
public constructor(@Inject(ApplicationRef) appRef: ApplicationRef) { | ||
this.ctrl = new CreateSerieController({ | ||
hooks: { | ||
doRender: appRef.tick.bind(this), | ||
}, | ||
}); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/cli/frameworks/angular/template/src/components/series/create/controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { InputControl } from '@leanup/form'; | ||
import { AbstractController, DI } from '@leanup/lib'; | ||
|
||
import { MeasuredSerieModel } from '../../../models/measured-series.model'; | ||
import { MeasurementService } from '../../../services/measurements/service'; | ||
import { RouterService } from '../../../services/router/service'; | ||
import { EditorForm } from '../editor/editor.form'; | ||
|
||
export class CreateSerieController extends AbstractController { | ||
private readonly measurementService: MeasurementService = DI.get('MeasurementService'); | ||
public editorForm: EditorForm = new EditorForm('new'); | ||
|
||
public onSubmit(): void { | ||
const title = <InputControl>this.editorForm.getControl('title'); | ||
const unit = <InputControl>this.editorForm.getControl('unit'); | ||
this.measurementService.addSerie(new MeasuredSerieModel(<string>title.value, <string>unit.value)); | ||
this.measurementService.store(); | ||
this.editorForm = new EditorForm('new'); | ||
this.onCancel(); | ||
} | ||
|
||
public onCancel(): void { | ||
RouterService.navigate('series'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters