Initial commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
(function () {
|
||||
global.dashModule
|
||||
.controller('addBidMarginCtrl', ['$scope', '$http', '$', '$translate', 'utilsService', addBidMarginCtrl])
|
||||
.directive('addBidMargin', [addBidMarginDirective]);
|
||||
|
||||
function addBidMarginDirective(){
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'bids/html/addBidMarginTemplate'
|
||||
};
|
||||
}
|
||||
function addBidMarginCtrl($scope, $http, $, $translate, utilsService) {
|
||||
$scope.init = init;
|
||||
$scope.saveBidMargin = saveBidMargin;
|
||||
$scope.bidMargin = {};
|
||||
|
||||
function init(bid){
|
||||
$scope.bidMargin.fixedExtra = bid.fixedExtra;
|
||||
$scope.bidMargin.recurrentExtra = bid.recurrentExtra;
|
||||
$scope.bidMargin.servicesExtra = bid.servicesExtra;
|
||||
}
|
||||
|
||||
function saveBidMargin(params){
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: 'bids/api/addBidMargin',
|
||||
data: $.param({
|
||||
idBid: params.bid.idBid,
|
||||
bidMargin: JSON.stringify($scope.bidMargin)
|
||||
})
|
||||
}).then((response)=>{displayMessage(response, params.getBids);} , utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function displayMessage(response, callback){
|
||||
if (typeof response.data.messages !== 'undefined') {
|
||||
response.data.messages.forEach((messageObj) => {
|
||||
const translatedMessage = $translate.instant('bids.messages.' + messageObj.message);
|
||||
utilsService.displayMessage(messageObj.code, translatedMessage);
|
||||
if(messageObj.code === 'success'){
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
145
api-wiaas/client/js/components/bids/add-bid.directive.js
Normal file
145
api-wiaas/client/js/components/bids/add-bid.directive.js
Normal file
@@ -0,0 +1,145 @@
|
||||
(function () {
|
||||
global.dashModule
|
||||
.controller('addBidCtrl', ['$scope', '$http', '$', '$translate', 'utilsService', addBidController])
|
||||
.directive('addBid', [addBidDirective]);
|
||||
|
||||
function addBidDirective() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'bids/html/addBidTemplate'
|
||||
};
|
||||
}
|
||||
|
||||
function addBidController($scope, $http, $, $translate, utilsService) {
|
||||
$scope.initAddBid = initAddBid;
|
||||
$scope.bid = {};
|
||||
$scope.onCLSelect = onCLSelect;
|
||||
$scope.onCustomerSelect = onCustomerSelect;
|
||||
$scope.onPackageSelect = onPackageSelect;
|
||||
$scope.onPayTypeSelect = onPayTypeSelect;
|
||||
$scope.isAddSupBidDialogVisible = false;
|
||||
$scope.isLinkSupBidDialogVisible = false;
|
||||
$scope.showSupBidDialog = showSupBidDialog;
|
||||
$scope.showLinkBidDialog = showLinkBidDialog;
|
||||
$scope.linkSuppliers = linkSuppliers;
|
||||
$scope.saveBid = saveBid;
|
||||
$scope.supplierBids = [];
|
||||
|
||||
function initAddBid() {
|
||||
getClCustomers();
|
||||
}
|
||||
|
||||
function getClCustomers() {
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: 'bids/api/getClCustomers'
|
||||
}).then(setClCustomers, utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function setClCustomers(response) {
|
||||
if (response.data) {
|
||||
$scope.clCustomers = response.data;
|
||||
}
|
||||
}
|
||||
|
||||
function getPackages(idCommercialLead, idCustomer) {
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: 'bids/api/getPackages',
|
||||
data: $.param({
|
||||
idCommercialLead,
|
||||
idCustomer
|
||||
})
|
||||
}).then(setPackages, utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function setPackages(response) {
|
||||
if (response.data) {
|
||||
$scope.packages = response.data;
|
||||
}
|
||||
}
|
||||
|
||||
function getPaymentTypes(idCommercialLead, idCustomer, idPackage) {
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: 'bids/api/getPayTypes',
|
||||
data: $.param({
|
||||
idCommercialLead,
|
||||
idCustomer,
|
||||
idPackage
|
||||
})
|
||||
}).then(setPayTypes, utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function setPayTypes(response) {
|
||||
if (response.data) {
|
||||
$scope.payTypes = response.data;
|
||||
}
|
||||
}
|
||||
|
||||
function onCLSelect(){
|
||||
$scope.selectedCustomer = null;
|
||||
}
|
||||
|
||||
function onCustomerSelect() {
|
||||
$scope.selectedPackage = null;
|
||||
$scope.bid.idCustomerInstance = $scope.selectedCustomer ? $scope.selectedCustomer.idCustomerInstance : 0;
|
||||
|
||||
if ($scope.selectedCl.idCommercialLead && $scope.selectedCustomer.idCustomer) {
|
||||
getPackages($scope.selectedCl.idCommercialLead, $scope.selectedCustomer.idCustomer);
|
||||
}
|
||||
}
|
||||
|
||||
function onPackageSelect() {
|
||||
$scope.selectedPayType = null;
|
||||
$scope.bid.idPackage = $scope.selectedPackage ? $scope.selectedPackage.idPackage : 0;
|
||||
if($scope.selectedCl.idCommercialLead && $scope.selectedCustomer.idCustomer && $scope.selectedPackage){
|
||||
getPaymentTypes($scope.selectedCl.idCommercialLead, $scope.selectedCustomer.idCustomer, $scope.selectedPackage.idPackage);
|
||||
}
|
||||
}
|
||||
|
||||
function onPayTypeSelect() {
|
||||
$scope.bid.idPaymentType = $scope.selectedPayType ? $scope.selectedPayType.idPaymentType : 0;
|
||||
}
|
||||
|
||||
function showSupBidDialog() {
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.isAddSupBidDialogVisible = !$scope.isAddSupBidDialogVisible;
|
||||
});
|
||||
}
|
||||
|
||||
function showLinkBidDialog() {
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.isLinkSupBidDialogVisible = !$scope.isLinkSupBidDialogVisible;
|
||||
});
|
||||
}
|
||||
|
||||
function linkSuppliers(params){
|
||||
$scope.bid.supplierBids = params.selectedBids;
|
||||
}
|
||||
|
||||
function saveBid(){
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: 'bids/api/addBid',
|
||||
data: $.param({
|
||||
bid: JSON.stringify($scope.bid)
|
||||
})
|
||||
}).then(displayMessage, utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function displayMessage(response){
|
||||
if (typeof response.data.messages !== 'undefined') {
|
||||
response.data.messages.forEach((messageObj) => {
|
||||
const translatedMessage = $translate.instant('bids.messages.' + messageObj.message);
|
||||
utilsService.displayMessage(messageObj.code, translatedMessage);
|
||||
if(messageObj.code === 'success'){
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.bid = {};
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,73 @@
|
||||
(function () {
|
||||
global.dashModule
|
||||
.controller('addSupplierBidCtrl', ['$scope', '$http', '$', '$translate', 'utilsService', addSupplierBidCtrl]);
|
||||
|
||||
function addSupplierBidCtrl($scope, $http, $, $translate, utilsService) {
|
||||
$scope.getSuppliers = getSuppliers();
|
||||
$scope.saveSupplierBid = saveSupplierBid;
|
||||
$scope.onSupplierSelect = onSupplierSelect;
|
||||
$scope.onProductSelect = onProductSelect;
|
||||
$scope.supplierBid = {};
|
||||
|
||||
function getSuppliers(){
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: 'bids/api/getSuppliers'
|
||||
}).then(setSuplliers, utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function setSuplliers(response){
|
||||
if (response.data) {
|
||||
$scope.suppliers = response.data;
|
||||
}
|
||||
}
|
||||
|
||||
function getProducts(idSupplier){
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: 'bids/api/getProducts',
|
||||
data: $.param({
|
||||
idSupplier
|
||||
})
|
||||
}).then(setProducts, utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function setProducts(response){
|
||||
if (response.data) {
|
||||
$scope.products = response.data;
|
||||
}
|
||||
}
|
||||
|
||||
function onSupplierSelect(){
|
||||
$scope.selectedProduct = null;
|
||||
$scope.supplierBid.idSupplier = $scope.selectedSupplier.idSupplier;
|
||||
|
||||
if ($scope.selectedSupplier.idSupplier) {
|
||||
getProducts($scope.selectedSupplier.idSupplier);
|
||||
}
|
||||
}
|
||||
|
||||
function onProductSelect(){
|
||||
$scope.supplierBid.idProduct = $scope.selectedProduct ? $scope.selectedProduct.idProduct : 0;
|
||||
}
|
||||
|
||||
function saveSupplierBid(){
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: 'bids/api/addSupplierBid',
|
||||
data: $.param({
|
||||
supplierBid: JSON.stringify($scope.supplierBid)
|
||||
})
|
||||
}).then(displayMessage, utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function displayMessage(response){
|
||||
if (typeof response.data.messages !== 'undefined') {
|
||||
response.data.messages.forEach((messageObj) => {
|
||||
const translatedMessage = $translate.instant('bids.messages.' + messageObj.message);
|
||||
utilsService.displayMessage(messageObj.code, translatedMessage);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
112
api-wiaas/client/js/components/bids/bids-view.directive.js
Normal file
112
api-wiaas/client/js/components/bids/bids-view.directive.js
Normal file
@@ -0,0 +1,112 @@
|
||||
(function () {
|
||||
global.dashModule
|
||||
.controller('bidsViewCtrl', ['$scope', '$http', '$', '$translate', 'utilsService', bidsViewController])
|
||||
.directive('bidsView', [bidsViewDirective]);
|
||||
|
||||
function bidsViewDirective() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'bids/html/bidsViewTemplate'
|
||||
};
|
||||
}
|
||||
|
||||
function bidsViewController($scope, $http, $, $translate, utilsService) {
|
||||
$scope.getBids = getBids;
|
||||
$scope.showBidMarginDialog = showBidMarginDialog;
|
||||
$scope.closeBidMarginDialog = closeBidMarginDialog;
|
||||
$scope.showBidRemoveDialog = showBidRemoveDialog;
|
||||
$scope.closeRemoveDialog = closeRemoveDialog;
|
||||
$scope.isCommercialLead = isCommercialLead;
|
||||
$scope.filterBids = filterBids;
|
||||
$scope.isUsedText = isUsedText;
|
||||
$scope.filteredBids = [];
|
||||
$scope.bidType = 'all';
|
||||
let bids = [];
|
||||
$scope.isMarginsDialogVisible = {};
|
||||
$scope.isRemoveDialogVisible = {};
|
||||
$scope.HEADER_COL = 'bid-header col-lg-4 col-md-5 col-sm-6 col-xs-6';
|
||||
$scope.LABEL_COL = 'col-lg-8 col-md-7 col-sm-6 col-xs-6';
|
||||
let userType = '';
|
||||
|
||||
function getBids() {
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: 'bids/api/getBids',
|
||||
data: $.param({
|
||||
filter: {}
|
||||
})
|
||||
}).then(setBids, utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function setBids(response) {
|
||||
if (response.data && response.data.bids) {
|
||||
bids = response.data.bids;
|
||||
$scope.filteredBids = bids;
|
||||
userType = response.data.userType;
|
||||
}
|
||||
}
|
||||
|
||||
function isCommercialLead() {
|
||||
return userType === 'commercial_lead';
|
||||
}
|
||||
|
||||
function showBidMarginDialog(idBid) {
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.isMarginsDialogVisible[idBid] = !$scope.isMarginsDialogVisible[idBid];
|
||||
});
|
||||
}
|
||||
|
||||
function closeBidMarginDialog() {
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.isMarginsDialogVisible = {};
|
||||
});
|
||||
}
|
||||
|
||||
function showBidRemoveDialog(idBid) {
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.isRemoveDialogVisible[idBid] = !$scope.isRemoveDialogVisible[idBid];
|
||||
});
|
||||
}
|
||||
|
||||
function closeRemoveDialog() {
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.isRemoveDialogVisible = {};
|
||||
});
|
||||
}
|
||||
|
||||
function isSearchedValue(bid, searchText){
|
||||
const regExpresion = new RegExp(searchText, 'i');
|
||||
return regExpresion.test(String(bid.bidNumber)) ||
|
||||
regExpresion.test(bid.packageName) ||
|
||||
regExpresion.test(bid.customer) ||
|
||||
regExpresion.test(bid.commercialLead);
|
||||
}
|
||||
|
||||
function filterBids(filterType) {
|
||||
if (filterType === 'all') {
|
||||
$scope.filteredBids = bids;
|
||||
$scope.searchText = '';
|
||||
}else if (filterType === 'available') {
|
||||
$scope.filteredBids = bids.filter((bid) => {
|
||||
return bid.status === 'available' && isSearchedValue(bid, $scope.searchText);
|
||||
});
|
||||
}else if (filterType === 'used') {
|
||||
$scope.filteredBids = bids.filter((bid) => {
|
||||
return bid.isUsed === 1 && isSearchedValue(bid, $scope.searchText);
|
||||
});
|
||||
}else if (filterType === 'expired') {
|
||||
$scope.filteredBids = bids.filter((bid) => {
|
||||
return bid.status === 'expired' && isSearchedValue(bid, $scope.searchText);
|
||||
});
|
||||
}else{
|
||||
$scope.filteredBids = bids.filter((bid) => {
|
||||
return isSearchedValue(bid, $scope.searchText);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function isUsedText(bid){
|
||||
return bid.isUsed === 1 ? 'Yes' : 'No';
|
||||
}
|
||||
}
|
||||
})();
|
||||
38
api-wiaas/client/js/components/bids/bids.directive.js
Normal file
38
api-wiaas/client/js/components/bids/bids.directive.js
Normal file
@@ -0,0 +1,38 @@
|
||||
(function () {
|
||||
global.dashModule
|
||||
.controller('bidsCtrl', ['$scope', bidsController])
|
||||
.directive('bids', [bidsDirective]);
|
||||
|
||||
function bidsDirective() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'bids/html/bidsTemplate'
|
||||
};
|
||||
}
|
||||
|
||||
function bidsController($scope) {
|
||||
$scope.isSubmoduleVisible = isSubmoduleVisible;
|
||||
$scope.setSubModule = setSubModule;
|
||||
$scope.subModule = global.getParameterByName('subModule') || 'bidsView';
|
||||
addUrlListener();
|
||||
|
||||
function addUrlListener() {
|
||||
window.addEventListener('popstate', function (e) {
|
||||
$scope.$evalAsync($scope => {
|
||||
$scope.subModule = e.state ? e.state.subModule : 'bidsView';
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
function setSubModule($event) {
|
||||
$scope.subModule = $event.currentTarget.attributes.subModule.value;
|
||||
history.pushState({
|
||||
subModule: $scope.subModule
|
||||
}, null, '?subModule=' + $scope.subModule);
|
||||
}
|
||||
|
||||
function isSubmoduleVisible(subModule) {
|
||||
return subModule === $scope.subModule;
|
||||
}
|
||||
}
|
||||
})();
|
||||
82
api-wiaas/client/js/components/bids/bids.less
Normal file
82
api-wiaas/client/js/components/bids/bids.less
Normal file
@@ -0,0 +1,82 @@
|
||||
@background-layer: rgba(255, 255, 255, 0.8);
|
||||
|
||||
.module-layer {
|
||||
background: @background-layer;
|
||||
margin-top: 1%;
|
||||
margin-bottom: 2%;
|
||||
}
|
||||
|
||||
#bids-view{
|
||||
.module-layer;
|
||||
|
||||
.bid-item{
|
||||
position: relative;
|
||||
display: block;
|
||||
padding: 1rem;
|
||||
border: 1px solid #3bb9ff;
|
||||
border-radius: 5px;
|
||||
min-height: 36rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.bid-header{
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.bid-date{
|
||||
font-size: 70%;
|
||||
}
|
||||
|
||||
.bid-number{
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.add-bid-margin-btn, .remove-bid-btn{
|
||||
position: absolute;
|
||||
margin-top: 1rem;
|
||||
bottom: 1rem;
|
||||
left: 2rem;
|
||||
}
|
||||
|
||||
.expired {
|
||||
background: rgba(217, 83, 79, 0.1);
|
||||
}
|
||||
|
||||
.used-status {
|
||||
color: rgb(31, 97, 141);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.expired-status{
|
||||
color: rgb(217, 83, 79);
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
#add-bid{
|
||||
.module-layer;
|
||||
}
|
||||
|
||||
#link-supplier-bids{
|
||||
.supplier-bid-header{
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.supplier-bid{
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.supplier-bid:hover{
|
||||
background: rgba(255, 255, 0, 0.5);
|
||||
|
||||
}
|
||||
|
||||
.supplier-bids-list{
|
||||
height: 25rem;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
.selected-bid{
|
||||
background: rgba(59, 185, 255, 0.2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
(function () {
|
||||
global.dashModule
|
||||
.controller('linkSupplierBidsCtrl', ['$scope', '$http', '$', '$translate', 'utilsService', linkSupplierBidsCtrl]);
|
||||
|
||||
function linkSupplierBidsCtrl($scope, $http, $, $translate, utilsService) {
|
||||
$scope.getUnlinkedSupplierBids = getUnlinkedSupplierBids();
|
||||
$scope.onSupBidSelect = onSupBidSelect;
|
||||
$scope.init = init;
|
||||
$scope.supplierBids = [];
|
||||
$scope.selectedBids = [];
|
||||
let existingSelection = [];
|
||||
|
||||
function init(supplierBids){
|
||||
existingSelection = supplierBids || [];
|
||||
}
|
||||
|
||||
function getUnlinkedSupplierBids(){
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: 'bids/api/getUnlinkedSupplierBids'
|
||||
}).then(setUnlinkedSupplierBids, utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function setUnlinkedSupplierBids(response){
|
||||
if (response.data) {
|
||||
$scope.supplierBids = response.data;
|
||||
if(existingSelection){
|
||||
existingSelection.forEach((existingSelection) => {
|
||||
const selected = $scope.supplierBids.find((supplierBid) => {
|
||||
return existingSelection.idSupplierBid === supplierBid.idSupplierBid;
|
||||
});
|
||||
onSupBidSelect(selected);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onSupBidSelect(supplierBid){
|
||||
const elemPosition = $scope.selectedBids.indexOf(supplierBid);
|
||||
|
||||
if(elemPosition === -1){
|
||||
supplierBid.class = 'selected-bid';
|
||||
$scope.selectedBids.push(supplierBid);
|
||||
}else{
|
||||
supplierBid.class = 'not-selected-bid';
|
||||
$scope.selectedBids.splice(elemPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
30
api-wiaas/client/js/components/bids/remove-bid.controller.js
Normal file
30
api-wiaas/client/js/components/bids/remove-bid.controller.js
Normal file
@@ -0,0 +1,30 @@
|
||||
(function () {
|
||||
global.dashModule
|
||||
.controller('removeBidCtrl', ['$scope', '$http', '$', '$translate', 'utilsService', removeBidCtrl]);
|
||||
|
||||
function removeBidCtrl($scope, $http, $, $translate, utilsService) {
|
||||
$scope.removeBid = removeBid;
|
||||
|
||||
function removeBid(params){
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: 'bids/api/removeBid',
|
||||
data: $.param({
|
||||
idBid: params.bid.idBid
|
||||
})
|
||||
}).then((response)=>{displayMessage(response, params.getBids);} , utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function displayMessage(response, callback){
|
||||
if (typeof response.data.messages !== 'undefined') {
|
||||
response.data.messages.forEach((messageObj) => {
|
||||
const translatedMessage = $translate.instant('bids.messages.' + messageObj.message);
|
||||
utilsService.displayMessage(messageObj.code, translatedMessage);
|
||||
if(messageObj.code === 'success'){
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user