Skip to content

Commit 6f2e81e

Browse files
committed
account's tenant feature done
1 parent c07be28 commit 6f2e81e

File tree

4 files changed

+74
-64
lines changed

4 files changed

+74
-64
lines changed
Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,56 @@
1-
<form autocomplete="off"
2-
#changeTenantForm="ngForm"
3-
(ngSubmit)="save()">
4-
<h1 mat-dialog-title >{{ "ChangeTenant" | localize }}</h1>
5-
<mat-dialog-content>
6-
<mat-form-field>
7-
<input
8-
matInput
9-
name="tenancyName"
10-
[placeholder]="'TenancyName' | localize"
11-
[(ngModel)]="tenancyName"
12-
maxlength="64"/>
13-
</mat-form-field>
14-
<span class="help-block">{{ "LeaveEmptyToSwitchToHost" | localize }}</span>
15-
</mat-dialog-content>
16-
<div mat-dialog-actions
17-
align="end">
18-
<button mat-button
19-
type="button"
20-
[disabled]="saving"
21-
(click)="close()">{{ "Cancel" | localize }}</button>
22-
<button mat-flat-button
23-
type="submit"
24-
flex="15"
25-
color="primary"
26-
[disabled]="!changeTenantForm.form.valid || saving">{{ "Save" | localize }}</button>
1+
<form
2+
class="form-horizontal"
3+
autocomplete="off"
4+
#changeTenantForm="ngForm"
5+
(ngSubmit)="save()"
6+
>
7+
<div class="modal-header">
8+
<h4 class="modal-title">{{ "ChangeTenant" | localize }}</h4>
9+
<button
10+
type="button"
11+
class="close"
12+
aria-label="Close"
13+
(click)="bsModalRef.hide()"
14+
>
15+
<span aria-hidden="true">×</span>
16+
</button>
17+
</div>
18+
<div class="modal-body">
19+
<div class="form-group row">
20+
<label class="col-md-3 col-form-label" for="tenancyName">
21+
{{ "TenancyName" | localize }}
22+
</label>
23+
<div class="col-md-9">
24+
<input
25+
type="text"
26+
class="form-control"
27+
id="tenancyName"
28+
name="tenancyName"
29+
[(ngModel)]="tenancyName"
30+
maxlength="64"
31+
/>
32+
</div>
2733
</div>
34+
<span>
35+
<i class="fa fa-info-circle"></i>
36+
{{ "LeaveEmptyToSwitchToHost" | localize }}
37+
</span>
38+
</div>
39+
<div class="modal-footer justify-content-between">
40+
<button
41+
type="button"
42+
class="btn btn-default"
43+
[disabled]="saving"
44+
(click)="bsModalRef.hide()"
45+
>
46+
{{ "Cancel" | localize }}
47+
</button>
48+
<button
49+
type="submit"
50+
class="btn btn-primary"
51+
[disabled]="!changeTenantForm.form.valid || saving"
52+
>
53+
{{ "Save" | localize }}
54+
</button>
55+
</div>
2856
</form>

angular/src/account/tenant/tenant-change-dialog.component.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, Injector } from '@angular/core';
2-
import { MatDialogRef } from '@angular/material';
32
import { finalize } from 'rxjs/operators';
3+
import { BsModalRef } from 'ngx-bootstrap/modal';
44
import { AppComponentBase } from '@shared/app-component-base';
55
import { AccountServiceProxy } from '@shared/service-proxies/service-proxies';
66
import { AppTenantAvailabilityState } from '@shared/AppEnums';
@@ -10,14 +10,7 @@ import {
1010
} from '@shared/service-proxies/service-proxies';
1111

