eservices-core 1.0.520 → 1.0.522
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.
|
@@ -6,13 +6,14 @@ declare const _default: {
|
|
|
6
6
|
id: number;
|
|
7
7
|
type: "error" | "warning" | "info";
|
|
8
8
|
msg: string;
|
|
9
|
-
children
|
|
10
|
-
|
|
11
|
-
msg: string;
|
|
12
|
-
}[];
|
|
9
|
+
children: string[];
|
|
10
|
+
timeout: number;
|
|
13
11
|
}[];
|
|
14
12
|
/**
|
|
15
|
-
* @description Adding new
|
|
13
|
+
* @description Adding new Notification Item.
|
|
14
|
+
* @param type Type of current notification
|
|
15
|
+
* @param msg {String} Text message of notification item.
|
|
16
|
+
* @param options Params for current notification item: children, timeout (Default 10) in seconds.
|
|
16
17
|
*/
|
|
17
18
|
add(type: INotificationCard["type"], msg: string, { children, timeout }?: {
|
|
18
19
|
children?: string[];
|
|
@@ -32,8 +33,5 @@ export interface INotificationCard {
|
|
|
32
33
|
id: number;
|
|
33
34
|
type: 'error' | 'warning' | 'info';
|
|
34
35
|
msg: string;
|
|
35
|
-
children
|
|
36
|
-
id: number;
|
|
37
|
-
msg: string;
|
|
38
|
-
}[];
|
|
36
|
+
children: string[];
|
|
39
37
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* eservices-core v1.0.
|
|
2
|
+
* eservices-core v1.0.522
|
|
3
3
|
* (c) 2023 ESERVICES
|
|
4
4
|
*/
|
|
5
5
|
'use strict';
|
|
@@ -1612,52 +1612,65 @@ var spinners = {
|
|
|
1612
1612
|
WidgetSpinner: script$w
|
|
1613
1613
|
};
|
|
1614
1614
|
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
*/
|
|
1621
|
-
this.store = vue.reactive([]);
|
|
1622
|
-
}
|
|
1615
|
+
/**
|
|
1616
|
+
* @description Notification system with array of cards.
|
|
1617
|
+
*/
|
|
1618
|
+
var NotificationSystem = new class NotificationSystem {
|
|
1619
|
+
constructor() {
|
|
1623
1620
|
/**
|
|
1624
|
-
* @description
|
|
1621
|
+
* @description Array of current cards.
|
|
1625
1622
|
*/
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1623
|
+
this.store = vue.reactive([]);
|
|
1624
|
+
}
|
|
1625
|
+
/**
|
|
1626
|
+
* @description Adding new Notification Item.
|
|
1627
|
+
* @param type Type of current notification
|
|
1628
|
+
* @param msg {String} Text message of notification item.
|
|
1629
|
+
* @param options Params for current notification item: children, timeout (Default 10) in seconds.
|
|
1630
|
+
*/
|
|
1631
|
+
add(type, msg, { children, timeout = 10 } = {}) {
|
|
1632
|
+
const card = new NotificationCard(type, msg, children || [], timeout);
|
|
1633
|
+
this.store.push(card);
|
|
1634
|
+
if (timeout)
|
|
1635
|
+
setTimeout(() => this.remove(card.id), timeout * 1000);
|
|
1636
|
+
}
|
|
1637
|
+
/**
|
|
1638
|
+
* @description Function remove item by id. Return true if card was founded, otherwise false.
|
|
1639
|
+
* */
|
|
1640
|
+
remove(id) {
|
|
1641
|
+
const cardIndex = this.store.findIndex(card => card.id === id);
|
|
1642
|
+
if (cardIndex === -1)
|
|
1643
|
+
return false; // Item not founded in the store
|
|
1644
|
+
this.store.splice(cardIndex, 1);
|
|
1645
|
+
}
|
|
1646
|
+
/**
|
|
1647
|
+
* @description Removing child message, Throwing error if card of children not founded.
|
|
1648
|
+
* */
|
|
1649
|
+
removeChild(cardId, childId) {
|
|
1650
|
+
throw new Error('Removing children error.');
|
|
1651
|
+
/*
|
|
1652
|
+
const card = this.store.find(card => card.id === cardId);
|
|
1653
|
+
if (!card) throw new Error(`Undefined card with id: ${cardId}`);
|
|
1654
|
+
|
|
1655
|
+
const childIndex = card.children?.findIndex(child => child.id === childId);
|
|
1656
|
+
if (childIndex === undefined || childIndex === -1)
|
|
1657
|
+
throw new Error(`Undefined children id: ${childId} in card ${cardId}`);
|
|
1658
|
+
|
|
1659
|
+
card.children?.splice(childIndex, 1);
|
|
1660
|
+
|
|
1661
|
+
*/
|
|
1662
|
+
}
|
|
1663
|
+
};
|
|
1664
|
+
class NotificationCard {
|
|
1665
|
+
constructor(type, msg, children, timeout) {
|
|
1666
|
+
this.type = type;
|
|
1667
|
+
this.msg = msg;
|
|
1668
|
+
this.children = children;
|
|
1669
|
+
this.timeout = timeout;
|
|
1670
|
+
this.id = NotificationCard.cardId++;
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
NotificationCard.cardId = 1;
|
|
1661
1674
|
|
|
1662
1675
|
const _hoisted_1$k = { class: "widget-error" };
|
|
1663
1676
|
const _hoisted_2$a = { class: "widget-error-wrap" };
|
|
@@ -1890,6 +1903,8 @@ class CoreError extends Error {
|
|
|
1890
1903
|
Please try again later or submit a feedback if problem doesn't go.`);
|
|
1891
1904
|
}
|
|
1892
1905
|
static AuthServiceError(message, errors) {
|
|
1906
|
+
if (!message && !errors)
|
|
1907
|
+
return CoreError.ApiNotAvailable();
|
|
1893
1908
|
return new CoreError(message || 'Authorization Error', errors);
|
|
1894
1909
|
}
|
|
1895
1910
|
static ApiResponseParseFailed() {
|
|
@@ -1952,6 +1967,225 @@ function ErrorModel(message, details = []) {
|
|
|
1952
1967
|
};
|
|
1953
1968
|
}
|
|
1954
1969
|
|
|
1970
|
+
class clientService {
|
|
1971
|
+
static getClientData() {
|
|
1972
|
+
return Request('/close-api/client-content');
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
/*!
|
|
1977
|
+
* jenesius-event-emitter v1.0.2
|
|
1978
|
+
* (c) 2022 Jenesius
|
|
1979
|
+
* @license MIT
|
|
1980
|
+
*/
|
|
1981
|
+
const _on = function (name, callback) {
|
|
1982
|
+
if (!(name in this.events))
|
|
1983
|
+
this.events[name] = [];
|
|
1984
|
+
this.events[name].push(callback);
|
|
1985
|
+
return this.off.bind(this, name, callback);
|
|
1986
|
+
};
|
|
1987
|
+
const _emit = function (name, data) {
|
|
1988
|
+
if (!(name in this.events))
|
|
1989
|
+
return;
|
|
1990
|
+
this.events[name].forEach(cl => cl(data));
|
|
1991
|
+
};
|
|
1992
|
+
const _off = function (name, callback) {
|
|
1993
|
+
const arr = this.events[name];
|
|
1994
|
+
if (!arr)
|
|
1995
|
+
return;
|
|
1996
|
+
const index = arr.indexOf(callback);
|
|
1997
|
+
if (index === -1)
|
|
1998
|
+
return;
|
|
1999
|
+
arr.splice(index, 1);
|
|
2000
|
+
};
|
|
2001
|
+
const _cleanEvents = function () {
|
|
2002
|
+
this.events = {};
|
|
2003
|
+
};
|
|
2004
|
+
class EventEmitter {
|
|
2005
|
+
constructor() {
|
|
2006
|
+
this.events = {};
|
|
2007
|
+
}
|
|
2008
|
+
on(name, callback) {
|
|
2009
|
+
return _on.call(this, name, callback);
|
|
2010
|
+
}
|
|
2011
|
+
emit(name, data) {
|
|
2012
|
+
return _emit.call(this, name, data);
|
|
2013
|
+
}
|
|
2014
|
+
off(name, callback) {
|
|
2015
|
+
return _off.call(this, name, callback);
|
|
2016
|
+
}
|
|
2017
|
+
cleanEvents() {
|
|
2018
|
+
_cleanEvents.call(this);
|
|
2019
|
+
}
|
|
2020
|
+
static on(name, callback) {
|
|
2021
|
+
return _on.call(EventEmitter, name, callback);
|
|
2022
|
+
}
|
|
2023
|
+
static emit(name, data) {
|
|
2024
|
+
return _emit.call(EventEmitter, name, data);
|
|
2025
|
+
}
|
|
2026
|
+
static off(name, callback) {
|
|
2027
|
+
return _off.call(EventEmitter, name, callback);
|
|
2028
|
+
}
|
|
2029
|
+
static cleanEvents() {
|
|
2030
|
+
_cleanEvents.call(EventEmitter);
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
/**
|
|
2034
|
+
* ONLY FOR GLOBAL USING!
|
|
2035
|
+
* */
|
|
2036
|
+
EventEmitter.events = {};
|
|
2037
|
+
|
|
2038
|
+
var _router, _type, _ready;
|
|
2039
|
+
class ApplicationManager extends EventEmitter {
|
|
2040
|
+
constructor() {
|
|
2041
|
+
super(...arguments);
|
|
2042
|
+
_router.set(this, void 0);
|
|
2043
|
+
/**
|
|
2044
|
+
* @description Office type. By Default is front
|
|
2045
|
+
* */
|
|
2046
|
+
_type.set(this, 'front');
|
|
2047
|
+
/**
|
|
2048
|
+
* @description List of organizations
|
|
2049
|
+
*/
|
|
2050
|
+
this.organizations = [];
|
|
2051
|
+
/**
|
|
2052
|
+
* @description Flag witch show that application was load the main user data. By Default - false;
|
|
2053
|
+
*/
|
|
2054
|
+
_ready.set(this, false);
|
|
2055
|
+
}
|
|
2056
|
+
get contextType() {
|
|
2057
|
+
var _a;
|
|
2058
|
+
if (!this.contextId)
|
|
2059
|
+
return undefined;
|
|
2060
|
+
if (((_a = this.person) === null || _a === void 0 ? void 0 : _a.id) === this.contextId)
|
|
2061
|
+
return 'person';
|
|
2062
|
+
return 'organization';
|
|
2063
|
+
}
|
|
2064
|
+
set router(v) {
|
|
2065
|
+
__classPrivateFieldSet(this, _router, v);
|
|
2066
|
+
}
|
|
2067
|
+
/**
|
|
2068
|
+
* @description VueRouter of Application
|
|
2069
|
+
* */
|
|
2070
|
+
get router() {
|
|
2071
|
+
if (!__classPrivateFieldGet(this, _router))
|
|
2072
|
+
throw new Error('Router was not founded. Please set router: Manager.router = router: VueRouter');
|
|
2073
|
+
return __classPrivateFieldGet(this, _router);
|
|
2074
|
+
}
|
|
2075
|
+
set type(type) {
|
|
2076
|
+
__classPrivateFieldSet(this, _type, type);
|
|
2077
|
+
}
|
|
2078
|
+
get type() {
|
|
2079
|
+
return __classPrivateFieldGet(this, _type);
|
|
2080
|
+
}
|
|
2081
|
+
get isBack() {
|
|
2082
|
+
return this.type === 'back';
|
|
2083
|
+
}
|
|
2084
|
+
get isFront() {
|
|
2085
|
+
return this.type === 'front';
|
|
2086
|
+
}
|
|
2087
|
+
set ready(v) {
|
|
2088
|
+
__classPrivateFieldSet(this, _ready, v);
|
|
2089
|
+
this.emit(ApplicationManager.EVENT_READY_UPDATE, v);
|
|
2090
|
+
}
|
|
2091
|
+
get ready() {
|
|
2092
|
+
return __classPrivateFieldGet(this, _ready);
|
|
2093
|
+
}
|
|
2094
|
+
onReady(callback) {
|
|
2095
|
+
return this.on(ApplicationManager.EVENT_READY_UPDATE, callback);
|
|
2096
|
+
}
|
|
2097
|
+
onupdateContext(callback) {
|
|
2098
|
+
return this.on(ApplicationManager.EVENT_CONTEXT_UPDATE, callback);
|
|
2099
|
+
}
|
|
2100
|
+
onupdateData(callback) {
|
|
2101
|
+
return this.on(ApplicationManager.EVENT_DATA_UPDATE, callback);
|
|
2102
|
+
}
|
|
2103
|
+
/**
|
|
2104
|
+
* @description Method for update current context. After success emit event[EVENT_UPDATE_CONTEXT]
|
|
2105
|
+
*/
|
|
2106
|
+
setCurrentContext(id) {
|
|
2107
|
+
if (this.contextId === id)
|
|
2108
|
+
return console.log(`[application-manager] The current context has already been installed.`);
|
|
2109
|
+
this.contextId = Number(id);
|
|
2110
|
+
localStorage.setItem(ApplicationManager.CURRENT_CONTEXT_KEY, String(id));
|
|
2111
|
+
this.emit(ApplicationManager.EVENT_CONTEXT_UPDATE, id);
|
|
2112
|
+
console.log(`Current context id %c${id}`, 'color: purple');
|
|
2113
|
+
}
|
|
2114
|
+
/**
|
|
2115
|
+
* @description Initialization of ApplicationManager
|
|
2116
|
+
*/
|
|
2117
|
+
init() {
|
|
2118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2119
|
+
try {
|
|
2120
|
+
const data = yield this.loadCustomerData();
|
|
2121
|
+
this.person = data;
|
|
2122
|
+
this.organizations = data.organizations;
|
|
2123
|
+
this.user = data.user;
|
|
2124
|
+
this.ready = true;
|
|
2125
|
+
const savedContext = Number.parseInt(localStorage.getItem(ApplicationManager.CURRENT_CONTEXT_KEY) || "");
|
|
2126
|
+
if (!Number.isNaN(savedContext) && this.validateContextId(Number(savedContext)))
|
|
2127
|
+
this.setCurrentContext(savedContext);
|
|
2128
|
+
else
|
|
2129
|
+
this.setCurrentContext(Number(data.id));
|
|
2130
|
+
}
|
|
2131
|
+
catch (e) {
|
|
2132
|
+
NotificationSystem.add('error', CoreError.ApiNotAvailable().message);
|
|
2133
|
+
}
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2136
|
+
loadCustomerData() {
|
|
2137
|
+
return clientService.getClientData();
|
|
2138
|
+
}
|
|
2139
|
+
/**
|
|
2140
|
+
* @description The main method of application. Load the main information about user.
|
|
2141
|
+
* @deprecated
|
|
2142
|
+
*/
|
|
2143
|
+
updateFullClientData() {
|
|
2144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2145
|
+
return this.init();
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
/**
|
|
2149
|
+
* @description Method using for validate provided ID, Checking with existing person ID and each organization ID.
|
|
2150
|
+
* */
|
|
2151
|
+
validateContextId(id) {
|
|
2152
|
+
var _a;
|
|
2153
|
+
if (((_a = this.person) === null || _a === void 0 ? void 0 : _a.id) == id)
|
|
2154
|
+
return true;
|
|
2155
|
+
return !!this.organizations.find(org => org.id === id);
|
|
2156
|
+
}
|
|
2157
|
+
getListKeyById(id) {
|
|
2158
|
+
return `list-information-${id}`;
|
|
2159
|
+
}
|
|
2160
|
+
getListInformationFromLocalStorage(id) {
|
|
2161
|
+
const data = localStorage.getItem(this.getListKeyById(id));
|
|
2162
|
+
return !!data ? JSON.parse(data) : data;
|
|
2163
|
+
}
|
|
2164
|
+
setListInformationToLocalStorage(id, info) {
|
|
2165
|
+
localStorage.setItem(this.getListKeyById(id), JSON.stringify(info));
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
_router = new WeakMap(), _type = new WeakMap(), _ready = new WeakMap();
|
|
2169
|
+
ApplicationManager.EVENT_CONTEXT_UPDATE = 'event:context-update';
|
|
2170
|
+
ApplicationManager.EVENT_READY_UPDATE = 'event:ready-update';
|
|
2171
|
+
ApplicationManager.EVENT_DATA_UPDATE = 'event:data-update';
|
|
2172
|
+
/**
|
|
2173
|
+
* @description Key for localStorage, saving current context ID. using after user login to system
|
|
2174
|
+
* */
|
|
2175
|
+
ApplicationManager.CURRENT_CONTEXT_KEY = 'CurrentContext';
|
|
2176
|
+
const Manager = new ApplicationManager();
|
|
2177
|
+
function useManagerState() {
|
|
2178
|
+
const state = vue.reactive({
|
|
2179
|
+
contextType: Manager.contextType,
|
|
2180
|
+
contextId: Manager.contextId
|
|
2181
|
+
});
|
|
2182
|
+
Manager.onupdateContext(() => {
|
|
2183
|
+
state.contextType = Manager.contextType;
|
|
2184
|
+
state.contextId = Manager.contextId;
|
|
2185
|
+
});
|
|
2186
|
+
return state;
|
|
2187
|
+
}
|
|
2188
|
+
|
|
1955
2189
|
function parseData(res) {
|
|
1956
2190
|
return res.text()
|
|
1957
2191
|
.then(res => {
|
|
@@ -1967,6 +2201,12 @@ function parseData(res) {
|
|
|
1967
2201
|
* @description Функция для запросов, имеет встроенные обработчик для ошибок на самом низком уровне
|
|
1968
2202
|
* */
|
|
1969
2203
|
function Request(url, params = {}) {
|
|
2204
|
+
if (Manager.isFront) {
|
|
2205
|
+
if (!params.headers)
|
|
2206
|
+
params.headers = {};
|
|
2207
|
+
// @ts-ignore
|
|
2208
|
+
params.headers["Context-Id"] = Manager.contextId;
|
|
2209
|
+
}
|
|
1970
2210
|
return fetch(url, params)
|
|
1971
2211
|
.catch(() => {
|
|
1972
2212
|
throw CoreError.ApiNotAvailable();
|
|
@@ -2167,7 +2407,7 @@ function requestHandler(callback, options = {}) {
|
|
|
2167
2407
|
if (error instanceof CoreError)
|
|
2168
2408
|
NotificationSystem.add('error', error.message, {
|
|
2169
2409
|
children: error.details || [],
|
|
2170
|
-
timeout: 12
|
|
2410
|
+
timeout: 12
|
|
2171
2411
|
});
|
|
2172
2412
|
else {
|
|
2173
2413
|
if (error === null || error === void 0 ? void 0 : error.message)
|
|
@@ -2272,68 +2512,6 @@ var types = /*#__PURE__*/Object.freeze({
|
|
|
2272
2512
|
__proto__: null
|
|
2273
2513
|
});
|
|
2274
2514
|
|
|
2275
|
-
/*!
|
|
2276
|
-
* jenesius-event-emitter v1.0.2
|
|
2277
|
-
* (c) 2022 Jenesius
|
|
2278
|
-
* @license MIT
|
|
2279
|
-
*/
|
|
2280
|
-
const _on = function (name, callback) {
|
|
2281
|
-
if (!(name in this.events))
|
|
2282
|
-
this.events[name] = [];
|
|
2283
|
-
this.events[name].push(callback);
|
|
2284
|
-
return this.off.bind(this, name, callback);
|
|
2285
|
-
};
|
|
2286
|
-
const _emit = function (name, data) {
|
|
2287
|
-
if (!(name in this.events))
|
|
2288
|
-
return;
|
|
2289
|
-
this.events[name].forEach(cl => cl(data));
|
|
2290
|
-
};
|
|
2291
|
-
const _off = function (name, callback) {
|
|
2292
|
-
const arr = this.events[name];
|
|
2293
|
-
if (!arr)
|
|
2294
|
-
return;
|
|
2295
|
-
const index = arr.indexOf(callback);
|
|
2296
|
-
if (index === -1)
|
|
2297
|
-
return;
|
|
2298
|
-
arr.splice(index, 1);
|
|
2299
|
-
};
|
|
2300
|
-
const _cleanEvents = function () {
|
|
2301
|
-
this.events = {};
|
|
2302
|
-
};
|
|
2303
|
-
class EventEmitter {
|
|
2304
|
-
constructor() {
|
|
2305
|
-
this.events = {};
|
|
2306
|
-
}
|
|
2307
|
-
on(name, callback) {
|
|
2308
|
-
return _on.call(this, name, callback);
|
|
2309
|
-
}
|
|
2310
|
-
emit(name, data) {
|
|
2311
|
-
return _emit.call(this, name, data);
|
|
2312
|
-
}
|
|
2313
|
-
off(name, callback) {
|
|
2314
|
-
return _off.call(this, name, callback);
|
|
2315
|
-
}
|
|
2316
|
-
cleanEvents() {
|
|
2317
|
-
_cleanEvents.call(this);
|
|
2318
|
-
}
|
|
2319
|
-
static on(name, callback) {
|
|
2320
|
-
return _on.call(EventEmitter, name, callback);
|
|
2321
|
-
}
|
|
2322
|
-
static emit(name, data) {
|
|
2323
|
-
return _emit.call(EventEmitter, name, data);
|
|
2324
|
-
}
|
|
2325
|
-
static off(name, callback) {
|
|
2326
|
-
return _off.call(EventEmitter, name, callback);
|
|
2327
|
-
}
|
|
2328
|
-
static cleanEvents() {
|
|
2329
|
-
_cleanEvents.call(EventEmitter);
|
|
2330
|
-
}
|
|
2331
|
-
}
|
|
2332
|
-
/**
|
|
2333
|
-
* ONLY FOR GLOBAL USING!
|
|
2334
|
-
* */
|
|
2335
|
-
EventEmitter.events = {};
|
|
2336
|
-
|
|
2337
2515
|
class dataService {
|
|
2338
2516
|
static anonymousGetList(entity) {
|
|
2339
2517
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -4729,163 +4907,6 @@ class ActionService {
|
|
|
4729
4907
|
}
|
|
4730
4908
|
}
|
|
4731
4909
|
|
|
4732
|
-
class clientService {
|
|
4733
|
-
static getClientData() {
|
|
4734
|
-
return Request('/close-api/client-content');
|
|
4735
|
-
}
|
|
4736
|
-
}
|
|
4737
|
-
|
|
4738
|
-
var _router, _type, _ready;
|
|
4739
|
-
class ApplicationManager extends EventEmitter {
|
|
4740
|
-
constructor() {
|
|
4741
|
-
super(...arguments);
|
|
4742
|
-
_router.set(this, void 0);
|
|
4743
|
-
/**
|
|
4744
|
-
* @description Office type. By Default is front
|
|
4745
|
-
* */
|
|
4746
|
-
_type.set(this, 'front');
|
|
4747
|
-
/**
|
|
4748
|
-
* @description List of organizations
|
|
4749
|
-
*/
|
|
4750
|
-
this.organizations = [];
|
|
4751
|
-
/**
|
|
4752
|
-
* @description Flag witch show that application was load the main user data. By Default - false;
|
|
4753
|
-
*/
|
|
4754
|
-
_ready.set(this, false);
|
|
4755
|
-
}
|
|
4756
|
-
get contextType() {
|
|
4757
|
-
var _a;
|
|
4758
|
-
if (!this.contextId)
|
|
4759
|
-
return undefined;
|
|
4760
|
-
if (((_a = this.person) === null || _a === void 0 ? void 0 : _a.id) === this.contextId)
|
|
4761
|
-
return 'person';
|
|
4762
|
-
return 'organization';
|
|
4763
|
-
}
|
|
4764
|
-
set router(v) {
|
|
4765
|
-
__classPrivateFieldSet(this, _router, v);
|
|
4766
|
-
}
|
|
4767
|
-
/**
|
|
4768
|
-
* @description VueRouter of Application
|
|
4769
|
-
* */
|
|
4770
|
-
get router() {
|
|
4771
|
-
if (!__classPrivateFieldGet(this, _router))
|
|
4772
|
-
throw new Error('Router was not founded. Please set router: Manager.router = router: VueRouter');
|
|
4773
|
-
return __classPrivateFieldGet(this, _router);
|
|
4774
|
-
}
|
|
4775
|
-
set type(type) {
|
|
4776
|
-
__classPrivateFieldSet(this, _type, type);
|
|
4777
|
-
}
|
|
4778
|
-
get type() {
|
|
4779
|
-
return __classPrivateFieldGet(this, _type);
|
|
4780
|
-
}
|
|
4781
|
-
get isBack() {
|
|
4782
|
-
return this.type === 'back';
|
|
4783
|
-
}
|
|
4784
|
-
get isFront() {
|
|
4785
|
-
return this.type === 'front';
|
|
4786
|
-
}
|
|
4787
|
-
set ready(v) {
|
|
4788
|
-
__classPrivateFieldSet(this, _ready, v);
|
|
4789
|
-
this.emit(ApplicationManager.EVENT_READY_UPDATE, v);
|
|
4790
|
-
}
|
|
4791
|
-
get ready() {
|
|
4792
|
-
return __classPrivateFieldGet(this, _ready);
|
|
4793
|
-
}
|
|
4794
|
-
onReady(callback) {
|
|
4795
|
-
return this.on(ApplicationManager.EVENT_READY_UPDATE, callback);
|
|
4796
|
-
}
|
|
4797
|
-
onupdateContext(callback) {
|
|
4798
|
-
return this.on(ApplicationManager.EVENT_CONTEXT_UPDATE, callback);
|
|
4799
|
-
}
|
|
4800
|
-
onupdateData(callback) {
|
|
4801
|
-
return this.on(ApplicationManager.EVENT_DATA_UPDATE, callback);
|
|
4802
|
-
}
|
|
4803
|
-
/**
|
|
4804
|
-
* @description Method for update current context. After success emit event[EVENT_UPDATE_CONTEXT]
|
|
4805
|
-
*/
|
|
4806
|
-
setCurrentContext(id) {
|
|
4807
|
-
if (this.contextId === id)
|
|
4808
|
-
return console.log(`[application-manager] The current context has already been installed.`);
|
|
4809
|
-
this.contextId = Number(id);
|
|
4810
|
-
localStorage.setItem(ApplicationManager.CURRENT_CONTEXT_KEY, String(id));
|
|
4811
|
-
this.emit(ApplicationManager.EVENT_CONTEXT_UPDATE, id);
|
|
4812
|
-
console.log(`Current context id %c${id}`, 'color: purple');
|
|
4813
|
-
}
|
|
4814
|
-
/**
|
|
4815
|
-
* @description Initialization of ApplicationManager
|
|
4816
|
-
*/
|
|
4817
|
-
init() {
|
|
4818
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4819
|
-
try {
|
|
4820
|
-
const data = yield this.loadCustomerData();
|
|
4821
|
-
this.person = data;
|
|
4822
|
-
this.organizations = data.organizations;
|
|
4823
|
-
this.user = data.user;
|
|
4824
|
-
this.ready = true;
|
|
4825
|
-
const savedContext = Number.parseInt(localStorage.getItem(ApplicationManager.CURRENT_CONTEXT_KEY) || "");
|
|
4826
|
-
if (!Number.isNaN(savedContext) && this.validateContextId(Number(savedContext)))
|
|
4827
|
-
this.setCurrentContext(savedContext);
|
|
4828
|
-
else
|
|
4829
|
-
this.setCurrentContext(Number(data.id));
|
|
4830
|
-
}
|
|
4831
|
-
catch (e) {
|
|
4832
|
-
NotificationSystem.add('error', CoreError.ApiNotAvailable().message);
|
|
4833
|
-
}
|
|
4834
|
-
});
|
|
4835
|
-
}
|
|
4836
|
-
loadCustomerData() {
|
|
4837
|
-
return clientService.getClientData();
|
|
4838
|
-
}
|
|
4839
|
-
/**
|
|
4840
|
-
* @description The main method of application. Load the main information about user.
|
|
4841
|
-
* @deprecated
|
|
4842
|
-
*/
|
|
4843
|
-
updateFullClientData() {
|
|
4844
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4845
|
-
return this.init();
|
|
4846
|
-
});
|
|
4847
|
-
}
|
|
4848
|
-
/**
|
|
4849
|
-
* @description Method using for validate provided ID, Checking with existing person ID and each organization ID.
|
|
4850
|
-
* */
|
|
4851
|
-
validateContextId(id) {
|
|
4852
|
-
var _a;
|
|
4853
|
-
if (((_a = this.person) === null || _a === void 0 ? void 0 : _a.id) == id)
|
|
4854
|
-
return true;
|
|
4855
|
-
return !!this.organizations.find(org => org.id === id);
|
|
4856
|
-
}
|
|
4857
|
-
getListKeyById(id) {
|
|
4858
|
-
return `list-information-${id}`;
|
|
4859
|
-
}
|
|
4860
|
-
getListInformationFromLocalStorage(id) {
|
|
4861
|
-
const data = localStorage.getItem(this.getListKeyById(id));
|
|
4862
|
-
return !!data ? JSON.parse(data) : data;
|
|
4863
|
-
}
|
|
4864
|
-
setListInformationToLocalStorage(id, info) {
|
|
4865
|
-
localStorage.setItem(this.getListKeyById(id), JSON.stringify(info));
|
|
4866
|
-
}
|
|
4867
|
-
}
|
|
4868
|
-
_router = new WeakMap(), _type = new WeakMap(), _ready = new WeakMap();
|
|
4869
|
-
ApplicationManager.EVENT_CONTEXT_UPDATE = 'event:context-update';
|
|
4870
|
-
ApplicationManager.EVENT_READY_UPDATE = 'event:ready-update';
|
|
4871
|
-
ApplicationManager.EVENT_DATA_UPDATE = 'event:data-update';
|
|
4872
|
-
/**
|
|
4873
|
-
* @description Key for localStorage, saving current context ID. using after user login to system
|
|
4874
|
-
* */
|
|
4875
|
-
ApplicationManager.CURRENT_CONTEXT_KEY = 'CurrentContext';
|
|
4876
|
-
const Manager = new ApplicationManager();
|
|
4877
|
-
function useManagerState() {
|
|
4878
|
-
const state = vue.reactive({
|
|
4879
|
-
contextType: Manager.contextType,
|
|
4880
|
-
contextId: Manager.contextId
|
|
4881
|
-
});
|
|
4882
|
-
Manager.onupdateContext(() => {
|
|
4883
|
-
state.contextType = Manager.contextType;
|
|
4884
|
-
state.contextId = Manager.contextId;
|
|
4885
|
-
});
|
|
4886
|
-
return state;
|
|
4887
|
-
}
|
|
4888
|
-
|
|
4889
4910
|
/**
|
|
4890
4911
|
* @description Используется для работы с конфигурацией списка. При работе делает копию, после чего её можно будет установить
|
|
4891
4912
|
* как конфигурацию по умолчанию
|
|
@@ -49,12 +49,12 @@ interface IWizardProcessResponse {
|
|
|
49
49
|
statusCode: number;
|
|
50
50
|
statusName: string;
|
|
51
51
|
token: string;
|
|
52
|
-
validationResults:
|
|
52
|
+
validationResults: IWizardValidationItem[];
|
|
53
53
|
}
|
|
54
54
|
export declare type IWizardFixedResponse = Omit<IWizardProcessResponse, 'createdEntites'> & {
|
|
55
55
|
createdEntities: IWizardProcessResponse['createdEntites'];
|
|
56
56
|
};
|
|
57
|
-
export interface
|
|
57
|
+
export interface IWizardValidationItem {
|
|
58
58
|
message: string;
|
|
59
59
|
name: string;
|
|
60
60
|
statusCode: number;
|