annotate app/model/Base.js @ 388:9591ca90d58d

Set client and server version
author Torsten Irländer <torsten.irlaender@intevation.de>
date Fri, 30 Aug 2013 11:24:03 +0200
parents 08bb418f31c9
children debfcc7713e3
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() {
385
08bb418f31c9 Use 'this' reference for idProperty in model.
Raimund Renkert <rrenkert@intevation.de>
parents: 359
diff changeset
14 return "/" + this.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