annotate app/model/Messprogramm.js @ 990:c2a726887dd7

The last status can not be edited anymore. When a new status is added, the new record is preset with ALL previous variables, this includes the StatusStufe! The Date is corrected to the current date. Also the store is sorted by Datum now.
author Dustin Demuth <dustin@intevation.de>
date Wed, 16 Dec 2015 09:49:09 +0100
parents f4eb53ba63fc
children f73ca04d73a7
rev   line source
745
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
3 *
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
7 */
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
8
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
9 /**
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
10 * A Messprogramm.
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
11 * This class represents and defines the model of a 'Messprogramm'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
12 **/
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
13 Ext.define('Lada.model.Messprogramm', {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
14 extend: 'Ext.data.Model',
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
15
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
16 fields: [{
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
17 name: 'id'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
18 }, {
754
6b0d0e62f7d7 added Probenintervalle to a Messprogramm... there is still a lot of work needed. For instance for the slider element.
Dustin Demuth <dustin@intevation.de>
parents: 749
diff changeset
19 name: 'test',
745
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
20 type: 'boolean'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
21 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
22 name: 'netzbetreiberId',
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
23 serialize: function(value) {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
24 if (value === '') {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
25 return null;
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
26 }
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
27 return value;
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
28 }
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
29 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
30 name: 'mstId'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
31 }, {
754
6b0d0e62f7d7 added Probenintervalle to a Messprogramm... there is still a lot of work needed. For instance for the slider element.
Dustin Demuth <dustin@intevation.de>
parents: 749
diff changeset
32 name: 'name'
6b0d0e62f7d7 added Probenintervalle to a Messprogramm... there is still a lot of work needed. For instance for the slider element.
Dustin Demuth <dustin@intevation.de>
parents: 749
diff changeset
33 }, {
745
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
34 name: 'datenbasisId'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
35 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
36 name: 'baId'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
37 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
38 name: 'gemId'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
39 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
40 name: 'ortId'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
41 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
42 name: 'mediaDesk'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
43 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
44 name: 'umwId',
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
45 serialize: function(value) {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
46 if (value === '') {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
47 return null;
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
48 }
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
49 return value;
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
50 }
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
51 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
52 name: 'probenartId'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
53 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
54 name: 'probenintervall'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
55 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
56 name: 'teilintervallVon'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
57 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
58 name: 'teilintervallBis'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
59 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
60 name: 'intervallOffset'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
61 }, {
774
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
62 name: 'gueltigVon',
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
63 type: 'date',
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
64 convert: function(v) {
793
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
65 var firstofyeartimestamp = new Date(
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
66 Date.UTC(
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
67 new Date().getFullYear(),0,1))
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
68 .valueOf();
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
69 var dayToMilli = 86400000;
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
70
774
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
71 if (!v) {
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
72 return v;
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
73 }
793
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
74 //check if v might be a date
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
75 // unless we go back in time this will work
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
76 if (v < 1000) {
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
77 v = v * dayToMilli;
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
78 v = v + firstofyeartimestamp;
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
79 v = new Date(v);
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
80 }
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
81 return v;
774
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
82 },
781
4c1101f0ba99 Serialize Date to DayOfYear when writing/saving
Dustin Demuth <dustin@intevation.de>
parents: 774
diff changeset
83 serialize: function(value) {
4c1101f0ba99 Serialize Date to DayOfYear when writing/saving
Dustin Demuth <dustin@intevation.de>
parents: 774
diff changeset
84 if (value instanceof Date && !isNaN(value.valueOf())) {
793
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
85 return Ext.Date.getDayOfYear(value);
781
4c1101f0ba99 Serialize Date to DayOfYear when writing/saving
Dustin Demuth <dustin@intevation.de>
parents: 774
diff changeset
86 }
4c1101f0ba99 Serialize Date to DayOfYear when writing/saving
Dustin Demuth <dustin@intevation.de>
parents: 774
diff changeset
87 }
745
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
88 }, {
774
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
89 name: 'gueltigBis',
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
90 type: 'date',
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
91 convert: function(v) {
793
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
92 var firstofyeartimestamp = new Date(
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
93 Date.UTC(
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
94 new Date().getFullYear(),0,1))
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
95 .valueOf();
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
96 var dayToMilli = 86400000;
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
97
774
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
98 if (!v) {
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
99 return v;
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
100 }
793
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
101
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
102 //check if v might be a date
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
103 // unless we go back in time this will work
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
104 if (v < 1000) {
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
105 v = v * dayToMilli;
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
106 v = v + firstofyeartimestamp;
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
107 v = new Date(v);
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
108 }
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
109 return v;
774
afc9076db490 Added Offset field
Dustin Demuth <dustin@intevation.de>
parents: 754
diff changeset
110 },
781
4c1101f0ba99 Serialize Date to DayOfYear when writing/saving
Dustin Demuth <dustin@intevation.de>
parents: 774
diff changeset
111 serialize: function(value) {
4c1101f0ba99 Serialize Date to DayOfYear when writing/saving
Dustin Demuth <dustin@intevation.de>
parents: 774
diff changeset
112 if (value instanceof Date && !isNaN(value.valueOf())) {
793
d4eb8fb99b5e Serialising GueltigVon and GueltigBis natively with Ext
Dustin Demuth <dustin@intevation.de>
parents: 781
diff changeset
113 return Ext.Date.getDayOfYear(value);
781
4c1101f0ba99 Serialize Date to DayOfYear when writing/saving
Dustin Demuth <dustin@intevation.de>
parents: 774
diff changeset
114 }
4c1101f0ba99 Serialize Date to DayOfYear when writing/saving
Dustin Demuth <dustin@intevation.de>
parents: 774
diff changeset
115 }
745
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
116 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
117 name: 'probeNehmerId'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
118 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
119 name: 'probeKommentar'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
120 }, {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
121 name: 'letzteAenderung',
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
122 type: 'date',
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
123 convert: function(v) {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
124 if (!v) {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
125 return v;
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
126 }
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
127 return new Date(v);
970
f4eb53ba63fc Setting Timestamps the correct way. Before this commit the times of the instatiation of the model were used as default values, which led to wrong dates.
Dustin Demuth <dustin@intevation.de>
parents: 793
diff changeset
128 }
745
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
129 }],
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
130
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
131 idProperty: 'id',
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
132
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
133 proxy: {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
134 type: 'rest',
749
78e73be45aaa Change store on radiobutton change for proben and messprogramm.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 745
diff changeset
135 url: 'lada-server/messprogramm', //not yet implemented
745
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
136 reader: {
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
137 type: 'json',
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
138 root: 'data'
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
139 }
df684c3d4a7c Added Messprogramme Store and Model
Dustin Demuth <dustin@intevation.de>
parents:
diff changeset
140 }
754
6b0d0e62f7d7 added Probenintervalle to a Messprogramm... there is still a lot of work needed. For instance for the slider element.
Dustin Demuth <dustin@intevation.de>
parents: 749
diff changeset
141 });

http://lada.wald.intevation.org