@barchart/portfolio-api-common 1.2.80 → 1.2.84

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.
@@ -276,7 +276,7 @@ module.exports = (() => {
276
276
 
277
277
  const existingBarchartSymbols = this.getPositionSymbols(false);
278
278
 
279
- removePositionItem.call(this, this._items.find((item) => item.position.position === position.position));
279
+ removePositionItem.call(this, this._items.find(item => item.position.position === position.position));
280
280
 
281
281
  summaries.forEach((summary) => {
282
282
  addSummaryCurrent(this._summariesCurrent, summary, this._currentSummaryFrame, this._currentSummaryRange);
@@ -336,7 +336,7 @@ module.exports = (() => {
336
336
  assert.argumentIsRequired(position, 'position', Object);
337
337
  assert.argumentIsRequired(position.position, 'position.position', String);
338
338
 
339
- removePositionItem.call(this, this._items.find((item) => item.position.position === position.position));
339
+ removePositionItem.call(this, this._items.find(item => item.position.position === position.position));
340
340
 
341
341
  recalculatePercentages.call(this);
342
342
  }
@@ -382,14 +382,30 @@ module.exports = (() => {
382
382
  assert.argumentIsRequired(position, 'position', Object);
383
383
  assert.argumentIsRequired(position.position, 'position.position', String);
384
384
 
385
- const item = this._items.find((i) => i.position.position === position.position);
385
+ const item = this._items.find(i => i.position.position === position.position);
386
386
 
387
387
  if (item) {
388
- item.setPositionLock(PositionItem.getIsLocked(position));
388
+ item.setPositionLock(position);
389
389
  }
390
390
  }
391
391
  }
392
392
 
393
+ /**
394
+ * Returns a position's lock status.
395
+ *
396
+ * @public
397
+ * @param {Object} position
398
+ * @return {Boolean}
399
+ */
400
+ getPositionLock(position) {
401
+ assert.argumentIsRequired(position, 'position', Object);
402
+ assert.argumentIsRequired(position.position, 'position.position', String);
403
+
404
+ const item = this._items.find(i => i.position.position === position.position);
405
+
406
+ return is.object(item) && item.locked;
407
+ }
408
+
393
409
  /**
394
410
  * Performs a batch update of both position quotes and forex quotes,
395
411
  * triggering updates to position(s) and data aggregation(s).
@@ -70,7 +70,7 @@ module.exports = (() => {
70
70
 
71
71
  this._data.newsExists = false;
72
72
  this._data.fundamental = { };
73
- this._data.locked = PositionItem.getIsLocked(position);
73
+ this._data.locked = getIsLocked(position);
74
74
 
75
75
  calculateStaticData(this);
76
76
  calculatePriceData(this, null);
@@ -242,18 +242,20 @@ module.exports = (() => {
242
242
  }
243
243
 
244
244
  /**
245
- * Sets position lock status.
245
+ * Sets a position's lock status.
246
246
  *
247
247
  * @public
248
- * @param {Boolean} value
248
+ * @param {Object} position
249
249
  */
250
- setPositionLock(value) {
251
- assert.argumentIsRequired(value, 'value', Boolean);
250
+ setPositionLock(position) {
251
+ assert.argumentIsRequired(position, 'position');
252
252
 
253
253
  if (this.getIsDisposed()) {
254
254
  return;
255
255
  }
256
256
 
257
+ const value = getIsLocked(position);
258
+
257
259
  if (this._data.locked !== value) {
258
260
  this._lockChangedEvent.fire(this._data.locked = value);
259
261
  }
@@ -337,19 +339,6 @@ module.exports = (() => {
337
339
  this._positionItemDisposeEvent.clear();
338
340
  }
339
341
 
340
- /**
341
- * Given a position object, returns its lock (for editing) status.
342
- *
343
- * @public
344
- * @param {Object{}} position
345
- * @returns {Boolean}
346
- */
347
- static getIsLocked(position) {
348
- assert.argumentIsRequired(position, 'position');
349
-
350
- return is.object(position.system) && is.boolean(position.system.locked) && position.system.locked
351
- }
352
-
353
342
  toString() {
354
343
  return '[PositionItem]';
355
344
  }
@@ -538,5 +527,11 @@ module.exports = (() => {
538
527
  return summary;
539
528
  }
540
529
 
530
+ function getIsLocked(position) {
531
+ assert.argumentIsRequired(position, 'position');
532
+
533
+ return is.object(position.system) && is.boolean(position.system.locked) && position.system.locked;
534
+ }
535
+
541
536
  return PositionItem;
542
537
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.80",
3
+ "version": "1.2.84",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -1655,7 +1655,7 @@ module.exports = (() => {
1655
1655
 
1656
1656
  const existingBarchartSymbols = this.getPositionSymbols(false);
1657
1657
 
1658
- removePositionItem.call(this, this._items.find((item) => item.position.position === position.position));
1658
+ removePositionItem.call(this, this._items.find(item => item.position.position === position.position));
1659
1659
 
1660
1660
  summaries.forEach((summary) => {
1661
1661
  addSummaryCurrent(this._summariesCurrent, summary, this._currentSummaryFrame, this._currentSummaryRange);
@@ -1715,7 +1715,7 @@ module.exports = (() => {
1715
1715
  assert.argumentIsRequired(position, 'position', Object);
1716
1716
  assert.argumentIsRequired(position.position, 'position.position', String);
1717
1717
 
1718
- removePositionItem.call(this, this._items.find((item) => item.position.position === position.position));
1718
+ removePositionItem.call(this, this._items.find(item => item.position.position === position.position));
1719
1719
 
1720
1720
  recalculatePercentages.call(this);
1721
1721
  }
@@ -1761,14 +1761,30 @@ module.exports = (() => {
1761
1761
  assert.argumentIsRequired(position, 'position', Object);
1762
1762
  assert.argumentIsRequired(position.position, 'position.position', String);
1763
1763
 
1764
- const item = this._items.find((i) => i.position.position === position.position);
1764
+ const item = this._items.find(i => i.position.position === position.position);
1765
1765
 
1766
1766
  if (item) {
1767
- item.setPositionLock(PositionItem.getIsLocked(position));
1767
+ item.setPositionLock(position);
1768
1768
  }
1769
1769
  }
1770
1770
  }
1771
1771
 
1772
+ /**
1773
+ * Returns a position's lock status.
1774
+ *
1775
+ * @public
1776
+ * @param {Object} position
1777
+ * @return {Boolean}
1778
+ */
1779
+ getPositionLock(position) {
1780
+ assert.argumentIsRequired(position, 'position', Object);
1781
+ assert.argumentIsRequired(position.position, 'position.position', String);
1782
+
1783
+ const item = this._items.find(i => i.position.position === position.position);
1784
+
1785
+ return is.object(item) && item.locked;
1786
+ }
1787
+
1772
1788
  /**
1773
1789
  * Performs a batch update of both position quotes and forex quotes,
1774
1790
  * triggering updates to position(s) and data aggregation(s).
@@ -3282,7 +3298,7 @@ module.exports = (() => {
3282
3298
 
3283
3299
  this._data.newsExists = false;
3284
3300
  this._data.fundamental = { };
3285
- this._data.locked = PositionItem.getIsLocked(position);
3301
+ this._data.locked = getIsLocked(position);
3286
3302
 
3287
3303
  calculateStaticData(this);
3288
3304
  calculatePriceData(this, null);
@@ -3454,18 +3470,20 @@ module.exports = (() => {
3454
3470
  }
3455
3471
 
3456
3472
  /**
3457
- * Sets position lock status.
3473
+ * Sets a position's lock status.
3458
3474
  *
3459
3475
  * @public
3460
- * @param {Boolean} value
3476
+ * @param {Object} position
3461
3477
  */
3462
- setPositionLock(value) {
3463
- assert.argumentIsRequired(value, 'value', Boolean);
3478
+ setPositionLock(position) {
3479
+ assert.argumentIsRequired(position, 'position');
3464
3480
 
3465
3481
  if (this.getIsDisposed()) {
3466
3482
  return;
3467
3483
  }
3468
3484
 
3485
+ const value = getIsLocked(position);
3486
+
3469
3487
  if (this._data.locked !== value) {
3470
3488
  this._lockChangedEvent.fire(this._data.locked = value);
3471
3489
  }
@@ -3549,19 +3567,6 @@ module.exports = (() => {
3549
3567
  this._positionItemDisposeEvent.clear();
3550
3568
  }
3551
3569
 
3552
- /**
3553
- * Given a position object, returns its lock (for editing) status.
3554
- *
3555
- * @public
3556
- * @param {Object{}} position
3557
- * @returns {Boolean}
3558
- */
3559
- static getIsLocked(position) {
3560
- assert.argumentIsRequired(position, 'position');
3561
-
3562
- return is.object(position.system) && is.boolean(position.system.locked) && position.system.locked
3563
- }
3564
-
3565
3570
  toString() {
3566
3571
  return '[PositionItem]';
3567
3572
  }
@@ -3750,6 +3755,12 @@ module.exports = (() => {
3750
3755
  return summary;
3751
3756
  }
3752
3757
 
3758
+ function getIsLocked(position) {
3759
+ assert.argumentIsRequired(position, 'position');
3760
+
3761
+ return is.object(position.system) && is.boolean(position.system.locked) && position.system.locked;
3762
+ }
3763
+
3753
3764
  return PositionItem;
3754
3765
  })();
3755
3766