Skip to content

Commit

Permalink
Add hidden count when config node filtered
Browse files Browse the repository at this point in the history
  • Loading branch information
knolleary committed Jan 13, 2016
1 parent 27cbaac commit 6dc640b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
20 changes: 18 additions & 2 deletions editor/js/ui/tab-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ RED.sidebar.config = (function() {
var container = $('<div class="palette-category workspace-config-node-category" id="workspace-config-node-category-'+name+'"></div>').appendTo(parent);
var header = $('<div class="workspace-config-node-tray-header palette-header"><i class="fa fa-angle-down expanded"></i></div>').appendTo(container);
if (label) {
$('<span/>').text(label).appendTo(header);
$('<span class="config-node-label"/>').text(label).appendTo(header);
} else {
$('<span data-i18n="sidebar.config.'+name+'">').appendTo(header);
$('<span class="config-node-label" data-i18n="sidebar.config.'+name+'">').appendTo(header);
}
$('<span class="config-node-filter-info"></span>').appendTo(header);
category = $('<ul class="palette-content config-node-list"></ul>').appendTo(container);
container.i18n();
var icon = header.find("i");
var result = {
label: label,
list: category,
size: function() {
return result.list.find("li:not(.config_node_none)").length
Expand Down Expand Up @@ -90,6 +92,11 @@ RED.sidebar.config = (function() {
}
});
categories[name] = result;
} else {
if (categories[name].label !== label) {
categories[name].list.parent().find('.config-node-label').text(label);
categories[name].label = label;
}
}
return categories[name];
}
Expand All @@ -104,9 +111,18 @@ RED.sidebar.config = (function() {
return 0;
});
if (showUnusedOnly) {
var hiddenCount = nodes.length;
nodes = nodes.filter(function(n) {
return n.users.length === 0;
})
hiddenCount = hiddenCount - nodes.length;
if (hiddenCount > 0) {
list.parent().find('.config-node-filter-info').text(RED._('sidebar.config.filtered',{count:hiddenCount})).show();
} else {
list.parent().find('.config-node-filter-info').hide();
}
} else {
list.parent().find('.config-node-filter-info').hide();
}
list.empty();
if (nodes.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion editor/js/ui/workspaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ RED.workspaces = (function() {
if (workspace.label != label) {
workspace_tabs.renameTab(workspace.id,label);
RED.nodes.dirty(true);
RED.sidebar.config.refresh();
$("#menu-item-workspace-menu-"+workspace.id.replace(".","-")).text(label);
// TODO: update entry in menu
}
$( this ).dialog( "close" );
}
Expand Down
5 changes: 5 additions & 0 deletions editor/sass/palette.scss
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,16 @@
}

.palette-header {
position: relative;
background: $palette-header-background;
cursor: pointer;
text-align: left;
padding: 9px;
font-weight: bold;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;

}
.palette-header i {
margin: 3px 10px 3px 3px;
Expand Down
12 changes: 12 additions & 0 deletions editor/sass/tab-config.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,15 @@
border-style: dashed;
color: #aaa;
}
.config-node-filter-info {
position: absolute;
top: 0;
right:0;
height: 38px;
line-height: 38px;
padding: 0 8px;
background: $palette-header-background;
font-size: 0.8em;
color: #999;
font-weight: normal;
}
3 changes: 2 additions & 1 deletion red/api/locales/en-US/editor.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@
"subflows": "subflows",
"flows": "flows",
"filterUnused":"unused",
"filterAll":"all"
"filterAll":"all",
"filtered": "__count__ hidden"
}
},
"typedInput": {
Expand Down

0 comments on commit 6dc640b

Please sign in to comment.