Commit a603a16b authored by Sang D NGO's avatar Sang D NGO
Browse files

Merge branch 'list-proposal' into 'master'

show proposal list

See merge request !7
parents 257f685c 9266f3e6
......@@ -7,7 +7,8 @@ function denormalize(proposal) {
type: proposal.type,
formData: proposal.formData,
status: proposal.status,
timestamps: proposal.timestamps,
createdAt: proposal.createdAt,
updatedAt: proposal.updatedAt,
reviewers: proposal.reviewers
};
}
@import './sidebar/most-sidebar';
@import './proposal/most-proposal';
.most-root {
& > .col-md-3, & > .col-md-8 {
margin-top: 45px;
@media (min-width: @screen-md-min) {
.most-root {
padding-top: 45px;
}
}
......@@ -15,23 +15,41 @@
};
function createProposal(data) {
return mostRestangular.all(API_PATH).post(data).then(_stripAndReturnData);
return mostRestangular.all(API_PATH).post(_encodeFormData(data)).then(_stripAndReturnData).then(_decodeFormData);
}
function getProposals(options) {
return mostRestangular.all(API_PATH).getList(options).then(_stripAndReturnData);
return mostRestangular.all(API_PATH).getList(options).then(_stripAndReturnData).then(function(proposals) {
return proposals.map(_decodeFormData);
});
}
function getProposal(id) {
return mostRestangular.one(API_PATH, id).get().then(_stripAndReturnData);
return mostRestangular.one(API_PATH, id).get().then(_stripAndReturnData).then(_decodeFormData);
}
function updateProposal(id, updateFields) {
return mostRestangular.one(API_PATH, id).customPOST(updateFields);
return mostRestangular.one(API_PATH, id).customPOST(_encodeFormData(updateFields)).then(_decodeFormData);
}
function _stripAndReturnData(resp) {
return mostRestangular.stripRestangular(resp.data);
}
function _decodeFormData(proposal) {
if (proposal.formData) {
proposal.formJson = JSON.parse(proposal.formData);
}
return proposal;
}
function _encodeFormData(proposal) {
if (proposal.formJson) {
proposal.formData = JSON.stringify(proposal.formJson);
}
return proposal;
}
}
})(angular);
(function(angular) {
'use strict';
angular.module('linagora.esn.most')
.component('mostProposalListItem', {
templateUrl: '/linagora.esn.most/app/proposal/list/item/most-proposal-list-item.html',
bindings: {
proposal: '<'
}
});
})(angular);
most-proposal-list-item {
& > .row {
.flex-space-between;
display: flex !important;
& > * {
.flex-vertical-centered;
}
}
& > .lv-actions {
top: 20px !important;
}
}
.row
.col-xs-6
h5.ellipsis(title="{{::$ctrl.proposal.formJson.title}}") {{::$ctrl.proposal.formJson.title}}
.col-xs-1
span.ellipsis(title="{{::$ctrl.proposal.type}}") {{::$ctrl.proposal.type}}
.col-xs-3
span(title=__('Cập nhật lúc %s', '{{::$ctrl.proposal.updatedAt}}'), am-time-ago="::$ctrl.proposal.updatedAt")
.col-xs-2
div(ng-switch="$ctrl.proposal.status")
span.text-muted(ng-switch-when="PENDING") Đang chờ
span.c-orange(ng-switch-when="REVIEWING") Đang xem xét
span.c-green(ng-switch-when="ACCEPTED") Đã chấp nhận
span.c-red(ng-switch-when="REJECTED") Đã từ chối
.lv-actions.actions
a(href="", data-toggle="dropdown", aria-expanded="false")
i.mdi.mdi-dots-vertical
ul.dropdown-menu.dropdown-menu-right
li
a(href="", esn-modal-launcher="/group/app/delete/group-delete.html") #{__('Delete')}
......@@ -4,6 +4,8 @@
angular.module('linagora.esn.most')
.component('mostProposalList', {
templateUrl: '/linagora.esn.most/app/proposal/list/most-proposal-list.html',
controller: 'MostProposalListController'
bindings: {
proposals: '<'
}
});
})(angular);
sub-header
most-proposal-list-subheader(data-title=__('Đề xuất'))
.card.fadeIn200ms
.listview.lv-bordered.lv-lg
.lv-body
most-proposal-list-item.lv-item.clickable(proposal='proposal', ng-repeat="proposal in $ctrl.proposals")
fab(icon="plus", ui-sref="most.proposal.create")
......@@ -2,9 +2,11 @@
'use strict';
angular.module('linagora.esn.most')
.controller('MostProposalListController', MostProposalListController);
function MostProposalListController() {
}
.component('mostProposalListSubheader', {
templateUrl: '/linagora.esn.most/app/proposal/list/subheader/most-proposal-list-subheader.html',
bindings: {
title: '@'
}
});
})(angular);
extends /modules/subheader/responsive-subheader.pug
block left
button.btn.btn-icon.btn-link.button.hidden-md(contextual-sidebar)
i.mdi.mdi-menu
span.title.ellipsis {{::$ctrl.title}}
......@@ -4,7 +4,18 @@
angular.module('linagora.esn.most')
.controller('MostProposalController', MostProposalController);
function MostProposalController() {
function MostProposalController(mostProposalApiClient) {
var self = this;
self.$onInit = $onInit;
function $onInit() {
self.status = 'loading';
mostProposalApiClient.getProposals().then(function(proposals) {
self.status = 'loaded';
self.proposals = proposals;
});
}
}
})(angular);
@import './create/most-proposal-create';
@import './list/item/most-proposal-list-item';
.card
most-proposal-list
most-proposal-list(proposals="$ctrl.proposals")
.text-center(ng-if="$ctrl.status === 'loading'", openpaas-logo-spinner, spinner-start-active='1', spinner-size='0.5')
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