Skip to content

Commit d8dfe1a

Browse files
authored
Merge branch 'canary' into test/canary-use-npm-scripts
2 parents d426be7 + ba4ede4 commit d8dfe1a

35 files changed

+570
-549
lines changed

src/test/get-expected-files.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export function app(options) {
8383
'server/config/environment/test.js',
8484
'server/config/environment/shared.js',
8585
'server/views/404.' + markup,
86+
'e2e/.eslintrc',
8687
'e2e/main/main.po.js',
8788
'e2e/main/main.spec.js',
8889
'e2e/components/navbar/navbar.po.js',

templates/app/.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ root = true
99

1010
# Change these settings to your own preference
1111
indent_style = space
12-
indent_size = 2
12+
indent_size = 4
1313

1414
# We recommend you to keep these unchanged
1515
end_of_line = lf

templates/app/.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
"id-blacklist": 0, //blacklist certain identifiers to prevent them being used
150150
"id-length": 0, //this option enforces minimum and maximum identifier lengths (variable names, property names etc.)
151151
"id-match": 0, //require identifiers to match the provided regular expression
152-
"indent": ["error", 2], //specify tab or space width for your code
152+
"indent": ["warn", 4], //specify tab or space width for your code
153153
"jsx-quotes": 0, //specify whether double or single quotes should be used in JSX attributes
154154
"key-spacing": 2, //enforce spacing between keys and values in object literal properties
155155
"keyword-spacing": [2, {

templates/app/_.babelrc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"presets": [
3-
"es2015",
4-
"es2016",
5-
"es2017",
6-
"stage-0"
3+
["babel-preset-env", {
4+
"targets": {
5+
"node": "6.2"
6+
}
7+
}]
78
],
89
"plugins": [
910
<%_ if(filters.flow) { -%>
1011
"transform-flow-comments",
1112
<%_ } -%>
12-
"angular2-annotations",
1313
"transform-runtime",
1414
"transform-decorators-legacy"
1515
]

templates/app/_package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
"babel-plugin-transform-class-properties": "^6.6.0",
119119
"babel-plugin-transform-runtime": "^6.6.0",
120120
"babel-plugin-istanbul": "^4.1.4",
121+
"babel-preset-env": "^1.6.1",
121122
"babel-preset-es2015": "^6.6.0",
122123
"cross-env": "^5.1.1",
123124
"eslint": "^2.12.0",
@@ -182,6 +183,7 @@
182183
<%# END WEBPACK %>
183184
"through2": "^2.0.1",
184185
"open": "~0.0.4",
186+
"protractor": "^5.3.0",
185187
"istanbul": "1.1.0-alpha.1",
186188
"chai": "^4.1.2",
187189
"sinon": "^3.2.1",
@@ -220,6 +222,7 @@
220222
"test": "gulp test",
221223
"test:client": "karma start ./karma.conf.js --single-run",
222224
"test:server": "cross-env NODE_ENV=test ./node_modules/.bin/mocha --reporter spec --timeout 5000 --require ./mocha.conf.js ./server/**/*.{spec,integration}.js mocha.global.js",
225+
"test:e2e": "gulp webpack:dev && protractor ./protractor.conf.js",
223226
<%_ if(filters.flow) { -%>
224227
"flow": "flow",
225228
<%_ } -%>

templates/app/client/app/account(auth)/login/login.component.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
// @flow
12
import { Component } from '@angular/core';
23
<%_ if(filters.uirouter) { -%>
34
import { StateService } from 'ui-router-ng2';<% } %>
45
<%_ if(filters.ngroute) { -%>
56
import { Router } from '@angular/router';<% } %>
67
import { AuthService } from '../../../components/auth/auth.service';
78

8-
// @flow
99
<%_ if(filters.flow) { -%>
1010
type User = {
1111
name: string;
@@ -48,8 +48,8 @@ export class LoginComponent {
4848
this.StateService = _StateService_;<% } %>
4949
}
5050

51-
login() {
52-
this.submitted = true;
51+
login(form) {
52+
if(form.invalid) return;
5353

5454
return this.AuthService.login({
5555
email: this.user.email,
@@ -63,7 +63,7 @@ export class LoginComponent {
6363
this.StateService.go('main');<% } %>
6464
})
6565
.catch(err => {
66-
this.errors.login = err.message;
66+
this.errors.login = err.json().message;
6767
});
6868
}
6969
}

templates/app/client/app/account(auth)/login/login.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ <h1>Login</h1>
66
<p>Admin account is <code>admin@example.com</code> / <code>admin</code></p>
77
</div>
88
<div class="col-sm-12">
9-
<form class="form" name="loginForm" (ngSubmit)="login()" novalidate #loginForm="ngForm">
9+
<form class="form" name="loginForm" (ngSubmit)="login(loginForm)" novalidate #loginForm="ngForm">
1010

1111
<div class="form-group">
1212
<label>Email</label>

templates/app/client/app/account(auth)/signup/signup.component.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import { StateService } from 'ui-router-ng2';<% } %>
55
<%_ if(filters.ngroute) { -%>
66
import { Router } from '@angular/router';<% } %>
77
import { AuthService } from '../../../components/auth/auth.service';
8+
import template from './signup.html';
89

910
<%_ if(filters.flow) { -%>
1011
type User = {
1112
name: string;
1213
email: string;
1314
password: string;
14-
};<% } %>
15-
<%_ if(filters.ts) { -%>
15+
};<% } %><%_ if(filters.ts) { -%>
1616
interface User {
1717
name: string;
1818
email: string;
@@ -21,7 +21,7 @@ interface User {
2121

2222
@Component({
2323
selector: 'signup',
24-
template: require('./signup.<%=templateExt%>')
24+
template,
2525
})
2626
export class SignupComponent {
2727
user: User = {
@@ -61,19 +61,27 @@ export class SignupComponent {
6161
<% if(filters.ngroute) { %>this.Router.navigateByUrl('/home');<% } -%>
6262
<% if(filters.uirouter) { %>this.StateService.go('main');<% } -%>
6363
})
64-
.catch(err => {
65-
err = err.data;
66-
this.errors = {};<% if(filters.mongooseModels) { %>
64+
.catch(err => {<% if(filters.mongooseModels) { %>
65+
this.errors = err.errors;
66+
6767
// Update validity of form fields that match the mongoose errors
68-
err.errors.forEach((error, field) => {
68+
Object.entries(err.errors).forEach(([field, error]) => {
6969
this.errors[field] = error.message;
70+
71+
if(field === 'email' && error.kind === 'user defined') {
72+
form.form.controls[field].setErrors({inUse: true});
73+
}
7074
});<% } %><% if(filters.sequelizeModels) { %>
75+
this.errors = {};
76+
7177
// Update validity of form fields that match the sequelize errors
7278
if(err.name) {
7379
err.fields.forEach(field => {
7480
this.errors[field] = err.message;
7581
});
7682
}<% } %>
83+
84+
this.submitted = false;
7785
});
7886
}
7987
}

templates/app/client/app/account(auth)/signup/signup.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<h1>Sign up</h1>
55
</div>
66
<div class="col-sm-12">
7-
<form class="form" name="form" (ngSubmit)="register(form)" novalidate #signupForm="ngForm">
7+
<form class="form" name="form" (ngSubmit)="register(signupForm)" novalidate #signupForm="ngForm">
88

99
<div class="form-group"
1010
[class.has-success]="name.valid && submitted"
@@ -26,11 +26,11 @@ <h1>Sign up</h1>
2626
required
2727
mongoose-error
2828
#email="ngModel">
29-
<p class="help-block" [hidden]="email.valid || (email.pristine && !signupForm.submitted)">
29+
<p class="help-block" [hidden]="email.valid || (email.pristine && !signupForm.submitted) || (email.errors ? email.errors.inUse : true)">
3030
Please enter a valid email address.
3131
</p>
32-
<p class="help-block" [hidden]="!errors.email">
33-
{{ errors.email }}
32+
<p class="help-block" [hidden]="email.errors ? !email.errors.inUse : true">
33+
This email address is already in use.
3434
</p>
3535
</div>
3636

templates/app/client/app/admin(auth)/admin.module.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { BrowserModule } from '@angular/platform-browser';<% if(filters.uirouter
33
import { UIRouterModule } from 'ui-router-ng2';<% } %><% if(filters.ngroute) { %>
44
import { RouterModule, Routes } from '@angular/router';<% } %>
55
import { AuthGuard } from '../../components/auth/auth-guard.service';
6+
import { AuthModule } from '../../components/auth/auth.module';
67
import { AdminComponent } from './admin.component';
78

89
<%_ if(filters.uirouter) { -%>
@@ -16,6 +17,7 @@ const adminRoutes: Routes = [{
1617

1718
@NgModule({
1819
imports: [
20+
AuthModule,
1921
BrowserModule,
2022
<%_ if(filters.ngroute) { _%>
2123
RouterModule.forChild(adminRoutes),<% } %>

0 commit comments

Comments
 (0)