Steveorevo/node-maker

Hidden fields (PR disguised as an issue)

Opened this issue · 2 comments

I wanted to create a PR for hidden fields, but PR'ing on a 200kb json is hard on whoever has to compare and merge.

One idea would be to divide this repo into individual json's for each field and subflow, and have a simple build.js script assemble the final json and place it in dist/ which would be our new goto.

In the meantime, here's an isolated subflow for hidden fields:

[
    {
        "id": "614e7fb59f287520",
        "type": "subflow",
        "name": "hidden ",
        "info": "",
        "category": "node maker",
        "in": [
            {
                "x": 50,
                "y": 30,
                "wires": [
                    {
                        "id": "d75df3167eea9a9b"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 360,
                "y": 240,
                "wires": [
                    {
                        "id": "5f7c79b770c5e406",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [
            {
                "name": "field_name",
                "type": "str",
                "value": "",
                "ui": {
                    "label": {
                        "en-US": "Field Name"
                    },
                    "type": "input",
                    "opts": {
                        "types": [
                            "str"
                        ]
                    }
                }
            },
            {
                "name": "field_default",
                "type": "str",
                "value": "",
                "ui": {
                    "label": {
                        "en-US": "Default"
                    },
                    "type": "input",
                    "opts": {
                        "types": [
                            "str"
                        ]
                    }
                }
            }
        ],
        "meta": {},
        "color": "#DDAA99",
        "icon": "node-red/hash.svg"
    },
    {
        "id": "d75df3167eea9a9b",
        "type": "function",
        "z": "614e7fb59f287520",
        "name": "function 41",
        "func": "msg.field_name = env.get('field_name');\nmsg.field_label = env.get('field_label');\nmsg.field_default = env.get('field_default');\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 190,
        "y": 80,
        "wires": [
            [
                "ce1349d2b09c5ba0"
            ]
        ]
    },
    {
        "id": "ce1349d2b09c5ba0",
        "type": "template",
        "z": "614e7fb59f287520",
        "name": "",
        "field": "payload",
        "fieldType": "msg",
        "format": "html",
        "syntax": "mustache",
        "template": "    <input type=\"hidden\" id=\"node-input-{{field_name}}\" name=\"node-input-{{field_name}}\"/>",
        "output": "str",
        "x": 190,
        "y": 140,
        "wires": [
            [
                "5f7c79b770c5e406"
            ]
        ]
    },
    {
        "id": "5f7c79b770c5e406",
        "type": "function",
        "z": "614e7fb59f287520",
        "name": "function 42",
        "func": "msg.edit_dialog.push(msg.payload);\nmsg.defaults.push(msg.field_name + ': {value:\"' + msg.field_default.toString() + '\"}');\n\nif (msg.hasOwnProperty('rgroup_name')) {\n    msg.rgroup_details.push({\n        field_name: msg.field_name,\n        field_default_type: '',\n        field_types: ''\n    });\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 190,
        "y": 200,
        "wires": [
            []
        ]
    },
    {
        "id": "c609db8aed86d3fb",
        "type": "subflow:614e7fb59f287520",
        "z": "82e9c64fb447d01a",
        "name": "",
        "env": [
            {
                "name": "field_name",
                "value": "hidden_field",
                "type": "str"
            },
            {
                "name": "field_default",
                "value": "hidden_default_value",
                "type": "str"
            }
        ],
        "x": 1020,
        "y": 40,
        "wires": [
            []
        ]
    }
]

It’s a holiday here in the states; I’ll definitely take a look when I get back. There is a slightly related project to address the lengthy flow files and code editing/viewing/differences; also allows you to use external code editors: flow2src. Created using the initial version of Node Maker too.

I have yet to check in the final version, but should be releasing a 1.0 shortly.

Hi Christian, hidden fields sounds like a good idea. I've updated the main branch to include a 'src' folder. This folder was generated via https://github.com/steveorevo/node-red-flow2src. This should make it a lot easier to see changes and additions to the project.

I'll write up directions on how to better contribute to node-maker, using Node-RED's project feature and flow2src; the directions will be in the README.md file.