Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
chore: release v1.6.31
Browse files Browse the repository at this point in the history
Changed the filter of objects
  • Loading branch information
GermanBluefox committed Jul 12, 2021
1 parent 9a07cda commit 8e04898
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 20 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,9 @@ The icons may not be reused in other projects without the proper flaticon licens
-->

## Changelog
### 1.6.31 (2021-07-12)
* (bluefox) Changed the filter of objects

### 1.6.30 (2021-06-30)
* (bluefox) Corrected the export of objects in object list

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iobroker/adapter-react",
"version": "1.6.30",
"version": "1.6.31",
"description": "React classes to develop admin interfaces for ioBroker with react.",
"author": {
"name": "bluefox",
Expand Down
30 changes: 20 additions & 10 deletions src/Components/ObjectBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ const styles = theme => ({
filteredOut: {
opacity: 0.5
},
filteredParentOut: {
opacity: 0.3
},
filterInput: {
marginTop: 0,
marginBottom: 0
Expand Down Expand Up @@ -775,18 +778,24 @@ function applyFilter(item, filters, lang, objects, context, counter, customFilte
});
}

const visible = data.visible || data.hasVisibleChildren;
if (counter && visible) {
//const visible = data.visible || data.hasVisibleChildren;
data.sumVisibility = data.visible || data.hasVisibleChildren || data.hasVisibleParent;
if (counter && data.sumVisibility) {
counter.count++;
}

return visible;
// show all children of visible object with opacity 0.5
if (data.id && data.sumVisibility && item.children) {
item.children.forEach(_item => _item.data.hasVisibleParent = true);
}

return data.visible || data.hasVisibleChildren;
}

function getVisibleItems(item, type, objects, _result) {
_result = _result || [];
const data = item.data;
if (data.visible || data.hasVisibleChildren) {
if (data.sumVisibility) {
data.id && objects[data.id] && (!type || objects[data.id].type === type) && _result.push(data.id);
item.children?.forEach(_item =>
getVisibleItems(_item, type, objects, _result));
Expand Down Expand Up @@ -2553,7 +2562,7 @@ class ObjectBrowser extends Component {
expanded = expanded || [];

root.children && root.children.forEach(item => {
if (item.data.hasVisibleChildren) {
if (item.data.sumVisibility) {
expanded.push(item.data.id);
this.onExpandAll(item, expanded);
}
Expand Down Expand Up @@ -2586,7 +2595,7 @@ class ObjectBrowser extends Component {
if (depth > 0) {
if (root.children) {
root.children.forEach(item => {
if (item.data.visible || item.data.hasVisibleChildren) {
if (item.data.sumVisibility) {
if (!binarySearch(expanded, item.data.id)) {
expanded.push(item.data.id);
expanded.sort();
Expand Down Expand Up @@ -3922,6 +3931,7 @@ class ObjectBrowser extends Component {
alias && classes.tableRowAlias,
readWriteAlias && classes.tableRowAliasReadWrite,
!item.data.visible && classes.filteredOut,
item.data.hasVisibleParent && !item.data.visible && !item.data.hasVisibleChildren && classes.filteredParentOut,
this.state.selected.includes(id) && classes.itemSelected,
this.state.selectedNonObject === id && classes.itemSelected
)}
Expand Down Expand Up @@ -4041,7 +4051,7 @@ class ObjectBrowser extends Component {
let leaf = this.renderLeaf(root, isExpanded, classes, counter);
let DragWrapper = this.props.DragWrapper;
if (this.props.dragEnabled) {
if (root.data.visible || root.data.hasVisibleChildren) {
if (root.data.sumVisibility) {
leaf = <DragWrapper key={root.data.id} item={root} className={classes.draggable}>{leaf}</DragWrapper>;
} else {
// change cursor
Expand All @@ -4057,7 +4067,7 @@ class ObjectBrowser extends Component {
root.children && items.push(root.children.map(item => {
// do not render too many items in column editor mode
if (!this.state.columnsSelectorShow || counter.count < 15) {
if (item.data.visible || item.data.hasVisibleChildren) {
if (item.data.sumVisibility) {
return this.renderItem(item, undefined, classes, counter);
}
}
Expand All @@ -4069,7 +4079,7 @@ class ObjectBrowser extends Component {
if (item.children) {
// do not render too many items in column editor mode
if (!this.state.columnsSelectorShow || counter.count < 15) {
if (item.data.visible || item.data.hasVisibleChildren) {
if (item.data.sumVisibility) {
return this.renderItem(item, undefined, classes, counter);
}
}
Expand All @@ -4082,7 +4092,7 @@ class ObjectBrowser extends Component {
if (!item.children) {
// do not render too many items in column editor mode
if (!this.state.columnsSelectorShow || counter.count < 15) {
if (item.data.visible || item.data.hasVisibleChildren) {
if (item.data.sumVisibility) {
return this.renderItem(item, undefined, classes, counter);
}
}
Expand Down
19 changes: 10 additions & 9 deletions src/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const PROGRESS = {
READY: 3
};

export const PERMISSION_ERROR = 'permissionError';
export const NOT_CONNECTED = 'notConnectedError';
const PERMISSION_ERROR = 'permissionError';
const NOT_CONNECTED = 'notConnectedError';

export const ERRORS = {
PERMISSION_ERROR,
Expand Down Expand Up @@ -885,12 +885,12 @@ class Connection {
cb && cb();
} else {
let obj = objs.pop();
this.delObject(obj._id)
.then(() => {
obj._id = obj.newId;
delete obj.newId;
return this.setObject(obj._id, obj)
})
let oldId = obj._id;
obj._id = obj.newId;
delete obj.newId;

this.setObject(obj._id, obj)
.then(() => this.delObject(oldId))
.then(() => setTimeout(() => this._renameGroups(objs, cb), 0))
.catch(err => cb && cb(err));
}
Expand Down Expand Up @@ -928,7 +928,8 @@ class Connection {
obj.common.name = newName;
}

return this.setObject(obj._id, obj);
return this.setObject(obj._id, obj)
.then(() => this.delObject(id));
}
});
}
Expand Down

0 comments on commit 8e04898

Please sign in to comment.