6 .controller("SendMessageController", SendMessageController);
8 SendMessageController.$inject = ["$uibModalInstance", "$uibModal", "parameters"];
10 function SendMessageController($uibModalInstance, $uibModal, parameters) {
14 vm.recipientList = [];
15 vm.messageContent = "";
16 vm.messageSubject = "";
18 vm.selectedContact = parameters.selectedContact;
19 vm.selectedCategory = parameters.selectedCategory;
20 vm.selectedList = parameters.selectedList;
21 vm.selectedCurrentContact = parameters.currentContact;
24 // Initialize the modal with recipients
25 if (vm.selectedCategory != undefined) {
26 console.log("send message to a category");
27 var recipient = vm.selectedCategory;
28 recipient.isCategory = true;
29 console.log("Adding to recipient list a category ", recipient);
30 vm.recipientList.push(recipient);
33 if (vm.selectedContact != undefined) {
34 console.log("send message to a contact1");
35 for (var i = 0 ; i < vm.selectedContact.length ; i++){
36 var recipient = vm.selectedContact[i];
37 recipient.isContact = true;
38 console.log("Adding to recipient list a contact ", recipient);
39 vm.recipientList.push(recipient);
43 if (vm.selectedList != undefined) {
44 console.log("send message to a list");
45 var recipient = vm.selectedList;
46 recipient.isList = true;
47 console.log("Adding to recipient list the list ", recipient);
48 vm.recipientList.push(recipient);
51 if (vm.selectedCurrentContact != undefined) {
52 console.log("send message to a contact2");
53 var recipient = vm.selectedCurrentContact;
54 recipient.isContact = true;
55 console.log("Adding to recipient list current contact ", recipient);
56 vm.recipientList.push(recipient);
62 vm.saveDraft = saveDraft;
63 vm.onCancel = onCancel;
66 // Use screen.height and screen.width if mobile isn't enough
67 var toolbarExpanded = true;
68 if (Liferay.Browser.isMobile() || Liferay.Browser.isIphone()) {
69 toolbarExpanded = false;
73 toolbarCanCollapse : true,
74 toolbarStartupExpanded : toolbarExpanded,
84 contactService.sendMessage(vm.recipientList, vm.messageSubject, vm.messageContent).then(function(data){
85 console.log("sending message");
87 })["catch"](function(message) {
88 toastr.error(message);
99 $uibModalInstance.dismiss("cancel");