...
 
Commits (3)
......@@ -29,6 +29,10 @@ module.exports = function(dependencies) {
query.creator = options.creator;
}
if (options.reviewer) {
query.reviewers = options.reviewer;
}
if (options.status) {
query.status = options.status;
}
......
......@@ -38,6 +38,7 @@ module.exports = function(dependencies, lib) {
function getProposals(req, res) {
var listOptions = {
creator: req.query.creator,
reviewer: req.query.reviewer,
type: req.query.type,
status: req.query.status,
limit: Number(req.query.limit),
......
......@@ -8,6 +8,7 @@
function mostProposalApiClient(
session,
mostRoleService,
mostRestangular
) {
return {
......@@ -22,8 +23,12 @@
}
function getProposals(options) {
if (!session.userIsDomainAdministrator()) {
var userRole = mostRoleService.getRole();
if (userRole === 'user') {
options.creator = session.user._id;
} else if (userRole === 'expert') {
options.reviewer = session.user._id;
}
return mostRestangular.all(API_PATH).getList(options).then(_stripAndReturnData).then(function(proposals) {
......
......@@ -5,7 +5,7 @@
.modal-header
button.close(type="button", data-dismiss="modal", aria-label="Close", ng-click="$hide()")
span(aria-hidden="true") ×
h4.modal-title #{__('Thiết lập chuyên gia')}
h4.modal-title #{__('Hỏi chuyên gia')}
.modal-body
p
| #{__('Chọn một nhóm chuyên gia:')}
......
......@@ -9,7 +9,8 @@
$modal,
$stateParams,
session,
mostProposalApiClient
mostProposalApiClient,
mostRoleService
) {
var self = this;
......@@ -20,7 +21,8 @@
self.onReviewBtnClick = onReviewBtnClick;
function $onInit() {
self.showAction = session.userIsDomainAdministrator();
self.userRole = mostRoleService.getRole();
mostProposalApiClient.getProposal($stateParams.proposalId)
.then(function(proposal) {
self.proposal = proposal;
......
sub-header
most-proposal-detail-subheader(
data-title="$ctrl.proposal.formJson.title",
show-action="$ctrl.showAction",
user-role="$ctrl.userRole",
on-reject-btn-click="$ctrl.onRejectBtnClick()",
on-set-experts-btn-click="$ctrl.onSetExpertsBtnClick()",
on-accept-btn-click="$ctrl.onAcceptBtnClick()",
......
......@@ -7,7 +7,7 @@
templateUrl: '/linagora.esn.most/app/proposal/detail/subheader/most-proposal-detail-subheader.html',
bindings: {
title: '<',
showAction: '<',
userRole: '<',
onRejectBtnClick: '&',
onReviewBtnClick: '&',
onSetExpertsBtnClick: '&',
......
......@@ -5,17 +5,17 @@ block left
span.title.ellipsis {{::$ctrl.title}}
block right
ul.actions.flex-space-around(ng-if="$ctrl.showAction")
ul.actions.flex-space-around(ng-if="$ctrl.userRole !== 'user'")
li.contact-dropdown.dropdown
a(href='', data-toggle='dropdown')
i.mdi.mdi-dots-vertical
ul.dropdown-menu.dropdown-menu-right
li
a(href='', ng-click='$ctrl.onRejectBtnClick()') Từ chối
li
a(href='', ng-click='$ctrl.onSetExpertsBtnClick()') Thiết lập chuyên gia
li
li(ng-if="$ctrl.userRole === 'moderator'")
a(href='', ng-click='$ctrl.onAcceptBtnClick()') Duyệt
li
a(href='', ng-click="$ctrl.onReviewBtnClick()") Nhận xét và đánh giá
li(ng-if="$ctrl.userRole === 'moderator'")
a(href='', ng-click='$ctrl.onRejectBtnClick()') Từ chối
li(ng-if="$ctrl.userRole === 'moderator'")
a(href='', ng-click='$ctrl.onSetExpertsBtnClick()') Hỏi chuyên gia
li(ng-if="$ctrl.userRole === 'expert'")
a(href='', ng-click="$ctrl.onReviewBtnClick()") Nhận xét
......@@ -6,7 +6,7 @@
function MostProposalController(
$stateParams,
session,
mostRoleService,
mostProposalApiClient
) {
var self = this;
......@@ -15,7 +15,7 @@
function $onInit() {
self.status = 'loading';
self.showCreateBtn = !session.userIsDomainAdministrator();
self.showCreateBtn = mostRoleService.getRole() === 'user';
mostProposalApiClient.getProposals({ status: $stateParams.status }).then(function(proposals) {
self.status = 'loaded';
......
(function(angular) {
'use strict';
angular.module('linagora.esn.most')
.factory('mostRoleService', mostRoleService);
function mostRoleService(
session
) {
return {
getRole: getRole
};
function getRole() {
if (userIsExpert()) {
return 'expert';
}
if (session.userIsDomainAdministrator()) {
return 'moderator';
}
return 'user';
}
function userIsExpert() {
return session.user.preferredEmail.indexOf('chuyengia') === 0;
}
}
})(angular);