Applications html and js behind it

This commit is contained in:
HooVee
2016-08-15 20:29:07 +03:00
parent feaadc49cc
commit 48570c13f1
5 changed files with 109 additions and 3 deletions
+29
View File
@@ -1,2 +1,31 @@
<h1> Jäsenhakemukset </h1>
<div>
<div class="panel panel-primary" ng-repeat="x in applications">
<div class="panel-heading">{{ x.member.first_name }} {{ x.member.last_name}}</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-4">Sähköposti: {{ x.member.email }}</div>
</div>
<div class="row">
<div class="col-sm-4">AYY-jäsen: {{ x.member.AYY }}</div>
</div>
<div class="row">
<div class="col-sm-4">JAS-listaan: {{ x.member.jas }}</div>
</div>
<div class="row">
<div class="col-sm-4">Asuinpaikka: {{ x.member.POR }}</div>
</div>
<div class="row">
<div class="col-sm-4">Lähetetty: {{ x.submitted }}</div>
</div>
<div class="row">
<div class="col-sm-4">
<a href="#applications/edit/{{x.id}}"<input type="button" value="Edit" class="btn btn-warning">Muokkaa</input></a>
<input type="button" value="Hyväksy" class="btn btn-success" confirmed-click="send_appl(x.id)" ng-confirm-click="Oletko varma, että haluat hyväksyä?"/>
<input type="button" value="Hylkää" class="btn btn-danger" confirmed-click="delete_appl(x.id)" ng-confirm-click="Oletko varma, että haluat hylätä hakemuksen?"/>
</div>
</div>
</div>
</div>
</div>
+1 -1
View File
@@ -1,5 +1,5 @@
<h1> Jäsenlista (jäseniä {{members.length}})</h1>
<div >
<div>
<table id="choose-address-table" class="table table-striped">
<thead>
<tr class="ui-widget-header">
@@ -0,0 +1,32 @@
<h1> Muokkaa hakemuksen jäsentietoja </h1>
<div id="input_form">
<form name="applicationForm">
<div class="form-group">
<label>Etunimi: </label>
<input id="firstNameField" required type="text" placeholder="Sähkö" class="form-control" ng-model="application.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="application.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="application.member.email"></input>
</div>
<div class="form-group">
<label>AYY jäsen: </label>
<input type="checkbox" id="AYY" ng-model="application.member.AYY"></input>
</div>
<div class="form-group">
<label>JAS-listaan: </label>
<input type="checkbox" id="jas" ng-model="application.member.jas"></input>
</div>
<div class="form-group">
<label>Asuinkunta: </label>
<input id="PORField" required type="text" placeholder="Otaniemi" class="form-control" ng-model="application.member.POR"></input>
</div>
<button class="btn btn-success" ng-click="sendappl()" type="submit" id="sendmember">Tallenna</button>
<button class="btn btn-warning" ng-click="cancelappl()" type="submit" id="sendmember">Peruuta</button>
</form>
</div>
+42 -1
View File
@@ -66,8 +66,49 @@ app.controller("editController", function($scope, $http, $route, $routeParams, $
}
});
app.controller("applController", function($scope, $http){
app.controller("applController", function($scope, $http, $route, $routeParams, $window, $location){
$http.get("/members/api/requests").then(function(response){
$scope.applications = response.data;
});
$scope.send_appl = function(id) {
$http.post("/members/api/requests/" + id).then(
function(response) {
$window.alert("Onnistui");
$location.path("#/applications");
},
function(response) {
$window.alert("Epäonnistui");
$location.path("#/applications");
}
);
};
$scope.delete_appl = function(id) {
$http.delete("/members/api/requests/" + id).then(
function(response) {
$window.alert("Onnistui");
$location.path("#/applications");
},
function(response) {
$window.alert("Epäonnistui");
$location.path("#/applications");
}
);
};
});
app.controller("appleditController", function($scope, $http, $route, $routeParams, $window, $location){
$scope.application = {"id": $routeParams.id};
$http.get("/members/api/requests"+$scope.application.id).then(function(response){
$scope.application = response.data;
});
$scope.sendappl = function() {
$http.put("/members/api/requests"+$scope.application.id, $scope.application).then(function(data){
$window.alert("Jäsentiedot tallennettu");
$location.path("#/applications");
});
}
$scope.cancelappl = function() { //user canceled. return to applications
$location.path("#/applications");
}
});
+5 -1
View File
@@ -25,9 +25,13 @@ app.config(['$routeProvider', function($routeProvider){
controller:'editController',
})
.when('/applications',{
templateUrl:'/static/html/jasenhakemukset.html',
templateUrl:"/static/html/jasenhakemukset.html",
controller:'applController',
})
.when('applications/edit/:id',{
templateUrl:"/static/html/muokkaa_hakemusta.html",
controller:'appleditController',
})
.otherwise({
'redirectTo':"/"
})