1212
@Component({
13-
templateUrl: './tenant-change-dialog.component.html',
14-
styles: [
15-
`
16-
mat-form-field {
17-
width: 100%;
18-
}
19-
`
20-
]
13+
templateUrl: './tenant-change-dialog.component.html'
2114
})
2215
export class TenantChangeDialogComponent extends AppComponentBase {
2316
saving = false;
@@ -26,15 +19,15 @@ export class TenantChangeDialogComponent extends AppComponentBase {
2619
constructor(
2720
injector: Injector,
2821
private _accountService: AccountServiceProxy,
29-
private _dialogRef: MatDialogRef<TenantChangeDialogComponent>
22+
public bsModalRef: BsModalRef
3023
) {
3124
super(injector);
3225
}
3326

3427
save(): void {
3528
if (!this.tenancyName) {
3629
abp.multiTenancy.setTenantIdCookie(undefined);
37-
this.close(true);
30+
this.bsModalRef.hide();
3831
location.reload();
3932
return;
4033
}
@@ -54,7 +47,6 @@ export class TenantChangeDialogComponent extends AppComponentBase {
5447
switch (result.state) {
5548
case AppTenantAvailabilityState.Available:
5649
abp.multiTenancy.setTenantIdCookie(result.tenantId);
57-
this.close(true);
5850
location.reload();
5951
return;
6052
case AppTenantAvailabilityState.InActive:
@@ -68,8 +60,4 @@ export class TenantChangeDialogComponent extends AppComponentBase {
6860
}
6961
});
7062
}
71-
72-
close(result?: any): void {
73-
this._dialogRef.close(result);
74-
}
7563
}
Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
<div
2-
*ngIf="isMultiTenancyEnabled"
3-
class="card tenant-change-component"
4-
style="margin-bottom: 3px;">
5-
<div class="body text-center">
6-
<span>
7-
{{ "CurrentTenant" | localize }}:
8-
<span *ngIf="tenancyName" title="{{ name }}">
9-
<strong>{{ tenancyName }}</strong>
10-
</span>
11-
<span *ngIf="!tenancyName">{{ "NotSelected" | localize }}</span>
12-
(<a href="javascript:;" (click)="showChangeModal()">{{ "Change" | localize }}</a>)
1+
<div *ngIf="isMultiTenancyEnabled" class="text-center tenant-change-component">
2+
<span>
3+
{{ "CurrentTenant" | localize }}:
4+
<span *ngIf="tenancyName" title="{{ name }}">
5+
<strong>{{ tenancyName }}</strong>
136
</span>
14-
</div>
7+
<span *ngIf="!tenancyName">{{ "NotSelected" | localize }}</span>
8+
(<a href="javascript:;" (click)="showChangeModal()">
9+
{{ "Change" | localize }} </a
10+
>)
11+
</span>
1512
</div>

angular/src/account/tenant/tenant-change.component.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnInit, Injector } from '@angular/core';
2-
import { MatDialog } from '@angular/material';
32
import { AppComponentBase } from '@shared/app-component-base';
43
import { TenantChangeDialogComponent } from './tenant-change-dialog.component';
4+
import { BsModalService } from 'ngx-bootstrap/modal';
55

66
@Component({
77
selector: 'tenant-change',
@@ -11,7 +11,7 @@ export class TenantChangeComponent extends AppComponentBase implements OnInit {
1111
tenancyName = '';
1212
name = '';
1313

14-
constructor(injector: Injector, private _dialog: MatDialog) {
14+
constructor(injector: Injector, private _modalService: BsModalService) {
1515
super(injector);
1616
}
1717

@@ -27,12 +27,9 @@ export class TenantChangeComponent extends AppComponentBase implements OnInit {
2727
}
2828

2929
showChangeModal(): void {
30-
this._dialog.open(TenantChangeDialogComponent, {
31-
width: '500px',
32-
height: '240px',
33-
position: {
34-
top: '50px'
35-
}
36-
});
30+
const modal = this._modalService.show(TenantChangeDialogComponent);
31+
if (this.appSession.tenant) {
32+
modal.content.tenancyName = this.appSession.tenant.tenancyName;
33+
}
3734
}
3835
}

0 commit comments

Comments
 (0)