Commit 3a89e698 authored by Tuan Tuan LE's avatar Tuan Tuan LE

Merge branch 'admin-aware' into 'master'

Admin aware

See merge request !15
parents 37b37b76 65fd95d4
......@@ -37,7 +37,7 @@ module.exports = function(dependencies, lib) {
function getProposals(req, res) {
var listOptions = {
creator: req.user.id,
creator: req.query.creator,
type: req.query.type,
status: req.query.status,
limit: Number(req.query.limit),
......
......@@ -6,7 +6,10 @@
var API_PATH = 'proposals';
function mostProposalApiClient(mostRestangular) {
function mostProposalApiClient(
session,
mostRestangular
) {
return {
createProposal: createProposal,
getProposals: getProposals,
......@@ -19,6 +22,10 @@
}
function getProposals(options) {
if (!session.userIsDomainAdministrator()) {
options.creator = session.user._id;
}
return mostRestangular.all(API_PATH).getList(options).then(_stripAndReturnData).then(function(proposals) {
return proposals.map(_decodeFormData);
});
......
......@@ -8,6 +8,7 @@
$state,
$stateParams,
$modal,
session,
mostProposalApiClient
) {
var self = this;
......@@ -18,6 +19,7 @@
self.onAcceptBtnClick = onAcceptBtnClick;
function $onInit() {
self.showAction = session.userIsDomainAdministrator();
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",
on-reject-btn-click="$ctrl.onRejectBtnClick()",
on-review-btn-click="$ctrl.onReviewBtnClick()",
on-accept-btn-click="$ctrl.onAcceptBtnClick()"
......
......@@ -7,6 +7,7 @@
templateUrl: '/linagora.esn.most/app/proposal/detail/subheader/most-proposal-detail-subheader.html',
bindings: {
title: '<',
showAction: '<',
onRejectBtnClick: '&',
onReviewBtnClick: '&',
onAcceptBtnClick: '&'
......
......@@ -5,7 +5,7 @@ block left
span.title.ellipsis {{::$ctrl.title}}
block right
ul.actions.flex-space-around
ul.actions.flex-space-around(ng-if="$ctrl.showAction")
li.contact-dropdown.dropdown
a(href='', data-toggle='dropdown')
i.mdi.mdi-dots-vertical
......
......@@ -18,4 +18,4 @@
i.mdi.mdi-dots-vertical
ul.dropdown-menu.dropdown-menu-right
li
a(href="", esn-modal-launcher="/group/app/delete/group-delete.html") #{__('Delete')}
a(href="", ui-sref="most.proposal.detail({proposalId: $ctrl.proposal.id})") #{__('Xem')}
......@@ -5,5 +5,3 @@ sub-header
.listview.lv-bordered.lv-lg
.lv-body
most-proposal-list-item.lv-item(proposal='proposal', ng-repeat="proposal in $ctrl.proposals")
fab(icon="plus", ui-sref="most.proposal.create")
......@@ -6,6 +6,7 @@
function MostProposalController(
$stateParams,
session,
mostProposalApiClient
) {
var self = this;
......@@ -14,6 +15,7 @@
function $onInit() {
self.status = 'loading';
self.showCreateBtn = !session.userIsDomainAdministrator();
mostProposalApiClient.getProposals({ status: $stateParams.status }).then(function(proposals) {
self.status = 'loaded';
......
......@@ -2,3 +2,5 @@
most-proposal-list(proposals="$ctrl.proposals")
.text-center(ng-if="$ctrl.status === 'loading'", openpaas-logo-spinner, spinner-start-active='1', spinner-size='0.5')
fab(ng-if="$ctrl.showCreateBtn", icon="plus", ui-sref="most.proposal.create")
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