annotate app/model/Zusatzwert.js @ 134:1620d02d2973

Reset idProperty to probeId again as it seems the the submitted data will have an autogenerated id property "id" in the other case which causes problems on the server side.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Tue, 25 Jun 2013 17:33:56 +0200
parents 968806c1a3cb
children 4dc84682110d
rev   line source
106
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
1 Ext.define('Lada.model.Zusatzwert', {
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
2 extend: 'Ext.data.Model',
122
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
3 requires: [
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
4 'Lada.model.Probenzusatzwert'
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
5 ],
106
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
6 fields: [
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
7 {name: "id"},
127
f5864914ebb3 Commented out pzsId in Zusatzwert model.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 123
diff changeset
8 // Commented out as pzsId must not be submitted to the server. On
f5864914ebb3 Commented out pzsId in Zusatzwert model.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 123
diff changeset
9 // serverside the pzsId is taken from the nested sprobenZusatz object.
f5864914ebb3 Commented out pzsId in Zusatzwert model.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 123
diff changeset
10 //{name: "pzsId", mapping: "id.pzsId"},
122
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
11 {name: "probeId", mapping: "id.probeId"},
114
189a93e31be9 Worked on Zusatzwerte. No all values are displayed correct in the List and
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 106
diff changeset
12 {name: "nwgZuMesswert", type: 'float'},
189a93e31be9 Worked on Zusatzwerte. No all values are displayed correct in the List and
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 106
diff changeset
13 {name: "messwertPzs", type: 'float'},
189a93e31be9 Worked on Zusatzwerte. No all values are displayed correct in the List and
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 106
diff changeset
14 {name: "messfehler", type: 'float'},
123
d78bb4ca6089 Enabled accessing nested data in the grid through a renderer.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 122
diff changeset
15 {name: "letzteAenderung", type: 'date', convert: ts2date, defaultValue: new Date()},
114
189a93e31be9 Worked on Zusatzwerte. No all values are displayed correct in the List and
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 106
diff changeset
16
123
d78bb4ca6089 Enabled accessing nested data in the grid through a renderer.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 122
diff changeset
17 // Field for the nested Probenzusatzobject. This one is needed to have
d78bb4ca6089 Enabled accessing nested data in the grid through a renderer.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 122
diff changeset
18 // access to the nested data in the grid.
d78bb4ca6089 Enabled accessing nested data in the grid through a renderer.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 122
diff changeset
19 // TODO: I would have expected that this field does not need to be
d78bb4ca6089 Enabled accessing nested data in the grid through a renderer.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 122
diff changeset
20 // defined explicitly as there is the hasOne asscociation defined
d78bb4ca6089 Enabled accessing nested data in the grid through a renderer.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 122
diff changeset
21 // which name and associationKey named "sprobenZusatz". Anyway it does
d78bb4ca6089 Enabled accessing nested data in the grid through a renderer.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 122
diff changeset
22 // not seem to make problems.
d78bb4ca6089 Enabled accessing nested data in the grid through a renderer.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 122
diff changeset
23 {name: "sprobenZusatz"}
106
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
24 ],
122
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
25 hasOne: [
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
26 {
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
27 model: 'Lada.model.Probenzusatzwert',
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
28 primaryKey: 'pzsId',
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
29 name: 'sprobenZusatz',
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
30 associationKey: 'sprobenZusatz',
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
31 foreignKey: 'pzsId',
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
32 getterName: 'getProbenzusatz',
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
33 setterName: 'setProbenzusatz'
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
34 }
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
35 ],
114
189a93e31be9 Worked on Zusatzwerte. No all values are displayed correct in the List and
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 106
diff changeset
36 idProperty: "id",
106
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
37 proxy: {
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
38 type: 'rest',
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
39 appendId: true, //default
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
40 url: 'server/rest/zusatzwert',
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
41 reader: {
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
42 type: 'json',
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
43 root: 'data'
122
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
44 },
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
45 writer: {
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
46 type: 'json',
a7bfaeb1655d Cleanup part three. Reenabled Zusatzwerte and implemented sending nested data.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 114
diff changeset
47 writeEverything : true
106
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
48 }
131
968806c1a3cb Implement custom getEidi function to build a ID from the pzsId and the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 127
diff changeset
49 },
968806c1a3cb Implement custom getEidi function to build a ID from the pzsId and the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 127
diff changeset
50 getEidi: function () {
968806c1a3cb Implement custom getEidi function to build a ID from the pzsId and the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 127
diff changeset
51 var sprobenZusatz = this.get('sprobenZusatz');
968806c1a3cb Implement custom getEidi function to build a ID from the pzsId and the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 127
diff changeset
52 var pzsId = sprobenZusatz.pzsId;
968806c1a3cb Implement custom getEidi function to build a ID from the pzsId and the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 127
diff changeset
53 var probeId = this.get('probeId');
968806c1a3cb Implement custom getEidi function to build a ID from the pzsId and the
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 127
diff changeset
54 return "/" + pzsId + "/" + probeId;
106
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
55 }
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
56 });
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
57
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
58 function buildId(v, record){
114
189a93e31be9 Worked on Zusatzwerte. No all values are displayed correct in the List and
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 106
diff changeset
59 return record.get('probeId') + ',' + record.get('pzsId');
106
b91d5376db19 Load Zusatzwerte from server
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
60 }
114
189a93e31be9 Worked on Zusatzwerte. No all values are displayed correct in the List and
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 106
diff changeset
61
189a93e31be9 Worked on Zusatzwerte. No all values are displayed correct in the List and
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 106
diff changeset
62 function ts2date(v, record){
189a93e31be9 Worked on Zusatzwerte. No all values are displayed correct in the List and
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 106
diff changeset
63 // Converts a timestamp into a date object.
189a93e31be9 Worked on Zusatzwerte. No all values are displayed correct in the List and
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 106
diff changeset
64 return new Date(v);
189a93e31be9 Worked on Zusatzwerte. No all values are displayed correct in the List and
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 106
diff changeset
65 }

http://lada.wald.intevation.org