--- /dev/null
+(function() {
+ "use strict";
+
+ angular
+ .module("nero.app")
+ .controller("SendMessageController", SendMessageController);
+
+ SendMessageController.$inject = ["$uibModalInstance", "$uibModal", "parameters"];
+
+ function SendMessageController($uibModalInstance, $uibModal, parameters) {
+
+ var vm = this;
+
+ vm.recipientList = [];
+ vm.messageContent = "";
+ vm.messageSubject = "";
+
+ vm.selectedContact = parameters.selectedContact;
+ vm.selectedCategory = parameters.selectedCategory;
+ vm.selectedList = parameters.selectedList;
+ vm.selectedCurrentContact = parameters.currentContact;
+
+
+ // Initialize the modal with recipients
+ if (vm.selectedCategory != undefined) {
+ console.log("send message to a category");
+ var recipient = vm.selectedCategory;
+ recipient.isCategory = true;
+ console.log("Adding to recipient list a category ", recipient);
+ vm.recipientList.push(recipient);
+ }
+
+ if (vm.selectedContact != undefined) {
+ console.log("send message to a contact1");
+ for (var i = 0 ; i < vm.selectedContact.length ; i++){
+ var recipient = vm.selectedContact[i];
+ recipient.isContact = true;
+ console.log("Adding to recipient list a contact ", recipient);
+ vm.recipientList.push(recipient);
+ }
+ }
+
+ if (vm.selectedList != undefined) {
+ console.log("send message to a list");
+ var recipient = vm.selectedList;
+ recipient.isList = true;
+ console.log("Adding to recipient list the list ", recipient);
+ vm.recipientList.push(recipient);
+ }
+
+ if (vm.selectedCurrentContact != undefined) {
+ console.log("send message to a contact2");
+ var recipient = vm.selectedCurrentContact;
+ recipient.isContact = true;
+ console.log("Adding to recipient list current contact ", recipient);
+ vm.recipientList.push(recipient);
+ }
+
+
+ // Methods
+ vm.send = send;
+ vm.saveDraft = saveDraft;
+ vm.onCancel = onCancel;
+
+
+ // Use screen.height and screen.width if mobile isn't enough
+ var toolbarExpanded = true;
+ if (Liferay.Browser.isMobile() || Liferay.Browser.isIphone()) {
+ toolbarExpanded = false;
+ }
+
+ vm.editorOptions = {
+ toolbarCanCollapse : true,
+ toolbarStartupExpanded : toolbarExpanded,
+ toolbar: 'Full',
+ height : '100px'
+ };
+
+ function send() {
+
+ var type = "";
+ var id = 0;
+ /*
+ contactService.sendMessage(vm.recipientList, vm.messageSubject, vm.messageContent).then(function(data){
+ console.log("sending message");
+
+ })["catch"](function(message) {
+ toastr.error(message);
+ });
+ */
+ }
+
+ function saveDraft(){
+
+ }
+
+ function onCancel(){
+
+ $uibModalInstance.dismiss("cancel");
+
+ }
+ }
+})();