mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	change property name to leave space if we want to also do main payload property
This commit is contained in:
		@@ -66,8 +66,8 @@
 | 
				
			|||||||
            <option value="all" data-i18n="trigger.alltopics"></option>
 | 
					            <option value="all" data-i18n="trigger.alltopics"></option>
 | 
				
			||||||
            <option value="topic" data-i18n="trigger.bytopics"></option>
 | 
					            <option value="topic" data-i18n="trigger.bytopics"></option>
 | 
				
			||||||
        </select>
 | 
					        </select>
 | 
				
			||||||
        <span class="form-row" id="node-trigger-property">
 | 
					        <span class="form-row" id="node-stream-topic">
 | 
				
			||||||
            <input type="text" id="node-input-property" style="width:46%;"/>
 | 
					            <input type="text" id="node-input-topic" style="width:46%;"/>
 | 
				
			||||||
        </span>
 | 
					        </span>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div class="form-row">
 | 
					    <div class="form-row">
 | 
				
			||||||
@@ -93,7 +93,7 @@
 | 
				
			|||||||
            reset: {value:""},
 | 
					            reset: {value:""},
 | 
				
			||||||
            bytopic: {value:"all"},
 | 
					            bytopic: {value:"all"},
 | 
				
			||||||
            outputs: {value:1},
 | 
					            outputs: {value:1},
 | 
				
			||||||
            property: {value:"topic",required:true}
 | 
					            topic: {value:"topic",required:true}
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        inputs:1,
 | 
					        inputs:1,
 | 
				
			||||||
        outputs:1,
 | 
					        outputs:1,
 | 
				
			||||||
@@ -121,9 +121,9 @@
 | 
				
			|||||||
            $("#node-input-bytopic").on("change", function() {
 | 
					            $("#node-input-bytopic").on("change", function() {
 | 
				
			||||||
                console.log("BYT",$("#node-input-bytopic").val());
 | 
					                console.log("BYT",$("#node-input-bytopic").val());
 | 
				
			||||||
                if ($("#node-input-bytopic").val() === "all") {
 | 
					                if ($("#node-input-bytopic").val() === "all") {
 | 
				
			||||||
                    $("#node-trigger-property").hide();
 | 
					                    $("#node-stream-topic").hide();
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    $("#node-trigger-property").show();
 | 
					                    $("#node-stream-topic").show();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,7 +25,7 @@ module.exports = function(RED) {
 | 
				
			|||||||
        this.op1type = n.op1type || "str";
 | 
					        this.op1type = n.op1type || "str";
 | 
				
			||||||
        this.op2type = n.op2type || "str";
 | 
					        this.op2type = n.op2type || "str";
 | 
				
			||||||
        this.second = n.second || false;
 | 
					        this.second = n.second || false;
 | 
				
			||||||
        this.property = n.property || "topic";
 | 
					        this.topic = n.topic || "topic";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (this.op1type === 'val') {
 | 
					        if (this.op1type === 'val') {
 | 
				
			||||||
            if (this.op1 === 'true' || this.op1 === 'false') {
 | 
					            if (this.op1 === 'true' || this.op1 === 'false') {
 | 
				
			||||||
@@ -113,7 +113,7 @@ module.exports = function(RED) {
 | 
				
			|||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var processMessage = function(msg) {
 | 
					        var processMessage = function(msg) {
 | 
				
			||||||
            var topic = RED.util.getMessageProperty(msg,node.property) || "_none";
 | 
					            var topic = RED.util.getMessageProperty(msg,node.topic) || "_none";
 | 
				
			||||||
            var promise;
 | 
					            var promise;
 | 
				
			||||||
            if (node.bytopic === "all") { topic = "_none"; }
 | 
					            if (node.bytopic === "all") { topic = "_none"; }
 | 
				
			||||||
            node.topics[topic] = node.topics[topic] || {};
 | 
					            node.topics[topic] = node.topics[topic] || {};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -379,7 +379,7 @@ describe('trigger node', function() {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it('should handle multiple other properties individually if asked to do so', function(done) {
 | 
					    it('should handle multiple other properties individually if asked to do so', function(done) {
 | 
				
			||||||
        var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", bytopic:"topic", property:"foo", op1:"1", op2:"0", op1type:"num", op2type:"num", duration:"30", wires:[["n2"]] },
 | 
					        var flow = [{"id":"n1", "type":"trigger", "name":"triggerNode", bytopic:"topic", topic:"foo", op1:"1", op2:"0", op1type:"num", op2type:"num", duration:"30", wires:[["n2"]] },
 | 
				
			||||||
            {id:"n2", type:"helper"} ];
 | 
					            {id:"n2", type:"helper"} ];
 | 
				
			||||||
        helper.load(triggerNode, flow, function() {
 | 
					        helper.load(triggerNode, flow, function() {
 | 
				
			||||||
            var n1 = helper.getNode("n1");
 | 
					            var n1 = helper.getNode("n1");
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user