bug fixed
This commit is contained in:
parent
b39312afb8
commit
3a9ae7300f
8
package-lock.json
generated
8
package-lock.json
generated
|
@ -2256,9 +2256,8 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@ucap/ng-store-organization": {
|
"@ucap/ng-store-organization": {
|
||||||
"version": "file:dist/store-organization/ucap-ng-store-organization-0.0.2.tgz",
|
"version": "file:dist/store-organization/ucap-ng-store-organization-0.0.3.tgz",
|
||||||
"integrity": "sha512-cCCFQNvIG3FJEdxd8VkYvsKHM0tEL5ySKUvA5YS+5i0kksZJYvE2lgz7wD1rHqfg5ea57HnvrdHfFjukusJK0A==",
|
"integrity": "sha512-qakDmEzWloikSk/Sczs2i/dL54ZAIEqkjx2x4jcn0dMKkCF2KseCphNXTfaLpAcMuGVR5ZAy2bQjy90NbbHeOg=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"@ucap/ng-ui": {
|
"@ucap/ng-ui": {
|
||||||
"version": "file:dist/ui/ucap-ng-ui-0.0.3.tgz",
|
"version": "file:dist/ui/ucap-ng-ui-0.0.3.tgz",
|
||||||
|
@ -2277,7 +2276,8 @@
|
||||||
},
|
},
|
||||||
"@ucap/ng-ui-skin-default": {
|
"@ucap/ng-ui-skin-default": {
|
||||||
"version": "file:dist/ui-skin-default/ucap-ng-ui-skin-default-0.0.1.tgz",
|
"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": {
|
"@ucap/ng-web-storage": {
|
||||||
"version": "file:dist/web-storage/ucap-ng-web-storage-0.0.1.tgz",
|
"version": "file:dist/web-storage/ucap-ng-web-storage-0.0.1.tgz",
|
||||||
|
|
|
@ -165,7 +165,7 @@
|
||||||
"@ucap/ng-store-authentication": "file:dist/store-authentication/ucap-ng-store-authentication-0.0.2.tgz",
|
"@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-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-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": "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-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",
|
"@ucap/ng-ui-organization": "file:dist/ui-organization/ucap-ng-ui-organization-0.0.1.tgz",
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
"umdModuleIds": {
|
"umdModuleIds": {
|
||||||
"@ngrx/store": "@ngrx/store",
|
"@ngrx/store": "@ngrx/store",
|
||||||
"@ngrx/effects": "@ngrx/effects",
|
"@ngrx/effects": "@ngrx/effects",
|
||||||
|
"@ucap/ng-api-external": "@ucap/ng-api-external",
|
||||||
"@ucap/ng-protocol-query": "@ucap/ng-protocol-query"
|
"@ucap/ng-protocol-query": "@ucap/ng-protocol-query"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
{
|
{
|
||||||
"name": "@ucap/ng-store-organization",
|
"name": "@ucap/ng-store-organization",
|
||||||
"version": "0.0.2",
|
"version": "0.0.3",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/"
|
"registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@angular/common": "^9.0.2",
|
"@angular/common": "^9.0.0",
|
||||||
"@angular/core": "^9.0.2",
|
"@angular/core": "^9.0.0",
|
||||||
"@ucap/core": "~0.0.1",
|
"@ucap/core": "~0.0.1",
|
||||||
"@ucap/protocol-query": "~0.0.1",
|
"@ucap/protocol-query": "~0.0.1",
|
||||||
|
"@ucap/ng-api-external": "~0.0.1",
|
||||||
"@ucap/ng-protocol-query": "~0.0.1",
|
"@ucap/ng-protocol-query": "~0.0.1",
|
||||||
"tslib": "^1.10.0"
|
"tslib": "^1.10.0"
|
||||||
}
|
}
|
||||||
|
|
25
projects/store-organization/src/lib/store/company/actions.ts
Normal file
25
projects/store-organization/src/lib/store/company/actions.ts
Normal 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 }>()
|
||||||
|
);
|
33
projects/store-organization/src/lib/store/company/effects.ts
Normal file
33
projects/store-organization/src/lib/store/company/effects.ts
Normal 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
|
||||||
|
) {}
|
||||||
|
}
|
|
@ -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
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
17
projects/store-organization/src/lib/store/company/state.ts
Normal file
17
projects/store-organization/src/lib/store/company/state.ts
Normal 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)
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,6 +1,11 @@
|
||||||
import { Type } from '@angular/core';
|
import { Type } from '@angular/core';
|
||||||
|
|
||||||
import { Effects as CommonEffects } from './common/effects';
|
import { Effects as CommonEffects } from './common/effects';
|
||||||
|
import { Effects as CompanyEffects } from './company/effects';
|
||||||
import { Effects as DepartmentEffects } from './department/effects';
|
import { Effects as DepartmentEffects } from './department/effects';
|
||||||
|
|
||||||
export const effects: Type<any>[] = [CommonEffects, DepartmentEffects];
|
export const effects: Type<any>[] = [
|
||||||
|
CommonEffects,
|
||||||
|
CompanyEffects,
|
||||||
|
DepartmentEffects
|
||||||
|
];
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import { combineReducers, Action } from '@ngrx/store';
|
import { combineReducers, Action } from '@ngrx/store';
|
||||||
|
|
||||||
import { reducer as CommonReducer } from './common/reducers';
|
import { reducer as CommonReducer } from './common/reducers';
|
||||||
|
import { reducer as CompanyReducer } from './company/reducers';
|
||||||
import { reducer as DepartmentReducer } from './department/reducers';
|
import { reducer as DepartmentReducer } from './department/reducers';
|
||||||
|
|
||||||
export function reducers(state: any | undefined, action: Action) {
|
export function reducers(state: any | undefined, action: Action) {
|
||||||
return combineReducers({
|
return combineReducers({
|
||||||
common: CommonReducer,
|
common: CommonReducer,
|
||||||
|
company: CompanyReducer,
|
||||||
department: DepartmentReducer
|
department: DepartmentReducer
|
||||||
})(state, action);
|
})(state, action);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
import { createFeatureSelector, createSelector } from '@ngrx/store';
|
import { createFeatureSelector, createSelector } from '@ngrx/store';
|
||||||
|
|
||||||
import * as CommonState from './common/state';
|
import * as CommonState from './common/state';
|
||||||
|
import * as CompanyState from './company/state';
|
||||||
import * as DepartmentState from './department/state';
|
import * as DepartmentState from './department/state';
|
||||||
|
|
||||||
export const KEY_FEATURE = 'organization';
|
export const KEY_FEATURE = 'organization';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
common: CommonState.State;
|
common: CommonState.State;
|
||||||
|
company: CompanyState.State;
|
||||||
department: DepartmentState.State;
|
department: DepartmentState.State;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +18,10 @@ export const CommonSelector = CommonState.selectors(
|
||||||
createSelector(Selector, (state: State) => state.common)
|
createSelector(Selector, (state: State) => state.common)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const CompanySelector = CompanyState.selectors(
|
||||||
|
createSelector(Selector, (state: State) => state.company)
|
||||||
|
);
|
||||||
|
|
||||||
export const DepartmentSelector = DepartmentState.selectors(
|
export const DepartmentSelector = DepartmentState.selectors(
|
||||||
createSelector(Selector, (state: State) => state.department)
|
createSelector(Selector, (state: State) => state.department)
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as CommonActions from './lib/store/common/actions';
|
import * as CommonActions from './lib/store/common/actions';
|
||||||
|
import * as CompanyActions from './lib/store/company/actions';
|
||||||
import * as DepartmentActions from './lib/store/department/actions';
|
import * as DepartmentActions from './lib/store/department/actions';
|
||||||
|
|
||||||
export * from './lib/config/module-config';
|
export * from './lib/config/module-config';
|
||||||
|
|
||||||
export { CommonActions, DepartmentActions };
|
export { CommonActions, CompanyActions, DepartmentActions };
|
||||||
|
|
||||||
export * from './lib/store/state';
|
export * from './lib/store/state';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user