Skip to content

Commit

Permalink
add basic filter node
Browse files Browse the repository at this point in the history
  • Loading branch information
shuart committed Oct 25, 2023
1 parent 1c6c18e commit 144437f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/js/modules/common_evaluators/evaluator_nodes_templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import showPopupInstancePreview from "../popup_instance_preview/popup_instance_p
import createAttributeManagement from "../common_project_management/attributes_management.js";
import state_manager from "../common_state/state_manager.js";

import { filter } from "./templates/node_filter.js";
import { settingsNodeColors as nodeColors} from "./templates/settings_node_colors.js";


var getProp = function(props,propName, data){
var valuePassed = props[propName].get()
Expand All @@ -19,13 +22,9 @@ var getProp = function(props,propName, data){

var evaluatorTemplates = {}

var nodeColors = {
input:0x83314a,
inputData:0x00d6a3,
inputObject:0xed9e5c,
output:0x1d1d1d,
attribute:0xa35abd,
}


evaluatorTemplates.filter = filter

// baseTemplates.input_number = {
// templateName : "input_number",
Expand Down
54 changes: 54 additions & 0 deletions src/js/modules/common_evaluators/templates/node_filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { settingsNodeColors as nodeColors } from "./settings_node_colors.js"

export var filter = {
templateName : "filter",
name : "Filter",
style:{
headerColor:nodeColors.inputObject,
},
category:"data",

props :[
{id:"output", expect:"text", label:"output", type:"hidden", editable:false, socket:"output", value:"output"},
{id:"paramName", expect:"text", label:"Param Name", type:"text", editable:true, socket:"input", value:"...."},
{id:"paramIndex", expect:"text", label:"Param Name", type:"text", editable:true, socket:"input", value:"...."},
{id:"a", expect:"data", label:"Data", type:"text", editable:true, socket:"input", value:"0"},
],
methods:{
},
event:{
onEvaluate:(props, globals) =>{
// var instanceRepo = createInstancesManagement()
// var currentInstance = instanceRepo.getById(globals.originInstance)
// props.output.set(currentInstance)
// var paramName = props.paramName.get()
// if (paramName!="....") {
// props.output.set("false")
// let url = window.location.hash.slice(1) || '/';
// if (url.split("?")[1]) {//if there are already search params
// var splitedParams = url.split("?")[1].split("&")
// url = url.split("?")[0]
// for (let i = 0; i < splitedParams.length; i++) {
// const sparam = splitedParams[i].split("=");
// if (paramName == sparam[0]) {
// props.output.set(sparam[1] || "flase")
// }
// }
// }
// }
if (Array.isArray(props.a.get()) && props.a.get()[0] && props.a.get()[0].attributes.type) {
var oldDataSet = props.a.get()
var newDataSet = []
for (let i = 0; i < oldDataSet.length; i++) {
const element = oldDataSet[i];
if (i<2) {
newDataSet.push(element)
}
}
props.output.set(newDataSet)
}
},
// onInit:(props) =>{
// },
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export var settingsNodeColors = {
input:0x83314a,
inputData:0x00d6a3,
inputObject:0xed9e5c,
output:0x1d1d1d,
attribute:0xa35abd,
}

0 comments on commit 144437f

Please sign in to comment.