monkey-front-core 0.0.427 → 0.0.428
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/core/interfaces/index.mjs +2 -1
- package/esm2020/lib/core/interfaces/monkeyecx-resolver.mjs +2 -0
- package/esm2020/lib/core/services/commons/index.mjs +2 -1
- package/esm2020/lib/core/services/commons/monkeyecx-commons-resolve.service.mjs +123 -0
- package/esm2020/lib/core/services/commons/monkeyecx-commons.service.mjs +2 -1
- package/fesm2015/monkey-front-core.mjs +124 -3
- package/fesm2015/monkey-front-core.mjs.map +1 -1
- package/fesm2020/monkey-front-core.mjs +120 -3
- package/fesm2020/monkey-front-core.mjs.map +1 -1
- package/lib/core/interfaces/index.d.ts +1 -0
- package/lib/core/interfaces/monkeyecx-resolver.d.ts +39 -0
- package/lib/core/services/commons/index.d.ts +1 -0
- package/lib/core/services/commons/monkeyecx-commons-resolve.service.d.ts +56 -0
- package/lib/core/services/commons/monkeyecx-commons.service.d.ts +1 -0
- package/monkey-front-core-0.0.428.tgz +0 -0
- package/package.json +1 -1
- package/monkey-front-core-0.0.427.tgz +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, Input, NgModule, Pipe, ViewEncapsulation, Injectable, EventEmitter, Directive, Output, HostBinding, HostListener, forwardRef, Self, InjectionToken, Inject, Optional, SkipSelf, NgZone, ErrorHandler } from '@angular/core';
|
|
2
|
+
import { Component, Input, NgModule, Pipe, ViewEncapsulation, Injectable, EventEmitter, Directive, Output, HostBinding, HostListener, forwardRef, Self, InjectionToken, Inject, Optional, inject, SkipSelf, NgZone, ErrorHandler } from '@angular/core';
|
|
3
3
|
import * as i1 from 'monkey-style-guide';
|
|
4
4
|
import { MonkeyButtonModule, MonkeyModalModule, MonkeyIconModule, MonkeyInputModule, MonkeyRadioButtonModule, MonkeyOptionModule, MonkeyUtils, MonkeyStyleGuideModule, MonkeyStyleGuideModalService, MonkeyStyleGuideSettingsService, MonkeyStyleGuideSnackbarService } from 'monkey-style-guide';
|
|
5
5
|
import * as i2 from '@angular/common';
|
|
@@ -14,13 +14,13 @@ import { HttpParams, HttpErrorResponse, HTTP_INTERCEPTORS, HttpClientModule } fr
|
|
|
14
14
|
import * as i2$1 from '@angular/platform-browser';
|
|
15
15
|
import * as i1$3 from 'ngx-cookie-service';
|
|
16
16
|
import * as i2$2 from '@angular/router';
|
|
17
|
-
import { NavigationStart, NavigationEnd, NavigationError, NavigationCancel } from '@angular/router';
|
|
17
|
+
import { NavigationStart, NavigationEnd, NavigationError, NavigationCancel, Router } from '@angular/router';
|
|
18
18
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
19
19
|
import { TemplatePortal } from '@angular/cdk/portal';
|
|
20
20
|
import * as i1$4 from '@angular/cdk/overlay';
|
|
21
21
|
import { OverlayModule } from '@angular/cdk/overlay';
|
|
22
22
|
import * as i2$3 from '@ngrx/store';
|
|
23
|
-
import { createAction, props, INIT, createReducer, on, createFeatureSelector, createSelector, StoreModule } from '@ngrx/store';
|
|
23
|
+
import { createAction, props, INIT, createReducer, on, createFeatureSelector, createSelector, Store, StoreModule } from '@ngrx/store';
|
|
24
24
|
import { createEntityAdapter } from '@ngrx/entity';
|
|
25
25
|
import { __decorate } from 'tslib';
|
|
26
26
|
import { datadogRum } from '@datadog/browser-rum';
|
|
@@ -2761,6 +2761,7 @@ class MonkeyEcxCommonsService {
|
|
|
2761
2761
|
this.__data$ = null;
|
|
2762
2762
|
this.__pagination$ = null;
|
|
2763
2763
|
this.__control$ = null;
|
|
2764
|
+
this.__page$ = null;
|
|
2764
2765
|
this.__savedState = null;
|
|
2765
2766
|
this.__error = null;
|
|
2766
2767
|
this.__handledError = null;
|
|
@@ -3098,6 +3099,122 @@ __decorate([
|
|
|
3098
3099
|
})
|
|
3099
3100
|
], MonkeyEcxCommonsService.prototype, "getGenericData", null);
|
|
3100
3101
|
|
|
3102
|
+
class MonkeyEcxCommonsResolveService extends MonkeyEcxCommonsService {
|
|
3103
|
+
constructor(monkeyecxService, tokenStorage, config) {
|
|
3104
|
+
super(monkeyecxService, tokenStorage);
|
|
3105
|
+
this.route = null;
|
|
3106
|
+
this.currentRoute = null;
|
|
3107
|
+
this.paginationService = inject(MonkeyEcxPaginationService);
|
|
3108
|
+
this.translateService = inject(TranslateService);
|
|
3109
|
+
this.router = inject(Router);
|
|
3110
|
+
this.store = inject(Store);
|
|
3111
|
+
this.monkeyDiscovery = inject(MonkeyEcxDiscoveryParamsService);
|
|
3112
|
+
const { actions, actionsPagination, selectors } = config;
|
|
3113
|
+
this.action = actions;
|
|
3114
|
+
this.actionPagination = actionsPagination;
|
|
3115
|
+
this.selector = selectors;
|
|
3116
|
+
}
|
|
3117
|
+
;
|
|
3118
|
+
async getData() {
|
|
3119
|
+
try {
|
|
3120
|
+
const { store, route, action, selector, tokenStorage } = this;
|
|
3121
|
+
const { companyId, companyType } = await tokenStorage?.getToken();
|
|
3122
|
+
const identifier = `${companyId}-${companyType}`;
|
|
3123
|
+
if (!route)
|
|
3124
|
+
return;
|
|
3125
|
+
const url = MonkeyEcxUtils.replaceVariables(route, { companyId });
|
|
3126
|
+
store.dispatch(action.load({ url, identifier }));
|
|
3127
|
+
this.__data$ = store.select(selector.selectByIdentifier({ identifier }));
|
|
3128
|
+
this.__control$ = store.select(selector.selectControl());
|
|
3129
|
+
if (selector?.selectLinks) {
|
|
3130
|
+
this.__pagination$ = store.select(selector.selectLinks({ identifier }));
|
|
3131
|
+
}
|
|
3132
|
+
if (selector?.selectPage) {
|
|
3133
|
+
this.__page$ = store.select(selector.selectPage({ identifier }));
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
catch (e) {
|
|
3137
|
+
throw new Error(`MECX Core - Method getData -> ${e}`);
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
async loadPage() {
|
|
3141
|
+
try {
|
|
3142
|
+
const { store, tokenStorage, actionPagination } = this;
|
|
3143
|
+
const { companyId, companyType } = await tokenStorage?.getToken();
|
|
3144
|
+
store.dispatch(actionPagination.load({
|
|
3145
|
+
identifier: `${companyId}-${companyType}`,
|
|
3146
|
+
pagination: {
|
|
3147
|
+
action: 'next'
|
|
3148
|
+
}
|
|
3149
|
+
}));
|
|
3150
|
+
}
|
|
3151
|
+
catch (e) {
|
|
3152
|
+
throw new Error(`MECX Core - Method loadPage -> ${e}`);
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
/**
|
|
3156
|
+
* @description Inicializar a class genérica
|
|
3157
|
+
* @param (args: MonkeyEcxInitialResolverConfig)
|
|
3158
|
+
* => route é obrigátorio pois ele quem inicializa a store.
|
|
3159
|
+
* A searchClass só se faz necessaria quando for usar filtros
|
|
3160
|
+
*/
|
|
3161
|
+
init(args) {
|
|
3162
|
+
try {
|
|
3163
|
+
const { searchClass, route } = args;
|
|
3164
|
+
this.route = route;
|
|
3165
|
+
if (searchClass) {
|
|
3166
|
+
// eslint-disable-next-line new-cap
|
|
3167
|
+
const searchInstance = new searchClass(this.__search);
|
|
3168
|
+
this.route = `${route}${searchInstance.buildParams()}`;
|
|
3169
|
+
this.__onSearchChanged$.next(searchInstance);
|
|
3170
|
+
}
|
|
3171
|
+
this.getData();
|
|
3172
|
+
}
|
|
3173
|
+
catch (e) {
|
|
3174
|
+
throw new Error(`${e?.message}`);
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
resolve(route, state, otherArgs) {
|
|
3178
|
+
this.__search = route?.queryParams;
|
|
3179
|
+
const [currentRoute] = state?.url.split('?') || [null];
|
|
3180
|
+
this.currentRoute = currentRoute;
|
|
3181
|
+
super.resolve(route, state, otherArgs);
|
|
3182
|
+
}
|
|
3183
|
+
/**
|
|
3184
|
+
* @description Atualizar os filtros da tela
|
|
3185
|
+
* @param (search: T, route?: string)
|
|
3186
|
+
* => route é opcional, passar ele apenas se a rota for diferente do padrão
|
|
3187
|
+
*/
|
|
3188
|
+
setSearch(search, route) {
|
|
3189
|
+
try {
|
|
3190
|
+
const { currentRoute, router } = this;
|
|
3191
|
+
this.setSearchByUrl(router, route || `${currentRoute}`, search);
|
|
3192
|
+
}
|
|
3193
|
+
catch (e) {
|
|
3194
|
+
throw new Error(`MECX Core - Method setSearch -> ${e}`);
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
/**
|
|
3198
|
+
* @description Navegação para details.
|
|
3199
|
+
* Por padrão sera redirecionado para '${currentRoute}/details'
|
|
3200
|
+
* @param (detailsData: T, route?: string)
|
|
3201
|
+
* => route é opcional, passar ele apenas se a rota for diferente do padrão
|
|
3202
|
+
*/
|
|
3203
|
+
navigateToDetails(detailsData, route) {
|
|
3204
|
+
try {
|
|
3205
|
+
const { router, currentRoute } = this;
|
|
3206
|
+
router.navigate([route || `${currentRoute}/details`], {
|
|
3207
|
+
state: {
|
|
3208
|
+
detailsData
|
|
3209
|
+
}
|
|
3210
|
+
});
|
|
3211
|
+
}
|
|
3212
|
+
catch (e) {
|
|
3213
|
+
throw new Error(`MECX Core - Method navigateToDetails -> ${e}`);
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3101
3218
|
let window$1;
|
|
3102
3219
|
const text = {
|
|
3103
3220
|
i18n: {
|