Skip to content

Commit c266881

Browse files
committed
Merge branch 'refactor/style-etc' into canary
2 parents 475ca51 + c137c6d commit c266881

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2052
-2236
lines changed

Diff for: src/test/get-expected-files.js

-11
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export function app(options) {
4747
'client/_index.html',
4848
'client/app/app.' + script,
4949
'client/app/app.component.' + script,
50-
'client/app/app.config.' + script,
5150
'client/app/app.constants.' + script,
5251
'client/app/app.module.' + script,
5352
'client/app/app.' + stylesheet,
@@ -130,13 +129,6 @@ export function app(options) {
130129
files.push('.flowconfig');
131130
}
132131

133-
/* Ui-Router */
134-
if (options.router === 'uirouter') {
135-
files = files.concat([
136-
'client/components/ui-router/ui-router.mock.' + script
137-
]);
138-
}
139-
140132
/* Models - Mongoose or Sequelize */
141133
if (models) {
142134
files = files.concat([
@@ -169,10 +161,7 @@ export function app(options) {
169161
'client/app/admin/admin.module.' + script,
170162
'client/components/auth/auth.module.' + script,
171163
'client/components/auth/auth.service.' + script,
172-
'client/components/auth/interceptor.service.' + script,
173-
'client/components/auth/router.decorator.' + script,
174164
'client/components/auth/user.service.' + script,
175-
'client/components/mongoose-error/mongoose-error.directive.' + script,
176165
'server/api/user/index.js',
177166
'server/api/user/index.spec.js',
178167
'server/api/user/user.controller.js',

Diff for: templates/app/client/app/account(auth)/account.module.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import { SignupComponent } from './signup/signup.component';
1414

1515
<%_ if(filters.ngroute) { -%>
1616
const accountRoutes: Routes = [{
17-
path: 'login',
18-
component: LoginComponent,
17+
path: 'login',
18+
component: LoginComponent,
1919
}, {
20-
path: 'settings',
21-
component: SettingsComponent,
20+
path: 'settings',
21+
component: SettingsComponent,
2222
}, {
23-
path: 'signup',
24-
component: SignupComponent,
23+
path: 'signup',
24+
component: SignupComponent,
2525
}];<% } %>
2626

2727
@NgModule({

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

+43-43
Original file line numberDiff line numberDiff line change
@@ -8,62 +8,62 @@ import { AuthService } from '../../../components/auth/auth.service';
88
// @flow
99
<%_ if(filters.flow) { -%>
1010
type User = {
11-
name: string;
12-
email: string;
13-
password: string;
11+
name: string;
12+
email: string;
13+
password: string;
1414
};
1515
<%_ } -%>
1616
<%_ if(filters.ts) { -%>
1717
interface User {
18-
name: string;
19-
email: string;
20-
password: string;
18+
name: string;
19+
email: string;
20+
password: string;
2121
}
2222
<%_ } -%>
2323

2424
@Component({
25-
selector: 'login',
26-
template: require('./login.<%=templateExt%>'),
25+
selector: 'login',
26+
template: require('./login.<%=templateExt%>'),
2727
})
2828
export class LoginComponent {
29-
user: User = {
30-
name: '',
31-
email: '',
32-
password: '',
33-
};
34-
errors = {login: undefined};
35-
submitted = false;
36-
AuthService;
37-
<%_ if(filters.ngroute) { -%>
38-
Router;<% } %>
39-
<%_ if(filters.uirouter) { -%>
40-
StateService;<% } %>
41-
42-
static parameters = [AuthService, <% if(filters.ngroute) { %>Router<% } else { %>StateService<% } %>];
43-
constructor(_AuthService_: AuthService, <% if(filters.ngroute) { %>router: Router<% } else { %>_StateService_: StateService<% } %>) {
44-
this.AuthService = _AuthService_;
29+
user: User = {
30+
name: '',
31+
email: '',
32+
password: '',
33+
};
34+
errors = {login: undefined};
35+
submitted = false;
36+
AuthService;
4537
<%_ if(filters.ngroute) { -%>
46-
this.Router = router;<% } %>
38+
Router;<% } %>
4739
<%_ if(filters.uirouter) { -%>
48-
this.StateService = _StateService_;<% } %>
49-
}
50-
51-
login() {
52-
this.submitted = true;
40+
StateService;<% } %>
5341

54-
return this.AuthService.login({
55-
email: this.user.email,
56-
password: this.user.password
57-
})
58-
.then(() => {
59-
// Logged in, redirect to home
42+
static parameters = [AuthService, <% if(filters.ngroute) { %>Router<% } else { %>StateService<% } %>];
43+
constructor(_AuthService_: AuthService, <% if(filters.ngroute) { %>router: Router<% } else { %>_StateService_: StateService<% } %>) {
44+
this.AuthService = _AuthService_;
6045
<%_ if(filters.ngroute) { -%>
61-
this.Router.navigateByUrl('/home');<% } %>
46+
this.Router = router;<% } %>
6247
<%_ if(filters.uirouter) { -%>
63-
this.StateService.go('main');<% } %>
64-
})
65-
.catch(err => {
66-
this.errors.login = err.message;
67-
});
68-
}
48+
this.StateService = _StateService_;<% } %>
49+
}
50+
51+
login() {
52+
this.submitted = true;
53+
54+
return this.AuthService.login({
55+
email: this.user.email,
56+
password: this.user.password
57+
})
58+
.then(() => {
59+
// Logged in, redirect to home
60+
<%_ if(filters.ngroute) { -%>
61+
this.Router.navigateByUrl('/home');<% } %>
62+
<%_ if(filters.uirouter) { -%>
63+
this.StateService.go('main');<% } %>
64+
})
65+
.catch(err => {
66+
this.errors.login = err.message;
67+
});
68+
}
6969
}

Diff for: templates/app/client/app/account(auth)/settings/settings.component.js

+34-34
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,52 @@ import { AuthService } from '../../../components/auth/auth.service';
44
// @flow
55
<%_ if(filters.flow) { -%>
66
type User = {
7-
oldPassword: string;
8-
newPassword: string;
9-
confirmPassword: string;
7+
oldPassword: string;
8+
newPassword: string;
9+
confirmPassword: string;
1010
};
1111
<%_ } -%>
1212
<%_ if(filters.ts) { -%>
1313
interface User {
14-
oldPassword: string;
15-
newPassword: string;
16-
confirmPassword: string;
14+
oldPassword: string;
15+
newPassword: string;
16+
confirmPassword: string;
1717
}
1818
<%_ } -%>
1919

2020
@Component({
21-
selector: 'settings',
22-
template: require('./settings.<%=templateExt%>'),
21+
selector: 'settings',
22+
template: require('./settings.<%=templateExt%>'),
2323
})
2424
export class SettingsComponent {
25-
user: User = {
26-
oldPassword: '',
27-
newPassword: '',
28-
confirmPassword: ''
29-
};
30-
errors = {other: undefined};
31-
message = '';
32-
submitted = false;
33-
AuthService;
25+
user: User = {
26+
oldPassword: '',
27+
newPassword: '',
28+
confirmPassword: ''
29+
};
30+
errors = {other: undefined};
31+
message = '';
32+
submitted = false;
33+
AuthService;
3434

35-
static parameters = [AuthService];
36-
constructor(_AuthService_: AuthService) {
37-
this.AuthService = _AuthService_;
38-
}
35+
static parameters = [AuthService];
36+
constructor(_AuthService_: AuthService) {
37+
this.AuthService = _AuthService_;
38+
}
3939

40-
changePassword(form) {
41-
if(form.invalid) return;
40+
changePassword(form) {
41+
if(form.invalid) return;
4242

43-
this.submitted = true;
43+
this.submitted = true;
4444

45-
return this.AuthService.changePassword(this.user.oldPassword, this.user.newPassword)
46-
.then(() => {
47-
this.message = 'Password successfully changed.';
48-
})
49-
.catch(() => {
50-
// form.password.$setValidity('mongoose', false);
51-
this.errors.other = 'Incorrect password';
52-
this.message = '';
53-
});
54-
}
45+
return this.AuthService.changePassword(this.user.oldPassword, this.user.newPassword)
46+
.then(() => {
47+
this.message = 'Password successfully changed.';
48+
})
49+
.catch(() => {
50+
// form.password.$setValidity('mongoose', false);
51+
this.errors.other = 'Incorrect password';
52+
this.message = '';
53+
});
54+
}
5555
}

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

+55-59
Original file line numberDiff line numberDiff line change
@@ -8,76 +8,72 @@ import { AuthService } from '../../../components/auth/auth.service';
88

99
<%_ if(filters.flow) { -%>
1010
type User = {
11-
name: string;
12-
email: string;
13-
password: string;
11+
name: string;
12+
email: string;
13+
password: string;
1414
};<% } %>
1515
<%_ if(filters.ts) { -%>
1616
interface User {
17-
name: string;
18-
email: string;
19-
password: string;
17+
name: string;
18+
email: string;
19+
password: string;
2020
}<% } %>
2121

2222
@Component({
23-
selector: 'signup',
24-
template: require('./signup.<%=templateExt%>')
23+
selector: 'signup',
24+
template: require('./signup.<%=templateExt%>')
2525
})
2626
export class SignupComponent {
27-
user: User = {
28-
name: '',
29-
email: '',
30-
password: ''
31-
};
32-
errors = {};
33-
submitted = false;
34-
AuthService;
35-
<%_ if(filters.ngroute) { -%>
36-
Router;<% } %>
37-
<%_ if(filters.uirouter) { -%>
38-
StateService;<% } %>
39-
40-
static parameters = [AuthService, <% if(filters.ngroute) { %>Router<% } else { %>StateService<% } %>];
41-
constructor(_AuthService_: AuthService, <% if(filters.ngroute) { %>router: Router<% } else { %>_StateService_: StateService<% } %>) {
42-
this.AuthService = _AuthService_;
27+
user: User = {
28+
name: '',
29+
email: '',
30+
password: ''
31+
};
32+
errors = {};
33+
submitted = false;
34+
AuthService;
4335
<%_ if(filters.ngroute) { -%>
44-
this.Router = router;<% } -%>
36+
Router;<% } %>
4537
<%_ if(filters.uirouter) { -%>
46-
this.StateService = _StateService_;<% } -%>
47-
}
38+
StateService;<% } %>
39+
40+
static parameters = [AuthService, <% if(filters.ngroute) { %>Router<% } else { %>StateService<% } %>];
41+
constructor(_AuthService_: AuthService, <% if(filters.ngroute) { %>router: Router<% } else { %>_StateService_: StateService<% } %>) {
42+
this.AuthService = _AuthService_;
43+
<%_ if(filters.ngroute) { -%>
44+
this.Router = router;<% } -%>
45+
<%_ if(filters.uirouter) { -%>
46+
this.StateService = _StateService_;<% } -%>
47+
}
4848

49-
register(form) {
50-
if(form.invalid) return;
49+
register(form) {
50+
if(form.invalid) return;
5151

52-
this.submitted = true;
52+
this.submitted = true;
5353

54-
return this.AuthService.createUser({
55-
name: this.user.name,
56-
email: this.user.email,
57-
password: this.user.password
58-
})
59-
.then(() => {
60-
// Account created, redirect to home
61-
<% if(filters.ngroute) { %>this.Router.navigateByUrl('/home');<% } -%>
62-
<% if(filters.uirouter) { %>this.StateService.go('main');<% } -%>
63-
})
64-
.catch(err => {
65-
err = err.data;
66-
this.errors = {};
67-
<%_ if(filters.mongooseModels) { -%>
68-
// Update validity of form fields that match the mongoose errors
69-
err.errors.forEach((error, field) => {
70-
// form[field].$setValidity('mongoose', false);
71-
this.errors[field] = error.message;
72-
});<% } %>
73-
<%_ if(filters.sequelizeModels) { -%>
74-
// Update validity of form fields that match the sequelize errors
75-
if(err.name) {
76-
err.fields.forEach(field => {
77-
// form[field].$setValidity('mongoose', false);
78-
this.errors[field] = err.message;
79-
});
80-
}<% } %>
81-
});
82-
}
54+
return this.AuthService.createUser({
55+
name: this.user.name,
56+
email: this.user.email,
57+
password: this.user.password
58+
})
59+
.then(() => {
60+
// Account created, redirect to home
61+
<% if(filters.ngroute) { %>this.Router.navigateByUrl('/home');<% } -%>
62+
<% if(filters.uirouter) { %>this.StateService.go('main');<% } -%>
63+
})
64+
.catch(err => {
65+
err = err.data;
66+
this.errors = {};<% if(filters.mongooseModels) { %>
67+
// Update validity of form fields that match the mongoose errors
68+
err.errors.forEach((error, field) => {
69+
this.errors[field] = error.message;
70+
});<% } %><% if(filters.sequelizeModels) { %>
71+
// Update validity of form fields that match the sequelize errors
72+
if(err.name) {
73+
err.fields.forEach(field => {
74+
this.errors[field] = err.message;
75+
});
76+
}<% } %>
77+
});
78+
}
8379
}

0 commit comments

Comments
 (0)