| .. | .. |
|---|
| 137 | 137 | this.getField = function(key, catalog) { |
|---|
| 138 | 138 | catalog = catalog || _current; |
|---|
| 139 | 139 | if (!catalog) |
|---|
| 140 | | - throw new Error( |
|---|
| 141 | | - 'There is no current catalog selected'); |
|---|
| 140 | + throw new Error('There is no current catalog selected'); |
|---|
| 142 | 141 | var index = -1; |
|---|
| 143 | 142 | if (typeof key === 'string') { |
|---|
| 144 | 143 | for (var i = catalog.fields.length - 1; i >= 0 |
|---|
| 145 | | - && catalog.fields[i].name !== key; i--) |
|---|
| 146 | | - ; |
|---|
| 144 | + && catalog.fields[i].name !== key; i--); |
|---|
| 147 | 145 | index = i; |
|---|
| 148 | 146 | } else { |
|---|
| 149 | | - index = key; // In this case key === |
|---|
| 150 | | - // field position |
|---|
| 147 | + index = key; // In this case key === field position |
|---|
| 151 | 148 | } |
|---|
| 152 | 149 | |
|---|
| 153 | 150 | return index === -1 ? {} |
|---|
| .. | .. |
|---|
| 160 | 157 | |
|---|
| 161 | 158 | function _success(response) { |
|---|
| 162 | 159 | console.debug('$resource action success') |
|---|
| 160 | + console.log(_current); |
|---|
| 161 | + |
|---|
| 163 | 162 | } |
|---|
| 164 | 163 | 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: ' |
|---|
| 167 | 165 | + response.status) |
|---|
| 168 | 166 | } |
|---|
| 169 | 167 | |
|---|
| 170 | 168 | this.save = function(data) { |
|---|
| 171 | 169 | if (!_current) |
|---|
| 172 | | - throw new Error( |
|---|
| 173 | | - 'There is no current catalog selected'); |
|---|
| 170 | + throw new Error('There is no current catalog selected'); |
|---|
| 174 | 171 | |
|---|
| 175 | 172 | var resource = this.getResource(); |
|---|
| 176 | 173 | return resource.save(data, _success, _fail); |
|---|
| .. | .. |
|---|
| 200 | 197 | if (!field) |
|---|
| 201 | 198 | return; |
|---|
| 202 | 199 | var resource = this.getResource(res); |
|---|
| 203 | | - var data = preloadedData |
|---|
| 204 | | - || resource.query({}, _success, |
|---|
| 205 | | - _fail); |
|---|
| 200 | + var data = preloadedData || resource.query({}, _success, _fail); |
|---|
| 206 | 201 | var that = this; |
|---|
| 207 | 202 | data.$promise.then(function(responseData) { |
|---|
| 208 | 203 | var pk = that.getPk(that |
|---|
| .. | .. |
|---|
| 223 | 218 | this.loadRefs = function(refs, refsFields) { |
|---|
| 224 | 219 | if (!refsFields || refsFields.length === 0) { |
|---|
| 225 | 220 | if (!_current) |
|---|
| 226 | | - throw new Error( |
|---|
| 227 | | - 'There is no current catalog selected'); |
|---|
| 221 | + throw new Error('There is no current catalog selected'); |
|---|
| 228 | 222 | refsFields = []; |
|---|
| 229 | 223 | _current.fields.forEach(function(f) { |
|---|
| 230 | 224 | if (f.resource) |
|---|