+ },\r
+\r
+ /* Filters on resources */\r
+ on_resources_filter_added: function(filter) { this._get_scope().$apply(); },\r
+ on_resources_filter_removed: function(filter) { this._get_scope().$apply(); },\r
+ on_resources_filter_clear: function() { this._get_scope().$apply(); },\r
+\r
+ /* Filters on leases ? */\r
+ on_leases_filter_added: function(filter) { this._get_scope().$apply(); },\r
+ on_leases_filter_removed: function(filter) { this._get_scope().$apply(); },\r
+ on_leases_filter_clear: function() { this._get_scope().$apply(); },\r
+\r
+ on_field_state_changed: function(data)\r
+ {\r
+ /*\r
+ this._set_lease_slots(lease_key, lease);\r
+\r
+ switch(data.state) {\r
+ case STATE_SET:\r
+ switch(data.op) {\r
+ case STATE_SET_IN:\r
+ case STATE_SET_IN_SUCCESS:\r
+ case STATE_SET_OUT_FAILURE:\r
+ this.set_checkbox_from_data(data.value, true);\r
+ this.set_bgcolor(data.value, QUERYTABLE_BGCOLOR_RESET);\r
+ break; \r
+ case STATE_SET_OUT:\r
+ case STATE_SET_OUT_SUCCESS:\r
+ case STATE_SET_IN_FAILURE:\r
+ this.set_checkbox_from_data(data.value, false);\r
+ this.set_bgcolor(data.value, QUERYTABLE_BGCOLOR_RESET);\r
+ break;\r
+ case STATE_SET_IN_PENDING:\r
+ this.set_checkbox_from_data(data.key, true);\r
+ this.set_bgcolor(data.value, QUERYTABLE_BGCOLOR_ADDED);\r
+ break; \r
+ case STATE_SET_OUT_PENDING:\r
+ this.set_checkbox_from_data(data.key, false);\r
+ this.set_bgcolor(data.value, QUERYTABLE_BGCOLOR_REMOVED);\r
+ break;\r
+ }\r
+ break;\r
+\r
+ case STATE_WARNINGS:\r
+ this.change_status(data.key, data.value);\r
+ break;\r
+ }\r
+ */\r
+ },\r
+\r
+\r
+ /* INTERNAL FUNCTIONS */\r
+\r
+ _set_lease_slots: function(lease_key, lease)\r
+ {\r
+ var resource, lease_status, lease_class;\r
+ var day_timestamp, id_start, id_end, colspan_lease;\r
+\r
+ resource = this.scope_resources_by_key[lease.resource];\r
+ day_timestamp = SchedulerDateSelected.getTime() / 1000;\r
+ id_start = Math.floor((lease.start_time - day_timestamp) / resource.granularity);\r
+\r
+ /* Some leases might be in the past */\r
+ if (id_start < 0)\r
+ id_start = 0;\r
+ /* Leases in the future: ignore */\r
+ if (id_start >= this._all_slots.length)\r
+ return true; // ~ continue\r
+\r
+ id_end = Math.ceil((lease.end_time - day_timestamp) / resource.granularity);\r
+ colspan_lease = resource.granularity / this._slot_length; //eg. 3600 / 1800 => 2 cells\r
+ if (id_end >= this._all_slots.length / colspan_lease) {\r
+ /* Limit the display to the current day */\r
+ id_end = this._all_slots.length / colspan_lease\r
+ }\r
+ lease_status = manifold.query_store.get_record_state(this.options.query_lease_uuid, lease_key, STATE_SET);\r
+ // the same slots might be affected multiple times.\r
+ // PENDING_IN + PENDING_OUT => IN \r
+ //\r
+ // RESERVED vs SELECTED !\r
+ //\r
+ // PENDING !!\r
+ switch(lease_status) {\r
+ case STATE_SET_IN:\r
+ lease_class = 'selected'; // my leases\r
+ lease_success = '';\r
+ break;\r
+ case STATE_SET_IN_SUCCESS:\r
+ lease_class = 'selected'; // my leases\r
+ lease_success = 'success';\r
+ case STATE_SET_OUT_FAILURE:\r
+ lease_class = 'selected'; // my leases\r
+ lease_success = 'failure';\r
+ break;\r
+ case STATE_SET_OUT:\r
+ lease_class = 'reserved'; // other leases\r
+ lease_success = '';\r
+ break;\r
+ case STATE_SET_OUT_SUCCESS:\r
+ lease_class = 'free'; // other leases\r
+ lease_success = 'success';\r
+ break;\r
+ case STATE_SET_IN_FAILURE:\r
+ lease_class = 'free'; // other leases\r
+ lease_success = 'failure';\r
+ break;\r
+ case STATE_SET_IN_PENDING:\r
+ lease_class = 'pendingin';\r
+ lease_success = '';\r
+ break;\r
+ case STATE_SET_OUT_PENDING:\r
+ // pending_in & pending_out == IN == replacement\r
+ if (resource.leases[i].status == 'pendingin')\r
+ lease_class = 'pendingin'\r
+ else\r
+ lease_class = 'pendingout';\r
+ lease_success = '';\r
+ break;\r
+ \r
+ }\r
+\r
+ for (i = id_start; i < id_end; i++) {\r
+ resource.leases[i].status = lease_class;\r
+ resource.leases[i].success = lease_success;\r
+ }\r
+ },\r
+\r
+/* XXX IN TEMPLATE XXX\r
+ if (SchedulerDataViewData.length == 0) {\r
+ $("#plugin-scheduler").hide();\r
+ $("#plugin-scheduler-empty").show();\r
+ tmpScope.clearStuff();\r
+ } else {\r
+ $("#plugin-scheduler-empty").hide();\r
+ $("#plugin-scheduler").show();\r
+ // initSchedulerResources\r
+ tmpScope.initSchedulerResources(schedulerMaxRows < SchedulerDataViewData.length ? schedulerMaxRows : SchedulerDataViewData.length);\r
+ }\r
+*/\r
+\r
+ /**\r
+ * Initialize the date picker, the table, the slider and the buttons. Once done, display scheduler.\r
+ */\r
+ _initUI: function() \r
+ {\r
+ var self = this;\r
+ var scope = self._get_scope();\r