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

Merge branch 'POC' into 'master'

POC create review

See merge request !16
parents 3a89e698 4dc8285a
......@@ -13,7 +13,6 @@ module.exports = function(dependencies) {
const schema = new Schema({
creator: { type: ObjectId, ref: 'User', index: true, required: true },
proposal: { type: ObjectId, ref: 'MostProposal', required: true },
status: { type: String, enum: ['ACCEPTED', 'REJECTED'], required: true },
attachments: {type: [AttachmentSchema], required: false}
}, { timestamps: true });
......
......@@ -14,8 +14,10 @@ module.exports = function(dependencies) {
updateById
};
function create(proposal) {
return Review.create(proposal);
function create(review) {
review = review instanceof Review ? review : new Review(review);
return Review.create(review);
}
function getById(id) {
......
......@@ -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 #{__('Lấy ý kiến chuyên gia')}
h4.modal-title #{__('Thiết lập chuyên gia')}
.modal-body
p
| #{__('Chọn một nhóm chuyên gia:')}
......
......@@ -2,9 +2,9 @@
'use strict';
angular.module('linagora.esn.most')
.controller('MostProposalDetailReviewController', MostProposalDetailReviewController);
.controller('MostProposalDetailExpertsController', MostProposalDetailExpertsController);
function MostProposalDetailReviewController(
function MostProposalDetailExpertsController(
$state,
$stateParams,
$modal,
......
......@@ -6,8 +6,8 @@
function MostProposalDetailController(
$state,
$stateParams,
$modal,
$stateParams,
session,
mostProposalApiClient
) {
......@@ -15,8 +15,9 @@
self.$onInit = $onInit;
self.onRejectBtnClick = onRejectBtnClick;
self.onReviewBtnClick = onReviewBtnClick;
self.onSetExpertsBtnClick = onSetExpertsBtnClick;
self.onAcceptBtnClick = onAcceptBtnClick;
self.onReviewBtnClick = onReviewBtnClick;
function $onInit() {
self.showAction = session.userIsDomainAdministrator();
......@@ -33,13 +34,13 @@
});
}
function onReviewBtnClick() {
function onSetExpertsBtnClick() {
$modal({
templateUrl: '/linagora.esn.most/app/proposal/detail/review/modal.html',
templateUrl: '/linagora.esn.most/app/proposal/detail/experts/modal.html',
backdrop: 'static',
placement: 'center',
controllerAs: '$ctrl',
controller: 'MostProposalDetailReviewController',
controller: 'MostProposalDetailExpertsController',
locals: {
proposal: self.proposal
}
......@@ -52,5 +53,18 @@
$state.go('most.proposal');
});
}
function onReviewBtnClick() {
$modal({
templateUrl: '/linagora.esn.most/app/review/create/most-review-create.html',
backdrop: 'static',
placement: 'center',
controllerAs: '$ctrl',
controller: 'MostReviewCreateController',
locals: {
proposal: self.proposal
}
});
}
}
})(angular);
......@@ -3,8 +3,9 @@ sub-header
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()"
on-set-experts-btn-click="$ctrl.onSetExpertsBtnClick()",
on-accept-btn-click="$ctrl.onAcceptBtnClick()",
on-review-btn-click="$ctrl.onReviewBtnClick()"
)
.card
.card-body.p-20
......
......@@ -10,6 +10,7 @@
showAction: '<',
onRejectBtnClick: '&',
onReviewBtnClick: '&',
onSetExpertsBtnClick: '&',
onAcceptBtnClick: '&'
}
});
......
......@@ -13,7 +13,9 @@ block right
li
a(href='', ng-click='$ctrl.onRejectBtnClick()') Từ chối
li
a(href='', ng-click='$ctrl.onReviewBtnClick()') Xem xét
a(href='', ng-click='$ctrl.onSetExpertsBtnClick()') Thiết lập chuyên gia
li
a(href='', ng-click='$ctrl.onAcceptBtnClick()') Duyệt
li
a(href='', ng-click="$ctrl.onReviewBtnClick()") Nhận xét và đánh giá
(function(angular) {
'use strict';
angular.module('linagora.esn.most')
.controller('MostReviewCreateController', MostReviewCreateController);
function MostReviewCreateController(
_,
fileUploadService,
mostReviewApiClient,
proposal
) {
var self = this;
init();
self.onAttachmentsSelect = onAttachmentsSelect;
self.onSubmitBtnClick = onSubmitBtnClick;
function init() {
self.proposal = proposal;
self.attachments = [];
self.review = {
attachments: [],
proposal: proposal.id
};
}
function onSubmitBtnClick() {
var reviewToCreate = {
proposal: self.proposal.id,
attachments: self.attachments.map(function(attachment) {
return {
_id: attachment._id,
name: attachment.name,
contentType: attachment.type,
length: attachment.size
};
})
};
return mostReviewApiClient.createReview(reviewToCreate);
}
function onAttachmentsSelect($attachments) {
$attachments.forEach(function(file) {
self.attachments.push(file);
_upload(file);
});
}
function _upload(attachment) {
var uploader = fileUploadService.get();
var uploadTask = uploader.addFile(attachment); // Do not start the upload immediately
attachment.status = 'uploading';
attachment.upload = {
progress: 0,
cancel: uploadTask.cancel
};
attachment.upload.promise = uploadTask.defer.promise.then(function(task) {
attachment.status = 'uploaded';
attachment.blobId = task.response.blobId;
attachment._id = task.response.data._id;
}, function() {
attachment.status = 'error';
}, function(uploadTask) {
attachment.upload.progress = uploadTask.progress;
}).finally(_updateAttachmentStatus);
_updateAttachmentStatus();
uploader.start(); // Start transferring data
}
function _updateAttachmentStatus() {
self.attachmentStatus = {
number: self.attachments.length,
uploading: _.some(self.attachments, { status: 'uploading' }),
error: _.some(self.attachments, { status: 'error' })
};
}
}
})(angular);
.modal.full-screen(tabindex="-1", role="dialog")
form(name="form", esn-submit="$hide(); $ctrl.onSubmitBtnClick()")
.modal-dialog
.modal-content
.modal-header
button.close(type="button", ng-click="$hide()") &times;
h4.modal-title Nhận xét và đánh giá đề xuất
.modal-body.p-t-20
.flex
p.m-r-10 Tải lên file nhận xét:
input(
name="myFile",
type="file",
ng-file-select="$ctrl.onAttachmentsSelect($files)",
required
)
div(ng-switch="$ctrl.proposal.type")
.flex(ng-switch-when="A1")
p.m-r-20
label.m-r-10 Mẫu B1-TVHĐ:
| Đề tài/Dự án SXTN
a(href='') Tải về
.flex.flex-space-between(ng-switch-when="A2")
p
label.m-r-10 Mẫu B2-TVHĐ:
| Đề án khoa học
a(href='') Tải về
.flex.flex-space-between(ng-switch-when="A3")
p
label.m-r-10 Mẫu B3-TVHĐ:
| Dự án khoa học và công nghệ
a(href='') Tải về
.modal-footer
button.btn.btn-default(type="button", ng-click="$hide()") Hủy
button.btn.btn-primary(
type="submit",
ng-disabled="form.$invalid || $ctrl.attachmentStatus.error || $ctrl.attachmentStatus.uploading"
) Gửi
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