Skip to content

Commit

Permalink
Merge pull request #1364 from FlowFuse/1106-have-dialog-group-types
Browse files Browse the repository at this point in the history
Implementation of dialog groups for all the layout types
  • Loading branch information
gayanSandamal authored Oct 9, 2024
2 parents 3f83d45 + 4a9749d commit 81a2150
Show file tree
Hide file tree
Showing 14 changed files with 504 additions and 16 deletions.
215 changes: 215 additions & 0 deletions docs/examples/group-dialog-type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
[
{
"id": "0aa38a714b8a3d67",
"type": "ui-form",
"z": "9337c17e1a7f6875",
"name": "",
"group": "c7871ac53089d535",
"label": "New User",
"order": 1,
"width": 0,
"height": 0,
"options": [
{
"label": "Name",
"key": "name",
"type": "text",
"required": true,
"rows": null
},
{
"label": "Admin",
"key": "isAdmin",
"type": "switch",
"required": false,
"rows": null
}
],
"formValue": {
"name": "",
"isAdmin": false
},
"payload": "",
"submit": "Add",
"cancel": "clear",
"resetOnSubmit": true,
"topic": "topic",
"topicType": "msg",
"splitLayout": "",
"className": "",
"passthru": false,
"dropdownOptions": [],
"x": 220,
"y": 100,
"wires": [
[
"adbd76ecf97076a1"
]
]
},
{
"id": "fa4925a5253341ce",
"type": "ui-control",
"z": "9337c17e1a7f6875",
"name": "",
"ui": "c2e1aa56f50f03bd",
"events": "all",
"x": 580,
"y": 100,
"wires": [
[]
]
},
{
"id": "adbd76ecf97076a1",
"type": "change",
"z": "9337c17e1a7f6875",
"name": "Hide Dialog",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"groups\":{\"hide\":[\"Active Development:Dialog Group\"]}}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 390,
"y": 100,
"wires": [
[
"fa4925a5253341ce",
"b9d77a856b1be020"
]
]
},
{
"id": "294ac777d99f5789",
"type": "ui-button",
"z": "9337c17e1a7f6875",
"group": "497106faf38a5190",
"name": "",
"label": "Add User (Dialog)",
"order": 1,
"width": 0,
"height": 0,
"emulateClick": false,
"tooltip": "",
"color": "",
"bgcolor": "",
"className": "",
"icon": "",
"iconPosition": "left",
"payload": "{\"groups\":{\"show\":[\"Active Development:Dialog Group\"]}}",
"payloadType": "json",
"topic": "topic",
"topicType": "msg",
"buttonColor": "",
"textColor": "",
"iconColor": "",
"x": 370,
"y": 140,
"wires": [
[
"fa4925a5253341ce",
"b9d77a856b1be020"
]
]
},
{
"id": "b9d77a856b1be020",
"type": "debug",
"z": "9337c17e1a7f6875",
"name": "debug 2572",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 590,
"y": 140,
"wires": []
},
{
"id": "c7871ac53089d535",
"type": "ui-group",
"name": "Dialog Group",
"page": "22b5519aa675ad88",
"width": "6",
"height": "1",
"order": 1,
"showTitle": true,
"className": "",
"visible": "true",
"disabled": "false",
"groupType": "dialog"
},
{
"id": "c2e1aa56f50f03bd",
"type": "ui-base",
"name": "Dashboard",
"path": "/dashboard",
"includeClientData": true,
"acceptsClientConfig": [
"ui-control",
"ui-notification"
],
"showPathInSidebar": false,
"showPageTitle": false,
"navigationStyle": "icon",
"titleBarStyle": "default"
},
{
"id": "497106faf38a5190",
"type": "ui-group",
"name": "Button Groups",
"page": "22b5519aa675ad88",
"width": "6",
"height": "1",
"order": 10,
"showTitle": true,
"className": "",
"visible": "true",
"disabled": "false"
},
{
"id": "22b5519aa675ad88",
"type": "ui-page",
"name": "Active Development",
"ui": "c2e1aa56f50f03bd",
"path": "/active-development",
"icon": "forum",
"layout": "grid",
"theme": "129e99574def90a3",
"order": 1,
"className": "",
"visible": "true",
"disabled": "false"
},
{
"id": "129e99574def90a3",
"type": "ui-theme",
"name": "Custom Theme",
"colors": {
"surface": "#000000",
"primary": "#ff4000",
"bgPage": "#f0f0f0",
"groupBg": "#ffffff",
"groupOutline": "#d9d9d9"
},
"sizes": {
"pagePadding": "24px",
"groupGap": "12px",
"groupBorderRadius": "9px",
"widgetGap": "6px",
"density": "default"
}
}
]
29 changes: 27 additions & 2 deletions docs/nodes/config/ui-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@
description: Group your widgets effectively in Node-RED Dashboard 2.0 for better organization and user navigation.
props:
Name: Descriptive name for this group, will show in the Node-RED Editor and as a label in the Dashboard.
Page: The Page (<code>ui-page</code>) that this group will render on.
Page: The Page (<code>ui-page</code>) that this group will render on.
Type: Controls whether the group appears as a default group or as a dialog, which needs to be triggered manually using ui-control. You can choose between 'Default' and 'Dialog' types.
Size: The width and height of the group. Height will always be reinforced by this value, the height is generally a <i>minimum</i> height, and will extend to fit it's content.
Class: Any custom CSS classes you wish to add to the Group.
Default State: <ul><li><b>Visibility</b> - Defines the default visibility of this group.</li><li><b>Interactivity</b> - Controls whether the group and it's contents are disabled/enabled when the page is loaded.</li></ul><p>Both of these can be overridden by the user at runtime using a <code>ui-control</code> node.</p>
---

<script setup>

