Files
osem/app/assets/javascripts/osem-schedule.js
AEtherC0r3 7eea930269 Implement track scheduling
Add track association to schedule
Show schedules in admin sidebar to track organizers
Allow track organizers to manage the schedules of their tracks
Don't allow self-organized track events to be dragged or unscheduled in
a conference schedule
Make scheduled events of self-organized tracks appear semitransparent in
conference schedules
Make the rooms of confirmed self_organized tracks appear semitransparent
and don't allow events to be scheduled to it in the conference schedules
during the dates of its track
Create admin/SchedulesController#new action
Add a button in admin/Schedules#index to create schedules for tracks
Add self_organized scope to Track
Modify Schedules#show to handle track schedules and show a unified
schedule
Allow track organizers to create new schedules for their tracks
Correctly identify scheduled and unscheduled events in Schedules#events
Fix Event#room and Event#time for when the event is scheduled in a track
schedule
Modify Program#selected_event_schedules to include the event_schedules
of selected track schedules
Modify Track#revoke_role_and_cleanup to destroy the track's schedules
and revert its events' state to new
Add tabs for conference and track schedules in admin/Schedules#index
Add button to Create/Show a tracks schedule in Tracks#index and #show
Fix concurrent_events in application_helper because of changes in
Program#selected_event_schedules
Do not take into account cfp_active in Event#valid_track
Modify EventsController#get_tracks accordingly
Enforce cfp_active of track to be enabled for proposals in
ProposalsController#create and #update
Add support for multiple schedules per track
Add selected_schedule_id to Track
Load EventSchedules of selected track schedules for conference schedules
in admin/SchedulesController#show
Modify SchedulesController#show to take into account only the selected
track schedules
Create Event#selected_schedule_id and use it in Event#scheduled? and
Event#time
Validate that an EventSchedule for an event of a self-organized track
belongs to one of the track's schedules
Add 'Manage' button in Tracks#index, #show that sends you to the admin
side of things
Add admin/TracksController#update_selected_schedule to update the
selected_schedule_id of tracks
2017-08-26 00:31:44 +03:00

145 lines
4.3 KiB
JavaScript

var url; // Should be initialize in Schedule.initialize
var schedule_id; // Should be initialize in Schedule.initialize
function showError(error){
// Delete other error messages before showing the new one
$('.unobtrusive-flash-container').empty();
UnobtrusiveFlash.showFlashMessage(error, {type: 'error'});
}
var Schedule = {
initialize: function(url_param, schedule_id_param) {
url = url_param;
schedule_id = schedule_id_param;
},
remove: function(element) {
var e = $("#" + element);
var event_schedule_id = e.attr("event_schedule_id");
if(event_schedule_id != null){
var my_url = url + '/' + event_schedule_id;
var success_callback = function(data) {
console.log(data);
e.attr("event_schedule_id", null);
e.appendTo($(".unscheduled-events"));
e.find(".schedule-event-delete-button").hide();
}
var error_callback = function(data) {
console.log(data);
showError($.parseJSON(data.responseText).errors);
}
$.ajax({
url: my_url,
type: 'DELETE',
success: success_callback,
error: error_callback,
dataType : 'json'
});
}
else{
showError("The event couldn't be unscheduled");
}
},
add: function (previous_parent, new_parent, event) {
event.appendTo(new_parent);
var event_schedule_id = event.attr("event_schedule_id");
var my_url = url;
var type = 'POST';
var params = { event_schedule: {
room_id: new_parent.attr("room_id"),
start_time: (new_parent.attr("date") + ' ' + new_parent.attr("hour"))
}};
if(event_schedule_id != null){
type = 'PUT';
my_url += ('/' + event_schedule_id);
}
else{
params['event_schedule']['event_id'] = event.attr("event_id");
params['event_schedule']['schedule_id'] = schedule_id;
}
var success_callback = function(data) {
console.log(data);
event.attr("event_schedule_id", data.event_schedule_id);
event.find(".schedule-event-delete-button").show();
}
var error_callback = function(data) {
console.log(data);
showError($.parseJSON(data.responseText).errors);
event.appendTo(previous_parent);
}
$.ajax({
url: my_url,
type: type,
data: params,
success: success_callback,
error: error_callback,
dataType : 'json'
});
}
};
$(document).ready( function() {
// hide the remove button for unscheduled and non schedulable events
$('.unscheduled-events .schedule-event-delete-button').hide();
$('.non_schedulable .schedule-event-delete-button').hide();
// set events as draggable
$('.schedule-event').not('.non_schedulable').draggable({
snap: '.schedule-room-slot',
revertDuration: 200,
revert: function (event, ui) {
console.log(event.attr);
return !event;
},
stop: function(event, ui) {
this._originalPosition = this._originalPosition || ui.originalPosition;
ui.helper.animate( this._originalPosition );
},
opacity: 0.7,
snapMode: "inner",
zIndex: 2
});
// set room cells as droppable
$('.schedule-room-slot').not('.non_schedulable .schedule-room-slot').droppable({
accept: '.schedule-event',
tolerance: "pointer",
drop: function(event, ui) {
$(ui.draggable).css("left", 0);
$(ui.draggable).css("top", 0);
$(this).css("background-color", "#ffffff");
Schedule.add($(ui.draggable).parent(), $(this), $(ui.draggable));
},
over: function(event, ui) {
$(this).css("background-color", "#009ED8");
},
out: function(event, ui) {
$(this).css("background-color", "#ffffff");
}
});
});
function eventClicked(e, element){
var url = $(element).data('url');
if(e.ctrlKey)
window.open(url,'_blank');
else
window.location = url;
}
/* Links inside event-panel (to make ctrl + click work for these links):
= link_to text, '#', onClick: 'insideLinkClicked();', 'data-url' => url
*/
function insideLinkClicked(event){
// stops the click from propagating
if (!event) // for IE
var event = window.event;
event.cancelBubble = true;
if (event.stopPropagation) event.stopPropagation();
var url = $(event.target).data('url');
if(event.ctrlKey)
window.open(url,'_blank');
else
window.location = url;
}