Skip to content

Commit

Permalink
WIP plugin tab
Browse files Browse the repository at this point in the history
  • Loading branch information
luisthieme committed Nov 21, 2024
1 parent 348775f commit a6e5339
Show file tree
Hide file tree
Showing 7 changed files with 203 additions and 36 deletions.
79 changes: 70 additions & 9 deletions nodes/dynamic-form-theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,60 @@
RED.nodes.registerType('dynamic-form-theme', {
category: 'config',
defaults: {
name: {
value: '',
required: true,
},
colors: {
value: {
surface: '#ffffff',
primary: '#0094CE',
bgPage: '#eeeeee',
groupBg: '#ffffff',
groupOutline: '#cccccc',
},
surface: '#ffffff',
primary: '#0094CE',
bgPage: '#eeeeee',
groupBg: '#ffffff',
groupOutline: '#cccccc',
},
},
label: function () {
return this.name || 'DynamicForm Theme';
},
oneditprepare: function () {},
oneditsave: function () {},
oneditprepare: function () {
// loop over keys in this.colors
if (!this.colors) {
this.colors = {};
// set default values
this.colors.surface = '#ffffff';
this.colors.primary = '#0094CE';
// pages
this.colors.bgPage = '#eeeeee';
// groups
this.colors.groupBg = '#ffffff';
this.colors.groupOutline = '#cccccc';
}

Object.keys(this.colors).forEach((color) => {
// get the value of the key
const value = this.colors[color];
// set the value of the input
$('#node-config-input-' + color).val(value);
});

// update label b/g to match the colour input values
// this provides nicer styling than the default browser styling
const colorWrappers = $('.color-picker-wrapper');
colorWrappers.each(function (i) {
const wrapper = $(this);
const colorPicker = wrapper.children("input[type='color']").eq(0);
colorPicker.on('change', () => {
wrapper.css('background-color', colorPicker.val());
});
wrapper.css('background-color', colorPicker.val());
});
},
oneditsave: function () {
Object.keys(this.colors).forEach((color) => {
// set the value of the input
this.colors[color] = $('#node-config-input-' + color).val();
});
},
});
</script>

Expand All @@ -25,6 +64,28 @@
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name" />
</div>
<div class="form-row form-row-flex labels-right" style="margin-bottom: 3px; gap: 9px;">
<div>
<label>Label</label>
<label
class="color-picker-wrapper"
for="node-config-input-primary"
style="width: 100px; height: 32px; border-radius: 6px; border: 1px solid #ccc"
>
<input type="color" id="node-config-input-surface" style="opacity: 0; width: 100%;" />
</label>
</div>
<div>
<label>Label</label>
<label
class="color-picker-wrapper"
for="node-config-input-primary"
style="width: 100px; height: 32px; border-radius: 6px; border: 1px solid #ccc"
>
<input type="color" id="node-config-input-primary" style="opacity: 0; width: 100%;" />
</label>
</div>
</div>
</script>

