From 225dc136c1c6fba26b2e4f8b763cbd3fc4d596e3 Mon Sep 17 00:00:00 2001
From: Roberto Sánchez <roberto.sanchez@curisit.net>
Date: Mon, 13 Jan 2014 12:37:25 +0000
Subject: [PATCH] #394 feature - Added error messages to Admin module
---
securis/src/main/resources/static/js/catalogs.js | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/securis/src/main/resources/static/js/catalogs.js b/securis/src/main/resources/static/js/catalogs.js
index 10dc1dd..518fd65 100644
--- a/securis/src/main/resources/static/js/catalogs.js
+++ b/securis/src/main/resources/static/js/catalogs.js
@@ -134,6 +134,33 @@
this.query = function() {
return this.getResource().query({}, _success, _fail);
}
+ this.refreshRef = function(refs, res, preloadedData) {
+ // We check if there is some field for the resource passed as parameter
+ var field = (function() {
+ for (var i = _current.fields.length - 1; i >= 0; i--) {
+ if (_current.fields[i].resource === res)
+ return _current.fields[i];
+ }
+ return null;
+ })();
+
+ // If field for that resource is not found there is nothing to refresh
+ if (!field) return;
+ var resource = this.getResource(res);
+ var data = preloadedData || resource.query({}, _success, _fail);
+ var that = this;
+ data.$promise.then(function(responseData) {
+ var pk = that.getPk(that.getMetadata(field.resource))
+ var comboData = []
+ responseData.forEach(function(row) {
+ comboData.push({
+ id: row[pk],
+ label: row.label || row.name || row.code || row.first_name + ' ' + row.last_name
+ });
+ })
+ refs[field.name] = comboData;
+ })
+ }
this.loadRefs = function(refs) {
if (!_current) throw new Error('There is no current catalog selected');
var refsFields = [];
--
Gitblit v1.3.2