Show message when vendor/product is created

When a vendor or product is successfully created, a 'success'
message is given to the user. Also, input fields for product/vendor
creation now are only cleared on success.

Change-Id: I82a97061114bbc3d342368a74aa9ebc9463a31d0
This commit is contained in:
Paul Van Eck 2017-02-02 14:56:50 -08:00
parent 95e79460e7
commit b68c3d0c81
4 changed files with 25 additions and 6 deletions

View File

@ -33,7 +33,7 @@
<div ng-if="ctrl.isUserProducts">
<hr />
<h4>Add new Product</h4>
<h4>Add New Product</h4>
<div class="row">
<div class="col-md-2">
<label>Name</label>
@ -66,7 +66,13 @@
<button type="submit" class="btn btn-primary" ng-click="ctrl.addProduct()">Add Product</button>
</div>
</div>
<div ng-show="ctrl.showSuccess" class="alert alert-success" role="success">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
<span class="sr-only">Success:</span>
Product successfully created.
</div>
</div>
<hr />
<div cg-busy="{promise:ctrl.authRequest,message:'Loading'}"></div>
<div cg-busy="{promise:ctrl.productsRequest,message:'Loading'}"></div>

View File

@ -182,6 +182,8 @@
* This will add new Product record.
*/
function addProduct() {
ctrl.showSuccess = false;
ctrl.showError = false;
var url = refstackApiUrl + '/products';
var data = {
name: ctrl.name,
@ -189,10 +191,12 @@
organization_id: ctrl.organizationId,
product_type: parseInt(ctrl.productType)
};
ctrl.name = '';
ctrl.description = '';
$http.post(url, data).success(function (data) {
ctrl.rawData = null;
ctrl.showSuccess = true;
ctrl.name = '';
ctrl.description = '';
ctrl.productType = null;
ctrl.update();
}).error(function (error) {
ctrl.showError = true;

View File

@ -35,7 +35,7 @@
<div ng-if="ctrl.isUserVendors">
<hr />
<h4>Add new vendor</h4>
<h4>Add New Vendor</h4>
<p>Creating a vendor allows you to associate test results to specific vendors/products.
Created vendors are private, but vendors can be registered with the Foundation to become public and official.
This will require approval by a Foundation administrator.</p>
@ -58,7 +58,13 @@
<button type="submit" class="btn btn-primary" ng-click="ctrl.addVendor()">Add Vendor</button>
</div>
</div>
<div ng-show="ctrl.showSuccess" class="alert alert-success" role="success">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
<span class="sr-only">Success:</span>
Vendor successfully created.
</div>
</div>
<hr />
<div cg-busy="{promise:ctrl.vendorsRequest,message:'Loading'}"></div>

View File

@ -141,14 +141,17 @@
* This will add a new vendor record.
*/
function addVendor() {
ctrl.showSuccess = false;
ctrl.showError = false;
var url = refstackApiUrl + '/vendors';
var data = {
name: ctrl.name,
description: ctrl.description
};
ctrl.name = '';
ctrl.description = '';
$http.post(url, data).success(function (data) {
ctrl.showSuccess = true;
ctrl.name = '';
ctrl.description = '';
ctrl.rawData = null;
ctrl.update();
}).error(function (error) {