@barchart/portfolio-api-common 1.0.131 → 1.0.132

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.
@@ -108,6 +108,20 @@ module.exports = (() => {
108
108
  return map;
109
109
  }, { });
110
110
 
111
+ this._symbolsDisplay = this._items.reduce((map, item) => {
112
+ const symbol = extractSymbolForDisplay(item.position);
113
+
114
+ if (symbol) {
115
+ if (!map.hasOwnProperty(symbol)) {
116
+ map[symbol] = [ ];
117
+ }
118
+
119
+ map[symbol].push(item);
120
+ }
121
+
122
+ return map;
123
+ }, { });
124
+
111
125
  this._currencies = this._items.reduce((map, item) => {
112
126
  const position = item.position;
113
127
 
@@ -327,14 +341,24 @@ module.exports = (() => {
327
341
  *
328
342
  * @public
329
343
  * @param {String} symbol
344
+ * @param {Boolean} display
330
345
  * @param {Boolean} exists
331
346
  */
332
- setNewsArticleExists(symbol, exists) {
347
+ setNewsArticleExists(symbol, display, exists) {
333
348
  assert.argumentIsRequired(symbol, 'symbol', String);
349
+ assert.argumentIsRequired(display, 'display', Boolean);
334
350
  assert.argumentIsRequired(exists, 'exists', Boolean);
335
351
 
336
- if (this._symbols.hasOwnProperty(symbol)) {
337
- this._symbols[symbol].forEach(item => item.setNewsArticleExists(exists));
352
+ let map;
353
+
354
+ if (display) {
355
+ map = this._symbols;
356
+ } else {
357
+ map = this._symbolsDisplay;
358
+ }
359
+
360
+ if (map.hasOwnProperty(symbol)) {
361
+ map[symbol].forEach(item => item.setNewsArticleExists(exists));
338
362
  }
339
363
  }
340
364
 
@@ -40,6 +40,7 @@ module.exports = (() => {
40
40
  this._suspended = false;
41
41
 
42
42
  this._marketPercentChangeEvent = new Event(this);
43
+ this._excludedChangeEvent = new Event(this);
43
44
 
44
45
  this._dataFormat = { };
45
46
  this._dataActual = { };
@@ -246,11 +247,7 @@ module.exports = (() => {
246
247
  assert.argumentIsRequired(value, 'value', Boolean);
247
248
 
248
249
  if (this._excluded !== value) {
249
- this._container.startTransaction(() => {
250
- this._items.forEach((item) => {
251
- item.setExcluded(value);
252
- });
253
- });
250
+ this._excludedChangeEvent(this._excluded = value);
254
251
  }
255
252
  }
256
253
 
@@ -62,13 +62,10 @@ module.exports = (() => {
62
62
 
63
63
  this._data.newsExists = false;
64
64
 
65
- this._excluded = false;
66
-
67
65
  calculateStaticData(this);
68
66
  calculatePriceData(this, null);
69
67
 
70
68
  this._quoteChangedEvent = new Event(this);
71
- this._excludedChangeEvent = new Event(this);
72
69
  this._newsExistsChangedEvent = new Event(this);
73
70
  }
74
71
 
@@ -142,10 +139,6 @@ module.exports = (() => {
142
139
  return this._currentQuote;
143
140
  }
144
141
 
145
- get excluded() {
146
- return this._excluded;
147
- }
148
-
149
142
  /**
150
143
  * Sets the current quote -- causing position-level data (e.g. market value) to
151
144
  * be recalculated.
@@ -168,14 +161,6 @@ module.exports = (() => {
168
161
  }
169
162
  }
170
163
 
171
- setExcluded(value) {
172
- assert.argumentIsRequired(value, 'value', Boolean);
173
-
174
- if (this._excluded !== value) {
175
- this._excludedChangeEvent.fire(this._excluded = value);
176
- }
177
- }
178
-
179
164
  /**
180
165
  * Sets a flag which indicates if news article(s) exist for the encapsulated position's
181
166
  * symbol.
@@ -202,10 +187,6 @@ module.exports = (() => {
202
187
  this._quoteChangedEvent.register(handler);
203
188
  }
204
189
 
205
- registerExcludedChangeHandler(handler) {
206
- this._excludedChangeEvent.register(handler);
207
- }
208
-
209
190
  /**
210
191
  * Registers an observer changes to the status of news existence.
211
192
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.131",
3
+ "version": "1.0.132",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -824,6 +824,20 @@ module.exports = (() => {
824
824
  return map;
825
825
  }, { });
826
826
 
827
+ this._symbolsDisplay = this._items.reduce((map, item) => {
828
+ const symbol = extractSymbolForDisplay(item.position);
829
+
830
+ if (symbol) {
831
+ if (!map.hasOwnProperty(symbol)) {
832
+ map[symbol] = [ ];
833
+ }
834
+
835
+ map[symbol].push(item);
836
+ }
837
+
838
+ return map;
839
+ }, { });
840
+
827
841
  this._currencies = this._items.reduce((map, item) => {
828
842
  const position = item.position;
829
843
 
@@ -1043,14 +1057,24 @@ module.exports = (() => {
1043
1057
  *
1044
1058
  * @public
1045
1059
  * @param {String} symbol
1060
+ * @param {Boolean} display
1046
1061
  * @param {Boolean} exists
1047
1062
  */
1048
- setNewsArticleExists(symbol, exists) {
1063
+ setNewsArticleExists(symbol, display, exists) {
1049
1064
  assert.argumentIsRequired(symbol, 'symbol', String);
1065
+ assert.argumentIsRequired(display, 'display', Boolean);
1050
1066
  assert.argumentIsRequired(exists, 'exists', Boolean);
1051
1067
 
1052
- if (this._symbols.hasOwnProperty(symbol)) {
1053
- this._symbols[symbol].forEach(item => item.setNewsArticleExists(exists));
1068
+ let map;
1069
+
1070
+ if (display) {
1071
+ map = this._symbols;
1072
+ } else {
1073
+ map = this._symbolsDisplay;
1074
+ }
1075
+
1076
+ if (map.hasOwnProperty(symbol)) {
1077
+ map[symbol].forEach(item => item.setNewsArticleExists(exists));
1054
1078
  }
1055
1079
  }
1056
1080
 
@@ -1170,6 +1194,7 @@ module.exports = (() => {
1170
1194
  this._suspended = false;
1171
1195
 
1172
1196
  this._marketPercentChangeEvent = new Event(this);
1197
+ this._excludedChangeEvent = new Event(this);
1173
1198
 
1174
1199
  this._dataFormat = { };
1175
1200
  this._dataActual = { };
@@ -1376,11 +1401,7 @@ module.exports = (() => {
1376
1401
  assert.argumentIsRequired(value, 'value', Boolean);
1377
1402
 
1378
1403
  if (this._excluded !== value) {
1379
- this._container.startTransaction(() => {
1380
- this._items.forEach((item) => {
1381
- item.setExcluded(value);
1382
- });
1383
- });
1404
+ this._excludedChangeEvent(this._excluded = value);
1384
1405
  }
1385
1406
  }
1386
1407
 
@@ -1746,13 +1767,10 @@ module.exports = (() => {
1746
1767
 
1747
1768
  this._data.newsExists = false;
1748
1769
 
1749
- this._excluded = false;
1750
-
1751
1770
  calculateStaticData(this);
1752
1771
  calculatePriceData(this, null);
1753
1772
 
1754
1773
  this._quoteChangedEvent = new Event(this);
1755
- this._excludedChangeEvent = new Event(this);
1756
1774
  this._newsExistsChangedEvent = new Event(this);
1757
1775
  }
1758
1776
 
@@ -1826,10 +1844,6 @@ module.exports = (() => {
1826
1844
  return this._currentQuote;
1827
1845
  }
1828
1846
 
1829
- get excluded() {
1830
- return this._excluded;
1831
- }
1832
-
1833
1847
  /**
1834
1848
  * Sets the current quote -- causing position-level data (e.g. market value) to
1835
1849
  * be recalculated.
@@ -1852,14 +1866,6 @@ module.exports = (() => {
1852
1866
  }
1853
1867
  }
1854
1868
 
1855
- setExcluded(value) {
1856
- assert.argumentIsRequired(value, 'value', Boolean);
1857
-
1858
- if (this._excluded !== value) {
1859
- this._excludedChangeEvent.fire(this._excluded = value);
1860
- }
1861
- }
1862
-
1863
1869
  /**
1864
1870
  * Sets a flag which indicates if news article(s) exist for the encapsulated position's
1865
1871
  * symbol.
@@ -1886,10 +1892,6 @@ module.exports = (() => {
1886
1892
  this._quoteChangedEvent.register(handler);
1887
1893
  }
1888
1894
 
1889
- registerExcludedChangeHandler(handler) {
1890
- this._excludedChangeEvent.register(handler);
1891
- }
1892
-
1893
1895
  /**
1894
1896
  * Registers an observer changes to the status of news existence.
1895
1897
  *