Skip to content

Commit 0b4a89b

Browse files
authored
Merge pull request #22 from iyilm4z/master
indentation and refactoring applied to tenant components
2 parents fd7a970 + bb3d14e commit 0b4a89b

File tree

8 files changed

+389
-310
lines changed

8 files changed

+389
-310
lines changed

angular/src/app/app.module.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ import { SharedModule } from '@shared/shared.module';
1717

1818
import { HomeComponent } from '@app/home/home.component';
1919
import { AboutComponent } from '@app/about/about.component';
20-
import { TenantsComponent } from '@app/tenants/tenants.component';
2120
import { TopBarComponent } from '@app/layout/topbar.component';
2221
import { TopBarLanguageSwitchComponent } from '@app/layout/topbar-languageswitch.component';
2322
import { SideBarUserAreaComponent } from '@app/layout/sidebar-user-area.component';
2423
import { SideBarNavComponent } from '@app/layout/sidebar-nav.component';
2524
import { SideBarFooterComponent } from '@app/layout/sidebar-footer.component';
2625
import { RightSideBarComponent } from '@app/layout/right-sidebar.component';
26+
// tenants
27+
import { TenantsComponent } from '@app/tenants/tenants.component';
2728
import { CreateTenantDialogComponent } from './tenants/create-tenant/create-tenant-dialog.component';
2829
import { EditTenantDialogComponent } from './tenants/edit-tenant/edit-tenant-dialog.component';
2930
// roles
@@ -40,15 +41,16 @@ import { EditUserDialogComponent } from '@app/users/edit-user/edit-user-dialog.c
4041
AppComponent,
4142
HomeComponent,
4243
AboutComponent,
43-
TenantsComponent,
44-
CreateTenantDialogComponent,
45-
EditTenantDialogComponent,
4644
TopBarComponent,
4745
TopBarLanguageSwitchComponent,
4846
SideBarUserAreaComponent,
4947
SideBarNavComponent,
5048
SideBarFooterComponent,
5149
RightSideBarComponent,
50+
// tenants
51+
TenantsComponent,
52+
CreateTenantDialogComponent,
53+
EditTenantDialogComponent,
5254
// roles
5355
RolesComponent,
5456
CreateRoleDialogComponent,
@@ -72,6 +74,7 @@ import { EditUserDialogComponent } from '@app/users/edit-user/edit-user-dialog.c
7274
],
7375
providers: [],
7476
entryComponents: [
77+
// tenants
7578
CreateTenantDialogComponent,
7679
EditTenantDialogComponent,
7780
// roles
Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,71 @@
1-
<form autocomplete="off"
2-
#createTenantForm="ngForm"
3-
(ngSubmit)="save()">
4-
<h1 mat-dialog-title>{{ "CreateNewTenant" | localize }}</h1>
5-
<mat-dialog-content>
1+
<form autocomplete="off" #createTenantForm="ngForm" (ngSubmit)="save()">
2+
<h1 mat-dialog-title>{{ "CreateNewTenant" | localize }}</h1>
3+
<mat-dialog-content>
4+
<div class="row-fluid">
5+
<div class="col-md-12">
66
<mat-form-field>
7-
<input matInput
8-
name="TenancyName"
9-
[(ngModel)]="tenant.tenancyName"
10-
required
11-
minlength="2"
12-
maxlength="64"
13-
[placeholder]="'TenancyName' | localize">
7+
<input
8+
matInput
9+
name="TenancyName"
10+
[placeholder]="'TenancyName' | localize"
11+
[(ngModel)]="tenant.tenancyName"
12+
required
13+
minlength="2"
14+
maxlength="64"
15+
/>
1416
</mat-form-field>
1517
<mat-form-field>
16-
<input matInput
17-
name="Name"
18-
[(ngModel)]="tenant.name"
19-
required
20-
maxlength="128"
21-
[placeholder]="'Name' | localize">
18+
<input
19+
matInput
20+
name="Name"
21+
[placeholder]="'Name' | localize"
22+
[(ngModel)]="tenant.name"
23+
required
24+
maxlength="128"
25+
/>
2226
</mat-form-field>
2327
<mat-form-field>
24-
<input matInput
25-
name="ConnectionString"
26-
[(ngModel)]="tenant.connectionString"
27-
maxlength="1024"
28-
[placeholder]="'DatabaseConnectionString' | localize">
28+
<input
29+
matInput
30+
name="ConnectionString"
31+
[placeholder]="'DatabaseConnectionString' | localize"
32+
[(ngModel)]="tenant.connectionString"
33+
maxlength="1024"
34+
/>
2935
</mat-form-field>
3036
<mat-form-field>
31-
<input matInput
32-
type="email"
33-
name="AdminEmailAddress"
34-
[(ngModel)]="tenant.adminEmailAddress"
35-
required
36-
maxlength="256"
37-
pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,})+$"
38-
[placeholder]="'AdminEmailAddress' | localize">
37+
<input
38+
matInput
39+
name="AdminEmailAddress"
40+
[placeholder]="'AdminEmailAddress' | localize"
41+
[(ngModel)]="tenant.adminEmailAddress"
42+
type="email"
43+
pattern="^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,})+$"
44+
required
45+
maxlength="256"
46+
/>
3947
</mat-form-field>
4048
<div class="checkbox-wrapper">
41-
<mat-checkbox name="IsActive"
42-
[(ngModel)]="tenant.isActive"
43-
style="padding-bottom: 5px">{{ "IsActive" | localize }}</mat-checkbox>
49+
<mat-checkbox name="IsActive" [(ngModel)]="tenant.isActive">
50+
{{ "IsActive" | localize }}
51+
</mat-checkbox>
4452
</div>
45-
46-
<p>{{ "DefaultPasswordIs" | localize:'123qwe' }}</p>
47-
</mat-dialog-content>
48-
<div mat-dialog-actions
49-
align="end">
50-
<button mat-button
51-
type="button"
52-
[disabled]="saving"
53-
(click)="close()">{{ "Cancel" | localize }}</button>
54-
<button mat-flat-button
55-
type="submit"
56-
flex="15"
57-
color="primary"
58-
[disabled]="!createTenantForm.form.valid || saving">{{ "Save" | localize }}</button>
53+
<p>{{ "DefaultPasswordIs" | localize: "123qwe" }}</p>
54+
</div>
5955
</div>
56+
</mat-dialog-content>
57+
<div mat-dialog-actions align="end">
58+
<button mat-button type="button" [disabled]="saving" (click)="close()">
59+
{{ "Cancel" | localize }}
60+
</button>
61+
<button
62+
mat-flat-button
63+
type="submit"
64+
flex="15"
65+
color="primary"
66+
[disabled]="!createTenantForm.form.valid || saving"
67+
>
68+
{{ "Save" | localize }}
69+
</button>
70+
</div>
6071
</form>
Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,59 @@
1-
2-
31
import { Component, Injector, OnInit } from '@angular/core';
4-
import { AppComponentBase } from '@shared/app-component-base';
5-
import { MatDialogRef, MatSnackBar } from '@angular/material';
6-
import { CreateTenantDto, TenantServiceProxy } from '@shared/service-proxies/service-proxies';
2+
import { MatDialogRef } from '@angular/material';
73
import { finalize } from 'rxjs/operators';
4+
import { AppComponentBase } from '@shared/app-component-base';
5+
import {
6+
CreateTenantDto,
7+
TenantServiceProxy
8+
} from '@shared/service-proxies/service-proxies';
9+
810
@Component({
9-
selector: 'create-tenant-dialog',
10-
templateUrl: 'create-tenant-dialog.component.html',
11-
styles: [`
12-
mat-form-field {
13-
width: 100%
14-
}
15-
`]
11+
templateUrl: 'create-tenant-dialog.component.html',
12+
styles: [
13+
`
14+
mat-form-field {
15+
width: 100%;
16+
}
17+
mat-checkbox {
18+
padding-bottom: 5px;
19+
}
20+
`
21+
]
1622
})
17-
export class CreateTenantDialogComponent extends AppComponentBase implements OnInit {
23+
export class CreateTenantDialogComponent extends AppComponentBase
24+
implements OnInit {
25+
saving = false;
26+
tenant: CreateTenantDto = new CreateTenantDto();
1827

19-
saving: boolean = false;
20-
tenant: CreateTenantDto = null;
28+
constructor(
29+
injector: Injector,
30+
private _tenantService: TenantServiceProxy,
31+
private _dialogRef: MatDialogRef<CreateTenantDialogComponent>
32+
) {
33+
super(injector);
34+
}
2135

22-
constructor(
23-
injector: Injector,
24-
public dialogRef: MatDialogRef<CreateTenantDialogComponent>,
25-
private _tenantService: TenantServiceProxy) {
26-
super(injector);
27-
}
36+
ngOnInit(): void {
37+
this.tenant.isActive = true;
38+
}
2839

29-
ngOnInit(): void {
30-
this.tenant = new CreateTenantDto();
31-
this.tenant.isActive = true;
32-
}
40+
save(): void {
41+
this.saving = true;
3342

34-
save(): void {
35-
this.saving = true;
36-
this._tenantService.create(this.tenant)
37-
.pipe(finalize(() => { this.saving = false; }))
38-
.subscribe(() => {
39-
this.notify.info(this.l('SavedSuccessfully'));
40-
this.close(true);
41-
})
42-
}
43+
this._tenantService
44+
.create(this.tenant)
45+
.pipe(
46+
finalize(() => {
47+
this.saving = false;
48+
})
49+
)
50+
.subscribe(() => {
51+
this.notify.info(this.l('SavedSuccessfully'));
52+
this.close(true);
53+
});
54+
}
4355

44-
close(result: any): void {
45-
this.dialogRef.close(result);
46-
}
56+
close(result: any): void {
57+
this._dialogRef.close(result);
58+
}
4759
}
Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,49 @@
1-
<form autocomplete="off"
2-
#createTenantForm="ngForm"
3-
(ngSubmit)="save()"
4-
*ngIf="active">
5-
<h1 mat-dialog-title>{{ "EditTenant" | localize }}</h1>
6-
<mat-dialog-content>
1+
<form autocomplete="off" #editTenantForm="ngForm" (ngSubmit)="save()">
2+
<h1 mat-dialog-title>{{ "EditTenant" | localize }}</h1>
3+
<mat-dialog-content>
4+
<div class="row-fluid">
5+
<div class="col-md-12">
76
<mat-form-field>
8-
<input matInput
9-
name="TenancyName"
10-
[(ngModel)]="tenant.tenancyName"
11-
required
12-
minlength="2"
13-
maxlength="64"
14-
[placeholder]="'TenancyName' | localize">
7+
<input
8+
matInput
9+
name="TenancyName"
10+
[placeholder]="'TenancyName' | localize"
11+
[(ngModel)]="tenant.tenancyName"
12+
required
13+
minlength="2"
14+
maxlength="64"
15+
/>
1516
</mat-form-field>
1617
<mat-form-field>
17-
<input matInput
18-
name="Name"
19-
[(ngModel)]="tenant.name"
20-
required
21-
maxlength="128"
22-
[placeholder]="'Name' | localize">
18+
<input
19+
matInput
20+
name="Name"
21+
[placeholder]="'Name' | localize"
22+
[(ngModel)]="tenant.name"
23+
required
24+
maxlength="128"
25+
/>
2326
</mat-form-field>
2427
<div class="checkbox-wrapper">
25-
<mat-checkbox name="IsActive"
26-
[(ngModel)]="tenant.isActive"
27-
style="padding-bottom: 5px">{{ "IsActive" | localize }}</mat-checkbox>
28+
<mat-checkbox name="IsActive" [(ngModel)]="tenant.isActive">
29+
{{ "IsActive" | localize }}
30+
</mat-checkbox>
2831
</div>
29-
</mat-dialog-content>
30-
<div mat-dialog-actions
31-
align="end">
32-
<button mat-button
33-
type="button"
34-
[disabled]="saving"
35-
(click)="close()">{{ "Cancel" | localize }}</button>
36-
<button mat-flat-button
37-
type="submit"
38-
flex="15"
39-
color="primary"
40-
[disabled]="!createTenantForm.form.valid || saving">{{ "Save" | localize }}</button>
32+
</div>
4133
</div>
34+
</mat-dialog-content>
35+
<div mat-dialog-actions align="end">
36+
<button mat-button type="button" [disabled]="saving" (click)="close()">
37+
{{ "Cancel" | localize }}
38+
</button>
39+
<button
40+
mat-flat-button
41+
type="submit"
42+
flex="15"
43+
color="primary"
44+
[disabled]="!editTenantForm.form.valid || saving"
45+
>
46+
{{ "Save" | localize }}
47+
</button>
48+
</div>
4249
</form>

0 commit comments

Comments
 (0)