# HG changeset patch # User Torsten Irländer # Date 1376055468 -7200 # Node ID aeeb0f53441101d03d3bd931645bf04a6e4e6b40 # Parent 51897f9a6bbb89447bf25d5d9051c52261149070 Added Base model class diff -r 51897f9a6bbb -r aeeb0f534411 app/model/Base.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/model/Base.js Fri Aug 09 15:37:48 2013 +0200 @@ -0,0 +1,46 @@ +/** + * Base class for models + */ +Ext.define('Lada.model.Base', { + extend: 'Ext.data.Model', + requires: ['Lada.lib.Helpers'], + /** + * Define fields in the model + */ + fields: [], + /** + * Define the property which is used as unique attribute in the model. + * This might cause problems whith combined PK in the database. See + * https://roundup-intern.intevation.de/bfs/issue30 + */ + idProperty: null, + /** + * Define the URL of the (REST) ressource where to query for this model + */ + proxyUrl: null, + /** + * The Proxy used for this model. Defaults to a REST proxy which returns + * JSON. The payload is expected to be in a "data" node. The url of the + * proxy is configured in the proxyUrl attribute. + */ + proxy: { + type: 'rest', + appendId: true, //default + url: this.proxyUrl, + reader: { + type: 'json', + root: 'data' + } + }, + /** + * Helper function to build an ID which is used in the proxy calls. This + * function is a workaround for + * https://roundup-intern.intevation.de/bfs/issue30 + * as some items can not be identified with a singe id. + */ + getEidi: function() { + var kid = this.get('kId'); + var probeId = this.get('probeId'); + return "/" + kid + "/" + probeId; + } +});