@iobroker/adapter-react-v5 7.7.3 → 7.7.4
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.
- package/build/Components/CustomModal.js +1 -1
- package/build/Components/CustomModal.js.map +1 -1
- package/build/Components/FileBrowser.js.map +1 -1
- package/build/Components/ObjectBrowser.d.ts +5 -5
- package/build/Components/ObjectBrowser.js +76 -37
- package/build/Components/ObjectBrowser.js.map +1 -1
- package/build/Components/Utils.js +1 -2
- package/build/Components/Utils.js.map +1 -1
- package/build/Dialogs/SelectID.d.ts +5 -5
- package/build/Dialogs/SelectID.js.map +1 -1
- package/package.json +2 -2
|
@@ -113,11 +113,11 @@ export declare const ITEM_IMAGES: Record<string, JSX.Element>;
|
|
|
113
113
|
export interface ObjectBrowserFilter {
|
|
114
114
|
id?: string;
|
|
115
115
|
name?: string;
|
|
116
|
-
room?: string;
|
|
117
|
-
func?: string;
|
|
118
|
-
role?: string;
|
|
119
|
-
type?: string;
|
|
120
|
-
custom?: string;
|
|
116
|
+
room?: string[];
|
|
117
|
+
func?: string[];
|
|
118
|
+
role?: string[];
|
|
119
|
+
type?: string[];
|
|
120
|
+
custom?: string[];
|
|
121
121
|
expertMode?: boolean;
|
|
122
122
|
}
|
|
123
123
|
interface AdapterColumn {
|
|
@@ -970,24 +970,30 @@ function applyFilter(item, filters, lang, objects, context, counter, customFilte
|
|
|
970
970
|
context.name = name;
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
|
-
if (filters.type) {
|
|
974
|
-
context.type = filters.type.toLowerCase();
|
|
973
|
+
if (filters.type?.length) {
|
|
974
|
+
context.type = filters.type.map(f => f.toLowerCase());
|
|
975
975
|
}
|
|
976
|
-
if (filters.custom) {
|
|
977
|
-
context.custom = filters.custom.toLowerCase();
|
|
976
|
+
if (filters.custom?.length) {
|
|
977
|
+
context.custom = filters.custom.map(c => c.toLowerCase());
|
|
978
978
|
}
|
|
979
|
-
if (filters.role) {
|
|
980
|
-
context.role = filters.role.toLowerCase();
|
|
979
|
+
if (filters.role?.length) {
|
|
980
|
+
context.role = filters.role.map(r => r.toLowerCase());
|
|
981
981
|
}
|
|
982
|
-
if (filters.room) {
|
|
983
|
-
context.room =
|
|
982
|
+
if (filters.room?.length) {
|
|
983
|
+
context.room = [];
|
|
984
|
+
filters.room.forEach(room => {
|
|
985
|
+
context.room = context.room.concat(objects[room]?.common?.members || []);
|
|
986
|
+
});
|
|
984
987
|
}
|
|
985
|
-
if (filters.func) {
|
|
986
|
-
context.func =
|
|
988
|
+
if (filters.func?.length) {
|
|
989
|
+
context.func = [];
|
|
990
|
+
filters.func.forEach(func => {
|
|
991
|
+
context.func = context.func.concat(objects[func]?.common?.members || []);
|
|
992
|
+
});
|
|
987
993
|
}
|
|
988
994
|
}
|
|
989
995
|
const data = item.data;
|
|
990
|
-
if (data
|
|
996
|
+
if (data?.id) {
|
|
991
997
|
const common = data.obj?.common;
|
|
992
998
|
if (customFilter) {
|
|
993
999
|
if (customFilter.type) {
|
|
@@ -1100,33 +1106,28 @@ function applyFilter(item, filters, lang, objects, context, counter, customFilte
|
|
|
1100
1106
|
filteredOut = !context.nameRx.test(data.fName);
|
|
1101
1107
|
}
|
|
1102
1108
|
}
|
|
1103
|
-
if (!filteredOut && filters.role && common) {
|
|
1104
|
-
|
|
1105
|
-
filteredOut = !(typeof common.role === 'string' && common.role.startsWith(context.role));
|
|
1106
|
-
}
|
|
1107
|
-
else {
|
|
1108
|
-
filteredOut = true;
|
|
1109
|
-
}
|
|
1109
|
+
if (!filteredOut && filters.role?.length && common) {
|
|
1110
|
+
filteredOut = !(typeof common.role === 'string' && context.role.find(role => common.role.startsWith(role)));
|
|
1110
1111
|
}
|
|
1111
|
-
if (!filteredOut && context.room) {
|
|
1112
|
+
if (!filteredOut && context.room?.length) {
|
|
1112
1113
|
filteredOut = !context.room.find(id => id === data.id || data.id.startsWith(`${id}.`));
|
|
1113
1114
|
}
|
|
1114
|
-
if (!filteredOut && context.func) {
|
|
1115
|
+
if (!filteredOut && context.func?.length) {
|
|
1115
1116
|
filteredOut = !context.func.find(id => id === data.id || data.id.startsWith(`${id}.`));
|
|
1116
1117
|
}
|
|
1117
|
-
if (!filteredOut && context.type) {
|
|
1118
|
-
filteredOut = !(data.obj &&
|
|
1118
|
+
if (!filteredOut && context.type?.length) {
|
|
1119
|
+
filteredOut = !(data.obj?.type && context.type.includes(data.obj.type));
|
|
1119
1120
|
}
|
|
1120
1121
|
if (!filteredOut && selectedTypes) {
|
|
1121
|
-
filteredOut = !(data.obj
|
|
1122
|
+
filteredOut = !(data.obj?.type && selectedTypes.includes(data.obj.type));
|
|
1122
1123
|
}
|
|
1123
|
-
if (!filteredOut && context.custom) {
|
|
1124
|
+
if (!filteredOut && context.custom?.length) {
|
|
1124
1125
|
if (common) {
|
|
1125
|
-
if (context.custom
|
|
1126
|
+
if (context.custom.includes('_')) {
|
|
1126
1127
|
filteredOut = !!common.custom;
|
|
1127
1128
|
}
|
|
1128
|
-
else {
|
|
1129
|
-
filteredOut = !common.custom
|
|
1129
|
+
else if (common.custom) {
|
|
1130
|
+
filteredOut = !context.custom.find(custom => common.custom[custom]);
|
|
1130
1131
|
}
|
|
1131
1132
|
}
|
|
1132
1133
|
else {
|
|
@@ -1859,11 +1860,11 @@ let objectsAlreadyLoaded = false;
|
|
|
1859
1860
|
const DEFAULT_FILTER = {
|
|
1860
1861
|
id: '',
|
|
1861
1862
|
name: '',
|
|
1862
|
-
room:
|
|
1863
|
-
func:
|
|
1864
|
-
role:
|
|
1865
|
-
type:
|
|
1866
|
-
custom:
|
|
1863
|
+
room: [],
|
|
1864
|
+
func: [],
|
|
1865
|
+
role: [],
|
|
1866
|
+
type: [],
|
|
1867
|
+
custom: [],
|
|
1867
1868
|
expertMode: false,
|
|
1868
1869
|
};
|
|
1869
1870
|
export class ObjectBrowserClass extends Component {
|
|
@@ -1974,6 +1975,22 @@ export class ObjectBrowserClass extends Component {
|
|
|
1974
1975
|
else {
|
|
1975
1976
|
filter = { ...DEFAULT_FILTER };
|
|
1976
1977
|
}
|
|
1978
|
+
// Migrate old filters to new one
|
|
1979
|
+
if (typeof filter.room === 'string') {
|
|
1980
|
+
filter.room = [filter.room];
|
|
1981
|
+
}
|
|
1982
|
+
if (typeof filter.func === 'string') {
|
|
1983
|
+
filter.func = [filter.func];
|
|
1984
|
+
}
|
|
1985
|
+
if (typeof filter.role === 'string') {
|
|
1986
|
+
filter.role = [filter.role];
|
|
1987
|
+
}
|
|
1988
|
+
if (typeof filter.type === 'string') {
|
|
1989
|
+
filter.type = [filter.type];
|
|
1990
|
+
}
|
|
1991
|
+
if (typeof filter.custom === 'string') {
|
|
1992
|
+
filter.custom = [filter.custom];
|
|
1993
|
+
}
|
|
1977
1994
|
filter.expertMode =
|
|
1978
1995
|
props.expertMode !== undefined
|
|
1979
1996
|
? props.expertMode
|
|
@@ -2364,6 +2381,13 @@ export class ObjectBrowserClass extends Component {
|
|
|
2364
2381
|
else if (this.state.selected.length === 1 && this.props.allowNonObjects) {
|
|
2365
2382
|
this.props.onSelect?.(this.state.selected, null, isDouble);
|
|
2366
2383
|
}
|
|
2384
|
+
else {
|
|
2385
|
+
// we have more than one state
|
|
2386
|
+
// Check if all IDs are objects
|
|
2387
|
+
if (!this.props.allowNonObjects || !this.state.selected.find(id => !this.objects[id])) {
|
|
2388
|
+
this.props.onSelect?.(this.state.selected, null, isDouble);
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2367
2391
|
}
|
|
2368
2392
|
else {
|
|
2369
2393
|
this.localStorage.removeItem(`${this.props.dialogName || 'App'}.objectSelected`);
|
|
@@ -3011,12 +3035,27 @@ export class ObjectBrowserClass extends Component {
|
|
|
3011
3035
|
onFilter(name, value) {
|
|
3012
3036
|
this.filterTimer = null;
|
|
3013
3037
|
const filter = { ...this.state.filter };
|
|
3014
|
-
Object.keys(this.filterRefs).forEach(_name => {
|
|
3038
|
+
Object.keys(this.filterRefs).forEach((_name) => {
|
|
3015
3039
|
if (this.filterRefs[_name]?.current) {
|
|
3016
3040
|
const filterRef = this.filterRefs[_name].current;
|
|
3017
3041
|
for (let i = 0; i < filterRef.children.length; i++) {
|
|
3018
3042
|
if (filterRef.children[i].tagName === 'INPUT') {
|
|
3019
|
-
|
|
3043
|
+
if (_name === 'role' ||
|
|
3044
|
+
_name === 'type' ||
|
|
3045
|
+
_name === 'func' ||
|
|
3046
|
+
_name === 'custom' ||
|
|
3047
|
+
_name === 'room') {
|
|
3048
|
+
const value = filterRef.children[i].value;
|
|
3049
|
+
if (value) {
|
|
3050
|
+
filter[_name] = value.split(',');
|
|
3051
|
+
}
|
|
3052
|
+
else {
|
|
3053
|
+
filter[_name] = undefined;
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
else {
|
|
3057
|
+
filter[_name] = filterRef.children[i].value;
|
|
3058
|
+
}
|
|
3020
3059
|
break;
|
|
3021
3060
|
}
|
|
3022
3061
|
}
|
|
@@ -3082,12 +3121,12 @@ export class ObjectBrowserClass extends Component {
|
|
|
3082
3121
|
getFilterSelect(name, values) {
|
|
3083
3122
|
const hasIcons = !!values?.find(item => item.icon);
|
|
3084
3123
|
return (React.createElement("div", { style: { position: 'relative' } },
|
|
3085
|
-
React.createElement(Select, { variant: "standard", key: `${name}_${this.state.filterKey}`, ref: this.filterRefs[name], sx: styles.headerCellInput, className: "no-underline", onChange: () => {
|
|
3124
|
+
React.createElement(Select, { variant: "standard", key: `${name}_${this.state.filterKey}`, ref: this.filterRefs[name], sx: styles.headerCellInput, className: "no-underline", multiple: true, onChange: () => {
|
|
3086
3125
|
if (this.filterTimer) {
|
|
3087
3126
|
clearTimeout(this.filterTimer);
|
|
3088
3127
|
}
|
|
3089
3128
|
this.filterTimer = setTimeout(() => this.onFilter(), 400);
|
|
3090
|
-
}, defaultValue: this.state.filter[name] ||
|
|
3129
|
+
}, defaultValue: this.state.filter[name] || [], inputProps: { name, id: name }, displayEmpty: true },
|
|
3091
3130
|
React.createElement(MenuItem, { key: "empty", value: "" },
|
|
3092
3131
|
React.createElement("span", { style: styles.selectNone }, name === 'custom' ? this.texts.showAll : this.texts[`filter_${name}`])),
|
|
3093
3132
|
values?.map(item => {
|
|
@@ -3110,7 +3149,7 @@ export class ObjectBrowserClass extends Component {
|
|
|
3110
3149
|
this.filterRefs[name]?.current?.childNodes[1]?.value ? (React.createElement(Box, { component: "div", sx: styles.selectClearButton },
|
|
3111
3150
|
React.createElement(IconButton, { size: "small", onClick: () => {
|
|
3112
3151
|
const newFilter = { ...this.state.filter };
|
|
3113
|
-
newFilter[name]
|
|
3152
|
+
delete newFilter[name];
|
|
3114
3153
|
(this.filterRefs[name].current?.childNodes[1]).value = '';
|
|
3115
3154
|
this.localStorage.setItem(`${this.props.dialogName || 'App'}.objectFilter`, JSON.stringify(newFilter));
|
|
3116
3155
|
this.setState({ filter: newFilter, filterKey: this.state.filterKey + 1 }, () => this.props.onFilterChanged && this.props.onFilterChanged(newFilter));
|