Includes
This commit is contained in:
1 parent
f8e81c5e3a
commit
de27a44a4c
5 files changed
+165
-1
No files matched your search
@@ -0,0 +1,84 @@
|
||||
function newIncludesFunctions() {
|
||||
thisObject = {
|
||||
includeMissingDataMines: includeMissingDataMines,
|
||||
includeMissingTradingMines: includeMissingTradingMines,
|
||||
includeMissingTradingSystems: includeMissingTradingSystems,
|
||||
includeMissingTradingEngines: includeMissingTradingEngines,
|
||||
includeMissingSuperScripts: includeMissingSuperScripts,
|
||||
includeMissingTutorials: includeMissingTutorials
|
||||
}
|
||||
return thisObject
|
||||
|
||||
function getIncludedFileNames(includeType, callBack) {
|
||||
callServer(undefined, 'IncludedFileNames/' + includeType, onResponse)
|
||||
|
||||
function onResponse(err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
console.log('Failed to Fetch Included ' + includeType + ' from the Backend')
|
||||
return
|
||||
}
|
||||
|
||||
let includedFileNames = JSON.parse(data)
|
||||
callBack(includedFileNames)
|
||||
}
|
||||
}
|
||||
|
||||
function addIncludedFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes) {
|
||||
for (let i = 0; i < fileNames.length; i++) {
|
||||
let fileName = fileNames[i]
|
||||
fileName = fileName.replace('.json', '')
|
||||
if (isMissingChildrenByName(node, fileName) === true) {
|
||||
let child = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Included File')
|
||||
child.name = fileName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function includeMissingDataMines(node, rootNodes, functionLibraryUiObjectsFromNodes) {
|
||||
getIncludedFileNames('Data-Mines', onNamesArrived)
|
||||
|
||||
function onNamesArrived(fileNames) {
|
||||
addIncludedFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
}
|
||||
|
||||
function includeMissingTradingMines(node, rootNodes, functionLibraryUiObjectsFromNodes) {
|
||||
getIncludedFileNames('Trading-Mines', onNamesArrived)
|
||||
|
||||
function onNamesArrived(fileNames) {
|
||||
addIncludedFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
}
|
||||
|
||||
function includeMissingTradingSystems(node, rootNodes, functionLibraryUiObjectsFromNodes) {
|
||||
getIncludedFileNames('Trading-Systems', onNamesArrived)
|
||||
|
||||
function onNamesArrived(fileNames) {
|
||||
addIncludedFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
}
|
||||
|
||||
function includeMissingTradingEngines(node, rootNodes, functionLibraryUiObjectsFromNodes) {
|
||||
getIncludedFileNames('Trading-Engines', onNamesArrived)
|
||||
|
||||
function onNamesArrived(fileNames) {
|
||||
addIncludedFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
}
|
||||
|
||||
function includeMissingSuperScripts(node, rootNodes, functionLibraryUiObjectsFromNodes) {
|
||||
getIncludedFileNames('Super-Scripts', onNamesArrived)
|
||||
|
||||
function onNamesArrived(fileNames) {
|
||||
addIncludedFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
}
|
||||
|
||||
function includeMissingTutorials(node, rootNodes, functionLibraryUiObjectsFromNodes) {
|
||||
getIncludedFileNames('Tutorials', onNamesArrived)
|
||||
|
||||
function onNamesArrived(fileNames) {
|
||||
addIncludedFileIfNeeded(node, fileNames, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ function newUiObjectsFromNodes() {
|
||||
|
||||
function onResponse(err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
console.log('Failed to Fetch Inclided Names from the Backend')
|
||||
console.log('Failed to Fetch Included Names from the Backend')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ function newWorkspace() {
|
||||
let functionLibraryDataStorageFunctions = newDataStorageFunctions()
|
||||
let functionLibraryChartingSpaceFunctions = newChartingSpaceFunctions()
|
||||
let functionLibraryTutorialFunctions = newTutorialFunctions()
|
||||
let functionLibraryIncludesFunctions = newIncludesFunctions()
|
||||
|
||||
thisObject.nodeChildren = newNodeChildren()
|
||||
|
||||
@@ -879,6 +880,36 @@ function newWorkspace() {
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'Include Missing Data Mines':
|
||||
{
|
||||
functionLibraryIncludesFunctions.includeMissingDataMines(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
break
|
||||
case 'Include Missing Trading Mines':
|
||||
{
|
||||
functionLibraryIncludesFunctions.includeMissingTradingMines(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
break
|
||||
case 'Include Missing Trading Systems':
|
||||
{
|
||||
functionLibraryIncludesFunctions.includeMissingTradingSystems(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
break
|
||||
case 'Include Missing Trading Engines':
|
||||
{
|
||||
functionLibraryIncludesFunctions.includeMissingTradingEngines(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
break
|
||||
case 'Include Missing Super Scripts':
|
||||
{
|
||||
functionLibraryIncludesFunctions.includeMissingSuperScripts(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
break
|
||||
case 'Include Missing Tutorials':
|
||||
{
|
||||
functionLibraryIncludesFunctions.includeMissingTutorials(payload.node, thisObject.workspaceNode.rootNodes, functionLibraryUiObjectsFromNodes)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,6 +108,14 @@ function newUiObjectTitle() {
|
||||
for (let i = 0; i < nodeDefinition.title.length; i++) {
|
||||
let titleReference = nodeDefinition.title[i]
|
||||
switch (titleReference) {
|
||||
case 'Use Parent': {
|
||||
let nodeToUse = thisObject.payload.parentNode
|
||||
if (nodeToUse !== undefined && nodeToUse.payload !== undefined) {
|
||||
thisObject.payload.title = thisObject.payload.title + separator + nodeToUse.payload.title
|
||||
thisObject.payload.node.name = thisObject.payload.node.name + separator + nodeToUse.payload.node.name
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'Use Reference Parent': {
|
||||
let nodeToUse = thisObject.payload.node.payload.referenceParent
|
||||
if (nodeToUse !== undefined && nodeToUse.payload !== undefined) {
|
||||
|
||||
@@ -184,4 +184,45 @@ function findChildIndexAtParentNode(startingNode) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isMissingChildrenByName(startingNode, nodeName) {
|
||||
/*
|
||||
This functioin scan all the children of a node and returns true or false
|
||||
depending if the node has a children with a certain name.
|
||||
*/
|
||||
if (startingNode === undefined) { return }
|
||||
|
||||
let nodeDefinition = APP_SCHEMA_MAP.get(startingNode.type)
|
||||
if (nodeDefinition === undefined) { return }
|
||||
|
||||
/* We scan through this node children */
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
for (let i = 0; i < nodeDefinition.properties.length; i++) {
|
||||
let property = nodeDefinition.properties[i]
|
||||
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
let child = startingNode[property.name]
|
||||
if (child.name === nodeName) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let startingNodePropertyArray = startingNode[property.name]
|
||||
if (startingNodePropertyArray !== undefined) {
|
||||
for (let m = 0; m < startingNodePropertyArray.length; m++) {
|
||||
let arrayItem = startingNodePropertyArray[m]
|
||||
if (arrayItem.name === nodeName) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user