[TASK] add on webadmin adding goods
This commit is contained in:
parent
2ea9033ba1
commit
9d33f6deda
|
@ -0,0 +1,20 @@
|
|||
<h1>{{product.title}}</h1>
|
||||
<form class="ui form" ng-submit="submit()">
|
||||
<div class="field">
|
||||
<label>Fouled at</label>
|
||||
<input type="date" name="fouled_at" placeholder="Fouled at date" ng-model="obj.fouled_at">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Position</label>
|
||||
<input type="text" name="position" placeholder="Location in Store", ng-model="obj.position">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Comment</label>
|
||||
<input type="text" name="comment" placeholder="Comment to this good", ng-model="obj.comment">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Count</label>
|
||||
<input type="number" name="count" ng-model="count" min="1">
|
||||
</div>
|
||||
<button class="ui button" type="submit">Submit</button>
|
||||
</form>
|
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('microStock')
|
||||
.controller('GlobalCtrl',['$scope',function($scope){
|
||||
$scope.loggedIn = false;
|
||||
|
||||
function setCookie(cname, cvalue, exdays) {
|
||||
var d = new Date();
|
||||
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
|
||||
var expires = "expires="+d.toUTCString();
|
||||
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
||||
}
|
||||
|
||||
$scope.login = function(){
|
||||
if($scope.loggedIn){
|
||||
setCookie("session","logoff",1);
|
||||
$scope.loggedIn = false;
|
||||
}else {
|
||||
setCookie("session","testsessionkey",1);
|
||||
$scope.loggedIn = true;
|
||||
}
|
||||
};
|
||||
}]);
|
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('microStock')
|
||||
.controller('ItemAddCtrl',['$scope','$http','$stateParams',function($scope,$http,$stateParams){
|
||||
$scope.product = {};
|
||||
$scope.obj = {};
|
||||
$scope.count = 1;
|
||||
|
||||
$http.get(config.microservice_dependencies.productById.replace("%d", $stateParams.productid)).then(function(res) {
|
||||
$scope.product = res.data
|
||||
});
|
||||
|
||||
$scope.submit = function(){
|
||||
function request(){
|
||||
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");
|
||||
})
|
||||
};
|
||||
}]);
|
Reference in New Issue