mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-17 09:18:13 +00:00
(js) Improve ng-messages of sg-subscribe
Improved dry mode of User.$filter and added error message when users search returns no match.
This commit is contained in:
1 parent
03ddcfd07a
commit
d92bf122ed
3 files changed
+14
-7
No files matched your search
@@ -65,8 +65,12 @@
|
||||
return this.uid == data.uid;
|
||||
};
|
||||
|
||||
if (options && options.dry)
|
||||
users = [];
|
||||
if (options) {
|
||||
if (options.dry)
|
||||
users = [];
|
||||
else if (options.results)
|
||||
users = options.results;
|
||||
}
|
||||
else
|
||||
users = User.$users;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
var vm = this;
|
||||
|
||||
vm.selectedUser = null;
|
||||
vm.users = User.$users;
|
||||
vm.users = [];
|
||||
|
||||
vm.searchTextOptions = {
|
||||
updateOn: 'default blur',
|
||||
@@ -74,11 +74,13 @@
|
||||
}
|
||||
};
|
||||
|
||||
vm.onChange = function() {
|
||||
User.$filter(vm.searchText).then(function() {
|
||||
vm.onChange = function(input) {
|
||||
User.$filter(vm.searchText, null, { results: vm.users }).then(function(users) {
|
||||
input.$setValidity('matches', users.length > 0);
|
||||
input.$setTouched();
|
||||
if (vm.selectedUser) {
|
||||
// If selected user is no longer part of the matching users, unselect it
|
||||
if (_.isUndefined(_.find(User.$users, function(user) {
|
||||
if (_.isUndefined(_.find(users, function(user) {
|
||||
return user.uid == vm.selectedUser.uid;
|
||||
}))) {
|
||||
vm.selectedUser = null;
|
||||
|
||||
Reference in new issue
Block a user