Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
4.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Extensible 1.0-beta2
  3. * Copyright(c) 2010-2011 Extensible, LLC
  4. * licensing@ext.ensible.com
  5. * http://ext.ensible.com
  6. */
  7. /**
  8. * @class Ext.ensible.cal.CalendarMappings
  9. * @extends Object
  10. * A simple object that provides the field definitions for
  11. * {@link Ext.ensible.cal.CalendarRecord CalendarRecord}s so that they can be easily overridden.
  12. *
  13. * <p>There are several ways of overriding the default Calendar record mappings to customize how
  14. * Ext records are mapped to your back-end data model. If you only need to change a handful
  15. * of field properties you can directly modify the CalendarMappings object as needed and then
  16. * reconfigure it. The simplest approach is to only override specific field attributes:</p>
  17. * <pre><code>
  18. var M = Ext.ensible.cal.CalendarMappings;
  19. M.Title.mapping = 'cal_title';
  20. M.Title.name = 'CalTitle';
  21. Ext.ensible.cal.CalendarRecord.reconfigure();
  22. </code></pre>
  23. *
  24. * <p>You can alternately override an entire field definition using object-literal syntax, or
  25. * provide your own custom field definitions (as in the following example). Note that if you do
  26. * this, you <b>MUST</b> include a complete field definition, including the <tt>type</tt> attribute
  27. * if the field is not the default type of <tt>string</tt>.</p>
  28. * <pre><code>
  29. // Add a new field that does not exist in the default CalendarMappings:
  30. Ext.ensible.cal.CalendarMappings.Owner = {
  31. name: 'Owner',
  32. mapping: 'owner',
  33. type: 'string'
  34. };
  35. Ext.ensible.cal.CalendarRecord.reconfigure();
  36. </code></pre>
  37. *
  38. * <p>If you are overriding a significant number of field definitions it may be more convenient
  39. * to simply redefine the entire EventMappings object from scratch. The following example
  40. * redefines the same fields that exist in the standard EventRecord object but the names and
  41. * mappings have all been customized. Note that the name of each field definition object
  42. * (e.g., 'EventId') should <b>NOT</b> be changed for the default EventMappings fields as it
  43. * is the key used to access the field data programmatically.</p>
  44. * <pre><code>
  45. Ext.ensible.cal.CalendarMappings = {
  46. CalendarId: {name:'CalendarId', mapping: 'id', type: 'int'},
  47. Title: {name:'Title', mapping: 'title', type: 'string'},
  48. Description: {name:'Description', mapping: 'desc', type: 'string'},
  49. ColorId: {name:'ColorId', mapping: 'color', type: 'int'},
  50. IsHidden: {name:'IsHidden', mapping: 'hidden', type: 'boolean'},
  51. // We can also add some new fields that do not exist in the standard EventRecord:
  52. Owner: {name: 'Owner', mapping: 'owner'}
  53. };
  54. // Don't forget to reconfigure!
  55. Ext.ensible.cal.CalendarRecord.reconfigure();
  56. </code></pre>
  57. *
  58. * <p><b>NOTE:</b> Any record reconfiguration you want to perform must be done <b>PRIOR to</b>
  59. * initializing your data store, otherwise the changes will not be reflected in the store's records.</p>
  60. *
  61. * <p>Another important note is that if you alter the default mapping for <tt>CalendarId</tt>, make sure to add
  62. * that mapping as the <tt>idProperty</tt> of your data reader, otherwise it won't recognize how to
  63. * access the data correctly and will treat existing records as phantoms. For example:</p>
  64. * <pre><code>
  65. var reader = new Ext.data.JsonReader({
  66. totalProperty: 'total',
  67. successProperty: 'success',
  68. root: 'data',
  69. messageProperty: 'message',
  70. // read the id property generically, regardless of the mapping:
  71. idProperty: Ext.ensible.cal.CalendarMappings.CalendarId.mapping || 'id',
  72. // this is also a handy way to configure your reader's fields generically:
  73. fields: Ext.ensible.cal.CalendarRecord.prototype.fields.getRange()
  74. });
  75. </code></pre>
  76. */
  77. Ext.ensible.cal.CalendarMappings = {
  78. CalendarId: {name:'CalendarId', mapping: 'id', type: 'int'},
  79. Title: {name:'Title', mapping: 'title', type: 'string'},
  80. Description: {name:'Description', mapping: 'desc', type: 'string'},
  81. ColorId: {name:'ColorId', mapping: 'color', type: 'int'},
  82. IsHidden: {name:'IsHidden', mapping: 'hidden', type: 'boolean'}
  83. };