ffffng/app/scripts/directives/tokenForm.js

42 lines
1.2 KiB
JavaScript
Raw 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)
.error(function (response, code) {
switch (code) {
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',
'submitLabel': '@fSubmitLabel'
2014-05-12 20:08:19 +02:00
}
};
});