Intial
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.app = angular.module('InventoryTraker', ['ngAnimate', 'ui.bootstrap', 'ui.grid']);
|
||||
})();
|
||||
@@ -0,0 +1,30 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
window.app.controller('LoginController', LoginController);
|
||||
|
||||
LoginController.$inject = ['$window', '$http'];
|
||||
function LoginController($window, $http) {
|
||||
var vm = this;
|
||||
vm.errorMessage = null;
|
||||
vm.loggingIn = false;
|
||||
vm.login = login;
|
||||
|
||||
function login() {
|
||||
|
||||
vm.loggingIn = true;
|
||||
vm.errorMessage = null;
|
||||
|
||||
$http.post("/Authentication/Login", { emailAddress: vm.emailAddress, password: vm.password })
|
||||
.success(function() {
|
||||
$window.location.href = "/";
|
||||
})
|
||||
.error(function(data) {
|
||||
vm.errorMessage = "There was a problem logging in: " + data;
|
||||
})
|
||||
.finally(function() {
|
||||
vm.loggingIn = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,38 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.app.directive('addCustomer', addCustomer);
|
||||
|
||||
function addCustomer() {
|
||||
return {
|
||||
templateUrl: '/customer/template/addCustomer.tmpl.cshtml',
|
||||
controller: controller,
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope', 'customerSvc'];
|
||||
function controller($scope, customerSvc) {
|
||||
var vm = this;
|
||||
vm.add = add;
|
||||
|
||||
vm.saving = false;
|
||||
vm.customer = {};
|
||||
vm.errorMessage = null;
|
||||
|
||||
function add() {
|
||||
vm.saving = true;
|
||||
customerSvc.add(vm.customer)
|
||||
.success(function () {
|
||||
//Close the modal
|
||||
$scope.$close();
|
||||
})
|
||||
.error(function(data) {
|
||||
vm.errorMessage = 'There was a problem adding the customer: ' + data;
|
||||
})
|
||||
.finally(function() {
|
||||
vm.saving = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,54 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.app.directive('customerDetails', customerDetails);
|
||||
function customerDetails() {
|
||||
return {
|
||||
scope: {
|
||||
customer: '='
|
||||
},
|
||||
templateUrl: '/customer/template/customerDetails.tmpl.cshtml',
|
||||
controller: controller,
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope', '$uibModal'];
|
||||
function controller($scope, $uibModal) {
|
||||
var vm = this;
|
||||
|
||||
vm.customer = $scope.customer;
|
||||
vm.selectedView = 'details';
|
||||
vm.setView = setView;
|
||||
vm.edit = edit;
|
||||
vm.addOpportunity = addOpportunity;
|
||||
vm.addRisk = addRisk;
|
||||
vm.customer = $scope.customer;
|
||||
|
||||
function setView(view) {
|
||||
vm.selectedView = view;
|
||||
}
|
||||
|
||||
|
||||
function edit() {
|
||||
$uibModal.open({
|
||||
template: '<edit-customer customer="customer" />',
|
||||
scope: angular.extend($scope.$new(true), { customer: vm.customer })
|
||||
});
|
||||
}
|
||||
|
||||
function addOpportunity() {
|
||||
$uibModal.open({
|
||||
template: '<add-opportunity customer="customer" />',
|
||||
scope: angular.extend($scope.$new(true), { customer: vm.customer })
|
||||
});
|
||||
}
|
||||
|
||||
function addRisk() {
|
||||
$uibModal.open({
|
||||
template: '<add-risk customer="customer" />',
|
||||
scope: angular.extend($scope.$new(true), { customer: vm.customer })
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,19 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.app.controller('CustomerListController', CustomerListController);
|
||||
|
||||
CustomerListController.$inject = ['$uibModal', 'customerSvc'];
|
||||
function CustomerListController($uibModal, customerSvc) {
|
||||
var vm = this;
|
||||
vm.add = add;
|
||||
vm.customers = customerSvc.customers;
|
||||
|
||||
|
||||
function add() {
|
||||
$uibModal.open({
|
||||
template: '<add-customer />'
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,41 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.app.directive('editCustomer', editCustomer);
|
||||
|
||||
function editCustomer() {
|
||||
return {
|
||||
scope: {
|
||||
customer: "="
|
||||
},
|
||||
templateUrl: '/customer/template/editCustomer.tmpl.cshtml',
|
||||
controller: controller,
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope', 'customerSvc'];
|
||||
function controller($scope, customerSvc) {
|
||||
var vm = this;
|
||||
vm.save = save;
|
||||
|
||||
vm.saving = false;
|
||||
vm.customer = angular.copy($scope.customer);
|
||||
vm.errorMessage = null;
|
||||
|
||||
function save() {
|
||||
vm.saving = true;
|
||||
customerSvc.update($scope.customer, vm.customer)
|
||||
.success(function () {
|
||||
//Close the modal
|
||||
$scope.$parent.$close();
|
||||
})
|
||||
.error(function(data) {
|
||||
vm.errorMessage = 'There was a problem saving changes to the customer: ' + data;
|
||||
})
|
||||
.finally(function() {
|
||||
vm.saving = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,49 @@
|
||||
(function() {
|
||||
window.app.factory('customerSvc', customerSvc);
|
||||
|
||||
customerSvc.$inject = ['$http'];
|
||||
function customerSvc($http) {
|
||||
var customers = [];
|
||||
|
||||
loadCustomers();
|
||||
|
||||
var svc = {
|
||||
add: add,
|
||||
update: update,
|
||||
customers: customers,
|
||||
getCustomer: getCustomer
|
||||
};
|
||||
|
||||
return svc;
|
||||
|
||||
function loadCustomers() {
|
||||
$http.post('/Customer/All')
|
||||
.success(function(data) {
|
||||
customers.addRange(data);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function add(customer) {
|
||||
return $http.post('/Customer/Add', customer)
|
||||
.success(function(customer) {
|
||||
customers.unshift(customer);
|
||||
});
|
||||
}
|
||||
|
||||
function update(existingCustomer, updatedCustomer) {
|
||||
return $http.post('/Customer/Update', updatedCustomer)
|
||||
.success(function(customer) {
|
||||
angular.extend(existingCustomer, customer);
|
||||
});
|
||||
}
|
||||
|
||||
function getCustomer(id) {
|
||||
for (var i = 0; i < customers.length; i++) {
|
||||
if (customers[i].Id == id) return customers[i];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,31 @@
|
||||
@using InventoryTraker.Web.Helpers
|
||||
@model InventoryTraker.Web.Models.AddCustomerForm
|
||||
<form novalidate
|
||||
name="vm.form"
|
||||
ng-submit="vm.form.$valid && vm.add()">
|
||||
<fieldset ng-disabled="vm.saving">
|
||||
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Add New Customer</h3>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="alert alert-info" ng-hide="vm.errorMessage != null">
|
||||
Enter details for the new customer below.
|
||||
</div>
|
||||
<div class="alert alert-danger" ng-show="vm.errorMessage != null">
|
||||
{{vm.errorMessage}}
|
||||
</div>
|
||||
|
||||
@Html.Angular().FormForModel("vm.customer")
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-success">Add</button>
|
||||
<button type="button" class="btn btn-warning" ng-click="$dismiss()">Cancel</button>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
@@ -0,0 +1,102 @@
|
||||
@using InventoryTraker.Web.Helpers
|
||||
@model InventoryTraker.Web.Models.CustomerViewModel
|
||||
@{
|
||||
var customer = Html.Angular().ModelFor("vm.customer");
|
||||
}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
@customer.BindingFor(x => x.Name) <a href="" ng-click="vm.edit()"><i class="fa fa-edit"></i></a>
|
||||
<div class="pull-right">
|
||||
<a class="btn btn-default" href=""
|
||||
ng-class="{active: vm.selectedView == 'details'}"
|
||||
ng-click="vm.setView('details')">
|
||||
<i class="fa fa-user"></i> Info
|
||||
</a>
|
||||
<a class="btn btn-green" href=""
|
||||
ng-class="{active: vm.selectedView == 'opportunities'}"
|
||||
ng-click="vm.setView('opportunities')">
|
||||
<i class="fa fa-usd"></i> Opportunities
|
||||
</a>
|
||||
<a class="btn btn-red" href=""
|
||||
ng-class="{active: vm.selectedView == 'risks'}"
|
||||
ng-click="vm.setView('risks')">
|
||||
<i class="fa fa-exclamation-triangle"></i>Risks
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table" ng-show="vm.selectedView == 'details'">
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
Rate this customer: @(Html.Angular().UIRating("vm.customer.rating")
|
||||
.NgClick("vm.setRating()")
|
||||
.Max(10))
|
||||
</td>
|
||||
</tr><tr class="info text-center" ng-show="@customer.ExpressionFor(x => x.TerminationDate)">
|
||||
<td colspan="4">
|
||||
Inactive Customer
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>E-mail</th>
|
||||
<td>
|
||||
Work: @customer.BindingFor(x => x.WorkEmail)<br />
|
||||
Home: @customer.BindingFor(x => x.HomeEmail)
|
||||
</td>
|
||||
<th>Phone</th>
|
||||
<td>
|
||||
Office: @customer.BindingFor(x => x.WorkPhone)<br />
|
||||
Mobile: @customer.BindingFor(x => x.HomePhone)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Work Address</th>
|
||||
<td style="white-space: pre">@customer.BindingFor(x => x.WorkAddress)</td>
|
||||
<th>Home Address</th>
|
||||
<td style="white-space: pre">@customer.BindingFor(x => x.HomeAddress)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="panel-body opportunity-list" ng-show="vm.selectedView == 'opportunities'">
|
||||
<div class="row">
|
||||
<div class="col-md-1 half">
|
||||
<span class="fa fa-2x fa-dollar text-success"></span>
|
||||
</div>
|
||||
<div class="col-md-11">
|
||||
<p ng-show="@customer.ExpressionFor(x => x.Opportunities.Count) == 0">There are no opportunities for this customer.</p>
|
||||
@using (var opportunity = customer.Repeat(x => x.Opportunities, "opportunity"))
|
||||
{
|
||||
<hr ng-hide="$index == 0" />
|
||||
<h3>
|
||||
@opportunity.BindingFor(x => x.Title)
|
||||
</h3>
|
||||
<p>@opportunity.BindingFor(x => x.Description)</p>
|
||||
}
|
||||
<p>
|
||||
<a class="add-btn" href="" ng-click="vm.addOpportunity()">Add a new opportunity</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body risk-list" ng-show="vm.selectedView == 'risks'">
|
||||
<div class="row">
|
||||
<div class="col-md-1 half">
|
||||
<span class="fa fa-2x fa-warning text-danger"></span>
|
||||
</div>
|
||||
<div class="col-md-11">
|
||||
<p ng-show="@customer.ExpressionFor(x => x.Risks.Count) == 0">There are no risks for this customer.</p>
|
||||
@using (var risk = customer.Repeat(x => x.Risks, "risk"))
|
||||
{
|
||||
<hr ng-hide="$index == 0" />
|
||||
<h3>
|
||||
@risk.BindingFor(x => x.Title)
|
||||
</h3>
|
||||
<p>@risk.BindingFor(x => x.Description)</p>
|
||||
}
|
||||
<p>
|
||||
<a class="add-btn" href="" ng-click="vm.addRisk()">Add a new risk</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,31 @@
|
||||
@using InventoryTraker.Web.Helpers
|
||||
@model InventoryTraker.Web.Models.EditCustomerForm
|
||||
<form novalidate
|
||||
name="vm.form"
|
||||
ng-submit="vm.form.$valid && vm.save()">
|
||||
<fieldset ng-disabled="vm.saving">
|
||||
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Edit Customer</h3>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="alert alert-info" ng-hide="vm.errorMessage != null">
|
||||
Make changes to the customer below.
|
||||
</div>
|
||||
<div class="alert alert-danger" ng-show="vm.errorMessage != null">
|
||||
{{vm.errorMessage}}
|
||||
</div>
|
||||
|
||||
@Html.Angular().FormForModel("vm.customer")
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-success">Save</button>
|
||||
<button type="button" class="btn btn-warning" ng-click="$parent.$dismiss()">Cancel</button>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
@@ -0,0 +1,38 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.app.directive('inventoryAdd', inventoryAdd);
|
||||
|
||||
function inventoryAdd() {
|
||||
return {
|
||||
templateUrl: '/inventory/template/inventoryAdd.tmpl.cshtml',
|
||||
controller: controller,
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope', 'inventorySvc'];
|
||||
function controller($scope, inventorySvc) {
|
||||
var vm = this;
|
||||
vm.add = add;
|
||||
|
||||
vm.saving = false;
|
||||
vm.inventory = {};
|
||||
vm.errorMessage = null;
|
||||
|
||||
function add() {
|
||||
vm.saving = true;
|
||||
inventorySvc.add(vm.inventory)
|
||||
.success(function () {
|
||||
//Close the modal
|
||||
$scope.$close();
|
||||
})
|
||||
.error(function(data) {
|
||||
vm.errorMessage = 'There was a problem adding the inventory: ' + data;
|
||||
})
|
||||
.finally(function() {
|
||||
vm.saving = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,31 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.app.directive('inventoryDetails', inventoryDetails);
|
||||
function inventoryDetails() {
|
||||
return {
|
||||
scope: {
|
||||
inventory: '='
|
||||
},
|
||||
templateUrl: '/inventory/template/inventoryDetails.tmpl.cshtml',
|
||||
controller: controller,
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope', '$uibModal'];
|
||||
function controller($scope, $uibModal) {
|
||||
var vm = this;
|
||||
|
||||
vm.inventory = $scope.inventory;
|
||||
vm.edit = edit;
|
||||
vm.inventory = $scope.inventory;
|
||||
|
||||
function edit() {
|
||||
$uibModal.open({
|
||||
template: '<editInventory inventory="inventory" />',
|
||||
scope: angular.extend($scope.$new(true), { inventory: vm.inventory })
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,41 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.app.directive('editInventory', editInventory);
|
||||
|
||||
function editInventory() {
|
||||
return {
|
||||
scope: {
|
||||
inventory: "="
|
||||
},
|
||||
templateUrl: '/inventory/template/inventoryEdit.tmpl.cshtml',
|
||||
controller: controller,
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope', 'inventorySvc'];
|
||||
function controller($scope, inventorySvc) {
|
||||
var vm = this;
|
||||
vm.save = save;
|
||||
|
||||
vm.saving = false;
|
||||
vm.inventory = angular.copy($scope.inventory);
|
||||
vm.errorMessage = null;
|
||||
|
||||
function save() {
|
||||
vm.saving = true;
|
||||
inventorySvc.update($scope.inventory, vm.inventory)
|
||||
.success(function () {
|
||||
//Close the modal
|
||||
$scope.$parent.$close();
|
||||
})
|
||||
.error(function(data) {
|
||||
vm.errorMessage = 'There was a problem saving changes to the inventory: ' + data;
|
||||
})
|
||||
.finally(function() {
|
||||
vm.saving = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,18 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.app.controller('InventoryListController', InventoryListController);
|
||||
|
||||
InventoryListController.$inject = ['$uibModal', 'inventorySvc'];
|
||||
function InventoryListController($uibModal, inventorySvc) {
|
||||
var vm = this;
|
||||
vm.add = add;
|
||||
vm.inventories = inventorySvc.inventories;
|
||||
|
||||
function add() {
|
||||
$uibModal.open({
|
||||
template: '<inventory-add />'
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,48 @@
|
||||
(function() {
|
||||
window.app.factory('inventorySvc', inventorySvc);
|
||||
|
||||
inventorySvc.$inject = ['$http'];
|
||||
function inventorySvc($http) {
|
||||
var inventories = [];
|
||||
|
||||
loadInventories();
|
||||
|
||||
var svc = {
|
||||
add: add,
|
||||
update: update,
|
||||
inventories: inventories,
|
||||
getInventory: getInventory
|
||||
};
|
||||
|
||||
return svc;
|
||||
|
||||
function loadInventories() {
|
||||
$http.post('/Inventory/All')
|
||||
.success(function(data) {
|
||||
inventories.addRange(data);
|
||||
});
|
||||
}
|
||||
|
||||
function add(inventory) {
|
||||
return $http.post('/Inventory/Add', inventory)
|
||||
.success(function(inventory) {
|
||||
inventories.unshift(inventory);
|
||||
});
|
||||
}
|
||||
|
||||
function update(existingInventory, updatedInventory) {
|
||||
return $http.post('/Inventory/Update', updatedInventory)
|
||||
.success(function(inventory) {
|
||||
angular.extend(existingInventory, inventory);
|
||||
});
|
||||
}
|
||||
|
||||
function getInventory(id) {
|
||||
for (var i = 0; i < inventories.length; i++) {
|
||||
if (inventories[i].Id == id) return inventories[i];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,36 @@
|
||||
@using InventoryTraker.Web.Helpers
|
||||
@model InventoryTraker.Web.Models.InventoryAddForm
|
||||
@{
|
||||
var inventory = Html.Angular().ModelFor("vm.inventory");
|
||||
}
|
||||
<form novalidate
|
||||
name="vm.form"
|
||||
ng-submit="vm.form.$valid && vm.add()">
|
||||
<fieldset ng-disabled="vm.saving">
|
||||
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Inventory Arrival</h3>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="alert alert-info" ng-hide="vm.errorMessage != null">
|
||||
Enter details for the inventory arrival below.
|
||||
</div>
|
||||
<div class="alert alert-danger" ng-show="vm.errorMessage != null">
|
||||
{{vm.errorMessage}}
|
||||
</div>
|
||||
|
||||
@inventory.FormGroupFor(m => m.ExpirationDate)
|
||||
@inventory.FormGroupFor(m => m.AddedDate)
|
||||
@inventory.FormGroupFor(m => m.Memo)
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-success">Add</button>
|
||||
<button type="button" class="btn" ng-click="$dismiss()">Cancel</button>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
@@ -0,0 +1,12 @@
|
||||
@using InventoryTraker.Web.Helpers
|
||||
@model InventoryTraker.Web.Models.InventoryViewModel
|
||||
@{
|
||||
var inventory = Html.Angular().ModelFor("vm.inventory");
|
||||
}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
@inventory.BindingFor(x => x.Name) <a href="" ng-click="vm.edit()"><i class="fa fa-edit"></i></a>
|
||||
</div>
|
||||
Quantity
|
||||
@inventory.BindingFor(x => x.Quantity)
|
||||
</div>
|
||||
@@ -0,0 +1,31 @@
|
||||
@using InventoryTraker.Web.Helpers
|
||||
@model InventoryTraker.Web.Models.InventoryAddForm
|
||||
<form novalidate
|
||||
name="vm.form"
|
||||
ng-submit="vm.form.$valid && vm.save()">
|
||||
<fieldset ng-disabled="vm.saving">
|
||||
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Edit Inventory</h3>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="alert alert-info" ng-hide="vm.errorMessage != null">
|
||||
Make changes to the inventory below.
|
||||
</div>
|
||||
<div class="alert alert-danger" ng-show="vm.errorMessage != null">
|
||||
{{vm.errorMessage}}
|
||||
</div>
|
||||
|
||||
@Html.Angular().FormForModel("vm.inventory")
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-success">Save</button>
|
||||
<button type="button" class="btn btn-warning" ng-click="$parent.$dismiss()">Cancel</button>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
@@ -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>
|
||||
@@ -0,0 +1,30 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.app.controller('EditProfileController', EditProfileController);
|
||||
|
||||
EditProfileController.$inject = ['$http', 'editProfileConfig', 'model'];
|
||||
function EditProfileController($http, editProfileConfig, model) {
|
||||
var vm = this;
|
||||
|
||||
vm.profile = model;
|
||||
vm.save = save;
|
||||
|
||||
function save() {
|
||||
vm.saving = true;
|
||||
vm.errorMessage = null;
|
||||
vm.success = false;
|
||||
|
||||
$http.post(editProfileConfig.saveUrl, vm.profile)
|
||||
.success(function() {
|
||||
vm.success = true;
|
||||
})
|
||||
.error(function(msg) {
|
||||
vm.errorMessage = msg;
|
||||
})
|
||||
.finally(function() {
|
||||
vm.saving = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,27 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.app.directive('lostCustomersReport', lostCustomersReport);
|
||||
|
||||
function lostCustomersReport() {
|
||||
return {
|
||||
scope: true,
|
||||
templateUrl: '/js/app/report/templates/lostCustomersReport.tmpl.html',
|
||||
controller: controller,
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$http'];
|
||||
function controller($http) {
|
||||
var vm = this;
|
||||
|
||||
vm.isLoading = true;
|
||||
|
||||
$http.post('/Report/LostCustomers')
|
||||
.success(function (customers) {
|
||||
vm.customers = customers;
|
||||
vm.isLoading = false;
|
||||
});
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,27 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.app.directive('newCustomersReport', newCustomersReport);
|
||||
|
||||
function newCustomersReport() {
|
||||
return {
|
||||
scope: true,
|
||||
templateUrl: '/js/app/report/templates/newCustomersReport.tmpl.html',
|
||||
controller: controller,
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$http'];
|
||||
function controller($http) {
|
||||
var vm = this;
|
||||
|
||||
vm.isLoading = true;
|
||||
|
||||
$http.post('/Report/NewCustomers')
|
||||
.success(function (customers) {
|
||||
vm.customers = customers;
|
||||
vm.isLoading = false;
|
||||
});
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,36 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">
|
||||
<i class="fa fa-pie-chart fa-fw"></i> Lost Customers
|
||||
</h3>
|
||||
</div>
|
||||
<table ng-hide="vm.isLoading || vm.customer.length == 0"
|
||||
class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Work E-mail</th>
|
||||
<th>Date Lost</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="customer in vm.customers">
|
||||
<td>
|
||||
{{customer.Name}}
|
||||
</td>
|
||||
<td>
|
||||
{{customer.WorkEmail}}
|
||||
</td>
|
||||
<td>
|
||||
{{customer.TerminationDate | parseDate | date: 'shortDate'}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="panel-body" ng-show="vm.isLoading">
|
||||
Loading...
|
||||
</div>
|
||||
<div class="panel-body" ng-show="!vm.isLoading && vm.customers.length == 0">
|
||||
There are no customers on the report.
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,36 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">
|
||||
<i class="fa fa-pie-chart fa-fw"></i> New Customers
|
||||
</h3>
|
||||
</div>
|
||||
<table ng-hide="vm.isLoading || vm.customers.length == 0"
|
||||
class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Work E-mail</th>
|
||||
<th>Date Acquired</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="customer in vm.customers">
|
||||
<td>
|
||||
{{customer.Name}}
|
||||
</td>
|
||||
<td>
|
||||
{{customer.WorkEmail}}
|
||||
</td>
|
||||
<td>
|
||||
{{customer.CreateDate | parseDate | date: 'shortDate'}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="panel-body" ng-show="vm.isLoading">
|
||||
Loading...
|
||||
</div>
|
||||
<div class="panel-body" ng-show="!vm.isLoading && vm.customers.length == 0">
|
||||
There are no customers on the report.
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,45 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.app.directive('addRisk', addRisk);
|
||||
|
||||
function addRisk() {
|
||||
return {
|
||||
scope: {
|
||||
customer: "="
|
||||
},
|
||||
templateUrl: '/risk/template/addRisk.tmpl.cshtml',
|
||||
controller: controller,
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope', '$http'];
|
||||
function controller($scope, $http) {
|
||||
var vm = this;
|
||||
|
||||
vm.saving = false;
|
||||
vm.risk = {
|
||||
customerId: $scope.customer.id
|
||||
}
|
||||
|
||||
vm.add = add;
|
||||
|
||||
function add() {
|
||||
vm.saving = true;
|
||||
|
||||
$http.post('/Risk/Add', vm.risk)
|
||||
.success(function (data) {
|
||||
$scope.customer.risks.push(data);
|
||||
//Close the modal
|
||||
$scope.$parent.$close();
|
||||
})
|
||||
.error(function (data) {
|
||||
vm.errorMessage = 'There was a problem adding the risk: ' + data;
|
||||
})
|
||||
.finally(function () {
|
||||
vm.saving = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,31 @@
|
||||
@using InventoryTraker.Web.Helpers
|
||||
@model InventoryTraker.Web.Models.AddRiskForm
|
||||
<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 Risk</h3>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="alert alert-info" ng-hide="vm.errorMessage != null">
|
||||
Enter details for the new risk.
|
||||
</div>
|
||||
<div class="alert alert-danger" ng-show="vm.errorMessage != null">
|
||||
{{vm.errorMessage}}
|
||||
</div>
|
||||
|
||||
@Html.Angular().FormForModel("vm.risk")
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-danger">Add Risk</button>
|
||||
<button type="button" class="btn btn-warning" ng-click="$parent.$dismiss()">Cancel</button>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
@@ -0,0 +1,14 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(Array.prototype, 'count', {
|
||||
get: function () { return this.length; }
|
||||
});
|
||||
|
||||
if (Array.prototype.addRange) return;
|
||||
|
||||
Array.prototype.addRange = function (target) {
|
||||
this.push.apply(this, target);
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,51 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
window.app.directive('formGroupValidation', formGroupValidation);
|
||||
|
||||
function formGroupValidation() {
|
||||
return {
|
||||
require: '^form',
|
||||
replace: true,
|
||||
transclude: true,
|
||||
template:
|
||||
'<div class="has-feedback" ng-class="vm.getValidationClass()">' +
|
||||
'<ng-transclude></ng-transclude>' +
|
||||
'<input-validation-icons field="vm.field"></input-validation-icons>' +
|
||||
'</div>',
|
||||
scope: {
|
||||
field: '@formGroupValidation'
|
||||
},
|
||||
controller: controller,
|
||||
controllerAs: 'vm',
|
||||
link: function (scope, element, attrs, formCtrl) {
|
||||
scope.form = formCtrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope'];
|
||||
function controller($scope) {
|
||||
var vm = this;
|
||||
|
||||
vm.field = $scope.field;
|
||||
vm.getValidationClass = getValidationClass;
|
||||
|
||||
function getValidationClass() {
|
||||
if (!canBeValidated()) return '';
|
||||
|
||||
if (isValid()) return 'has-success';
|
||||
|
||||
return 'has-error';
|
||||
}
|
||||
|
||||
function canBeValidated() {
|
||||
return ($scope.form[vm.field].$touched || $scope.form.$submitted);
|
||||
}
|
||||
|
||||
function isValid() {
|
||||
return $scope.form[vm.field].$valid;
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,41 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
window.app.directive('inputValidationIcons', inputValidationIcons);
|
||||
|
||||
function inputValidationIcons() {
|
||||
return {
|
||||
require: '^form',
|
||||
scope: {
|
||||
field: '='
|
||||
},
|
||||
template:
|
||||
'<span ng-show="vm.canBeValidated() && vm.isValid()" ' +
|
||||
'class="fa fa-2x fa-check-square form-control-feedback"></span>' +
|
||||
'<span ng-show="vm.canBeValidated() && !vm.isValid()" ' +
|
||||
'class="fa fa-2x fa-exclamation-triangle form-control-feedback"></span>',
|
||||
controller: controller,
|
||||
controllerAs: 'vm',
|
||||
link: function (scope, element, attrs, formCtrl) {
|
||||
scope.form = formCtrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope'];
|
||||
function controller($scope) {
|
||||
var vm = this;
|
||||
|
||||
vm.field = $scope.field;
|
||||
vm.canBeValidated = canBeValidated;
|
||||
vm.isValid = isValid;
|
||||
|
||||
function canBeValidated() {
|
||||
return ($scope.form[vm.field].$touched || $scope.form.$submitted);
|
||||
}
|
||||
|
||||
function isValid() {
|
||||
return $scope.form[vm.field].$valid;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,46 @@
|
||||
(function () {
|
||||
|
||||
window.app.directive('mvcGrid', mvcGrid);
|
||||
function mvcGrid() {
|
||||
return {
|
||||
scope: {
|
||||
gridDataUrl: '@',
|
||||
title: '@',
|
||||
columns: '@?'
|
||||
},
|
||||
template:
|
||||
'<div>' +
|
||||
'<h4><i class="fa fa-pie-chart fa-fw"></i> {{vm.title}}</h4>' +
|
||||
'<div>' +
|
||||
'<p ng-if="vm.loading">Loading...</p>' +
|
||||
'<div ng-if="!vm.loading" ui-grid="vm.gridOptions"></div>' +
|
||||
'</div>' +
|
||||
'</div>',
|
||||
controllerAs: 'vm',
|
||||
controller: controller
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope', '$http'];
|
||||
function controller($scope, $http) {
|
||||
var vm = this;
|
||||
|
||||
vm.gridOptions = {
|
||||
enableHorizontalScrollbar: 0
|
||||
}
|
||||
|
||||
vm.loading = true;
|
||||
|
||||
vm.title = $scope.title;
|
||||
|
||||
if ($scope.columns)
|
||||
vm.gridOptions.columnDefs = angular.fromJson($scope.columns);
|
||||
|
||||
$http.post($scope.gridDataUrl)
|
||||
.success(function (data) {
|
||||
vm.gridOptions.data = data;
|
||||
vm.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,11 @@
|
||||
(function() {
|
||||
window.app.filter('parseDate', parseDate);
|
||||
|
||||
function parseDate() {
|
||||
return function(input) {
|
||||
if (typeof input != 'string' || input.indexOf('/Date') === -1) return input;
|
||||
|
||||
return new Date(parseInt(input.substr(6)));
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
|
||||
<system.web.webPages.razor>
|
||||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
<pages pageBaseType="System.Web.Mvc.WebViewPage">
|
||||
<namespaces>
|
||||
<add namespace="System.Web.Mvc" />
|
||||
<add namespace="System.Web.Mvc.Ajax" />
|
||||
<add namespace="System.Web.Mvc.Html" />
|
||||
<add namespace="System.Web.Routing" />
|
||||
<add namespace="Microsoft.Web.Mvc" />
|
||||
<add namespace="InventoryTraker.Web" />
|
||||
<add namespace="InventoryTraker.Web.Controllers" />
|
||||
</namespaces>
|
||||
</pages>
|
||||
</system.web.webPages.razor>
|
||||
|
||||
<appSettings>
|
||||
<add key="webpages:Enabled" value="false" />
|
||||
</appSettings>
|
||||
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<remove name="BlockViewHandler"/>
|
||||
<add name="BlockViewHandler" path="*.cshtml" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user