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