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.

228 lines
7.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. /**
  8. * @class Ext.calendar.EventEditForm
  9. * @extends Ext.form.FormPanel
  10. * <p>A custom form used for detailed editing of events.</p>
  11. * <p>This is pretty much a standard form that is simply pre-configured for the options needed by the
  12. * calendar components. It is also configured to automatically bind records of type {@link Ext.calendar.EventRecord}
  13. * to and from the form.</p>
  14. * <p>This form also provides custom events specific to the calendar so that other calendar components can be easily
  15. * notified when an event has been edited via this component.</p>
  16. * <p>The default configs are as follows:</p><pre><code>
  17. labelWidth: 65,
  18. title: 'Event Form',
  19. titleTextAdd: 'Add Event',
  20. titleTextEdit: 'Edit Event',
  21. bodyStyle: 'background:transparent;padding:20px 20px 10px;',
  22. border: false,
  23. buttonAlign: 'center',
  24. autoHeight: true,
  25. cls: 'ext-evt-edit-form',
  26. </code></pre>
  27. * @constructor
  28. * @param {Object} config The config object
  29. */
  30. Ext.calendar.EventEditForm = Ext.extend(Ext.form.FormPanel, {
  31. labelWidth: 65,
  32. title: 'Event Form',
  33. titleTextAdd: 'Add Event',
  34. titleTextEdit: 'Edit Event',
  35. bodyStyle: 'background:transparent;padding:20px 20px 10px;',
  36. border: false,
  37. buttonAlign: 'center',
  38. autoHeight: true,
  39. // to allow for the notes field to autogrow
  40. cls: 'ext-evt-edit-form',
  41. // private properties:
  42. newId: 10000,
  43. layout: 'column',
  44. // private
  45. initComponent: function() {
  46. this.addEvents({
  47. /**
  48. * @event eventadd
  49. * Fires after a new event is added
  50. * @param {Ext.calendar.EventEditForm} this
  51. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was added
  52. */
  53. eventadd: true,
  54. /**
  55. * @event eventupdate
  56. * Fires after an existing event is updated
  57. * @param {Ext.calendar.EventEditForm} this
  58. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was updated
  59. */
  60. eventupdate: true,
  61. /**
  62. * @event eventdelete
  63. * Fires after an event is deleted
  64. * @param {Ext.calendar.EventEditForm} this
  65. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was deleted
  66. */
  67. eventdelete: true,
  68. /**
  69. * @event eventcancel
  70. * Fires after an event add/edit operation is canceled by the user and no store update took place
  71. * @param {Ext.calendar.EventEditForm} this
  72. * @param {Ext.calendar.EventRecord} rec The new {@link Ext.calendar.EventRecord record} that was canceled
  73. */
  74. eventcancel: true
  75. });
  76. this.titleField = new Ext.form.TextField({
  77. fieldLabel: 'Title',
  78. name: Ext.calendar.EventMappings.Title.name,
  79. anchor: '90%'
  80. });
  81. this.dateRangeField = new Ext.calendar.DateRangeField({
  82. fieldLabel: 'When',
  83. anchor: '90%'
  84. });
  85. this.reminderField = new Ext.calendar.ReminderField({
  86. name: 'Reminder'
  87. });
  88. this.notesField = new Ext.form.TextArea({
  89. fieldLabel: 'Notes',
  90. name: Ext.calendar.EventMappings.Notes.name,
  91. grow: true,
  92. growMax: 150,
  93. anchor: '100%'
  94. });
  95. this.locationField = new Ext.form.TextField({
  96. fieldLabel: 'Location',
  97. name: Ext.calendar.EventMappings.Location.name,
  98. anchor: '100%'
  99. });
  100. this.urlField = new Ext.form.TextField({
  101. fieldLabel: 'Web Link',
  102. name: Ext.calendar.EventMappings.Url.name,
  103. anchor: '100%'
  104. });
  105. var leftFields = [this.titleField, this.dateRangeField, this.reminderField],
  106. rightFields = [this.notesField, this.locationField, this.urlField];
  107. if (this.calendarStore) {
  108. this.calendarField = new Ext.calendar.CalendarPicker({
  109. store: this.calendarStore,
  110. name: Ext.calendar.EventMappings.CalendarId.name
  111. });
  112. leftFields.splice(2, 0, this.calendarField);
  113. };
  114. this.items = [{
  115. id: 'left-col',
  116. columnWidth: 0.65,
  117. layout: 'form',
  118. border: false,
  119. items: leftFields
  120. },
  121. {
  122. id: 'right-col',
  123. columnWidth: 0.35,
  124. layout: 'form',
  125. border: false,
  126. items: rightFields
  127. }];
  128. this.fbar = [{
  129. text: 'Save',
  130. scope: this,
  131. handler: this.onSave
  132. },
  133. {
  134. cls: 'ext-del-btn',
  135. text: 'Delete',
  136. scope: this,
  137. handler: this.onDelete
  138. },
  139. {
  140. text: 'Cancel',
  141. scope: this,
  142. handler: this.onCancel
  143. }];
  144. Ext.calendar.EventEditForm.superclass.initComponent.call(this);
  145. },
  146. // inherited docs
  147. loadRecord: function(rec) {
  148. this.form.loadRecord.apply(this.form, arguments);
  149. this.activeRecord = rec;
  150. this.dateRangeField.setValue(rec.data);
  151. if (this.calendarStore) {
  152. this.form.setValues({
  153. 'calendar': rec.data[Ext.calendar.EventMappings.CalendarId.name]
  154. });
  155. }
  156. this.isAdd = !!rec.data[Ext.calendar.EventMappings.IsNew.name];
  157. if (this.isAdd) {
  158. rec.markDirty();
  159. this.setTitle(this.titleTextAdd);
  160. Ext.select('.ext-del-btn').setDisplayed(false);
  161. }
  162. else {
  163. this.setTitle(this.titleTextEdit);
  164. Ext.select('.ext-del-btn').setDisplayed(true);
  165. }
  166. this.titleField.focus();
  167. },
  168. // inherited docs
  169. updateRecord: function() {
  170. var dates = this.dateRangeField.getValue();
  171. this.form.updateRecord(this.activeRecord);
  172. this.activeRecord.set(Ext.calendar.EventMappings.StartDate.name, dates[0]);
  173. this.activeRecord.set(Ext.calendar.EventMappings.EndDate.name, dates[1]);
  174. this.activeRecord.set(Ext.calendar.EventMappings.IsAllDay.name, dates[2]);
  175. },
  176. // private
  177. onCancel: function() {
  178. this.cleanup(true);
  179. this.fireEvent('eventcancel', this, this.activeRecord);
  180. },
  181. // private
  182. cleanup: function(hide) {
  183. if (this.activeRecord && this.activeRecord.dirty) {
  184. this.activeRecord.reject();
  185. }
  186. delete this.activeRecord;
  187. if (this.form.isDirty()) {
  188. this.form.reset();
  189. }
  190. },
  191. // private
  192. onSave: function() {
  193. if (!this.form.isValid()) {
  194. return;
  195. }
  196. this.updateRecord();
  197. if (!this.activeRecord.dirty) {
  198. this.onCancel();
  199. return;
  200. }
  201. this.fireEvent(this.isAdd ? 'eventadd': 'eventupdate', this, this.activeRecord);
  202. },
  203. // private
  204. onDelete: function() {
  205. this.fireEvent('eventdelete', this, this.activeRecord);
  206. }
  207. });
  208. Ext.reg('eventeditform', Ext.calendar.EventEditForm);