Web UI for ARGUS server
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.

238 lines
7.9 KiB

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