Intial
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.app.directive('addOpportunity', addOpportunity);
|
||||
|
||||
function addOpportunity() {
|
||||
return {
|
||||
scope: {
|
||||
customer: "="
|
||||
},
|
||||
templateUrl: '/opportunity/template/addOpportunity.tmpl.cshtml',
|
||||
controller: controller,
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope', '$http'];
|
||||
function controller($scope, $http) {
|
||||
var vm = this;
|
||||
|
||||
vm.saving = false;
|
||||
vm.opportunity = {
|
||||
customerId: $scope.customer.id
|
||||
}
|
||||
|
||||
vm.add = add;
|
||||
|
||||
function add() {
|
||||
vm.saving = true;
|
||||
|
||||
$http.post('/Opportunity/Add', vm.opportunity)
|
||||
.success(function (data) {
|
||||
$scope.customer.opportunities.push(data);
|
||||
//Close the modal
|
||||
$scope.$parent.$close();
|
||||
})
|
||||
.error(function (data) {
|
||||
vm.errorMessage = "There was a problem adding the opportunity: " + data;
|
||||
})
|
||||
.finally(function () {
|
||||
vm.saving = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,31 @@
|
||||
@using InventoryTraker.Web.Helpers
|
||||
@model InventoryTraker.Web.Models.AddOpportunityForm
|
||||
<form novalidate
|
||||
ng-submit="vm.form.$valid && vm.add()"
|
||||
name="vm.form">
|
||||
<fieldset ng-disabled="vm.saving">
|
||||
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Add New Opportunity</h3>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="alert alert-info" ng-hide="vm.errorMessage != null">
|
||||
Enter details for the new opportunity.
|
||||
</div>
|
||||
<div class="alert alert-danger" ng-show="vm.errorMessage != null">
|
||||
{{vm.errorMessage}}
|
||||
</div>
|
||||
|
||||
@Html.Angular().FormForModel("vm.opportunity")
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-success">Add Opportunity</button>
|
||||
<button type="button" class="btn btn-warning" ng-click="$parent.$dismiss()">Cancel</button>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
Reference in New Issue
Block a user