@barchart/portfolio-api-common 1.2.79 → 1.2.80

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.
@@ -371,6 +371,12 @@ module.exports = (() => {
371
371
  return array.unique(symbols);
372
372
  }
373
373
 
374
+ /**
375
+ * Causes a position to be flagged as locked (for editing).
376
+ *
377
+ * @public
378
+ * @param {Object} position
379
+ */
374
380
  setPositionLock(position) {
375
381
  if (position) {
376
382
  assert.argumentIsRequired(position, 'position', Object);
@@ -379,9 +385,7 @@ module.exports = (() => {
379
385
  const item = this._items.find((i) => i.position.position === position.position);
380
386
 
381
387
  if (item) {
382
- const locked = is.object(position.system) && is.boolean(position.system.locked) && position.system.locked;
383
-
384
- item.setPositionLock(locked);
388
+ item.setPositionLock(PositionItem.getIsLocked(position));
385
389
  }
386
390
  }
387
391
  }
@@ -70,7 +70,7 @@ module.exports = (() => {
70
70
 
71
71
  this._data.newsExists = false;
72
72
  this._data.fundamental = { };
73
- this._data.locked = is.object(position.system) && is.boolean(position.system.locked) && position.system.locked;
73
+ this._data.locked = PositionItem.getIsLocked(position);
74
74
 
75
75
  calculateStaticData(this);
76
76
  calculatePriceData(this, null);
@@ -337,6 +337,19 @@ module.exports = (() => {
337
337
  this._positionItemDisposeEvent.clear();
338
338
  }
339
339
 
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
+
340
353
  toString() {
341
354
  return '[PositionItem]';
342
355
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.79",
3
+ "version": "1.2.80",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -1750,6 +1750,12 @@ module.exports = (() => {
1750
1750
  return array.unique(symbols);
1751
1751
  }
1752
1752
 
1753
+ /**
1754
+ * Causes a position to be flagged as locked (for editing).
1755
+ *
1756
+ * @public
1757
+ * @param {Object} position
1758
+ */
1753
1759
  setPositionLock(position) {
1754
1760
  if (position) {
1755
1761
  assert.argumentIsRequired(position, 'position', Object);
@@ -1758,9 +1764,7 @@ module.exports = (() => {
1758
1764
  const item = this._items.find((i) => i.position.position === position.position);
1759
1765
 
1760
1766
  if (item) {
1761
- const locked = is.object(position.system) && is.boolean(position.system.locked) && position.system.locked;
1762
-
1763
- item.setPositionLock(locked);
1767
+ item.setPositionLock(PositionItem.getIsLocked(position));
1764
1768
  }
1765
1769
  }
1766
1770
  }
@@ -3278,7 +3282,7 @@ module.exports = (() => {
3278
3282
 
3279
3283
  this._data.newsExists = false;
3280
3284
  this._data.fundamental = { };
3281
- this._data.locked = is.object(position.system) && is.boolean(position.system.locked) && position.system.locked;
3285
+ this._data.locked = PositionItem.getIsLocked(position);
3282
3286
 
3283
3287
  calculateStaticData(this);
3284
3288
  calculatePriceData(this, null);
@@ -3545,6 +3549,19 @@ module.exports = (() => {
3545
3549
  this._positionItemDisposeEvent.clear();
3546
3550
  }
3547
3551
 
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
+
3548
3565
  toString() {
3549
3566
  return '[PositionItem]';
3550
3567
  }