From 0336880c1973d39eed743a25b3bb9ad3242e2b8f Mon Sep 17 00:00:00 2001
From: Yves Noirjean <yves.noirjean@id.ethz.ch>
Date: Fri, 23 Nov 2018 13:31:48 +0100
Subject: [PATCH] SSDM-7517: bugfix - showing on error when the user is not
 allowed to search role assignments

---
 .../eln-lims/html/js/controllers/MainController.js    |  2 ++
 .../webapps/eln-lims/html/js/server/ServerFacade.js   | 11 ++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js
index 755d4a9cef5..2a1d14c272d 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js
@@ -278,6 +278,8 @@ function MainController(profile) {
 					}
 				}
 				callback(roles);
+			}, function(errorResult) {
+				callback([]);
 			});
 		}
 	}
diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
index 7d8d2dd5335..e8dd6a389c4 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
@@ -2401,7 +2401,8 @@ function ServerFacade(openbisServer) {
 			});
 	}
 
-	this.searchRoleAssignments = function(criteriaParams, callbackFunction) {
+	// errorHandler: optional. if present, it is called instead of showing the error and the callbackFunction is not called
+	this.searchRoleAssignments = function(criteriaParams, callbackFunction, errorHandler) {
 		require(["as/dto/roleassignment/search/RoleAssignmentSearchCriteria", "as/dto/roleassignment/fetchoptions/RoleAssignmentFetchOptions"], 
 			function(RoleAssignmentSearchCriteria, RoleAssignmentFetchOptions) {
 				var criteria = new RoleAssignmentSearchCriteria();
@@ -2424,8 +2425,12 @@ function ServerFacade(openbisServer) {
 				mainController.openbisV3.searchRoleAssignments(criteria, fetchOptions).done(function(result) {
 					callbackFunction(result.objects);
 				}).fail(function(result) {
-					Util.showError("Call failed to server: " + JSON.stringify(result));
-					callbackFunction(false);
+					if (errorHandler) {
+						errorHandler(result);
+					} else {
+						Util.showError("Call failed to server: " + JSON.stringify(result));
+						callbackFunction(false);
+					}
 				});
 			});
 	}
-- 
GitLab