Commit c62087d2 authored by Sang D NGO's avatar Sang D NGO

invite expert to event

parent 714e8036
......@@ -37,7 +37,10 @@
backdrop: 'static',
placement: 'center',
controllerAs: '$ctrl',
controller: 'MostProposalDetailReviewController'
controller: 'MostProposalDetailReviewController',
locals: {
proposal: self.proposal
}
});
}
......
......@@ -8,7 +8,10 @@
$state,
$stateParams,
$modal,
mostProposalApiClient
$q,
proposal,
mostProposalApiClient,
mostService
) {
var self = this;
......@@ -24,6 +27,7 @@
mostProposalApiClient
.updateProposal($stateParams.proposalId, { reviewers: userIds, status: 'REVIEWING' })
.then(_inviteExperts)
.finally(function() {
$state.go('most.proposal');
});
......@@ -43,5 +47,9 @@
return userIds;
}
function _inviteExperts() {
mostService.inviteExperts(proposal.formJson.title, self.experts);
}
}
})(angular);
(function(angular) {
'use strict';
angular.module('linagora.esn.most')
.factory('mostService', mostService);
function mostService(
uuid4,
session,
CalendarShell,
calEventAPI,
calMoment,
calAttendeesDenormalizerService,
esnMemberResolverRegistry,
calAttendeeService,
ICAL
) {
return {
inviteExperts: inviteExperts
};
function inviteExperts(title, experts) {
var vcalendar = new ICAL.Component('vcalendar');
var vevent = new ICAL.Component('vevent');
var uuid = uuid4.generate();
vcalendar.addSubcomponent(vevent);
vevent.addPropertyWithValue('uid', uuid);
var shell = new CalendarShell(vcalendar);
var eventPath = '/calendars/' + session.user._id + '/events/' + uuid + '.ics';
shell.title = 'V/v: ' + title;
shell.start = calMoment().add(2, 'hour');
shell.end = calMoment().add(5, 'hour');
shell.organizer = session.user;
shell.path = eventPath;
groupMemberResolver(experts[0]).then(function(attendees) {
shell.attendees = attendees;
return calEventAPI.create(eventPath, shell.vcalendar, {});
});
}
function groupMemberResolver(group) {
var resolver = esnMemberResolverRegistry.getResolver('group');
if (!resolver) {
return group;
}
return resolver.resolve(group.email).then(function(members) {
return members.map(function(member) {
return calAttendeeService.userAsAttendee(member.member);
});
});
}
}
})(angular);
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