fix(tenant-management): rename GetTenant action to GetTenants

pull/1612/head
TheDiaval 6 years ago
parent 96c11740aa
commit ed7cbc1848

@ -1,7 +1,7 @@
import { TenantManagement } from '../models/tenant-management';
import { ABP } from '@abp/ng.core';
export class GetTenant {
export class GetTenants {
static readonly type = '[TenantManagement] Get Tenant';
constructor(public payload?: ABP.PageQueryParams) {}
}

@ -8,7 +8,7 @@ import { debounceTime, finalize, pluck, switchMap, take } from 'rxjs/operators';
import {
CreateTenant,
DeleteTenant,
GetTenant,
GetTenants,
GetTenantById,
UpdateTenant,
} from '../../actions/tenant-management.actions';
@ -197,7 +197,7 @@ export class TenantsComponent {
get() {
this.loading = true;
this.store
.dispatch(new GetTenant(this.pageQuery))
.dispatch(new GetTenants(this.pageQuery))
.pipe(finalize(() => (this.loading = false)))
.subscribe();
}

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Store } from '@ngxs/store';
import { GetTenant } from '../actions/tenant-management.actions';
import { GetTenants } from '../actions/tenant-management.actions';
import { TenantManagement } from '../models/tenant-management';
import { TenantManagementState } from '../states/tenant-management.state';
@ -11,6 +11,6 @@ export class TenantsResolver implements Resolve<TenantManagement.State> {
resolve() {
const data = this.store.selectSnapshot(TenantManagementState.get);
return data && data.length ? null : this.store.dispatch(new GetTenant());
return data && data.length ? null : this.store.dispatch(new GetTenants());
}
}

@ -3,7 +3,7 @@ import { switchMap, tap } from 'rxjs/operators';
import {
CreateTenant,
DeleteTenant,
GetTenant,
GetTenants,
GetTenantById,
UpdateTenant,
} from '../actions/tenant-management.actions';
@ -28,8 +28,8 @@ export class TenantManagementState {
constructor(private tenantManagementService: TenantManagementService) {}
@Action(GetTenant)
get({ patchState }: StateContext<TenantManagement.State>, { payload }: GetTenant) {
@Action(GetTenants)
get({ patchState }: StateContext<TenantManagement.State>, { payload }: GetTenants) {
return this.tenantManagementService.getTenant(payload).pipe(
tap(result =>
patchState({
@ -52,19 +52,19 @@ export class TenantManagementState {
@Action(DeleteTenant)
delete({ dispatch }: StateContext<TenantManagement.State>, { payload }: DeleteTenant) {
return this.tenantManagementService.deleteTenant(payload).pipe(switchMap(() => dispatch(new GetTenant())));
return this.tenantManagementService.deleteTenant(payload).pipe(switchMap(() => dispatch(new GetTenants())));
}
@Action(CreateTenant)
add({ dispatch }: StateContext<TenantManagement.State>, { payload }: CreateTenant) {
return this.tenantManagementService.createTenant(payload).pipe(switchMap(() => dispatch(new GetTenant())));
return this.tenantManagementService.createTenant(payload).pipe(switchMap(() => dispatch(new GetTenants())));
}
@Action(UpdateTenant)
update({ dispatch, getState }: StateContext<TenantManagement.State>, { payload }: UpdateTenant) {
return dispatch(new GetTenantById(payload.id)).pipe(
switchMap(() => this.tenantManagementService.updateTenant({ ...getState().selectedItem, ...payload })),
switchMap(() => dispatch(new GetTenant())),
switchMap(() => dispatch(new GetTenants())),
);
}
}

Loading…
Cancel
Save