rsanchez
2014-10-14 fb1b6755a9ecd43601dc4fbef9166d11d8a86f24
securis/src/main/resources/static/js/catalogs.js
....@@ -137,17 +137,14 @@
137137 this.getField = function(key, catalog) {
138138 catalog = catalog || _current;
139139 if (!catalog)
140
- throw new Error(
141
- 'There is no current catalog selected');
140
+ throw new Error('There is no current catalog selected');
142141 var index = -1;
143142 if (typeof key === 'string') {
144143 for (var i = catalog.fields.length - 1; i >= 0
145
- && catalog.fields[i].name !== key; i--)
146
- ;
144
+ && catalog.fields[i].name !== key; i--);
147145 index = i;
148146 } else {
149
- index = key; // In this case key ===
150
- // field position
147
+ index = key; // In this case key === field position
151148 }
152149
153150 return index === -1 ? {}
....@@ -160,17 +157,17 @@
160157
161158 function _success(response) {
162159 console.debug('$resource action success')
160
+ console.log(_current);
161
+
163162 }
164163 function _fail(response) {
165
- console
166
- .error('Error trying to get data, HTTP error code: '
164
+ console.error('Error trying to get data, HTTP error code: '
167165 + response.status)
168166 }
169167
170168 this.save = function(data) {
171169 if (!_current)
172
- throw new Error(
173
- 'There is no current catalog selected');
170
+ throw new Error('There is no current catalog selected');
174171
175172 var resource = this.getResource();
176173 return resource.save(data, _success, _fail);
....@@ -200,9 +197,7 @@
200197 if (!field)
201198 return;
202199 var resource = this.getResource(res);
203
- var data = preloadedData
204
- || resource.query({}, _success,
205
- _fail);
200
+ var data = preloadedData || resource.query({}, _success, _fail);
206201 var that = this;
207202 data.$promise.then(function(responseData) {
208203 var pk = that.getPk(that
....@@ -223,8 +218,7 @@
223218 this.loadRefs = function(refs, refsFields) {
224219 if (!refsFields || refsFields.length === 0) {
225220 if (!_current)
226
- throw new Error(
227
- 'There is no current catalog selected');
221
+ throw new Error('There is no current catalog selected');
228222 refsFields = [];
229223 _current.fields.forEach(function(f) {
230224 if (f.resource)