mirror of
https://github.com/fluxscape/fluxscape.git
synced 2026-01-11 06:42:56 +01:00
feat(viewer-react): Array, add "First Item Id" output (#71)
Same behaviour as Query Record's "First Record Id"
This commit is contained in:
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
const { Node } = require('@noodl/runtime');
|
const { Node } = require('@noodl/runtime');
|
||||||
|
|
||||||
var Model = require('@noodl/runtime/src/model'),
|
const Collection = require('@noodl/runtime/src/collection');
|
||||||
Collection = require('@noodl/runtime/src/collection');
|
|
||||||
|
|
||||||
var CollectionNode = {
|
var CollectionNode = {
|
||||||
name: 'Collection2',
|
name: 'Collection2',
|
||||||
@@ -27,6 +26,7 @@ var CollectionNode = {
|
|||||||
|
|
||||||
_this.scheduleAfterInputsHaveUpdated(function () {
|
_this.scheduleAfterInputsHaveUpdated(function () {
|
||||||
_this.sendSignalOnOutput('changed');
|
_this.sendSignalOnOutput('changed');
|
||||||
|
_this.flagOutputDirty('firstItemId');
|
||||||
_this.flagOutputDirty('count');
|
_this.flagOutputDirty('count');
|
||||||
collectionChangedScheduled = false;
|
collectionChangedScheduled = false;
|
||||||
});
|
});
|
||||||
@@ -117,6 +117,17 @@ var CollectionNode = {
|
|||||||
return this._internal.collection;
|
return this._internal.collection;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
firstItemId: {
|
||||||
|
type: 'string',
|
||||||
|
displayName: 'First Item Id',
|
||||||
|
group: 'General',
|
||||||
|
getter: function () {
|
||||||
|
if (this._internal.collection) {
|
||||||
|
var firstItem = this._internal.collection.get(0);
|
||||||
|
if (firstItem !== undefined) return firstItem.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
count: {
|
count: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
displayName: 'Count',
|
displayName: 'Count',
|
||||||
@@ -150,6 +161,7 @@ var CollectionNode = {
|
|||||||
collection.on('change', this._internal.collectionChangedCallback);
|
collection.on('change', this._internal.collectionChangedCallback);
|
||||||
|
|
||||||
this.flagOutputDirty('items');
|
this.flagOutputDirty('items');
|
||||||
|
this.flagOutputDirty('firstItemId');
|
||||||
this.flagOutputDirty('count');
|
this.flagOutputDirty('count');
|
||||||
},
|
},
|
||||||
setSourceCollection: function (collection) {
|
setSourceCollection: function (collection) {
|
||||||
|
|||||||
Reference in New Issue
Block a user