ffffng/app/scripts/directives/tokenForm.js

43 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2014-05-12 20:08:19 +02:00
'use strict';
angular.module('ffffng')
.directive('fTokenForm', function () {
var ctrl = function ($scope, Constraints) {
$scope.constraints = Constraints;
$scope.submitted = false;
2014-05-12 20:08:19 +02:00
$scope.doSubmit = function (token) {
$scope.submitted = true;
if ($scope.tokenForm.$invalid) {
return;
}
2014-05-12 20:08:19 +02:00
$scope.error = null;
$scope.onSubmit(token)
.catch(function (response) {
switch (response.status) {
2014-05-12 20:08:19 +02:00
case 404: // not found
$scope.error = 'Zum Token wurde kein passender Eintrag gefunden.';
break;
default:
$scope.error = 'Es ist ein Fehler aufgetreten. Versuche es später noch einmal.';
}
});
};
};
return {
'controller': ctrl,
'restrict': 'E',
'templateUrl': 'views/directives/tokenForm.html',
'scope': {
'onSubmit': '=fSubmit',
2016-05-16 18:27:03 +02:00
'onCancel': '=fCancel',
'submitIcon': '@fSubmitIcon',
2016-05-16 22:30:35 +02:00
'submitLabel': '@fSubmitLabel',
'submitBtn': '@fSubmitBtn'
2014-05-12 20:08:19 +02:00
}
};
});