import { ref } from 'vue'
import FlowViewer from '../../components/FlowViewer.vue'
import ExampleGroupDialog from '../../examples/group-dialog-type.json'

const examples = ref({
'group-dialog': ExampleGroupDialog
})
</script>

# Config: UI Group `ui-group`
Expand All @@ -17,4 +26,20 @@ Each group is rendered within a `ui-page` as part of a [Layout](../../contributi

## Properties

<PropsTable :hide-dynamic="true"/>
<PropsTable :hide-dynamic="true"/>

## Type

Defines how the group will be displayed. Either as a regular (**Default**) group or as a **Dialog** group. A 'Default' group is visible by default, while a 'Dialog' group must be triggered manually using the `ui-control` node ([see documentation](/nodes/widgets/ui-control.html#show-hide)). You can choose between these two options based on your layout needs.

### Default Groups

![Example of how the type 'Default' option looks](/images/node-examples/ui-group-type-default.png "Example of how the type 'Default' option looks"){data-zoomable}
_Example of how the type 'Default' option looks_

### Dialog Groups

![Example of how the type 'Dialog' option looks](/images/node-examples/ui-group-type-dialog.png "Example of how the type 'Dialog' option looks"){data-zoomable}
_Example of how the type 'Dialog' option looks_

<FlowViewer :flow="examples['group-dialog']" height="250px" />
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 46 additions & 3 deletions nodes/config/locales/en-US/ui_group.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
<script type="text/html" data-help-name="ui-group">
<p>Group</p>
<p>
A container for multiple UI Widgets. Groups can be used to organize and manage the layout of UI Widgets.
</p>
<p>A container for multiple UI Widgets. Groups can be used to organize and manage the layout of UI Widgets.</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>
Page
<span class="property-type">option</span>
</dt>
<dd>
Specifies the page within the Node-RED Dashboard 2.0 where the group will be displayed. You can select or change the page using this option.
</dd>
<dt>
Type
<span class="property-type">option</span>
</dt>
<dd>
Controls whether the group appears as a default, inline, group or is rendered as a modal/dialog. IN the latter case, you can use a <code>ui-control</code> to open/close the dialog.
</dd>
<dt>
Size
<span class="property-type">input</span>
</dt>
<dd>
Defines the width and height of the group in grid units. You can adjust these values to control the space allocated to the group on the dashboard.
</dd>
<dt>
Class
<span class="property-type">input</span>
</dt>
<dd>
Allows the assignment of custom CSS class names for advanced styling of the group and its contents.
</dd>
<dt>
Visibility
<span class="property-type">option</span>
</dt>
<dd>
Visibility controls whether the group is displayed (Visible/Hidden).
</dd>
<dt>
Interactivity
<span class="property-type">option</span>
</dt>
<dd>
Iteractivity defines whether user interaction is allowed.(Active/Disabled).
</dd>
</dl>
</script>
5 changes: 4 additions & 1 deletion nodes/config/locales/en-US/ui_group.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
"interactivity": "Interactivity",
"active": "Active",
"disabled": "Disabled",
"openDashboardSidebar": "Open Dashboard 2.0 Sidebar"
"openDashboardSidebar": "Open Dashboard 2.0 Sidebar",
"type": "Type",
"typeDefault": "Default",
"typeDialog": "Dialog"
}
}
}
2 changes: 1 addition & 1 deletion nodes/config/ui_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@
const titleRow = $('<div>', { class: 'nrdb2-sb-list-header nrdb2-sb-groups-list-header' }).appendTo(container)
$('<i class="nrdb2-sb-list-handle nrdb2-sb-group-list-handle fa fa-bars"></i>').appendTo(titleRow)
const chevron = $('<i class="fa fa-angle-down nrdb2-sb-list-chevron">', { style: 'width:10px;' }).appendTo(titleRow)
const groupicon = 'fa-table'
const groupicon = group.node.groupType === 'dialog' ? 'fa-window-restore' : 'fa-table'
$('<i>', { class: 'nrdb2-sb-icon nrdb2-sb-group-icon fa ' + groupicon }).appendTo(titleRow)
$('<span>', { class: 'nrdb2-sb-title' }).text(group.name || group.id).appendTo(titleRow)
$('<span>', { class: 'nrdb2-sb-info' }).text(`${widgets.length} Widgets`).appendTo(titleRow)
Expand Down
12 changes: 11 additions & 1 deletion nodes/config/ui_group.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
showTitle: { value: true }, // show title on group card
className: { value: '' },
visible: { value: true },
disabled: { value: false }
disabled: { value: false },
groupType: { value: 'default' }
},
label: function () {
const page = RED.nodes.node(this.page)?.name || ''
Expand Down Expand Up @@ -45,6 +46,8 @@
this.disabled = true
$('#node-config-input-disabled').val('true')
}

$('#node-config-input-groupType').val(this.groupType || 'default')
},
oneditsave: function () {
// convert string to boolean
Expand Down Expand Up @@ -75,6 +78,13 @@
<label for="node-config-input-page"><i class="fa fa-bookmark"></i> <span data-i18n="ui-group.label.page"></label>
<input type="text" id="node-config-input-page">
</div>
<div class="form-row">
<label for="node-config-input-groupType"><i class="fa fa-window-restore"></i> <span data-i18n="ui-group.label.type"></label>
<select id="node-config-input-groupType" style="width: 70%;">
<option value="default" data-i18n="ui-group.label.typeDefault"></option>
<option value="dialog" data-i18n="ui-group.label.typeDialog"></option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-size"><i class="fa fa-arrows-h"></i> <span data-i18n="ui-group.label.size"></label>
<input type="hidden" id="node-config-input-width">
Expand Down
Loading

0 comments on commit 81a2150

Please sign in to comment.