Permalink
Browse files

added add invoice view, controller and data model service

  • Loading branch information...
SimonDoy committed May 8, 2016
1 parent 491f24b commit 5f8afd7e3f2987603b6baa692faa1dcdd722c3d1
Showing with 36 additions and 26 deletions.
  1. +5 −2 app/app.js
  2. +3 −10 app/controllers/invoiceControllers.js
  3. +11 −0 app/index.html
  4. +7 −1 app/services/dataModelService.js
  5. +10 −13 app/views/add-invoice.html
View
@@ -2,12 +2,15 @@
var invoiceFormApp = angular.module('itspInvoiceFormApp',
[
'ngRoute', 'invoiceControllersModule'
'ngRoute', 'invoiceControllersModule', 'dataModelService'
]);
var appStart = function($routeProvider) {
$routeProvider.when('/invoices', {
$routeProvider.when('/invoices/add', {
templateUrl:'/app/views/add-invoice.html',
controller: 'addInvoiceController'
}).when('/invoices', {
templateUrl:'/app/views/list-invoices.html',
controller: 'listInvoicesController'
}).otherwise({
@@ -85,16 +85,9 @@ invoiceControllersModule.controller('addInvoiceController', ['$scope', 'dataMode
$scope.error="";
$scope.saveInvoice = function saveInvoiceStub(){
invoiceDataService.saveNewInvoice($scope.invoiceNo, $scope.invoice).then(function processSuccess(response){
$scope.status="Successfully Saved Invoice";
$location.path("#");
return true;
},
function processFailure(response){
//alert(response.data);
$scope.error="Failed to create invoice: " + response.data.message;
});
$scope.status="Successfully Saved Invoice";
$location.path("#");
return true;
};
}]);
View
@@ -7,6 +7,16 @@
<link rel="stylesheet" type="text/css" href="/app/css/invoiceformapp.css" />
</head>
<body>
<div>
<nav class="navbar navbar-default">
<div class="container-fluid">
<ul class="nav navbar-nav">
<li><a class="btn primary" href="#">Home</a></li>
<li><a class="btn primary" href="#/invoices/add" title="Create Invoice">New Invoice</a></li>
</ul>
</div>
</nav>
</div>
<div ng-view></div>
</body>
<script src="/bower_components/angular/angular.js"></script>
@@ -17,6 +27,7 @@
<script src="/app/controllers/invoiceControllers.js"></script>
<script src="/app/services/dataModelService.js"></script>
<script src="/app/app.js"></script>
@@ -1,6 +1,12 @@
var dataModelService = angular.module('dataModelService', []);
dataModelService.factory('dataModelService', [dataModelServiceFactory]);
dataModelService.service('dataModelService', [dataModelServiceFactory]);
dataModelService.provider('dataModelService', function dataModelServiceProvider(){
this.$get = [function initDataModelService(){
var service=new dataModelServiceFactory();
return service;
}];
});
function dataModelServiceFactory()
{
View
@@ -1,14 +1,10 @@
<div class="container">
<div class="row">
<div class="col-md-4 col-sd-12">
<button ng-show="mode=='view'" class="btn btn-default" type="button" title="Edit" ng-click="editInvoice()"><i class="fa fa-2x fa-pencil" aria-hidden="true"></i><span class="sr-only">Edit</span></button>
<button class="btn btn-default" type="button" title="Save" ng-click="saveInvoice()">Save</button>
&nbsp;
<button ng-hide="mode=='view'" class="btn btn-default" type="button" title="Save" ng-click="saveInvoice()"><i class="fa fa-2x fa-save" aria-hidden="true"></i><span class="sr-only">Save</span></button>
&nbsp;
<button class="btn" type="button" title="Cancel" ng-click="cancel()"><i class="fa fa-2x fa-times-circle" aria-hidden="true"></i><span class="sr-only">Cancel</span></button>
&nbsp;
<button class="btn" type="button" title="Create Pdf" ng-click="createPdf('#invoiceDiv');"><i class="fa fa-2x fa-photo" aria-hidden="true"></i><span class="sr-only">Create Pdf</span></button>
</div>
<button class="btn" type="button" title="Cancel" ng-click="cancel()">Cancel</button>
</div>
<div class="col-md-8 col-sd-12">
<span ng-show="status !== ''">{{status}}</span>
@@ -18,16 +14,16 @@
</div>
<form>
<div id="invoiceDiv" class="row">
<h2>Invoice: {{invoice.reference}} ({{mode}})</h2>
<h2>Invoice: {{invoice.reference}}</h2>
<div class="col-md-4 col-sd-12">
<div class="form-group">
<input type="hidden" ng-model="invoice.id"" id="invoiceid" />
<label for="invoiceReference">Invoice Reference</label>
<input type="text" ng-model="invoice.reference" required class="form-control" id="invoiceReference" placeholder="Please enter Invoice Reference">
<input type="text" ng-model="invoice.reference" class="form-control" id="invoiceReference" placeholder="Please enter Invoice Reference">
</div>
<div class="form-group">
<label for="invoiceDate">Date</label>
<input type="date" ng-model="invoice.invoiceDate" required class="form-control" id="invoiceDate" placeholder="Please enter Invoice Date">
<input type="date" ng-model="invoice.invoiceDate" class="form-control" id="invoiceDate" placeholder="Please enter Invoice Date">
</div>
<div class="form-group">
<label for="vatRate">Vat Rate</label>
@@ -43,11 +39,11 @@ <h2>Invoice: {{invoice.reference}} ({{mode}})</h2>
<div class="col-md-4 col-sd-12">
<div class="form-group">
<label for="clientName">Client</label>
<input type="text" required ng-model="invoice.companyName" class="form-control" id="companyName" placeholder="Please provide the name of the client.">
<input type="text" ng-model="invoice.companyName" class="form-control" id="companyName" placeholder="Please provide the name of the client.">
</div>
<div class="form-group">
<label for="clientContact">Contact Name</label>
<input type="text" required ng-model="invoice.contact" class="form-control" id="clientContact" placeholder="Please provide the name of the contact at the clients.">
<input type="text" ng-model="invoice.contact" class="form-control" id="clientContact" placeholder="Please provide the name of the contact at the clients.">
</div>
<div class="form-group">
<label for="addressLine1">Address</label>
@@ -57,7 +53,7 @@ <h2>Invoice: {{invoice.reference}} ({{mode}})</h2>
<input type="text" ng-model="invoice.addressLine4" class="form-control" id="addressLine4">
<label for="addressCity">City</label>
<input type="text" ng-model="invoice.addressCity" class="form-control" id="addressCity" required />
<input type="text" ng-model="invoice.addressCity" class="form-control" id="addressCity" />
<label for="addressPostCode">Postcode</label>
<input type="text" ng-model="invoice.addressPostCode" class="form-control" id="addressPostCode">
<label for="addressCountry">Country</label>
@@ -66,6 +62,7 @@ <h2>Invoice: {{invoice.reference}} ({{mode}})</h2>
</div>
</div>
<div class="well">
<button ng-click="addInvoiceLine()" title="Add new line">Add line to Invoice</button>
<table class="table table-striped">
<tr>
<th>

0 comments on commit 5f8afd7

Please sign in to comment.