[TASK] add design to add form of goods
This commit is contained in:
parent
0ffcf653c9
commit
ced8a5d959
|
@ -16,7 +16,7 @@
|
|||
<a class="item" ui-sref="statistics" ui-active="active">Statistics</a><
|
||||
<div class="right menu">
|
||||
<a class="ui item" ng-click="login()">
|
||||
<i class="icon" ng-class="{'unlock':loggedIn,'lock':!loggedIn}"></i>
|
||||
<i class="icon" ng-class="{'unlock':!loggedIn,'lock':loggedIn}"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
<h1>{{product.title}}</h1>
|
||||
<form class="ui form" ng-submit="submit()">
|
||||
<h1>
|
||||
{{product.title}}
|
||||
<a ui-sref="item({productid:product.id})">
|
||||
<i class="icon linkify"></i>
|
||||
</a>
|
||||
</h1>
|
||||
|
||||
<form class="ui form segment" ng-submit="submit()" ng-class="{'top attached':msg.type}">
|
||||
<div class="field">
|
||||
<label>Fouled at</label>
|
||||
<input type="date" name="fouled_at" placeholder="Fouled at date" ng-model="obj.fouled_at">
|
||||
|
@ -18,3 +24,6 @@
|
|||
</div>
|
||||
<button class="ui button" type="submit">Submit</button>
|
||||
</form>
|
||||
<div class="ui bottom attached message {{msg.type}}" ng-show="msg.type">
|
||||
{{msg.text}}
|
||||
</div>
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
</tr>
|
||||
</table>
|
||||
<h2>Goods of this product</h2>
|
||||
<div class="ui warning message" ng-if="list.length <= 0">
|
||||
<p>There are no goods for this product.</p>
|
||||
</div>
|
||||
<table class="ui table list" ng-if="list.length > 0">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -31,9 +34,7 @@
|
|||
<td>{{item.position}}</td>
|
||||
<td>{{item.comment}}</td>
|
||||
<td></td>
|
||||
<td valign="middle">
|
||||
<img class="icon" ng-src="/api/good/freshness/{{item.id}}"/>
|
||||
</td>
|
||||
<td valign="middle"><img class="icon" ng-src="/api/good/freshness/{{item.id}}"/></td>
|
||||
<td><i class="trash icon" ng-click="delete(item.id)"></i></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -4,6 +4,7 @@ angular.module('microStock')
|
|||
.controller('ItemAddCtrl',['$scope','$http','$stateParams',function($scope,$http,$stateParams){
|
||||
$scope.product = {};
|
||||
$scope.obj = {};
|
||||
$scope.msg = {};
|
||||
$scope.count = 1;
|
||||
|
||||
$http.get(config.microservice_dependencies.productById.replace("%d", $stateParams.productid)).then(function(res) {
|
||||
|
@ -11,15 +12,20 @@ angular.module('microStock')
|
|||
});
|
||||
|
||||
$scope.submit = function(){
|
||||
var count = 0;
|
||||
function request(){
|
||||
count++;
|
||||
return $http.post(config.store.goods.productById.replace("%d",$stateParams.productid),$scope.obj);
|
||||
}
|
||||
var last = request();
|
||||
for(var i=1;i < $scope.count;i++){
|
||||
last.then(request);
|
||||
}
|
||||
last.then(null,function(){
|
||||
console.log("did not work");
|
||||
last.then(function(){
|
||||
$scope.obj = {};
|
||||
$scope.msg = {type:'success',text:'There was '+count+' goods saved from '+$scope.product.title+'.'};
|
||||
},function(){
|
||||
$scope.msg = {type:'error',text:'There was '+count+' goods saved from '+$scope.product.title+'.'};
|
||||
})
|
||||
};
|
||||
}]);
|
||||
|
|
Reference in New Issue