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"> <div ng-if="ctrl.isUserProducts">
<hr /> <hr />
<h4>Add new Product</h4> <h4>Add New Product</h4>
<div class="row"> <div class="row">
<div class="col-md-2"> <div class="col-md-2">
<label>Name</label> <label>Name</label>
@ -66,7 +66,13 @@
<button type="submit" class="btn btn-primary" ng-click="ctrl.addProduct()">Add Product</button> <button type="submit" class="btn btn-primary" ng-click="ctrl.addProduct()">Add Product</button>
</div> </div>
</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> </div>
<hr />
<div cg-busy="{promise:ctrl.authRequest,message:'Loading'}"></div> <div cg-busy="{promise:ctrl.authRequest,message:'Loading'}"></div>
<div cg-busy="{promise:ctrl.productsRequest,message:'Loading'}"></div> <div cg-busy="{promise:ctrl.productsRequest,message:'Loading'}"></div>

View File

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

View File

@ -35,7 +35,7 @@
<div ng-if="ctrl.isUserVendors"> <div ng-if="ctrl.isUserVendors">
<hr /> <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. <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. 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> 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> <button type="submit" class="btn btn-primary" ng-click="ctrl.addVendor()">Add Vendor</button>
</div> </div>
</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> </div>
<hr />
<div cg-busy="{promise:ctrl.vendorsRequest,message:'Loading'}"></div> <div cg-busy="{promise:ctrl.vendorsRequest,message:'Loading'}"></div>

View File

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