Commit 6cdaa474 authored by JC Brand's avatar JC Brand

Fix roster filter functionality

parent 493ecb2e
...@@ -5769,8 +5769,7 @@ body.reset { ...@@ -5769,8 +5769,7 @@ body.reset {
#conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .available-chatroom.unread-msgs .open-room, #conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .available-chatroom.unread-msgs .open-room,
#conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .open-chatroom.unread-msgs .available-room, #conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .open-chatroom.unread-msgs .available-room,
#conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .open-chatroom.unread-msgs .open-room { #conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .open-chatroom.unread-msgs .open-room {
max-width: 55%; width: 100%;
width: auto;
font-weight: bold; } font-weight: bold; }
#conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .available-chatroom a.room-info:before, #conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .available-chatroom a.room-info:before,
#conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .open-chatroom a.room-info:before { #conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .open-chatroom a.room-info:before {
...@@ -6026,19 +6025,20 @@ body.reset { ...@@ -6026,19 +6025,20 @@ body.reset {
#conversejs #converse-roster .search-xmpp ul li.chat-info { #conversejs #converse-roster .search-xmpp ul li.chat-info {
padding-left: 10px; } padding-left: 10px; }
#conversejs #converse-roster .roster-filter-form { #conversejs #converse-roster .roster-filter-form {
width: 100%; width: 100%; }
/* (dynamically added) if input has value: */ #conversejs #converse-roster .roster-filter-form .button-group {
/* (dynamically added) if mouse is over the 'x' input area*/ } padding: 0.2em; }
#conversejs #converse-roster .roster-filter-form span { #conversejs #converse-roster .roster-filter-form span {
padding: 0.3em; padding: 0.3em;
color: #888; color: #888;
cursor: pointer; } cursor: pointer; }
#conversejs #converse-roster .roster-filter-form .roster-filter { #conversejs #converse-roster .roster-filter-form .roster-filter {
width: 100%; } width: 100%; }
#conversejs #converse-roster .roster-filter-form .roster-filter.x { #conversejs #converse-roster .roster-filter-form .clear-roster-filter {
background-position: right 3px center; } position: absolute;
#conversejs #converse-roster .roster-filter-form .roster-filter.onX { right: 0.2em;
cursor: pointer; } cursor: pointer;
font-size: 0.75rem; }
#conversejs #converse-roster .roster-filter-form .state-type { #conversejs #converse-roster .roster-filter-form .state-type {
font-size: calc(14px - 2px); font-size: calc(14px - 2px);
height: 25px; height: 25px;
......
...@@ -5841,8 +5841,7 @@ body { ...@@ -5841,8 +5841,7 @@ body {
#conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .available-chatroom.unread-msgs .open-room, #conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .available-chatroom.unread-msgs .open-room,
#conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .open-chatroom.unread-msgs .available-room, #conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .open-chatroom.unread-msgs .available-room,
#conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .open-chatroom.unread-msgs .open-room { #conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .open-chatroom.unread-msgs .open-room {
max-width: 55%; width: 100%;
width: auto;
font-weight: bold; } font-weight: bold; }
#conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .available-chatroom a.room-info:before, #conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .available-chatroom a.room-info:before,
#conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .open-chatroom a.room-info:before { #conversejs #controlbox #chatrooms .rooms-list-container .rooms-list .open-chatroom a.room-info:before {
...@@ -6152,19 +6151,20 @@ body { ...@@ -6152,19 +6151,20 @@ body {
#conversejs #converse-roster .search-xmpp ul li.chat-info { #conversejs #converse-roster .search-xmpp ul li.chat-info {
padding-left: 10px; } padding-left: 10px; }
#conversejs #converse-roster .roster-filter-form { #conversejs #converse-roster .roster-filter-form {
width: 100%; width: 100%; }
/* (dynamically added) if input has value: */ #conversejs #converse-roster .roster-filter-form .button-group {
/* (dynamically added) if mouse is over the 'x' input area*/ } padding: 0.2em; }
#conversejs #converse-roster .roster-filter-form span { #conversejs #converse-roster .roster-filter-form span {
padding: 0.3em; padding: 0.3em;
color: #888; color: #888;
cursor: pointer; } cursor: pointer; }
#conversejs #converse-roster .roster-filter-form .roster-filter { #conversejs #converse-roster .roster-filter-form .roster-filter {
width: 100%; } width: 100%; }
#conversejs #converse-roster .roster-filter-form .roster-filter.x { #conversejs #converse-roster .roster-filter-form .clear-roster-filter {
background-position: right 3px center; } position: absolute;
#conversejs #converse-roster .roster-filter-form .roster-filter.onX { right: 0.2em;
cursor: pointer; } cursor: pointer;
font-size: 0.75rem; }
#conversejs #converse-roster .roster-filter-form .state-type { #conversejs #converse-roster .roster-filter-form .state-type {
font-size: calc(16px - 2px); font-size: calc(16px - 2px);
height: 30px; height: 30px;
......
...@@ -48,7 +48,10 @@ ...@@ -48,7 +48,10 @@
</div> </div>
<form class="roster-filter-form input-button-group"> <form class="roster-filter-form input-button-group">
<div class="form-inline flex-nowrap"> <div class="form-inline flex-nowrap">
<input value="" class="roster-filter form-control" placeholder="Filter"> <div class="btn-group">
<input value="" class="roster-filter form-control" placeholder="Filter">
<span class="clear-roster-filter fa fa-times {[ if (!o.filter_text) { ]} hidden {[ } ]}"></span>
</div>
<div class="filter-by d-flex flex-nowrap"> <div class="filter-by d-flex flex-nowrap">
<span class="fa fa-user" title="Filter by contacts"></span> <span class="fa fa-user" title="Filter by contacts"></span>
<span class="fa fa-users" title="Filter by groups"></span> <span class="fa fa-users" title="Filter by groups"></span>
......
...@@ -224,8 +224,7 @@ ...@@ -224,8 +224,7 @@
&.unread-msgs { &.unread-msgs {
.available-room, .available-room,
.open-room { .open-room {
max-width: 55%; width: 100%;
width: auto;
font-weight: bold; font-weight: bold;
} }
} }
......
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
.roster-filter-form { .roster-filter-form {
width: 100%; width: 100%;
.button-group {
padding: 0.2em;
}
span { span {
padding: 0.3em; padding: 0.3em;
color: #888; color: #888;
...@@ -40,13 +44,11 @@ ...@@ -40,13 +44,11 @@
.roster-filter { .roster-filter {
width: 100%; width: 100%;
} }
/* (dynamically added) if input has value: */ .clear-roster-filter {
.roster-filter.x { position: absolute;
background-position: right 3px center; right: 0.2em;
}
/* (dynamically added) if mouse is over the 'x' input area*/
.roster-filter.onX {
cursor: pointer; cursor: pointer;
font-size: 0.75rem;
} }
.state-type { .state-type {
font-size: calc(#{$font-size} - 2px); font-size: calc(#{$font-size} - 2px);
......
...@@ -134,15 +134,14 @@ ...@@ -134,15 +134,14 @@
events: { events: {
"keydown .roster-filter": "liveFilter", "keydown .roster-filter": "liveFilter",
"submit form.roster-filter-form": "submitFilter", "submit form.roster-filter-form": "submitFilter",
"click .onX": "clearFilter", "click .clear-roster-filter": "clearFilter",
"mousemove .x": "toggleX",
"click .filter-by span": "changeTypeFilter", "click .filter-by span": "changeTypeFilter",
"change .state-type": "changeChatStateFilter" "change .state-type": "changeChatStateFilter"
}, },
initialize () { initialize () {
this.model.on('change:filter_type', this.render, this); this.model.on('change:filter_type', this.render, this);
this.model.on('change:filter_text', this.renderClearButton, this); this.model.on('change:filter_text', this.render, this);
}, },
toHTML () { toHTML () {
...@@ -164,28 +163,6 @@ ...@@ -164,28 +163,6 @@
})); }));
}, },
afterRender () {
this.renderClearButton();
},
renderClearButton () {
const roster_filter = this.el.querySelector('.roster-filter');
if (_.isNull(roster_filter)) {
return;
}
roster_filter.classList[this.tog(roster_filter.value)]('x');
},
tog (v) {
return v?'add':'remove';
},
toggleX (ev) {
if (ev && ev.preventDefault) { ev.preventDefault(); }
const el = ev.target;
el.classList[this.tog(el.offsetWidth-18 < ev.clientX-el.getBoundingClientRect().left)]('onX');
},
changeChatStateFilter (ev) { changeChatStateFilter (ev) {
if (ev && ev.preventDefault) { ev.preventDefault(); } if (ev && ev.preventDefault) { ev.preventDefault(); }
this.model.save({ this.model.save({
...@@ -264,10 +241,10 @@ ...@@ -264,10 +241,10 @@
clearFilter (ev) { clearFilter (ev) {
if (ev && ev.preventDefault) { if (ev && ev.preventDefault) {
ev.preventDefault(); ev.preventDefault();
ev.target.classList.remove('x'); u.hideElement(this.el.querySelector('.clear-roster-filter'));
ev.target.classList.remove('onX');
ev.target.value = '';
} }
const roster_filter = this.el.querySelector('.roster-filter');
roster_filter.value = '';
this.model.save({'filter_text': ''}); this.model.save({'filter_text': ''});
} }
}); });
...@@ -359,9 +336,9 @@ ...@@ -359,9 +336,9 @@
const chat_status = item.get('chat_status') || 'offline'; const chat_status = item.get('chat_status') || 'offline';
if (chat_status === 'online') { if (chat_status === 'online') {
status_icon = 'fa-circle'; status_icon = 'fa-circle';
} else if (chat_status === 'away' || chat_status === 'dnd') { } else if (chat_status === 'away' || chat_status === 'xa') {
status_icon = 'fa-circle-o'; status_icon = 'fa-circle-o';
} else if (chat_status === 'busy') { } else if (chat_status === 'dnd') {
status_icon = 'fa-minus-circle'; status_icon = 'fa-minus-circle';
} }
this.el.innerHTML = tpl_roster_item( this.el.innerHTML = tpl_roster_item(
...@@ -558,10 +535,18 @@ ...@@ -558,10 +535,18 @@
filter (q, type) { filter (q, type) {
/* Filter the group's contacts based on the query "q". /* Filter the group's contacts based on the query "q".
* The query is matched against the contact's full name. *
* If all contacts are filtered out (i.e. hidden), then the * If all contacts are filtered out (i.e. hidden), then the
* group must be filtered out as well. * group must be filtered out as well.
*/ */
if (_.isNil(q)) {
type = type || _converse.rosterview.filter_view.model.get('filter_type');
if (type === 'state') {
q = _converse.rosterview.filter_view.model.get('chat_state');
} else {
q = _converse.rosterview.filter_view.model.get('filter_text');
}
}
this.filterOutContacts(this.getFilterMatches(q, type)); this.filterOutContacts(this.getFilterMatches(q, type));
}, },
...@@ -577,10 +562,7 @@ ...@@ -577,10 +562,7 @@
ev.target.classList.remove("icon-closed"); ev.target.classList.remove("icon-closed");
ev.target.classList.add("icon-opened"); ev.target.classList.add("icon-opened");
this.model.save({state: _converse.OPENED}); this.model.save({state: _converse.OPENED});
this.filter( this.filter();
_converse.rosterview.el.querySelector('.roster-filter').value,
_converse.rosterview.el.querySelector('.filter-type').value
);
u.showElement(this.el); u.showElement(this.el);
u.slideOut(this.contacts_el); u.slideOut(this.contacts_el);
} }
......
<form class="roster-filter-form input-button-group {[ if (!o.visible) { ]} hidden {[ } ]}"> <form class="roster-filter-form input-button-group {[ if (!o.visible) { ]} hidden {[ } ]}">
<div class="form-inline flex-nowrap"> <div class="form-inline flex-nowrap">
<input value="{{{o.filter_text}}}" <div class="btn-group">
class="roster-filter form-control {[ if (o.filter_type === 'state') { ]} hidden {[ } ]}" <input value="{{{o.filter_text}}}"
placeholder="{{{o.placeholder}}}"> class="roster-filter form-control {[ if (o.filter_type === 'state') { ]} hidden {[ } ]}"
placeholder="{{{o.placeholder}}}">
<span class="clear-roster-filter fa fa-times {[ if (!o.filter_text) { ]} hidden {[ } ]}"></span>
</div>
<select class="form-control state-type {[ if (o.filter_type !== 'state') { ]} hidden {[ } ]}"> <select class="form-control state-type {[ if (o.filter_type !== 'state') { ]} hidden {[ } ]}">
<option value="">{{{o.label_any}}}</option> <option value="">{{{o.label_any}}}</option>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment