Skip to content

Commit

Permalink
Merge pull request #125 from ottemo/awk_95989020_add-notes-to-orders
Browse files Browse the repository at this point in the history
 add notes to orders

[#95989020 Delivered]
  • Loading branch information
James Vastbinder committed Jun 3, 2015
2 parents 1398555 + 34b536d commit 5b3bd45
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
15 changes: 9 additions & 6 deletions app/scripts/order/controller/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ function ($scope, $routeParams, $location, $q, $orderApiService, $dashboardUtils
);
}

$scope.back = function () {
$location.path("/orders");
};

/**
* Event handler to save the order data.
* Creates new order if ID in current order is empty OR updates current order if ID is set
Expand All @@ -96,18 +92,25 @@ function ($scope, $routeParams, $location, $q, $orderApiService, $dashboardUtils
delete $scope.order["updated_at"];
if (orderId !== null && JSON.stringify(oldString) !== JSON.stringify($scope.order)) {
$orderApiService.update({"orderID": orderId}, $scope.order).$promise.then(function (response) {

// Success
if (response.error === null) {
$scope.message = $dashboardUtilsService.getMessage(null , 'success', 'Order was updated successfully');

// Update the notes list with whatever is on the server.
// we get the whole order back, so we could set the entire thing
$scope.order.note = '';
$scope.order.notes = response.result.notes || [];

for (var field in response.result) {
if (response.result.hasOwnProperty(field) && "updated_at" !== field) {
oldString[field] = response.result[field];

}
}
} else {
$scope.message = $dashboardUtilsService.getMessage(response);
}
$('[ng-click="save()"]').removeClass('disabled').children('i').remove();
$('[ng-click="save()"]').removeClass('disabled').children('i').remove();
$('[ng-click="save()"]').siblings('.btn').removeClass('disabled');
});

Expand Down
2 changes: 1 addition & 1 deletion app/scripts/order/controller/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function ($rootScope, $scope, $location, $routeParams, $q, DashboardListService,
* @param id
*/
$scope.select = function (id) {
$location.path("/order/" + id);
$location.path("/order/" + id).search('');
};

/**
Expand Down
11 changes: 9 additions & 2 deletions app/themes/views/order/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,16 @@ <h3>Order Totals</h3>
</label>

<div class="clearfix"></div>

<h3>Notes</h3>
<ul ng-if="order.notes">
<li ng-repeat="note in order.notes">{{ note }}</li>
</ul>
<textarea name="newNote" id="newNote" rows="5" class="form-control" ng-model="order.note"></textarea>

<br>
<div class="text-center">
<a class="btn btn-default" ng-click="save()">Save</a>
<a class="btn btn-primary" href="#/orders/">Back to orders</a>
<a class="btn btn-default" href="/orders">Back to orders</a>
<a class="btn btn-primary" ng-click="save()">Save</a>
</div>
<br>

0 comments on commit 5b3bd45

Please sign in to comment.