bug fixed

This commit is contained in:
richard-loafle 2020-03-30 17:56:15 +09:00
parent b39312afb8
commit 3a9ae7300f
12 changed files with 116 additions and 10 deletions

8
package-lock.json generated
View File

@ -2256,9 +2256,8 @@
"dev": true
},
"@ucap/ng-store-organization": {
"version": "file:dist/store-organization/ucap-ng-store-organization-0.0.2.tgz",
"integrity": "sha512-cCCFQNvIG3FJEdxd8VkYvsKHM0tEL5ySKUvA5YS+5i0kksZJYvE2lgz7wD1rHqfg5ea57HnvrdHfFjukusJK0A==",
"dev": true
"version": "file:dist/store-organization/ucap-ng-store-organization-0.0.3.tgz",
"integrity": "sha512-qakDmEzWloikSk/Sczs2i/dL54ZAIEqkjx2x4jcn0dMKkCF2KseCphNXTfaLpAcMuGVR5ZAy2bQjy90NbbHeOg=="
},
"@ucap/ng-ui": {
"version": "file:dist/ui/ucap-ng-ui-0.0.3.tgz",
@ -2277,7 +2276,8 @@
},
"@ucap/ng-ui-skin-default": {
"version": "file:dist/ui-skin-default/ucap-ng-ui-skin-default-0.0.1.tgz",
"integrity": "sha512-vtgJBOsJj/S2GjP02PpBz9ebGikNtzdsC7JQc5HKkCZRC6JKkzZmWzcaFGlLPsh9dcWEeZuNhwnAZfmPXgz6Aw=="
"integrity": "sha512-vtgJBOsJj/S2GjP02PpBz9ebGikNtzdsC7JQc5HKkCZRC6JKkzZmWzcaFGlLPsh9dcWEeZuNhwnAZfmPXgz6Aw==",
"dev": true
},
"@ucap/ng-web-storage": {
"version": "file:dist/web-storage/ucap-ng-web-storage-0.0.1.tgz",

View File

@ -165,7 +165,7 @@
"@ucap/ng-store-authentication": "file:dist/store-authentication/ucap-ng-store-authentication-0.0.2.tgz",
"@ucap/ng-store-chat": "file:dist/store-chat/ucap-ng-store-chat-0.0.3.tgz",
"@ucap/ng-store-group": "file:dist/store-group/ucap-ng-store-group-0.0.3.tgz",
"@ucap/ng-store-organization": "file:dist/store-organization/ucap-ng-store-organization-0.0.2.tgz",
"@ucap/ng-store-organization": "file:dist/store-organization/ucap-ng-store-organization-0.0.3.tgz",
"@ucap/ng-ui": "file:dist/ui/ucap-ng-ui-0.0.3.tgz",
"@ucap/ng-ui-authentication": "file:dist/ui-authentication/ucap-ng-ui-authentication-0.0.1.tgz",
"@ucap/ng-ui-organization": "file:dist/ui-organization/ucap-ng-ui-organization-0.0.1.tgz",

View File

@ -6,6 +6,7 @@
"umdModuleIds": {
"@ngrx/store": "@ngrx/store",
"@ngrx/effects": "@ngrx/effects",
"@ucap/ng-api-external": "@ucap/ng-api-external",
"@ucap/ng-protocol-query": "@ucap/ng-protocol-query"
}
}

View File

