@iobroker/adapter-react-v5 7.4.10 → 7.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -97,6 +97,13 @@ export interface TreeItem {
97
97
  data: TreeItemData;
98
98
  children?: TreeItem[];
99
99
  }
100
+ export declare function filterRoles(roleArray: {
101
+ role: string;
102
+ type: ioBroker.CommonType;
103
+ }[], type: ioBroker.CommonType, defaultRoles?: {
104
+ role: string;
105
+ type: ioBroker.CommonType;
106
+ }[]): string[];
100
107
  export declare function getSelectIdIconFromObjects(objects: Record<string, ioBroker.Object>, id: string, lang: ioBroker.Languages, imagePrefix?: string): string | JSX.Element | null;
101
108
  export declare const ITEM_IMAGES: Record<string, JSX.Element>;
102
109
  export interface ObjectBrowserFilter {
@@ -121,11 +128,15 @@ interface AdapterColumn {
121
128
  align?: 'center' | 'left' | 'right';
122
129
  }
123
130
  interface ObjectBrowserEditRoleProps {
124
- roles: string[];
131
+ roleArray: {
132
+ role: string;
133
+ type: ioBroker.CommonType;
134
+ }[];
125
135
  id: string;
126
136
  socket: Connection;
127
137
  onClose: (obj?: ioBroker.Object | null) => void;
128
138
  t: Translate;
139
+ commonType: ioBroker.CommonType;
129
140
  }
130
141
  interface ObjectViewFileDialogProps {
131
142
  t: Translate;
@@ -188,7 +199,10 @@ interface ObjectBrowserValueProps {
188
199
  interface ObjectBrowserEditObjectProps {
189
200
  socket: Connection;
190
201
  obj: ioBroker.AnyObject;
191
- roleArray: string[];
202
+ roleArray: {
203
+ role: string;
204
+ type: ioBroker.CommonType;
205
+ }[];
192
206
  expertMode: boolean;
193
207
  themeType: ThemeType;
194
208
  theme: IobTheme;
@@ -204,6 +218,10 @@ interface ObjectBrowserEditObjectProps {
204
218
  }
205
219
  export interface ObjectAliasEditorProps {
206
220
  t: Translate;
221
+ roleArray: {
222
+ role: string;
223
+ type: ioBroker.CommonType;
224
+ }[];
207
225
  socket: Connection;
208
226
  objects: Record<string, ioBroker.AnyObject>;
209
227
  onRedirect: (id: string, delay?: number) => void;
@@ -784,6 +784,17 @@ excludeTranslations) {
784
784
  result[key] = isObject ? filterObject(value, filterKeys, excludeTranslations) : value;
785
785
  });
786
786
  }
787
+ export function filterRoles(roleArray, type, defaultRoles) {
788
+ const bigRoleArray = [];
789
+ roleArray.forEach(role => (role.type === 'mixed' || role.type) === type &&
790
+ !bigRoleArray.includes(role.role) &&
791
+ bigRoleArray.push(role.role));
792
+ defaultRoles.forEach(role => (role.type === 'mixed' || role.type) === type &&
793
+ !bigRoleArray.includes(role.role) &&
794
+ bigRoleArray.push(role.role));
795
+ bigRoleArray.sort();
796
+ return bigRoleArray;
797
+ }
787
798
  /**
788
799
  * Function to generate a json-file for an object and trigger download it
789
800
  */
@@ -1233,9 +1244,9 @@ function buildTree(objects, options) {
1233
1244
  }
1234
1245
  if (obj) {
1235
1246
  const common = obj.common;
1236
- const role = common && common.role;
1237
- if (role && !info.roles.includes(role)) {
1238
- info.roles.push(role);
1247
+ const role = common?.role;
1248
+ if (role && !info.roles.find(it => it.role === role)) {
1249
+ info.roles.push({ role, type: common.type });
1239
1250
  }
1240
1251
  else if (id.startsWith('enum.rooms.')) {
1241
1252
  info.roomEnums.push(id);
@@ -1403,7 +1414,7 @@ function buildTree(objects, options) {
1403
1414
  }
1404
1415
  return 0;
1405
1416
  });
1406
- info.roles.sort();
1417
+ info.roles.sort((a, b) => a.role.localeCompare(b.role));
1407
1418
  info.types.sort();
1408
1419
  return { info, root };
1409
1420
  }
@@ -3014,7 +3025,7 @@ export class ObjectBrowserClass extends Component {
3014
3025
  React.createElement(IconClose, null)))) : null));
3015
3026
  }
3016
3027
  getFilterSelectRole() {
3017
- return this.getFilterSelect('role', this.info.roles);
3028
+ return this.getFilterSelect('role', this.info.roles.map(it => it.role));
3018
3029
  }
3019
3030
  getFilterSelectRoom() {
3020
3031
  const rooms = this.info.roomEnums.map(id => ({
@@ -4093,7 +4104,7 @@ export class ObjectBrowserClass extends Component {
4093
4104
  }
4094
4105
  if (this.state.roleDialog && this.props.objectBrowserEditRole) {
4095
4106
  const ObjectBrowserEditRole = this.props.objectBrowserEditRole;
4096
- return (React.createElement(ObjectBrowserEditRole, { key: "objectBrowserEditRole", id: this.state.roleDialog, socket: this.props.socket, t: this.props.t, roles: this.info.roles, onClose: (obj) => {
4107
+ return (React.createElement(ObjectBrowserEditRole, { key: "objectBrowserEditRole", id: this.state.roleDialog, socket: this.props.socket, t: this.props.t, roleArray: this.info.roles, commonType: this.info.objects[this.state.roleDialog]?.common?.type, onClose: (obj) => {
4097
4108
  if (obj) {
4098
4109
  this.info.objects[this.state.roleDialog] = obj;
4099
4110
  }
@@ -5544,7 +5555,7 @@ export class ObjectBrowserClass extends Component {
5544
5555
  return null;
5545
5556
  }
5546
5557
  const ObjectBrowserAliasEditor = this.props.objectBrowserAliasEditor;
5547
- return (React.createElement(ObjectBrowserAliasEditor, { key: "editAlias", obj: this.objects[this.state.showAliasEditor], objects: this.objects, socket: this.props.socket, t: this.props.t, onClose: () => this.setState({ showAliasEditor: '' }), onRedirect: (id, timeout) => setTimeout(() => this.onSelect(id, false, () => this.expandAllSelected(() => {
5558
+ return (React.createElement(ObjectBrowserAliasEditor, { key: "editAlias", obj: this.objects[this.state.showAliasEditor], roleArray: this.info.roles, objects: this.objects, socket: this.props.socket, t: this.props.t, onClose: () => this.setState({ showAliasEditor: '' }), onRedirect: (id, timeout) => setTimeout(() => this.onSelect(id, false, () => this.expandAllSelected(() => {
5548
5559
  this.scrollToItem(id);
5549
5560
  setTimeout(() => this.setState({
5550
5561
  editObjectDialog: id,