CC-2436: Save pulldown settings
Fixing the issue of "show entries" dropdown setting not being saved. After some investigation, it seems like we're destroying the calendar everytime we modify the dropdown value, and create a new one, which explains why the new setting is not being saved. Fixed by moving the code that handles the updating to the place after we create the new calendar. This makes the code cleaner as well.
This commit is contained in:
parent
a5939afd3f
commit
a0bf7c90ba
3 changed files with 28 additions and 44 deletions
|
@ -559,19 +559,24 @@ class Application_Model_Preference
|
||||||
/* User specific preferences start */
|
/* User specific preferences start */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the time scale preference (day/week/month) in Calendar.
|
* Sets the time scale preference (agendaDay/agendaWeek/month) in Calendar.
|
||||||
*
|
*
|
||||||
* @param $timeScale new time scale
|
* @param $timeScale new time scale
|
||||||
*/
|
*/
|
||||||
public static function SetCalendarTimeScale($timeScale) {
|
public static function SetCalendarTimeScale($timeScale) {
|
||||||
return self::SetValue("calendar_time_scale", $timeScale, true /* user specific */);
|
self::SetValue("calendar_time_scale", $timeScale, true /* user specific */);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the time scale preference for the current user.
|
* Retrieves the time scale preference for the current user.
|
||||||
|
* Defaults to month if no entry exists
|
||||||
*/
|
*/
|
||||||
public static function GetCalendarTimeScale() {
|
public static function GetCalendarTimeScale() {
|
||||||
return self::GetValue("calendar_time_scale", true /* user specific */);
|
$val = self::GetValue("calendar_time_scale", true /* user specific */);
|
||||||
|
if(strlen($val) == 0) {
|
||||||
|
$val = 'month';
|
||||||
|
}
|
||||||
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -580,7 +585,7 @@ class Application_Model_Preference
|
||||||
* @param $numEntries new number of entries to show
|
* @param $numEntries new number of entries to show
|
||||||
*/
|
*/
|
||||||
public static function SetLibraryNumEntries($numEntries) {
|
public static function SetLibraryNumEntries($numEntries) {
|
||||||
return self::SetValue("library_num_entries", $numEntries, true /* user specific */);
|
self::SetValue("library_num_entries", $numEntries, true /* user specific */);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -595,15 +600,20 @@ class Application_Model_Preference
|
||||||
*
|
*
|
||||||
* @param $timeInterval new time interval
|
* @param $timeInterval new time interval
|
||||||
*/
|
*/
|
||||||
public static function SetCalendarTimeInterval($timeInterval) {
|
public static function SetCalendarTimeInterval($timeInterval) {
|
||||||
return self::SetValue("calendar_time_interval", $timeInterval, true /* user specific */);
|
self::SetValue("calendar_time_interval", $timeInterval, true /* user specific */);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the time interval preference for the current user.
|
* Retrieves the time interval preference for the current user.
|
||||||
|
* Defaults to 30 min if no entry exists
|
||||||
*/
|
*/
|
||||||
public static function GetCalendarTimeInterval() {
|
public static function GetCalendarTimeInterval() {
|
||||||
return self::GetValue("calendar_time_interval", true /* user specific */);
|
$val = self::GetValue("calendar_time_interval", true /* user specific */);
|
||||||
|
if(strlen($val) == 0) {
|
||||||
|
$val = "30";
|
||||||
|
}
|
||||||
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* User specific preferences end */
|
/* User specific preferences end */
|
||||||
|
|
|
@ -197,6 +197,10 @@ function viewDisplay( view ) {
|
||||||
.fullCalendar('destroy')
|
.fullCalendar('destroy')
|
||||||
.fullCalendar(opt)
|
.fullCalendar(opt)
|
||||||
.fullCalendar( 'gotoDate', date );
|
.fullCalendar( 'gotoDate', date );
|
||||||
|
|
||||||
|
//save slotMin value to db
|
||||||
|
var url = '/Schedule/set-time-interval/format/json';
|
||||||
|
$.post(url, {timeInterval: slotMin});
|
||||||
});
|
});
|
||||||
|
|
||||||
var topLeft = $(view.element).find("table.fc-agenda-days > thead th:first");
|
var topLeft = $(view.element).find("table.fc-agenda-days > thead th:first");
|
||||||
|
@ -214,6 +218,10 @@ function viewDisplay( view ) {
|
||||||
if(($("#add-show-form").length == 1) && ($("#add-show-form").css('display')=='none') && ($('.fc-header-left > span').length == 5)) {
|
if(($("#add-show-form").length == 1) && ($("#add-show-form").css('display')=='none') && ($('.fc-header-left > span').length == 5)) {
|
||||||
makeAddShowButton();
|
makeAddShowButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//save view name to db
|
||||||
|
var url = '/Schedule/set-time-scale/format/json';
|
||||||
|
$.post(url, {timeScale: view.name});
|
||||||
}
|
}
|
||||||
|
|
||||||
function eventRender(event, element, view) {
|
function eventRender(event, element, view) {
|
||||||
|
|
|
@ -306,26 +306,14 @@ function buildScheduleDialog(json){
|
||||||
* Use user preference for time scale; defaults to month if preference was never set
|
* Use user preference for time scale; defaults to month if preference was never set
|
||||||
*/
|
*/
|
||||||
function getTimeScalePreference(data) {
|
function getTimeScalePreference(data) {
|
||||||
var timeScale = data.calendarInit.timeScale;
|
return data.calendarInit.timeScale;
|
||||||
if(timeScale == 'day') {
|
|
||||||
timeScale = 'agendaDay';
|
|
||||||
} else if(timeScale == 'week') {
|
|
||||||
timeScale = 'agendaWeek';
|
|
||||||
} else {
|
|
||||||
timeScale = 'month';
|
|
||||||
}
|
|
||||||
return timeScale;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use user preference for time interval; defaults to 30m if preference was never set
|
* Use user preference for time interval; defaults to 30m if preference was never set
|
||||||
*/
|
*/
|
||||||
function getTimeIntervalPreference(data) {
|
function getTimeIntervalPreference(data) {
|
||||||
var timeInterval = data.calendarInit.timeInterval;
|
return parseInt(data.calendarInit.timeInterval);
|
||||||
if(timeInterval == '') {
|
|
||||||
timeInterval = '30';
|
|
||||||
}
|
|
||||||
return parseInt(timeInterval);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createFullCalendar(data){
|
function createFullCalendar(data){
|
||||||
|
@ -366,28 +354,6 @@ function createFullCalendar(data){
|
||||||
eventDrop: eventDrop,
|
eventDrop: eventDrop,
|
||||||
eventResize: eventResize
|
eventResize: eventResize
|
||||||
});
|
});
|
||||||
|
|
||||||
//Update time scale preference when day/week/month button is clicked
|
|
||||||
$(".fc-button-content").click(function() {
|
|
||||||
var url = '/Schedule/set-time-scale/format/json';
|
|
||||||
$.post(url, {timeScale: $(this).text()},
|
|
||||||
function(json){
|
|
||||||
if(json.error) {
|
|
||||||
alert(json.error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
//Update time interval preference when dropdown is updated
|
|
||||||
$(".schedule_change_slots.input_select").change(function() {
|
|
||||||
var url = '/Schedule/set-time-interval/format/json';
|
|
||||||
$.post(url, {timeInterval: $(this).val()},
|
|
||||||
function(json){
|
|
||||||
if(json.error) {
|
|
||||||
alert(json.error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Alert the error and reload the page
|
//Alert the error and reload the page
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue