dyo-tools 0.3.2 → 0.4.1
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/{dist/constants.d.ts → constants.d.ts} +1 -0
- package/constants.d.ts.map +1 -0
- package/constants.js +67 -0
- package/constants.js.map +1 -0
- package/core/DTAction.d.ts +12 -0
- package/core/DTAction.d.ts.map +1 -0
- package/{dist/core → core}/DTAction.js +3 -6
- package/core/DTAction.js.map +1 -0
- package/{dist/core → core}/DTBunch.d.ts +8 -5
- package/core/DTBunch.d.ts.map +1 -0
- package/{dist/core → core}/DTBunch.js +53 -19
- package/core/DTBunch.js.map +1 -0
- package/core/DTComponent.d.ts +31 -0
- package/core/DTComponent.d.ts.map +1 -0
- package/{dist/core → core}/DTComponent.js +23 -10
- package/core/DTComponent.js.map +1 -0
- package/core/DTComponentPhysical.d.ts +16 -0
- package/core/DTComponentPhysical.d.ts.map +1 -0
- package/core/DTComponentPhysical.js +37 -0
- package/core/DTComponentPhysical.js.map +1 -0
- package/core/DTComponentWithMeta.d.ts +12 -0
- package/core/DTComponentWithMeta.d.ts.map +1 -0
- package/core/DTComponentWithMeta.js +46 -0
- package/core/DTComponentWithMeta.js.map +1 -0
- package/core/DTElement.d.ts +15 -0
- package/core/DTElement.d.ts.map +1 -0
- package/{dist/core → core}/DTElement.js +8 -9
- package/core/DTElement.js.map +1 -0
- package/core/DTError.d.ts +14 -0
- package/core/DTError.d.ts.map +1 -0
- package/{dist/core → core}/DTError.js +1 -5
- package/core/DTError.js.map +1 -0
- package/core/DTManager.d.ts +36 -0
- package/core/DTManager.d.ts.map +1 -0
- package/{dist/core → core}/DTManager.js +84 -26
- package/core/DTManager.js.map +1 -0
- package/core/DTMaster.d.ts +27 -0
- package/core/DTMaster.d.ts.map +1 -0
- package/{dist/core → core}/DTMaster.js +48 -31
- package/core/DTMaster.js.map +1 -0
- package/core/DTModule.d.ts +17 -0
- package/core/DTModule.d.ts.map +1 -0
- package/{dist/core → core}/DTModule.js +6 -6
- package/core/DTModule.js.map +1 -0
- package/{src/index.ts → index.d.ts} +14 -17
- package/index.d.ts.map +1 -0
- package/{dist/index.d.ts → index.js} +1 -0
- package/index.js.map +1 -0
- package/{dist/libs → libs}/DYOFinder.d.ts +1 -0
- package/libs/DYOFinder.d.ts.map +1 -0
- package/{dist/libs → libs}/DYOFinder.js +10 -14
- package/libs/DYOFinder.js.map +1 -0
- package/libs/dix/DIXModule.module.d.ts +8 -0
- package/libs/dix/DIXModule.module.d.ts.map +1 -0
- package/libs/dix/DIXModule.module.js +73 -0
- package/libs/player/DTPlayer.element.d.ts +6 -0
- package/libs/player/DTPlayer.element.d.ts.map +1 -0
- package/libs/player/DTPlayer.element.js +7 -0
- package/libs/player/DTPlayer.element.js.map +1 -0
- package/libs/player/DTPlayer.manager.d.ts +12 -0
- package/libs/player/DTPlayer.manager.d.ts.map +1 -0
- package/libs/player/DTPlayer.manager.js +35 -0
- package/libs/player/DTPlayer.manager.js.map +1 -0
- package/package.json +9 -47
- package/tsconfig.dev.tsbuildinfo +1 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/{dist/types → types}/core.d.ts +40 -12
- package/types/core.d.ts.map +1 -0
- package/{dist/types → types}/core.js +2 -6
- package/types/core.js.map +1 -0
- package/{src/types/index.ts → types/index.d.ts} +3 -2
- package/types/index.d.ts.map +1 -0
- package/types/index.js.map +1 -0
- package/{dist/types → types}/player.d.ts +1 -1
- package/types/player.d.ts.map +1 -0
- package/types/player.js +1 -0
- package/.c8rc.json +0 -4
- package/.eslintignore +0 -2
- package/.eslintrc.json +0 -47
- package/Makefile +0 -34
- package/README.md +0 -0
- package/babel.config.js +0 -1
- package/cucumber-report.html +0 -48
- package/dist/constants.js +0 -63
- package/dist/constants.js.map +0 -1
- package/dist/core/DTAction.d.ts +0 -10
- package/dist/core/DTAction.js.map +0 -1
- package/dist/core/DTBunch.js.map +0 -1
- package/dist/core/DTComponent.d.ts +0 -28
- package/dist/core/DTComponent.js.map +0 -1
- package/dist/core/DTComponentPhysical.d.ts +0 -13
- package/dist/core/DTComponentPhysical.js +0 -22
- package/dist/core/DTComponentPhysical.js.map +0 -1
- package/dist/core/DTComponentWithMeta.d.ts +0 -9
- package/dist/core/DTComponentWithMeta.js +0 -32
- package/dist/core/DTComponentWithMeta.js.map +0 -1
- package/dist/core/DTElement.d.ts +0 -13
- package/dist/core/DTElement.js.map +0 -1
- package/dist/core/DTError.d.ts +0 -13
- package/dist/core/DTError.js.map +0 -1
- package/dist/core/DTManager.d.ts +0 -33
- package/dist/core/DTManager.js.map +0 -1
- package/dist/core/DTMaster.d.ts +0 -24
- package/dist/core/DTMaster.js.map +0 -1
- package/dist/core/DTModule.d.ts +0 -14
- package/dist/core/DTModule.js.map +0 -1
- package/dist/index.js +0 -28
- package/dist/index.js.map +0 -1
- package/dist/libs/DYOFinder.js.map +0 -1
- package/dist/libs/player/DTPlayer.element.d.ts +0 -5
- package/dist/libs/player/DTPlayer.element.js +0 -11
- package/dist/libs/player/DTPlayer.element.js.map +0 -1
- package/dist/libs/player/DTPlayer.manager.d.ts +0 -11
- package/dist/libs/player/DTPlayer.manager.js +0 -42
- package/dist/libs/player/DTPlayer.manager.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/core.js.map +0 -1
- package/dist/types/index.js +0 -19
- package/dist/types/index.js.map +0 -1
- package/dist/types/player.js +0 -3
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -29
- package/docs/assets/main.js +0 -59
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1414
- package/docs/classes/core_DTAction.DYOToolsAction.html +0 -89
- package/docs/classes/core_DTBunch.DYOToolsBunch.html +0 -254
- package/docs/classes/core_DTComponent.DYOToolsComponent.html +0 -76
- package/docs/classes/core_DTComponentPhysical.DYOToolsComponentPhysical.html +0 -110
- package/docs/classes/core_DTComponentWithMeta.DYOToolsComponentWithMeta.html +0 -96
- package/docs/classes/core_DTElement.DYOToolsElement.html +0 -135
- package/docs/classes/core_DTError.DYOToolsError.html +0 -37
- package/docs/classes/core_DTManager.DYOToolsManager.html +0 -237
- package/docs/classes/core_DTMaster.DYOToolsMaster.html +0 -150
- package/docs/classes/core_DTModule.DYOToolsModule.html +0 -92
- package/docs/classes/libs_DYOFinder.DYOFinder.html +0 -34
- package/docs/classes/libs_player_DTPlayer_element.DYOToolsPlayer.html +0 -134
- package/docs/classes/libs_player_DTPlayer_manager.DYOToolsPlayerManager.html +0 -243
- package/docs/enums/types_core.FilterOperatorType.html +0 -10
- package/docs/hierarchy.html +0 -1
- package/docs/index.html +0 -1
- package/docs/interfaces/types_core.DTBunchFilters.html +0 -6
- package/docs/interfaces/types_core.DTBunchOptions.html +0 -19
- package/docs/interfaces/types_core.DTBunchToObject.html +0 -7
- package/docs/interfaces/types_core.DTComponentOptions.html +0 -5
- package/docs/interfaces/types_core.DTComponentToObject.html +0 -4
- package/docs/interfaces/types_core.DTElementToObject.html +0 -7
- package/docs/interfaces/types_core.DTManagerFilters.html +0 -6
- package/docs/interfaces/types_core.DTManagerOptions.html +0 -8
- package/docs/interfaces/types_core.DTManagerToObject.html +0 -5
- package/docs/interfaces/types_core.DTMasterToObject.html +0 -8
- package/docs/interfaces/types_core.DTModuleToObject.html +0 -6
- package/docs/interfaces/types_core.DYOFinderConfigurationPropDefault.html +0 -4
- package/docs/interfaces/types_core.DYOFinderConfigurationPropObjectSearch.html +0 -4
- package/docs/interfaces/types_core.DYOFinderFilterOperatorAdvanced.html +0 -5
- package/docs/interfaces/types_core.DYOFinderFilterOperatorBase.html +0 -5
- package/docs/interfaces/types_player.DTPlayerManagerSimpleConfiguration.html +0 -3
- package/docs/modules/constants.html +0 -6
- package/docs/modules/core_DTAction.html +0 -2
- package/docs/modules/core_DTBunch.html +0 -2
- package/docs/modules/core_DTComponent.html +0 -2
- package/docs/modules/core_DTComponentPhysical.html +0 -2
- package/docs/modules/core_DTComponentWithMeta.html +0 -2
- package/docs/modules/core_DTElement.html +0 -2
- package/docs/modules/core_DTError.html +0 -2
- package/docs/modules/core_DTManager.html +0 -2
- package/docs/modules/core_DTMaster.html +0 -2
- package/docs/modules/core_DTModule.html +0 -2
- package/docs/modules/libs_DYOFinder.html +0 -2
- package/docs/modules/libs_player_DTPlayer_element.html +0 -2
- package/docs/modules/libs_player_DTPlayer_manager.html +0 -2
- package/docs/modules/types.html +0 -29
- package/docs/modules/types_core.html +0 -28
- package/docs/modules/types_player.html +0 -2
- package/docs/types/types_core.DTAcceptedMetaData.html +0 -2
- package/docs/types/types_core.DTManagerItemType.html +0 -1
- package/docs/types/types_core.DTManagerItemsType.html +0 -2
- package/docs/types/types_core.DYOFinderComponentType.html +0 -1
- package/docs/types/types_core.DYOFinderConfiguration.html +0 -2
- package/docs/types/types_core.DYOFinderConfigurationProp.html +0 -1
- package/docs/types/types_core.DYOFinderFilterOperator.html +0 -1
- package/docs/types/types_core.DYOFinderFilterOperatorArgument.html +0 -1
- package/docs/types/types_core.DYOFinderFilters.html +0 -1
- package/docs/types/types_core.StandardPrimitiveType.html +0 -2
- package/docs/types/types_core.StandardPrimitiveTypeWithArray.html +0 -1
- package/docs/variables/constants.bunchDefaultOptions.html +0 -2
- package/docs/variables/constants.componentBunchDefaultFinderConfiguration.html +0 -1
- package/docs/variables/constants.componentManagerDefaultFinderConfiguration.html +0 -1
- package/docs/variables/constants.componentPhysicalDefaultFinderConfiguration.html +0 -1
- package/docs/variables/constants.managerDefaultOptions.html +0 -2
- package/jest.config.js +0 -6
- package/src/constants.ts +0 -85
- package/src/core/DTAction.ts +0 -52
- package/src/core/DTBunch.ts +0 -467
- package/src/core/DTComponent.ts +0 -225
- package/src/core/DTComponentPhysical.ts +0 -54
- package/src/core/DTComponentWithMeta.ts +0 -65
- package/src/core/DTElement.ts +0 -102
- package/src/core/DTError.ts +0 -78
- package/src/core/DTManager.ts +0 -465
- package/src/core/DTMaster.ts +0 -318
- package/src/core/DTModule.ts +0 -90
- package/src/libs/DYOFinder.ts +0 -175
- package/src/libs/player/DTPlayer.element.ts +0 -9
- package/src/libs/player/DTPlayer.manager.ts +0 -84
- package/src/types/core.ts +0 -169
- package/src/types/player.ts +0 -6
- package/test/core/DTAction.double.ts +0 -78
- package/test/core/DTAction.spec.ts +0 -76
- package/test/core/DTBunch.double.ts +0 -261
- package/test/core/DTBunch.spec.ts +0 -910
- package/test/core/DTComponent.double.ts +0 -164
- package/test/core/DTComponent.spec.ts +0 -295
- package/test/core/DTComponentPhysical.double.ts +0 -76
- package/test/core/DTComponentPhysical.spec.ts +0 -78
- package/test/core/DTComponentWithMeta.double.ts +0 -115
- package/test/core/DTComponentWithMeta.spec.ts +0 -124
- package/test/core/DTElement.double.ts +0 -163
- package/test/core/DTElement.spec.ts +0 -146
- package/test/core/DTError.double.ts +0 -92
- package/test/core/DTError.spec.ts +0 -89
- package/test/core/DTManager.double.ts +0 -216
- package/test/core/DTManager.spec.ts +0 -965
- package/test/core/DTMaster.double.ts +0 -141
- package/test/core/DTMaster.spec.ts +0 -584
- package/test/core/DTModule.double.ts +0 -80
- package/test/core/DTModule.spec.ts +0 -138
- package/test/core/copy.spec.ts +0 -243
- package/test/libs/DYOFinder.double.ts +0 -152
- package/test/libs/DYOFinder.spec.ts +0 -194
- package/test/libs/player/DTPlayer.element.double.ts +0 -55
- package/test/libs/player/DTPlayer.element.spec.ts +0 -28
- package/test/libs/player/DTPlayer.manager.double.ts +0 -92
- package/test/libs/player/DTPlayer.manager.spec.ts +0 -178
- package/tsconfig.dev.json +0 -22
- package/tsconfig.json +0 -21
- /package/{dist/types/index.d.ts → types/index.js} +0 -0
- /package/{dist/types → types}/player.js.map +0 -0
package/src/core/DTBunch.ts
DELETED
|
@@ -1,467 +0,0 @@
|
|
|
1
|
-
import DYOToolsElement from './DTElement';
|
|
2
|
-
import DYOToolsManager from './DTManager';
|
|
3
|
-
import {
|
|
4
|
-
DTAcceptedMetaData, DTBunchFilters, DTBunchOptions, DTBunchToObject, DYOFinderConfiguration,
|
|
5
|
-
} from '../types';
|
|
6
|
-
import DYOToolsError from './DTError';
|
|
7
|
-
import DYOToolsComponentPhysical from './DTComponentPhysical';
|
|
8
|
-
import { bunchDefaultOptions as defaultOptions, componentBunchDefaultFinderConfiguration } from '../constants';
|
|
9
|
-
import DYOFinder from '../libs/DYOFinder';
|
|
10
|
-
|
|
11
|
-
export default class DYOToolsBunch<
|
|
12
|
-
IBunchItem extends DYOToolsElement<DTAcceptedMetaData> = DYOToolsElement<DTAcceptedMetaData>,
|
|
13
|
-
IComponentMeta extends DTAcceptedMetaData = DTAcceptedMetaData,
|
|
14
|
-
> extends DYOToolsComponentPhysical<IComponentMeta, DTBunchOptions> {
|
|
15
|
-
/**
|
|
16
|
-
* Defining component type to "bunch".
|
|
17
|
-
*/
|
|
18
|
-
protected _componentType = 'bunch';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Ordered Array of DTElement instance managed by the bunch.
|
|
22
|
-
*/
|
|
23
|
-
protected _items: IBunchItem[];
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Current DYOFinder instance.
|
|
27
|
-
*
|
|
28
|
-
* This instance offers advanced methods to manipulate items, like searching.
|
|
29
|
-
*/
|
|
30
|
-
protected _finder: DYOFinder;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Applying the parent constructor, and execute following process steps :
|
|
34
|
-
* * Add **items** to the bunch instance (using adding specifications).
|
|
35
|
-
* * Merge specific **options** configuration with default in _options.
|
|
36
|
-
* * Initialize *DYOFinder* with **getFinderConfiguration** method.
|
|
37
|
-
*
|
|
38
|
-
* @see [addAtIndex](#addAtIndex) method for adding specifications.
|
|
39
|
-
* @param key
|
|
40
|
-
* @param items Array of DTElement instance to add. Default empty array.
|
|
41
|
-
* @param options Specific options configuration for the instance. Default empty object.
|
|
42
|
-
*/
|
|
43
|
-
constructor(key?: string, items: IBunchItem[] = [], options: Partial<DTBunchOptions> = {}) {
|
|
44
|
-
super(key, { ...defaultOptions, ...options });
|
|
45
|
-
|
|
46
|
-
this._items = [];
|
|
47
|
-
if (items && items.length > 0) {
|
|
48
|
-
this.addMany(items);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
this._finder = new DYOFinder(this, this.getFinderConfiguration());
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Returns DYOFinder configuration for standard DTBunch instance.
|
|
56
|
-
*
|
|
57
|
-
* This method can be overridden to extend the configuration.
|
|
58
|
-
*
|
|
59
|
-
* @returns DYOFinderConfiguration standard configuration.
|
|
60
|
-
*/
|
|
61
|
-
getFinderConfiguration(): DYOFinderConfiguration {
|
|
62
|
-
return componentBunchDefaultFinderConfiguration;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Setter for _owner property.
|
|
67
|
-
*
|
|
68
|
-
* If **inheritOwner** is *true*, apply new **owner** to each item.
|
|
69
|
-
*/
|
|
70
|
-
setOwner(value: string): void {
|
|
71
|
-
super.setOwner(value);
|
|
72
|
-
|
|
73
|
-
// Update owner elements
|
|
74
|
-
const { inheritOwner } = this._options;
|
|
75
|
-
if (inheritOwner) {
|
|
76
|
-
this._items.forEach((item) => { item.setOwner(this.getOwner()); });
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Remove the current owner of bunch.
|
|
82
|
-
*
|
|
83
|
-
* If **inheritOwner** is *true*, remove current owner to each item.
|
|
84
|
-
*/
|
|
85
|
-
removeOwner(): void {
|
|
86
|
-
super.removeOwner();
|
|
87
|
-
|
|
88
|
-
// Update owner elements
|
|
89
|
-
const { inheritOwner } = this._options;
|
|
90
|
-
if (inheritOwner) {
|
|
91
|
-
this._items.forEach((item) => { item.removeOwner(); });
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Add an element **item** as the last element into _items property array.
|
|
97
|
-
*
|
|
98
|
-
* @see [addAtIndex](#addAtIndex) method for adding specifications.
|
|
99
|
-
* @param item A DTElement instance to add into the bunch.
|
|
100
|
-
* @param options Optional Bunch option configuration object to apply only for this method execution. Options are not
|
|
101
|
-
* saved in current _options property. Available Options are : **uniqueKey**, **inheritOwner**, **replaceIndex**
|
|
102
|
-
* and **errors**.
|
|
103
|
-
*/
|
|
104
|
-
add(item: IBunchItem, options: Partial<Omit<DTBunchOptions, 'virtualContainer'>> = {}): void {
|
|
105
|
-
this.addAtIndex(item, this._items.length, options);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Add an element **item** at specified **index** into _items property array.
|
|
110
|
-
*
|
|
111
|
-
* The adding process has the following specifications :
|
|
112
|
-
* * If the added item has the same _id than existing item, an error occurred (depending on **errors** option).
|
|
113
|
-
* * Option **uniqueKey** = *true*. If the added item has the same _key than existing item,
|
|
114
|
-
* an error occurred (depending on **errors** option).
|
|
115
|
-
* * Option **inheritOwner** = *true*. When the new item is added, its owner is replaced by the current bunch owner.
|
|
116
|
-
* * Option **virtualContainer** = *false*. When the new item is added, its container is replaced by the current bunch
|
|
117
|
-
* instance. The item is removed from the old container.
|
|
118
|
-
* * If an item already exists at the specified index, the new item is added at the index, and following items are
|
|
119
|
-
* automatically affected at next indexes. If **replaceIndex** option is *true*, the new item replaces the former one
|
|
120
|
-
* at the index instead.
|
|
121
|
-
* * If the bunch has a parent **Manager**, the added item is also added to the **Manager library**, only if this one
|
|
122
|
-
* doesn't already exist in the library.
|
|
123
|
-
*
|
|
124
|
-
* @param item A DTElement instance to add into the bunch.
|
|
125
|
-
* @param index Index value where the item might be added. Must be a number between 0 and the current _items length.
|
|
126
|
-
* If not, the provided argument is automatically changed to 0 or current _items length.
|
|
127
|
-
* @param options Optional Bunch option configuration object to apply only for this method execution. Options are not
|
|
128
|
-
* saved in current _options property. Available Options are : **uniqueKey**, **inheritOwner**, **replaceIndex**
|
|
129
|
-
* and **errors**.
|
|
130
|
-
*/
|
|
131
|
-
addAtIndex(item: IBunchItem, index: number, options: Partial<Omit<DTBunchOptions, ''>> = {}): void {
|
|
132
|
-
const {
|
|
133
|
-
uniqueKey, replaceIndex, inheritOwner, virtualContainer,
|
|
134
|
-
}: Partial<DTBunchOptions> = { ...this._options, ...options };
|
|
135
|
-
let hasError = false;
|
|
136
|
-
let finalIndex = index;
|
|
137
|
-
|
|
138
|
-
// Handle ID conflicts
|
|
139
|
-
const existingItem = this.get(item.getId());
|
|
140
|
-
if (existingItem) {
|
|
141
|
-
hasError = true;
|
|
142
|
-
this.triggerError(new DYOToolsError(
|
|
143
|
-
'id_conflict',
|
|
144
|
-
'Element with same id already exists in the bunch',
|
|
145
|
-
this,
|
|
146
|
-
item,
|
|
147
|
-
));
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Handle Key conflicts
|
|
151
|
-
if (uniqueKey && !hasError) {
|
|
152
|
-
const existingItemByKey = this.find({ key: { $eq: item.getKey() } });
|
|
153
|
-
if (existingItemByKey) {
|
|
154
|
-
hasError = true;
|
|
155
|
-
this.triggerError(new DYOToolsError(
|
|
156
|
-
'key_conflict',
|
|
157
|
-
'Element with same key already exists in the bunch',
|
|
158
|
-
this,
|
|
159
|
-
item,
|
|
160
|
-
));
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (!hasError) {
|
|
165
|
-
// Update indexes if out of limits
|
|
166
|
-
if (index < 0) {
|
|
167
|
-
finalIndex = 0;
|
|
168
|
-
}
|
|
169
|
-
if (index > this._items.length) {
|
|
170
|
-
finalIndex = this._items.length;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// Update Context with manager
|
|
174
|
-
if (this._context) {
|
|
175
|
-
item.setContext(this._context);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (!virtualContainer) {
|
|
179
|
-
const oldContainer = item.getContainer();
|
|
180
|
-
if (oldContainer && oldContainer.getComponentType() === 'bunch') {
|
|
181
|
-
(oldContainer as DYOToolsBunch<IBunchItem, DTAcceptedMetaData>).remove(item.getId());
|
|
182
|
-
}
|
|
183
|
-
item.setContainer(this);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Update Owner
|
|
187
|
-
if (inheritOwner) {
|
|
188
|
-
item.setOwner(this._owner);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Update Manager library
|
|
192
|
-
if (this.getContext('manager')) {
|
|
193
|
-
const manager: DYOToolsManager<IBunchItem> = this.getContext('manager') as DYOToolsManager<IBunchItem>;
|
|
194
|
-
if (manager.getLibrary().getId() !== this._id && !manager.getLibrary().get(item.getId())) {
|
|
195
|
-
manager.getLibrary().add(item);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// Add the new Item
|
|
200
|
-
if (replaceIndex) {
|
|
201
|
-
this._items[finalIndex] = item;
|
|
202
|
-
} else {
|
|
203
|
-
const arrayPart1 = this._items.slice(0, finalIndex);
|
|
204
|
-
const arrayPart2 = this._items.slice(finalIndex);
|
|
205
|
-
|
|
206
|
-
this._items = [...arrayPart1, item, ...arrayPart2];
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Add each element of an array **items** at the end of the _items property array.
|
|
213
|
-
*
|
|
214
|
-
* @see [addAtIndex](#addAtIndex) method for adding specifications.
|
|
215
|
-
* @param items An array of DTElement instances to add into the bunch.
|
|
216
|
-
* @param options Optional Bunch option configuration object to apply only for this method execution. Options are not
|
|
217
|
-
* saved in current _options property. Available Options are : **uniqueKey**, **inheritOwner**, **replaceIndex**
|
|
218
|
-
* and **errors**.
|
|
219
|
-
*/
|
|
220
|
-
addMany(items: IBunchItem[], options: Partial<Omit<DTBunchOptions, 'virtualContainer'>> = {}): void {
|
|
221
|
-
this.addManyAtIndex(items, this._items.length, options);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Add each element of an array **items** at specified **index** into _items property array.
|
|
226
|
-
* The first element is added at provided **index** argument, and each next element at next indexes, following adding
|
|
227
|
-
* specifications.
|
|
228
|
-
*
|
|
229
|
-
* @see [addAtIndex](#addAtIndex) method for adding specifications.
|
|
230
|
-
* @param items An array of DTElement instances to add into the bunch.
|
|
231
|
-
* @param index Index value where the item might be added. Must be a number between 0 and the current _items length.
|
|
232
|
-
* If not, the provided argument is automatically changed to 0 or current _items length.
|
|
233
|
-
* @param options Optional Bunch option configuration object to apply only for this method execution. Options are not
|
|
234
|
-
* saved in current _options property. Available Options are : **uniqueKey**, **inheritOwner**, **replaceIndex**
|
|
235
|
-
* and **errors**.
|
|
236
|
-
*/
|
|
237
|
-
addManyAtIndex(items: IBunchItem[], index: number, options: Partial<Omit<DTBunchOptions, 'virtualContainer'>> = {}): void {
|
|
238
|
-
const previousItems = this._items;
|
|
239
|
-
const { errors }: Partial<DTBunchOptions> = { ...this._options, ...options };
|
|
240
|
-
let currentIndex = index;
|
|
241
|
-
|
|
242
|
-
if (index < 0) {
|
|
243
|
-
currentIndex = 0;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
try {
|
|
247
|
-
for (const item of items) {
|
|
248
|
-
this.addAtIndex(item, currentIndex, options);
|
|
249
|
-
currentIndex += 1;
|
|
250
|
-
}
|
|
251
|
-
} catch (exception) {
|
|
252
|
-
if (!errors) {
|
|
253
|
-
this._items = previousItems;
|
|
254
|
-
throw exception;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Return one DTElement instance included in the _items property by index or id.
|
|
261
|
-
*
|
|
262
|
-
* * If a Number is provided, return the DTElement instance at the corresponding index into _items.
|
|
263
|
-
* * If a String is provided, return the DTElement instance with the corresponding _id property into _items.
|
|
264
|
-
*
|
|
265
|
-
* @param index Number index value or String _id value.
|
|
266
|
-
* @returns DTElement instance that corresponds to index or id provided, or undefined if not found.
|
|
267
|
-
*/
|
|
268
|
-
get(index: string | number): IBunchItem | undefined {
|
|
269
|
-
if (typeof index === 'number') {
|
|
270
|
-
return this._items[index];
|
|
271
|
-
}
|
|
272
|
-
const itemFiltered = this._items.filter((item: IBunchItem) => item.getId() === index);
|
|
273
|
-
return itemFiltered.length > 0 ? itemFiltered[0] : undefined;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Return all DTElement instance managed by the Bunch.
|
|
278
|
-
*
|
|
279
|
-
* @returns DTElement array corresponding to current _items property.
|
|
280
|
-
*/
|
|
281
|
-
getAll(): IBunchItem[] {
|
|
282
|
-
return this._items;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Return current index of a DTElement instance into _items property by _id.
|
|
287
|
-
*
|
|
288
|
-
* @param id String _id value of the DTElement instance.
|
|
289
|
-
* @returns Current index number into _items, or -1 if not found.
|
|
290
|
-
*/
|
|
291
|
-
indexOf(id: string): number {
|
|
292
|
-
let indexOfItem = -1;
|
|
293
|
-
for (let i = 0; i < this._items.length; i += 1) {
|
|
294
|
-
if (this._items[i].getId() === id) {
|
|
295
|
-
indexOfItem = i;
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
return indexOfItem;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Remove a DTElement instance into the _items property by index or id.
|
|
304
|
-
*
|
|
305
|
-
* * If a Number is provided, remove the DTElement instance at the corresponding index into _items.
|
|
306
|
-
* * If a String is provided, remove the DTElement instance with the corresponding _id property into _items.
|
|
307
|
-
*
|
|
308
|
-
* Note : Remove also affectation to the current container of the removed item
|
|
309
|
-
* (only if Option **virtualContainer** is *false*).
|
|
310
|
-
*
|
|
311
|
-
* @param index Number index value or String _id value.
|
|
312
|
-
*/
|
|
313
|
-
remove(index: string | number): void {
|
|
314
|
-
if (typeof index === 'number') {
|
|
315
|
-
this.removeMany([index as number]);
|
|
316
|
-
} else {
|
|
317
|
-
this.removeMany([index as string]);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Remove multiple DTElement instances into the _items property by index or id. An array of indexes or ids to remove
|
|
323
|
-
* must be provided.
|
|
324
|
-
*
|
|
325
|
-
* * If a Number Array is provided, remove DTElement instances at corresponding indexes into _items.
|
|
326
|
-
* * If a String Array is provided, remove DTElement instances with corresponding _id properties into _items.
|
|
327
|
-
*
|
|
328
|
-
* Note : Remove also affectation to the current container of removed items
|
|
329
|
-
* (only if Option **virtualContainer** is *false*).
|
|
330
|
-
*
|
|
331
|
-
* @param indexes Number Array index values or String Array _id values.
|
|
332
|
-
*/
|
|
333
|
-
removeMany(indexes: string[] | number[]): void {
|
|
334
|
-
const { virtualContainer } = this._options;
|
|
335
|
-
const newItems = [];
|
|
336
|
-
for (let i = 0; i < this._items.length; i += 1) {
|
|
337
|
-
if (typeof indexes[0] === 'number') {
|
|
338
|
-
if (!(indexes as number[]).includes(i)) {
|
|
339
|
-
newItems.push(this._items[i]);
|
|
340
|
-
} else if (!virtualContainer) {
|
|
341
|
-
this._items[i].removeContainer();
|
|
342
|
-
}
|
|
343
|
-
} else if (!(indexes as string[]).includes(this._items[i].getId())) {
|
|
344
|
-
newItems.push(this._items[i]);
|
|
345
|
-
} else if (!virtualContainer) {
|
|
346
|
-
this._items[i].removeContainer();
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
this._items = newItems;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Remove all DTElement instances into the _items property.
|
|
355
|
-
*
|
|
356
|
-
* Note : Remove also affectation to the current container of removed items
|
|
357
|
-
* (only if Option **virtualContainer** is *false*).
|
|
358
|
-
*/
|
|
359
|
-
removeAll(): void {
|
|
360
|
-
const keysToRemove: number[] = this._items.map((item, index) => index);
|
|
361
|
-
this.removeMany(keysToRemove);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Return an array of DTElement from _items property filtered with a **filters** argument.
|
|
366
|
-
*
|
|
367
|
-
* This method use the DYOFinder instance **execute** method.
|
|
368
|
-
*
|
|
369
|
-
* Search filters can be applied on following DTElement properties :
|
|
370
|
-
* * **id** : property _id. Basic operators only.
|
|
371
|
-
* * **key** : property _key. Basic operators only.
|
|
372
|
-
* * **container** : property _id of current _container instance. Basic operators only.
|
|
373
|
-
* * **owner** : property _owner. Basic operators only.
|
|
374
|
-
* * **meta** : each meta Key of _meta property. Extended operators can be used.
|
|
375
|
-
*
|
|
376
|
-
* Examples of **filters** argument :
|
|
377
|
-
* * { key: { $eq: "key_1" } } : Return all DTElement instance into _items with *key_1* as _key property.
|
|
378
|
-
* * { context: { $in: [null, "bunch_1"] } } : Return all DTElement instance into _items having no context or a
|
|
379
|
-
* bunch context with *bunch_1* as _id property.
|
|
380
|
-
* * { key: { $ne: "key_1" }, meta: { score: { $gte: 50, $lte: 100 } } } : Return all DTElement instance into _items
|
|
381
|
-
* with _key property different than *key_1*, and meta key *score* value from _meta property between 50 and 100.
|
|
382
|
-
*
|
|
383
|
-
* @param filters Filters Object. The format is :
|
|
384
|
-
* { [property_1] : { [operator_1] : filter_value, [operator_2] : filter_value_2, ... }, [property_2] : { ... }, ... }
|
|
385
|
-
*
|
|
386
|
-
* For **meta**, you have to pass the meta key before the operator :
|
|
387
|
-
* { meta: { [meta_key1] : { [operator_1] : filter_value_1, ... }, [meta_key2] : { ... }, ... }, ... }
|
|
388
|
-
* @returns Array of DTElement instance corresponding to the filters. Empty if no filter or invalid ones are passed.
|
|
389
|
-
* @see DYOFinder
|
|
390
|
-
*/
|
|
391
|
-
find(filters: Partial<DTBunchFilters>): IBunchItem[] {
|
|
392
|
-
return this._finder.execute<IBunchItem>(filters);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Create and return a new DTBunch instance by applying from current instance :
|
|
397
|
-
* - Copy _key property
|
|
398
|
-
* - Copy _meta property
|
|
399
|
-
* - Copy _globalOptions property
|
|
400
|
-
* - Make a copy of each element in _items, and add it into _items of the copied Bunch.
|
|
401
|
-
*
|
|
402
|
-
* @returns New DTBunch instance copied.
|
|
403
|
-
*/
|
|
404
|
-
copy(): DYOToolsBunch<IBunchItem, IComponentMeta> {
|
|
405
|
-
let copyItems;
|
|
406
|
-
if (this._options.virtualContainer) {
|
|
407
|
-
copyItems = this._items;
|
|
408
|
-
} else {
|
|
409
|
-
copyItems = this._items.length === 0 ? [] : this._items.map((item) => item.copy() as IBunchItem);
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
const copyBunch = new DYOToolsBunch<IBunchItem, IComponentMeta>(this._key, copyItems, this._options);
|
|
413
|
-
copyBunch.setManyMeta({ ...this.getManyMeta() });
|
|
414
|
-
|
|
415
|
-
return copyBunch;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Return JSON Object representation of the Bunch instance.
|
|
420
|
-
*
|
|
421
|
-
* JSON Object returned has the following structure :
|
|
422
|
-
* * **id** : _id property of the Bunch.
|
|
423
|
-
* * **key** : _key property of the Bunch.
|
|
424
|
-
* * **type** : _componentType property of the Bunch.
|
|
425
|
-
* * **items** : Array of JSON Object representation for each DTElement instance in _items property of the Bunch.
|
|
426
|
-
* * **owner** : String current value of _owner property of the Bunch (only if defined).
|
|
427
|
-
* * **meta** : JSON Object of all current metadata in _meta property of the Bunch (only if not empty).
|
|
428
|
-
*
|
|
429
|
-
* @returns JSON Object representation of the Bunch.
|
|
430
|
-
*/
|
|
431
|
-
toObject(): DTBunchToObject<IComponentMeta> {
|
|
432
|
-
const objectBunch: DTBunchToObject<IComponentMeta> = {
|
|
433
|
-
id: this._id,
|
|
434
|
-
key: this._key,
|
|
435
|
-
type: this._componentType,
|
|
436
|
-
items: [],
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
if (this._items.length) {
|
|
440
|
-
objectBunch.items = this._items.map((item) => item.toObject());
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
if (this._owner) {
|
|
444
|
-
objectBunch.owner = this._owner.toString();
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
if (this._meta && Object.keys(this._meta).length > 0) {
|
|
448
|
-
objectBunch.meta = { ...this.getManyMeta() };
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
return objectBunch;
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* Return String representation of the Bunch instance.
|
|
456
|
-
*
|
|
457
|
-
* @returns String representation of the Bunch.
|
|
458
|
-
*/
|
|
459
|
-
toString(): string {
|
|
460
|
-
let ownerKey = '';
|
|
461
|
-
if (this._owner) {
|
|
462
|
-
ownerKey = ` - Owner: ${this._owner}`;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
return `Component ${this._key} - Type: Bunch${ownerKey} - Items: ${this._items.length}`;
|
|
466
|
-
}
|
|
467
|
-
}
|
package/src/core/DTComponent.ts
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import * as uuid from 'uuid';
|
|
2
|
-
import DYOToolsError from './DTError';
|
|
3
|
-
import { DTComponentOptions } from '../types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @template {string} DTComponentOptions
|
|
7
|
-
*/
|
|
8
|
-
export default abstract class DYOToolsComponent<IComponentOptions extends DTComponentOptions = DTComponentOptions> {
|
|
9
|
-
/**
|
|
10
|
-
* Component unique ID. Use uuid v4 generator.
|
|
11
|
-
*/
|
|
12
|
-
protected _id: string;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Component specific and accessible label.
|
|
16
|
-
* If not provided, the key is set with ID by default.
|
|
17
|
-
*/
|
|
18
|
-
protected _key: string;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Component Parent Context.
|
|
22
|
-
*
|
|
23
|
-
* A component can have only one *context*, and be managed by a parent Component.
|
|
24
|
-
*/
|
|
25
|
-
protected _context?: DYOToolsComponent;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Higher Level Component category.
|
|
29
|
-
*
|
|
30
|
-
* Describing component Type, like Element, Bunch, Manager...
|
|
31
|
-
*/
|
|
32
|
-
protected abstract _componentType: string;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Second Level Component category.
|
|
36
|
-
*
|
|
37
|
-
* Describing component Domain, like Card, Dice, Token...
|
|
38
|
-
*/
|
|
39
|
-
protected _domain?: string;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Third Level Component category.
|
|
43
|
-
*
|
|
44
|
-
* Describing component extra type, like Hand, Deck, Trick...
|
|
45
|
-
*/
|
|
46
|
-
protected _subKind?: string;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Array of current errors for the Component.
|
|
50
|
-
*
|
|
51
|
-
* Errors are only available if the **errors** option is enabled.
|
|
52
|
-
*/
|
|
53
|
-
protected _errors: DYOToolsError[];
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Component options configuration.
|
|
57
|
-
* Defined by generic type IComponentOptions.
|
|
58
|
-
*
|
|
59
|
-
* For all component, global option can be :
|
|
60
|
-
* * **errors** : Default *false*. If *true*, no exception is thrown when an error occurred, a new DTError instance is
|
|
61
|
-
* added to the _errors property array instead. If *false*, throw the exception with a DTError instance.
|
|
62
|
-
*/
|
|
63
|
-
protected _options: IComponentOptions;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Set automatic unique _id and _key.
|
|
67
|
-
*
|
|
68
|
-
* @param key Optional Key to set. If not provided, set the _key with the _id value.
|
|
69
|
-
* @param options Specific options configuration for the instance. Default empty object.
|
|
70
|
-
*/
|
|
71
|
-
constructor(key?: string, options: Partial<IComponentOptions> = {}) {
|
|
72
|
-
this._id = uuid.v4();
|
|
73
|
-
this._key = key || this._id;
|
|
74
|
-
this._errors = [];
|
|
75
|
-
|
|
76
|
-
const defaultOptions: DTComponentOptions = {
|
|
77
|
-
errors: false,
|
|
78
|
-
};
|
|
79
|
-
this._options = {
|
|
80
|
-
...defaultOptions,
|
|
81
|
-
...options,
|
|
82
|
-
} as IComponentOptions;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Getter for _id property.
|
|
87
|
-
*/
|
|
88
|
-
getId(): string {
|
|
89
|
-
return this._id;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Getter for _key property.
|
|
94
|
-
*/
|
|
95
|
-
getKey(): string {
|
|
96
|
-
return this._key;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Getter for _context property.
|
|
101
|
-
*
|
|
102
|
-
* @param contextType If provided, the getter parse all component level hierarchy to find the corresponding component
|
|
103
|
-
* with **contextType** as _componentType value, and returns it. Return undefined if not found.
|
|
104
|
-
*
|
|
105
|
-
* @returns Direct parent Component or higher level Component if filtered with **contextType**.
|
|
106
|
-
* Returns undefined if context doesn't exist.
|
|
107
|
-
*/
|
|
108
|
-
getContext<IContext extends DYOToolsComponent = DYOToolsComponent>(contextType?: string): IContext | undefined {
|
|
109
|
-
if (this._context) {
|
|
110
|
-
if (!contextType || this._context.getComponentType() === contextType) {
|
|
111
|
-
return this._context as IContext;
|
|
112
|
-
}
|
|
113
|
-
return this._context.getContext(contextType);
|
|
114
|
-
}
|
|
115
|
-
return undefined;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Setter for _context property.
|
|
120
|
-
*/
|
|
121
|
-
setContext<IContext extends DYOToolsComponent = DYOToolsComponent>(value: IContext): void {
|
|
122
|
-
this._context = value;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Remove the current context of component.
|
|
127
|
-
*/
|
|
128
|
-
removeContext(): void {
|
|
129
|
-
this._context = undefined;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Getter for _componentType property.
|
|
134
|
-
*/
|
|
135
|
-
getComponentType(): string {
|
|
136
|
-
return this._componentType;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Getter for _domain property.
|
|
141
|
-
*/
|
|
142
|
-
getDomain(): string {
|
|
143
|
-
return this._domain;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Getter for _subKind property.
|
|
148
|
-
*/
|
|
149
|
-
getSubKind(): string {
|
|
150
|
-
return this._subKind;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Getter for _errors property.
|
|
155
|
-
*
|
|
156
|
-
* Note : Errors are always provided by the higher order component, defined into the _context property.
|
|
157
|
-
*/
|
|
158
|
-
getErrors(): DYOToolsError[] {
|
|
159
|
-
if (this.getContext()) {
|
|
160
|
-
return this.getContext().getErrors();
|
|
161
|
-
}
|
|
162
|
-
return this._errors;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Return the last error (most recent) of the current component. Undefined if _errors is empty.
|
|
167
|
-
*
|
|
168
|
-
* Note : Errors are always provided by the higher order component, defined into the _context property.
|
|
169
|
-
*/
|
|
170
|
-
getLastError(): DYOToolsError | undefined {
|
|
171
|
-
if (this.getContext()) {
|
|
172
|
-
return this.getContext().getLastError();
|
|
173
|
-
}
|
|
174
|
-
return this._errors.length > 0 ? this._errors[this._errors.length - 1] : undefined;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Generic method to trigger an error, depending on the **errors** option :
|
|
179
|
-
* * if the option is set to *false*, throw the DTError instance passed as an argument.
|
|
180
|
-
* * if the option is set to *true*, add DTError instance passed as an argument in the _errors array.
|
|
181
|
-
*
|
|
182
|
-
* Note : Errors are always stored into the higher order component, defined into the _context property.
|
|
183
|
-
*
|
|
184
|
-
* @param error DYOToolsError instance to trigger
|
|
185
|
-
*/
|
|
186
|
-
triggerError(error: DYOToolsError): void {
|
|
187
|
-
const { errors = false } = this._options;
|
|
188
|
-
if (this.getContext()) {
|
|
189
|
-
this.getContext().triggerError(error);
|
|
190
|
-
} else if (!errors) {
|
|
191
|
-
throw error;
|
|
192
|
-
} else {
|
|
193
|
-
this._errors.push(error);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Clear all current errors.
|
|
199
|
-
*
|
|
200
|
-
* Note : Errors are always stored into the higher order component, defined into the _context property.
|
|
201
|
-
*/
|
|
202
|
-
clearErrors(): void {
|
|
203
|
-
if (this.getContext()) {
|
|
204
|
-
this.getContext().clearErrors();
|
|
205
|
-
}
|
|
206
|
-
this._errors = [];
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Getter for _options property.
|
|
211
|
-
*/
|
|
212
|
-
getOptions(): IComponentOptions {
|
|
213
|
-
return this._options;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Abstract method for JSON Object representation of the component and returning it.
|
|
218
|
-
*/
|
|
219
|
-
abstract toObject(): unknown;
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Abstract method for String representation of the component and returning it.
|
|
223
|
-
*/
|
|
224
|
-
abstract toString(): string;
|
|
225
|
-
}
|