Externalize HTML templates in separate files.

This commit is contained in:
Alexis Lahouze 2018-06-10 00:30:56 +02:00
parent 408a1e71b7
commit d30a8951f6
5 changed files with 50 additions and 88 deletions

View File

@ -1,38 +0,0 @@
<!-- vim: set tw=80 ts=2 sw=2 sts=2: -->
<div class="modal top am-fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="modal-title">Authentification requise</h3>
</div>
<form class="form-horizontal" ng-submit="$login()">
<div class="modal-body" id="modal-body">
<div class="form-group">
<label for="email" class="col-sm-4 control-label">Adresse email</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="email" ng-model="email"
placeholder="Nom d'utilisateur">
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-4 control-label">Mot de passe</label>
<div class="col-sm-8">
<input type="password" class="form-control" id="password"
ng-model="password" placeholder="Mot de passe">
</div>
</div>
</div>
<div class="modal-footer">
<input class="btn btn-primary" type="submit" value="OK"/>
<button class="btn btn-default" type="button" ng-click="$hide()">
Annuler
</button>
</div>
</form>
</div>
</div>
</div>

View File

@ -0,0 +1,29 @@
<form novalidate (keyup.enter)="submit()" [formGroup]="form">
<div class="form-group row">
<label for="email" class="col-sm-4 control-label">Adresse email</label>
<div class="col-sm-8"
[class.has-danger]="email.errors">
<input type="text" class="form-control" id="email"
formControlName="email" placeholder="Nom d'utilisateur">
<div class="help-block text-danger" *ngIf="email.errors">
<p *ngIf="email.errors.required">The email is required.</p>
</div>
</div>
</div>
<div class="form-group row">
<label for="password" class="col-sm-4 control-label">Mot de passe</label>
<div class="col-sm-8"
[class.has-danger]="password.errors">
<input type="password" class="form-control" id="password"
formControlName="password" placeholder="Mot de passe">
<div class="help-block text-danger" *ngIf="password.errors">
<p *ngIf="password.errors.required">The password is required.</p>
</div>
</div>
</div>
</form>

View File

@ -7,37 +7,7 @@ import { Login } from './login';
@Component({ @Component({
selector: 'login-form', selector: 'login-form',
exportAs: 'loginForm', exportAs: 'loginForm',
template: ` templateUrl: './loginForm.component.html'
<form novalidate (keyup.enter)="submit()" [formGroup]="form">
<div class="form-group row">
<label for="email" class="col-sm-4 control-label">Adresse email</label>
<div class="col-sm-8"
[class.has-danger]="email.errors">
<input type="text" class="form-control" id="email"
formControlName="email" placeholder="Nom d'utilisateur">
<div class="help-block text-danger" *ngIf="email.errors">
<p *ngIf="email.errors.required">The email is required.</p>
</div>
</div>
</div>
<div class="form-group row">
<label for="password" class="col-sm-4 control-label">Mot de passe</label>
<div class="col-sm-8"
[class.has-danger]="password.errors">
<input type="password" class="form-control" id="password"
formControlName="password" placeholder="Mot de passe">
<div class="help-block text-danger" *ngIf="password.errors">
<p *ngIf="password.errors.required">The password is required.</p>
</div>
</div>
</div>
</form>
`
}) })
export class LoginFormComponent { export class LoginFormComponent {

View File

@ -0,0 +1,17 @@
<div class="modal-header">
<h3 class="modal-title" id="modal-title">Authentification requise</h3>
</div>
<div class="modal-body" id="modal-body">
<login-form (submit)="submit()" #loginForm="loginForm"></login-form>
</div>
<div class="modal-footer">
<button class="btn btn-succes" [disabled]="!loginForm.form.valid" (click)="submit()">
Login
</button>
<button class="btn btn-default" (click)="cancel()">
Cancel
</button>
</div>

View File

@ -2,31 +2,15 @@
import { Component, Input, ViewChild } from '@angular/core'; import { Component, Input, ViewChild } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
//import { jqxWindowComponent } from 'jqwidgets-scripts/jqwidgets-ts/angular_jqxwindow';
import { jqxButtonComponent } from 'jqwidgets-scripts/jqwidgets-ts/angular_jqxbuttons';
import { Login } from './login'; import { Login } from './login';
import { LoginFormComponent } from './loginForm.component'; import { LoginFormComponent } from './loginForm.component';
@Component({ @Component({
selector: 'login-modal', selector: 'login-modal',
template: ` templateUrl: './loginModal.component.html'
<div class="modal-header">
<h3 class="modal-title" id="modal-title">Authentification requise</h3>
</div>
<div class="modal-body" id="modal-body">
<login-form (submit)="submit()" #loginForm="loginForm"></login-form>
</div>
<div class="modal-footer">
<button class="btn btn-primary" [disabled]="!loginForm.form.valid" (click)="submit()">
Login
</button>
<button class="btn btn-default" (click)="cancel()">
Cancel
</button>
</div>
`
}) })
export class LoginModalComponent { export class LoginModalComponent {
@ViewChild('loginForm') loginForm: LoginFormComponent; @ViewChild('loginForm') loginForm: LoginFormComponent;