<script type="text/markdown" data-help-name="dynamic-form-theme">
Expand Down
4 changes: 4 additions & 0 deletions nodes/dynamic-form-theme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = function (RED) {
function DynamicFormTheme(n) {
RED.nodes.createNode(this, n);

this.name = n.name;

this.colors = n.colors;
}
RED.nodes.registerType('dynamic-form-theme', DynamicFormTheme);
};
38 changes: 21 additions & 17 deletions nodes/ui-dynamic-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
name: { value: '' },
group: { type: 'ui-group', required: true },
order: { value: 0 },
theme: { value: '', type: 'dynamic-form-theme' },
options: {
value: [{ label: '' }],
validate: function (v) {
Expand Down Expand Up @@ -173,6 +174,10 @@
<input type="hidden" id="node-input-height">
<button class="editor-button" id="node-input-size"></button>
</div>
<div class="form-row">
<label for="node-input-theme"><i class="fa fa-table"></i> Theme</label>
<input type="text" id="node-input-theme">
</div>

<div class="form-row form-row-flex node-input-option-container-row" style="margin-bottom: 0px;width: 100%">
<label for="node-input-width" style="vertical-align:top"><i class="fa fa-list-alt"></i> Actions</label>
Expand Down Expand Up @@ -203,35 +208,34 @@
</div>
</script>


<script type="text/markdown" data-help-name="ui-dynamic-form">
A UI-Node to display usertasks forms from the ProcessCube Engine dynamicly.
A UI-Node to display usertasks forms from the ProcessCube Engine dynamicly.

## Usage
## Usage

Connect the UI-Node to the usertask input node. Every action in the configuration of the node will display as a button at the bottom of the form.
Connect the UI-Node to the usertask input node. Every action in the configuration of the node will display as a button at the bottom of the form.

## Validation
## Validation

### message
### message

Access to the message object is available through _msg_
Access to the message object is available through _msg_

### form fields
### form fields

Access to the form fields is available through the _fields_ object. A single form field can be accessed by selecting the field id as a key.
Example: _fields.field_01_
Access to the form fields is available through the _fields_ object. A single form field can be accessed by selecting the field id as a key.
Example: _fields.field_01_

### usertask
### usertask

Access to the usertask object is available through _usertask_
Access to the usertask object is available through _usertask_

## Outputs
## Outputs

: usertask (Object) : The representative object of the usertask.
: usertask (Object) : The representative object of the usertask.

### References
### References

- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; Plattform
- [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED Integration in ProcessCube&copy;
- [The ProcessCube Developer Network](https://processcube.io) - All documentation for the ProcessCube&copy; Plattform
- [Node-RED Integration in ProcessCube&copy;](https://processcube.io/docs/node-red) - Node-RED Integration in ProcessCube&copy;
</script>
2 changes: 2 additions & 0 deletions nodes/ui-dynamic-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module.exports = function (RED) {
// which group are we rendering this widget
const group = RED.nodes.getNode(config.group);

config.theme = RED.nodes.getNode(config.theme);

const base = group.getBase();

// server-side event handlers
Expand Down
108 changes: 101 additions & 7 deletions plugins/node-red-dashboard-2-dynamic-form-theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
}

function addDefaultTheme() {
console.log('adding default theme...');
const theme = RED.nodes.getType('dynamic-form-theme');
console.log('theme777', theme);
const themeNode = {
_def: theme,
id: RED.nodes.id(),
Expand All @@ -50,11 +48,69 @@
};

addConfigNode(themeNode);
console.log('node added');

const listItem = $('<div>', { class: 'list-item' }).appendTo(themeList);
listItem.append($('<p>', { class: 'list-item-text', text: theme.name }));
$(
'<button class="editor-button editor-button-small nr-db-sb-list-header-button"><i class="fa fa-paint-brush"></i> ' +
'Edit' +
'</button>'
)
.click(function (evt) {
RED.editor.editConfig('', theme.type, theme.id);
evt.preventDefault();
})
.appendTo(listItem);

return themeNode;
}

const tab = $('<div>', { class: 'test_class_luis' }).appendTo(parent);
tab.append($('<button>', { text: 'Add DynamicForm Theme', click: () => addDefaultTheme() }));
const tab = $('<div>', { class: 'dynamicform-tab' }).appendTo(parent);
const headerDiv = $('<div>', { class: 'header-div' }).appendTo(tab);
const themeList = $('<div>', { class: 'theme-list' }).appendTo(tab);

headerDiv.append($('<b>', { text: 'DynamicForm Themes' }));
$(
'<button class="editor-button editor-button-small nr-db-sb-list-header-button"><i class="fa fa-plus"></i> ' +
'Add DynamicForm Theme' +
'</button>'
)
.click(function (evt) {
const themeResult = addDefaultTheme();
RED.editor.editConfig('', themeResult.type, themeResult.id);
})
.appendTo(headerDiv);

let themes = {};

RED.nodes.eachConfig(function (n) {
if (n.type === 'dynamic-form-theme') {
themes[n.id] = n;
}
});

Object.values(themes).forEach(function (theme) {
const listItem = $('<div>', { class: 'list-item' }).appendTo(themeList);
listItem.append($('<p>', { class: 'list-item-text', text: theme.name }));
$(
'<button class="editor-button editor-button-small nr-db-sb-list-header-button"><i class="fa fa-paint-brush"></i> ' +
'Edit' +
'</button>'
)
.click(function (evt) {
// if (themes.includes(itemc)) {
// RED.editor.editConfig('', item.type, item.id);
// } else {
// RED.editor.edit(item?.node);
// }

RED.editor.editConfig('', theme.type, theme.id);
evt.stopPropagation();
evt.preventDefault();
})
.appendTo(listItem);
});
},
},
],
Expand All @@ -64,10 +120,48 @@
</script>

<style>
.test_class_luis {
background-color: aqua;
.dynamicform-tab {
width: 100%;
padding: 10px;
border-radius: 5px;
}

.theme-list {
padding-top: 20px;
width: 95%;
justify-content: center;
}
.list-item-text {
margin: 0 !important;
}

.list-item {
border: solid;
padding: 8px;
border-color: rgba(200, 200, 200, 1);
border-width: 1px;
border-radius: 6px;
margin-bottom: 5px;
display: flex;
align-items: center;
justify-content: space-between;
}

.dynamicform-button {
height: 20px;
min-width: 20px;
line-height: 18px;
font-size: 10px;
border-radius: 2px;
padding: 0 5px;
}

.heading {
font-weight: 600;
}

.header-div {
width: 95%;
display: flex;
justify-content: space-between;
}
</style>
5 changes: 3 additions & 2 deletions ui/components/UIDynamicForm.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<!-- Component must be wrapped in a block so props such as className and style can be passed in from parent -->
<div className="ui-dynamic-form-wrapper">
<div className="ui-dynamic-form-wrapper" :style="{ '--luis-bg-footer': primary }">
<p v-if="hasFields()">
<v-form ref="form" v-model="form" :class="dynamicClass">
<h3 style="padding: 16px">{{ this.props.name }}</h3>
Expand Down Expand Up @@ -89,11 +89,13 @@ export default {
formData: {},
taskInput: {},
theme: '',
primary: '',
error: false,
errorMsg: '',
};
},
created() {
this.primary = this.props.theme.colors.primary;
const currentPath = window.location.pathname;
const lastPart = currentPath.substring(currentPath.lastIndexOf('/'));
Expand Down Expand Up @@ -129,7 +131,6 @@ export default {
'Der Usertask wird automatisch angezeigt, wenn ein entsprechender Task vorhanden ist.'
);
},
dynamicClass() {
return `ui-dynamic-form-${this.theme}`;
},
Expand Down
3 changes: 2 additions & 1 deletion ui/stylesheets/ui-dynamic-form.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ code {
flex-direction: column;
gap: 8px;
padding: 16px;
background-color: rgba(249, 250, 251, 1);
/* background-color: rgba(249, 250, 251, 1); */
background-color: var(--luis-bg-footer);
margin: 0;
border-bottom-left-radius: 12px;
border-bottom-right-radius: 12px;
Expand Down

0 comments on commit a6e5339

Please sign in to comment.