Skip to content

Commit

Permalink
Merge pull request #98 from flowforge/ui-template
Browse files Browse the repository at this point in the history
Add Basic UI Template Node
  • Loading branch information
joepavitt authored Aug 3, 2023
2 parents b8bb9e0 + 7fe3bdb commit 8ef3366
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
14 changes: 7 additions & 7 deletions nodes/widgets/ui_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}
},
height: { value: 0 },
format: { value: '<div ng-bind-html="msg.payload"></div>' },
format: { value: '<div>{{ msg.payload }}</div>' },
storeOutMessages: { value: true },
fwdInMessages: { value: true },
resendOnRefresh: { value: true },
Expand Down Expand Up @@ -170,6 +170,12 @@
<option value="global" data-i18n="ui-template.label.global"></option>
</select>
</div>-->
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<div style="display:inline-block; width:calc(100% - 105px)">
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
</div>
<div class="form-row">
<label for="node-input-group"><i class="fa fa-table"></i> Group</label>
<input type="text" id="node-input-group">
Expand All @@ -184,12 +190,6 @@
<label for="node-input-className"><i class="fa fa-code"></i> <span data-i18n="ui-template.label.className"></label>
<input type="text" id="node-input-className" data-i18n="[placeholder]ui-template.label.classNamePlaceholder"/>
</div>-->
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<div style="display:inline-block; width:calc(100% - 105px)">
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
</div>
<div class="form-row" style="margin-bottom:0px;">
<label for="node-input-format"><i class="fa fa-copy"></i> <span data-i18n="ui-template.label.template"></span></label>
<input type="hidden" id="node-input-format">
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"ui-switch": "nodes/widgets/ui_switch.js",
"ui-text": "nodes/widgets/ui_text.js",
"ui-chart": "nodes/widgets/ui_chart.js",
"ui-markdown": "nodes/widgets/ui_markdown.js"
"ui-markdown": "nodes/widgets/ui_markdown.js",
"ui-template": "nodes/widgets/ui_template.js"
}
},
"dependencies": {
Expand Down
27 changes: 20 additions & 7 deletions ui/src/widgets/ui-template/UITemplate.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<template>
<div class="nrdb-ui-widget">Template Node: {{ props.format }}</div>
</template>

<script>
// eslint-disable vue/one-component-per-file
import { h } from 'vue'
import { useDataTracker } from '../data-tracker.js' // eslint-disable-line import/order
import { mapState } from 'vuex' // eslint-disable-line import/order
Expand All @@ -15,9 +16,21 @@ export default {
},
setup (props) {
useDataTracker(props.id)
},
computed: {
...mapState('data', ['values'])
return () => h({
props: ['id', 'props'],
template: props.props.format,
computed: {
...mapState('data', ['values']),
msg () {
return {
payload: this.values[this.id]
}
}
}
}, {
id: props.id,
props: props.props
})
}
}
</script>
Expand Down
1 change: 1 addition & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require('path')
const { defineConfig } = require('@vue/cli-service')

module.exports = defineConfig({
runtimeCompiler: true,
transpileDependencies: true,
publicPath: './',
chainWebpack: config => {
Expand Down

0 comments on commit 8ef3366

Please sign in to comment.