templatized editor function for requests
This commit is contained in:
@@ -21,11 +21,11 @@
|
||||
</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>
|
||||
<a href="#/applications/edit/{{x.member.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>
|
||||
</div>
|
||||
|
||||
@@ -19,15 +19,6 @@ app.controller("getController", function($scope, $http, $window, $location){
|
||||
layout: "bottomRight",
|
||||
type: "success",
|
||||
timeout: 10000
|
||||
// ,
|
||||
// buttons: [
|
||||
// {
|
||||
// addClass: 'btn btn-primary', text: 'Undo', onClick: function() {
|
||||
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
// http://ned.im/noty/#/about
|
||||
});
|
||||
$scope.getFunction();
|
||||
},
|
||||
@@ -73,15 +64,6 @@ function()
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
// var msg = attr.ngConfirmClick || "Are you sure?";
|
||||
// var clickAction = attr.confirmedClick;
|
||||
// element.bind('click',function (event)
|
||||
// {
|
||||
// if ( window.confirm(msg) ) {
|
||||
// scope.$eval(clickAction)
|
||||
// }
|
||||
// });
|
||||
}
|
||||
}}]);
|
||||
|
||||
@@ -104,27 +86,30 @@ app.controller("postController", function($scope, $http, $location) {
|
||||
});
|
||||
}
|
||||
});
|
||||
app.controller("editController", function($scope, $http, $route, $routeParams, $window, $location) {
|
||||
$scope.member = {"id": $routeParams.id};
|
||||
$http.get("/members/api/member/"+$scope.member.id).then(function(response){
|
||||
$scope.member = response.data;
|
||||
});
|
||||
|
||||
$scope.send = function() {
|
||||
$http.put("/members/api/member/"+$scope.member.id, $scope.member).then(function(data){
|
||||
noty({
|
||||
text: "Jäsentiedot tallennettu",
|
||||
layout: "bottomRight",
|
||||
type: "success",
|
||||
timeout: 10000
|
||||
});
|
||||
$location.path("/list");
|
||||
function editor(returnpath){
|
||||
return function($scope, $http, $route, $routeParams, $window, $location) {
|
||||
$scope.member = {"id": $routeParams.id};
|
||||
$http.get("/members/api/member/"+$scope.member.id).then(function(response){
|
||||
$scope.member = response.data;
|
||||
});
|
||||
}
|
||||
$scope.cancel = function() { //user canceled. return to list
|
||||
$location.path("/list");
|
||||
}
|
||||
});
|
||||
|
||||
$scope.send = function() {
|
||||
$http.put("/members/api/member/"+$scope.member.id, $scope.member).then(function(data){
|
||||
noty({
|
||||
text: "Jäsentiedot tallennettu",
|
||||
layout: "bottomRight",
|
||||
type: "success",
|
||||
timeout: 10000
|
||||
});
|
||||
$location.path(returnpath);
|
||||
});
|
||||
}
|
||||
$scope.cancel = function() { //user canceled. return to list
|
||||
$location.path(returnpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
app.controller("editController",editor("/list"));
|
||||
|
||||
app.controller("applController", function($scope, $http, $route, $routeParams, $window, $location){
|
||||
$scope.applGetFunction = function() {
|
||||
@@ -179,24 +164,4 @@ app.controller("applController", function($scope, $http, $route, $routeParams, $
|
||||
};
|
||||
});
|
||||
|
||||
app.controller("appleditController", function($scope, $http, $route, $routeParams, $window, $location){
|
||||
$scope.application = {"id": $routeParams.id};
|
||||
$http.get("/members/api/request/"+$scope.application.id).then(function(response){
|
||||
$scope.application = response.data;
|
||||
});
|
||||
|
||||
$scope.sendappl = function() {
|
||||
$http.put("/members/api/request/"+$scope.application.id, $scope.application).then(function(data){
|
||||
noty({
|
||||
text: "Jäsentiedot tallennettu",
|
||||
layout: "bottomRight",
|
||||
type: "success",
|
||||
timeout: 10000
|
||||
});
|
||||
$location.path("/applications");
|
||||
});
|
||||
};
|
||||
$scope.cancelappl = function() { //user canceled. return to applications
|
||||
$location.path("/applications");
|
||||
};
|
||||
});
|
||||
app.controller("appleditController", editor("/applications"));
|
||||
|
||||
@@ -21,7 +21,7 @@ app.config(['$routeProvider', function($routeProvider){
|
||||
controller:'applController',
|
||||
})
|
||||
.when('/applications/edit/:id',{
|
||||
templateUrl:"/static/html/muokkaa_hakemusta.html",
|
||||
templateUrl:"/static/html/muokkaa_jasenta.html",
|
||||
controller:'appleditController',
|
||||
})
|
||||
.otherwise({
|
||||
|
||||
Reference in New Issue
Block a user