@ -1,14 +1,15 @@
{
"name": "@ucap/ng-store-organization",
"version": "0.0.2",
"version": "0.0.3",
"publishConfig": {
"registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/"
},
"peerDependencies": {
"@angular/common": "^9.0.2",
"@angular/core": "^9.0.2",
"@angular/common": "^9.0.0",
"@angular/core": "^9.0.0",
"@ucap/core": "~0.0.1",
"@ucap/protocol-query": "~0.0.1",
"@ucap/ng-api-external": "~0.0.1",
"@ucap/ng-protocol-query": "~0.0.1",
"tslib": "^1.10.0"
}

View File

@ -0,0 +1,25 @@
import { createAction, props } from '@ngrx/store';
import { CompanyListRequest, CompanyListResponse } from '@ucap/api-external';
/**
* retrieve company list
*/
export const companies = createAction(
'[ucap::organization::company] companies',
props<{ req: CompanyListRequest }>()
);
/**
* Success of companies request
*/
export const companiesSuccess = createAction(
'[ucap::organization::company] companies Success',
props<{ res: CompanyListResponse }>()
);
/**
* Failure of companies request
*/
export const companiesFailure = createAction(
'[ucap::organization::company] companies Failure',
props<{ error: any }>()
);

View File

@ -0,0 +1,33 @@
import { of } from 'rxjs';
import { catchError, map, switchMap } from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { Store } from '@ngrx/store';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { ExternalApiService } from '@ucap/ng-api-external';
import { companies, companiesSuccess, companiesFailure } from './actions';
@Injectable()
export class Effects {
companies$ = createEffect(() => {
return this.actions$.pipe(
ofType(companies),
map(action => action.req),
switchMap(req =>
this.externalApiService.companyList(req).pipe(
map(res => companiesSuccess({ res })),
catchError(error => of(companiesFailure({ error })))
)
)
);
});
constructor(
private actions$: Actions,
private store: Store<any>,
private externalApiService: ExternalApiService
) {}
}

View File

@ -0,0 +1,15 @@
import { createReducer, on } from '@ngrx/store';
import { companiesSuccess } from './actions';
import { initialState } from './state';
export const reducer = createReducer(
initialState,
on(companiesSuccess, (state, action) => {
return {
...state,
companyList: action.res.companyList
};
})
);

View File

@ -0,0 +1,17 @@
import { Selector, createSelector } from '@ngrx/store';
import { DeptInfo, UserInfoSS } from '@ucap/protocol-query';
import { Company } from '@ucap/api-external';
export interface State {
companyList: Company[] | null;
}
export const initialState: State = {
companyList: null
};
export function selectors<S>(selector: Selector<any, State>) {
return {
companyList: createSelector(selector, (state: State) => state.companyList)
};
}

View File

@ -1,6 +1,11 @@
import { Type } from '@angular/core';
import { Effects as CommonEffects } from './common/effects';
import { Effects as CompanyEffects } from './company/effects';
import { Effects as DepartmentEffects } from './department/effects';
export const effects: Type<any>[] = [CommonEffects, DepartmentEffects];
export const effects: Type<any>[] = [
CommonEffects,
CompanyEffects,
DepartmentEffects
];

View File

@ -1,11 +1,13 @@
import { combineReducers, Action } from '@ngrx/store';
import { reducer as CommonReducer } from './common/reducers';
import { reducer as CompanyReducer } from './company/reducers';
import { reducer as DepartmentReducer } from './department/reducers';
export function reducers(state: any | undefined, action: Action) {
return combineReducers({
common: CommonReducer,
company: CompanyReducer,
department: DepartmentReducer
})(state, action);
}

View File

@ -1,12 +1,14 @@
import { createFeatureSelector, createSelector } from '@ngrx/store';
import * as CommonState from './common/state';
import * as CompanyState from './company/state';
import * as DepartmentState from './department/state';
export const KEY_FEATURE = 'organization';
export interface State {
common: CommonState.State;
company: CompanyState.State;
department: DepartmentState.State;
}
@ -16,6 +18,10 @@ export const CommonSelector = CommonState.selectors(
createSelector(Selector, (state: State) => state.common)
);
export const CompanySelector = CompanyState.selectors(
createSelector(Selector, (state: State) => state.company)
);
export const DepartmentSelector = DepartmentState.selectors(
createSelector(Selector, (state: State) => state.department)
);

View File

@ -3,11 +3,12 @@
*/
import * as CommonActions from './lib/store/common/actions';
import * as CompanyActions from './lib/store/company/actions';
import * as DepartmentActions from './lib/store/department/actions';
export * from './lib/config/module-config';
export { CommonActions, DepartmentActions };
export { CommonActions, CompanyActions, DepartmentActions };
export * from './lib/store/state';