-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unverified Buyer List #186
base: develop
Are you sure you want to change the base?
Changes from 5 commits
c4003a4
844db51
628ecd4
f7779b6
0d1270d
b188243
5bb088b
9245743
efc96bc
8505307
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
angular.module('jasmic.controllers') | ||
.controller('AdministratorCtrl', ['$scope','$mdDialog', '$mdToast','UsersFactory','CropsFactory','SuppliersFactory', | ||
.controller('AdministratorCtrl', ['$scope','$mdDialog', '$mdToast','$window','UsersFactory','CropsFactory','SuppliersFactory', | ||
'UserFactory','CropFactory','SupplierFactory', 'EmailFactory', 'UserProfileFactory', 'ParishesFactory', | ||
function($scope, $mdDialog, $mdToast, UsersFactory, CropsFactory, SuppliersFactory, UserFactory, CropFactory, | ||
SupplierFactory, EmailFactory, UserProfileFactory, ParishesFactory){ | ||
'BuyersListingFactory', 'BuyerFactory', | ||
function($scope, $mdDialog, $mdToast, $window, UsersFactory, CropsFactory, SuppliersFactory, UserFactory, CropFactory, | ||
SupplierFactory, EmailFactory, UserProfileFactory, ParishesFactory, BuyersListingFactory, BuyerFactory){ | ||
/** | ||
* Get all users from the database. | ||
*/ | ||
|
@@ -47,24 +48,38 @@ angular.module('jasmic.controllers') | |
}); | ||
} | ||
getParishes(); | ||
/** | ||
* Gets all unverified buyers from the database | ||
*/ | ||
getUnverifiedBuyers = function(){ | ||
BuyersListingFactory.query({bu_verified: "Unverified"}, function(buyers){ | ||
$scope.buyers = buyers; | ||
},function(error){ | ||
$scope.buyers = []; | ||
}); | ||
} | ||
getUnverifiedBuyers(); | ||
|
||
$scope.user_obj = {}; | ||
$scope.crop_type = {}; | ||
$scope.supplier = {}; | ||
$scope.buyer = {}; | ||
$scope.usertypes = ['Administrator', 'Call Representative']; | ||
$scope.states = ['Approved', 'Pending']; | ||
$scope.buyer_states = ['Unverified', 'Verified']; | ||
/** | ||
* Used to toggle list of records. | ||
* @type {{user: boolean, croptype: boolean, supplier: boolean}} | ||
*/ | ||
$scope.hideList = { user: false, croptype: false, supplier: false}; | ||
$scope.hideList = { user: false, croptype: false, supplier: false, buyer: false}; | ||
/** | ||
* Determines if form to create user must edit a record or create a new record. | ||
* @type {boolean} | ||
*/ | ||
$scope.editUser = false; | ||
$scope.editCrop = false; | ||
$scope.editSupplier = false; | ||
$scope.editBuyer = false; | ||
/** | ||
* Displays form specific to each entity i.e. user, crop or supplier. | ||
* @param entity | ||
|
@@ -118,6 +133,13 @@ angular.module('jasmic.controllers') | |
} | ||
getSuppliers(); | ||
$scope.hideList.supplier = !$scope.hideList.supplier; | ||
}else if(entity === 'buyer'){ | ||
if($scope.editBuyer){ | ||
$scope.editBuyer = !$scope.editBuyer; | ||
} | ||
$scope.buyer = {}; | ||
getUnverifiedBuyers(); | ||
$scope.hideList.buyer = !$scope.hideList.buyer; | ||
} | ||
}; | ||
/** | ||
|
@@ -182,6 +204,10 @@ angular.module('jasmic.controllers') | |
$scope.hideList.supplier = !$scope.hideList.supplier; | ||
$scope.supplier = obj; | ||
break; | ||
case 'buyer' : $scope.editBuyer = !$scope.editBuyer; | ||
$scope.hideList.buyer = !$scope.hideList.buyer; | ||
$scope.buyer = obj; | ||
break; | ||
default: showDialog($mdDialog,{statusText: "Error"}, false); | ||
break | ||
} | ||
|
@@ -197,6 +223,8 @@ angular.module('jasmic.controllers') | |
updateCrop(); | ||
}else if(type === 'supplier'){ | ||
updateSupplier(); | ||
}else if(type === 'buyer'){ | ||
updateBuyer(); | ||
} | ||
}; | ||
/** | ||
|
@@ -236,6 +264,7 @@ angular.module('jasmic.controllers') | |
*/ | ||
function updateSupplier(){ | ||
SupplierFactory.update({id:$scope.supplier._id}, $scope.supplier, function(success){ | ||
$window.scrollTo(0,0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @matjames007 here's the reference to the line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh when u are updating the supplier! not the buyer...lol ok There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @matjames007 actually both! lol.. |
||
showDialog($mdDialog, {statusText: 'Supplier Updated!'}, false); | ||
}, function(error){ | ||
showDialog($mdDialog, error, false); | ||
|
@@ -244,6 +273,21 @@ angular.module('jasmic.controllers') | |
$scope.hideList.supplier = !$scope.hideList.supplier; | ||
getSuppliers(); | ||
} | ||
/** | ||
* Updates a buyer record. Requires admin privileges. | ||
*/ | ||
function updateBuyer(){ | ||
BuyerFactory.update({id: $scope.buyer._id}, $scope.buyer, function(success){ | ||
$window.scrollTo(0,0); | ||
showDialog($mdDialog,{statusText: "Buyer Updated!"}, false); | ||
$scope.buyer = {}; | ||
$scope.editBuyer = !$scope.editBuyer; | ||
}, function(error){ | ||
showDialog($mdDialog, error, false); | ||
}); | ||
$scope.hideList.buyer = !$scope.hideList.buyer; | ||
getUnverifiedBuyers(); | ||
} | ||
}]); | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<md-content layout-padding layout="column"> | ||
<div layout="row"> | ||
<md-input-container flex> | ||
<label>Buyer Name</label> | ||
<input type="text" ng-model="buyer.bu_buyer_name"> | ||
</md-input-container> | ||
<md-input-container flex> | ||
<label>Buyer Type</label> | ||
<input type="text" ng-model="buyer.bt_buyer_type.bt_buyer_type_name"> | ||
</md-input-container> | ||
<md-input-container flex> | ||
<label>Contact</label> | ||
<input type="text" ng-model="buyer.bu_phone"> | ||
</md-input-container> | ||
</div> | ||
|
||
<div layout="row"> | ||
<md-input-container flex> | ||
<label>Address 1</label> | ||
<input type="text" ng-model="buyer.ad_address.ad_address1"> | ||
</md-input-container> | ||
<md-input-container flex> | ||
<label>Address 2</label> | ||
<input type="text" ng-model="buyer.ad_address.ad_address2"> | ||
</md-input-container> | ||
<md-select placeholder="Parish" ng-model="buyer.ad_address.pa_parish" flex> | ||
<md-option ng-repeat="parish in parishes" value={{parish.pa_parish_name}}>{{parish.pa_parish_name}}</md-option> | ||
</md-select> | ||
</div> | ||
|
||
<div layout="row"> | ||
<md-input-container flex> | ||
<label>Email</label> | ||
<input type="text" ng-model="buyer.bu_email"> | ||
</md-input-container> | ||
<md-input-container flex> | ||
<label>Payment Terms</label> | ||
<input type="text" ng-model="buyer.bu_payment_terms"> | ||
</md-input-container> | ||
<md-select placeholder="Verified" ng-model="buyer.bu_verified" flex> | ||
<md-option ng-repeat="state in buyer_states" value={{state}}>{{state}}</md-option> | ||
</md-select> | ||
</div> | ||
|
||
<md-input-container layout="row" layout-align="center center"> | ||
<md-button ng-click="cancel('buyer')">Cancel</md-button> | ||
<md-button ng-click="update('buyer')" ng-if="editBuyer">Update</md-button> | ||
</md-input-container> | ||
</md-content> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matjames007 I encountered an issue after updating a buyer. The screen would turn grey but the dialog box was not seen. In testing the branch, you can remove the $window.scroll line to see if you get encounter this behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't seen the behaviour described. I also haven't seen the
$window.scroll
line u mentioned. Could you point me to the file and line number on this branch?