Commit f722ba72 authored by Vladimir Baranov's avatar Vladimir Baranov

rref #5392. Add popups to add user/unit to channel

parent 964b97b2
......@@ -10,6 +10,18 @@ angular.module("ulakbus.messaging")
return channelKey;
}
function searchWrapper(scope, promiseWrapper){
scope.loading = true;
scope.searchResult = [];
promiseWrapper()
.then(function(result){
scope.searchResult = result;
})
.finally(function(){
scope.loading = false;
})
}
return {
templateUrl: 'components/messaging/templates/index.html',
restrict: 'E',
......@@ -31,15 +43,9 @@ angular.module("ulakbus.messaging")
rootElement: popupRootElement,
link: function(scope){
scope.onChange = function(query){
scope.loading = true;
scope.searchResult = [];
MessagingService.search_user(query)
.then(function(users){
scope.searchResult = users;
})
.finally(function(){
scope.loading = false;
})
searchWrapper(scope, function(){
return MessagingService.search_user(query);
})
};
scope.onChange("");
}
......@@ -56,10 +62,48 @@ angular.module("ulakbus.messaging")
scope.channel = {};
}
}).then(function(channel){
return MessagingService.create_channel(channel.name, channel.description);
return MessagingService.create_channel(channel.name, channel.description||"");
});
};
iScope.addUserToChannel = function(channel){
MessagingPopup.show({
templateUrl: "components/messaging/templates/add_user_unit.html",
rootElement: popupRootElement,
link: function(scope){
scope.title = "Add User";
scope.placeholder = "Search User to Add";
scope.onChange = function(query){
searchWrapper(scope, function(){
return MessagingService.search_user(query);
})
};
scope.onChange("");
}
}).then(function(userKey){
return MessagingService.add_members([userKey]);
});
};
iScope.addUnitToChannel = function(){
MessagingPopup.show({
templateUrl: "components/messaging/templates/add_user_unit.html",
rootElement: popupRootElement,
link: function(scope){
scope.title = "Add Unit";
scope.placeholder = "Search Unit to Add";
scope.onChange = function(query){
searchWrapper(scope, function(){
return MessagingService.search_unit(query);
})
};
scope.onChange("");
}
}).then(function(unitKey){
var channelKey = getKey(iScope.selectedChannel);
return MessagingService.add_members(channelKey, unitKey);
});
};
},
controller: function ($scope) {
......@@ -117,6 +161,10 @@ angular.module("ulakbus.messaging")
$scope.shared.message = "";
});
}
$scope.canAddUserAndChannel = function (channel) {
return channel && channel.type == MessagingService.CHANNEL_TYPE.PUBLIC;
}
}
};
})
......
<div class="chat-popup-window add-user-unit" style="display:block;">
<div class="close-chat-popup-window"><span class="glyphicon glyphicon-remove"></span></div>
<h3>Add User/Unit</h3>
<h3>{{title}}</h3>
<div class="text-center">
<input type="text" placeholder="Search User/Unit to Add"><br>
<input type="text" placeholder="{{placeholder}}">
<div class="search-results">
<span class="loader" ng-show="loading"></span>
<div class="user" ng-repeat="item in searchResult" ng-click="done(item[1])">
<img ng-src="{{item[2]}}" ng-show="item[2]">
<div class="user-name">{{item[0]}}</div>
</div>
</div>
</div>
</div>
......@@ -26,8 +26,8 @@
<li><a ng-click="applyChannelAction(action)" ng-repeat="action in selectedChannel.actions">{{action[0]}}</a></li>
</ul>
</div>
<div class="close-chat-app">
<span class="glyphicon glyphicon-remove" ng-click="hideApp()"></span>
<div class="close-chat-app" ng-click="hideApp()">
<span class="glyphicon glyphicon-remove"></span>
</div>
</div>
......
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