added member editing
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
<h1> Muokkaa jäsentietoja </h1>
|
||||||
|
|
||||||
|
<div id="input_form">
|
||||||
|
<form name="memberForm">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Etunimi: </label>
|
||||||
|
<input id="firstNameField" required type="text" placeholder="Sähkö" class="form-control" ng-model="member.first_name"></input>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Sukunimi: </label>
|
||||||
|
<input id="lastNameField" required type="text" placeholder="Insinööri" class="form-control" ng-model="member.last_name"></input>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Sähköposti: </label>
|
||||||
|
<input id="emailField" required type="text" placeholder="sahko.insinoori@aalto.fi" class="form-control" ng-model="member.email"></input>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>AYY jäsen: </label>
|
||||||
|
<input type="checkbox" id="AYY" ng-model="member.AYY"></input>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>JAS-listaan: </label>
|
||||||
|
<input type="checkbox" id="jas" ng-model="member.jas"></input>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Asuinkunta: </label>
|
||||||
|
<input id="PORField" required type="text" placeholder="Otaniemi" class="form-control" ng-model="member.POR"></input>
|
||||||
|
</div>
|
||||||
|
<button ng-click="send()" type="submit" id="sendmember">Tallenna</button>
|
||||||
|
<button ng-click="cancel()" type="submit" id="sendmember">Peruuta</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
@@ -31,17 +31,23 @@ app.controller("postController", function($scope, $http) {
|
|||||||
$scope.JAS = "";
|
$scope.JAS = "";
|
||||||
$scope.POR = "";
|
$scope.POR = "";
|
||||||
$scope.send = function() {
|
$scope.send = function() {
|
||||||
$http.post("/members/api/member", {"first_name":$scope.firstName, "last_name":$scope.lastName, "email":$scope.email, "AYY":$scope.AYY, "jas":$scope.JAS, "POR":$scope.POR});
|
$http.post("/members/api/member/", {"first_name":$scope.firstName, "last_name":$scope.lastName, "email":$scope.email, "AYY":$scope.AYY, "jas":$scope.JAS, "POR":$scope.POR});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
app.controller("editController", function($scope, $http, $route, $routeParams) {
|
app.controller("editController", function($scope, $http, $route, $routeParams, $window, $location) {
|
||||||
$scope.member = {"id": $routeParams.id};
|
$scope.member = {"id": $routeParams.id};
|
||||||
$http.get("/members/api/member/"+$scope.member.id).then(function(response){
|
$http.get("/members/api/member/"+$scope.member.id).then(function(response){
|
||||||
scope.member = response.data;
|
$scope.member = response.data;
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.send = function() {
|
$scope.send = function() {
|
||||||
$http.put("/members/api/member", $scope.member);
|
$http.put("/members/api/member/"+$scope.member.id, $scope.member).then(function(data){
|
||||||
|
$window.alert("Jäsentiedot tallennettu");
|
||||||
|
$location.path("#/list");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$scope.cancel = function() { //user canceled. return to list
|
||||||
|
$location.path("#/list");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user