annotate app/model/Base.js @ 374:832e3c8f9191

Implemented dynamic ProbelList model. The model will get initialized by the fields configured in the sql configuration.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Tue, 20 Aug 2013 16:50:47 +0200
parents 8bc067b5f9c5
children 08bb418f31c9
rev   line source
310
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
1 /**
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
2 * Base class for models
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
3 */
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
4 Ext.define('Lada.model.Base', {
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
5 extend: 'Ext.data.Model',
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
6 requires: ['Lada.lib.Helpers'],
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
7 /**
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
8 * Helper function to build an ID which is used in the proxy calls. This
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
9 * function is a workaround for
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
10 * https://roundup-intern.intevation.de/bfs/issue30
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
11 * as some items can not be identified with a singe id.
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
12 */
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
13 getEidi: function() {
324
7f5f74e62658 Removed documentation of things which are already documented in the Ext model
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 310
diff changeset
14 return "/" + idProperty;
359
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
15 },
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
16 /**
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
17 * Helper function to make a AJAX request against the authinfo interface
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
18 * of the server
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
19 * @param callback function(model, readonly, isowner)
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
20 * @private
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
21 */
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
22 getAuthInfo: function(cb) {
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
23 Ext.Ajax.request({
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
24 scope: this,
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
25 url: 'server/rest/authinfo/' + this.data.probeId,
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
26 success: function(response, opts) {
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
27 var obj = Ext.decode(Ext.decode(response.responseText).data);
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
28 cb(this, obj.readonly, obj.isOwner);
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
29 },
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
30 failure: function(response, opts) {
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
31 console.log('server-side failure with status code ' + response.status);
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
32 cb(this, true, false);
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
33 }
8bc067b5f9c5 Added helper function to get authorisation information for the current item.
Torsten Irländer <torsten.irlaender@intevation.de>
parents: 324
diff changeset
34 });
310
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
35 }
aeeb0f534411 Added Base model class
Torsten Irländer <torsten.irlaender@intevation.de>
parents:
diff changeset
36 });

http://lada.wald.intevation.org