From 44ec40e27b3039096c6202bcc19bae9561943818 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Mon, 20 Oct 2014 16:45:49 +0000
Subject: [PATCH] #2021 fix - Corrected license form validations
---
securis/src/main/resources/static/js/licenses.js | 32 ++++++++++++++++++++++----------
1 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/securis/src/main/resources/static/js/licenses.js b/securis/src/main/resources/static/js/licenses.js
index e0624fd..09a33bd 100644
--- a/securis/src/main/resources/static/js/licenses.js
+++ b/securis/src/main/resources/static/js/licenses.js
@@ -20,6 +20,7 @@
var HTTP_ERRORS = {
401: "Unathorized action",
+ 418: "Application error",
403: "Forbidden action",
500: "Server error",
404: "Element not found"
@@ -40,6 +41,7 @@
BootstrapDialog.alert($L.get("Open your .req file with a text editor and copy&paste the content in the form text field?"));
return;
}
+ console.log('File selected');
//console.log('scope.license: ' + scope.$parent.license);
var field = $parse(attrs.fileLoader);
//console.log('field: ' + field);
@@ -48,17 +50,17 @@
var reader = new FileReader();
reader.onerror = function(data) {
setter(scope.$parent, 'ERROR');
- //scope.$apply();
+ scope.$apply();
}
reader.onload = function(data) {
setter(scope.$parent, reader.result);
- //scope.$apply();
+ scope.$apply();
}
reader.readAsText(fileList[0]);
} else {
setter(scope.$parent, '');
- //scope.$apply();
+ scope.$apply();
}
});
@@ -182,8 +184,14 @@
$scope.editPack = function(selectedPack) {
$scope.isNew = false;
$scope.showForm = true;
+ if (!(selectedPack.init_valid_date instanceof Date)) {
+ selectedPack.init_valid_date = new Date(selectedPack.init_valid_date);
+ }
+ if (!(selectedPack.end_valid_date instanceof Date)) {
+ selectedPack.end_valid_date = new Date(selectedPack.end_valid_date);
+ }
$scope.pack = selectedPack;
- setTimeout(function() {
+ setTimeout(function() {
$('#code').focus();
}, 0);
}
@@ -292,6 +300,7 @@
}
$scope.maxlength = {
code: 50,
+ request_data: 500,
comments: 1024
}
$scope.refs = {};
@@ -319,14 +328,17 @@
// });
$scope.save = function() {
- $( "form#licenseForm" )
- .attr( "enctype", "multipart/form-data" )
- .attr( "encoding", "multipart/form-data" );
+ //$( "form#licenseForm" ).attr( "enctype", "multipart/form-data" ).attr( "encoding", "multipart/form-data" );
var _success = function() {
if (!$scope.isNew) $scope.showForm = false;
$scope.licenses = licenseResource.query({packId: $scope.currentPack.id});
- }
- licenseResource.save_w_upload($scope.license, _success)
+ toaster.pop('success', Catalogs.getName(), $L.get("License '{0}' {1} successfully", $scope.license.code, $scope.isNew ? $L.get("created") : $L.get("updated")));
+ }
+ var _error = function(error) {
+ console.log(error);
+ toaster.pop('error', Catalogs.getName(), $L.get("Error {0} license '{1}'. Reason: {2}", $scope.isNew ? $L.get("creating") : $L.get("updating"), $scope.pack.code, $L.get(error.headers('X-SECURIS-ERROR'))));
+ }
+ licenseResource.save($scope.license, _success, _error)
}
$scope.newLicense = function() {
@@ -395,7 +407,7 @@
}
$scope.isActionVisible = function(action, lic) {
var validStatuses = ACTIONS_BY_STATUS[action];
- return lic && validStatuses.indexOf(lic.status) !== -1;
+ return lic && validStatuses && validStatuses.indexOf(lic.status) !== -1;
}
} ]);
--
Gitblit v1.3.2