Roberto Sánchez
2014-01-10 3d0c6e4865d4a0ddd764da533a327faf76e0cb32
securis/src/main/resources/static/js/catalogs.js
....@@ -11,24 +11,15 @@
1111 var resources = {
1212 application : $resource('/application/:appId', {
1313 appId : '@id'
14
- }, {
15
- update : {
16
- method : "PUT"
17
- }
1814 }),
1915 user : $resource('/user/:userId', {
20
- userId : '@id'
21
- }, {
22
- update : {
23
- method : "PUT"
24
- }
16
+ userId : '@username'
17
+ }),
18
+ organization : $resource('/organization/:orgId', {
19
+ orgId : '@id'
2520 }),
2621 licensetype : $resource('/licensetype/:licenseTypeId', {
2722 licenseTypeId : '@id'
28
- }, {
29
- update : {
30
- method : "PUT"
31
- }
3223 })
3324 }
3425
....@@ -96,8 +87,8 @@
9687 this.getFFF = this.getFirstFocusableField = function() {
9788 if (!_current) throw new Error('There is no current catalog selected');
9889
99
- for(var i = i; i < _current.fields.length; i++)
100
- if (f.readOnly) return f.name;
90
+ for(var i = 0; i < _current.fields.length; i++)
91
+ if (!_current.fields[i].readOnly) return _current.fields[i].name;
10192
10293 return null;
10394 }
....@@ -135,10 +126,7 @@
135126 if (!_current) throw new Error('There is no current catalog selected');
136127
137128 var resource = this.getResource();
138
- if (data.id && data.id !== '')
139
- return resource.update(data, _success, _fail);
140
- else
141
- return resource.save(data, _success, _fail);
129
+ return resource.save(data, _success, _fail);
142130 }
143131 this.remove = function(data) {
144132 return this.getResource().remove({}, data, _success, _fail)
....@@ -165,18 +153,19 @@
165153 console.log('promises: ' + promises.length + ' ')
166154 console.log(promises)
167155 $q.all(promises).then(function() {
168
- console.log('ALL promises OK :::::::::::::::::::::::::::: ')
169156 for (var k in refs) {
170
- var pk = that.getPk(that.getMetadata(k))
171
- console.log('PK for '+k+' is ' + pk);
157
+ var pk = that.getPk(that.getMetadata(that.getField(k).resource))
158
+ console.log('PK field for ' + k + ' is ' + pk)
172159 var comboData = []
173160 refs[k].forEach(function(row) {
174161 comboData.push({
175162 id: row[pk],
176
- label: row.label || row.name || row.code
163
+ label: row.label || row.name || row.code || row.first_name + ' ' + row.last_name
177164 });
178165 })
179166 refs[k] = comboData;
167
+ console.log('Ready for combo for ' + k)
168
+ console.log(comboData);
180169 }
181170
182171 })