diff --git a/dashboard-ui/scripts/userparentalcontrol.js b/dashboard-ui/scripts/userparentalcontrol.js
index ec5c94ab10..d4bd4d5abd 100644
--- a/dashboard-ui/scripts/userparentalcontrol.js
+++ b/dashboard-ui/scripts/userparentalcontrol.js
@@ -100,9 +100,67 @@
$('#selectMaxParentalRating', page).val(ratingValue).selectmenu("refresh");
+ if (user.Configuration.IsAdministrator) {
+ $('.accessScheduleSection', page).hide();
+ } else {
+ $('.accessScheduleSection', page).show();
+ }
+
+ renderAccessSchedule(page, user.Configuration.AccessSchedules || []);
+
Dashboard.hideLoadingMsg();
}
+ function getDisplayTime(hour) {
+
+ return new Date(2000, 1, 1, hour, 0, 0, 0).toLocaleTimeString();
+
+ }
+
+ function deleteAccessSchedule(page, schedules, index) {
+
+ schedules.splice(index, 1);
+
+ renderAccessSchedule(page, schedules);
+ }
+
+ function renderAccessSchedule(page, schedules) {
+
+ var html = '
';
+
+ var elem = $('.accessScheduleList', page).html(html).trigger('create');
+
+ $('.btnDelete', elem).on('click', function () {
+
+ deleteAccessSchedule(page, schedules, parseInt(this.getAttribute('data-index')));
+ });
+ }
+
function onSaveComplete(page) {
Dashboard.hideLoadingMsg();
@@ -120,6 +178,8 @@
}).get();
+ user.Configuration.AccessSchedules = getSchedulesFromPage(page);
+
ApiClient.updateUser(user).done(function () {
onSaveComplete(page);
});
@@ -139,12 +199,103 @@
saveUser(result, page);
});
+ // Disable default form submission
+ return false;
+ },
+
+ onScheduleFormSubmit: function () {
+
+ var page = $(this).parents('.page');
+
+ saveSchedule(page);
+
// Disable default form submission
return false;
}
};
- $(document).on('pageshow', "#userParentalControlPage", function () {
+ function populateHours(page) {
+
+ var html = '';
+
+ for (var i = 0; i < 24; i++) {
+
+ html += '';
+ }
+
+ $('#selectStart', page).html(html).selectmenu('refresh');
+ $('#selectEnd', page).html(html).selectmenu('refresh');
+ }
+
+ function showSchedulePopup(page, schedule, index) {
+
+ schedule = schedule || {};
+
+ $('#popupSchedule', page).popup('open');
+
+ $('#fldScheduleIndex', page).val(index);
+
+ $('#selectDay', page).val(schedule.DayOfWeek || 'Sunday').selectmenu('refresh');
+ $('#selectStart', page).val(schedule.StartHour || 0).selectmenu('refresh');
+ $('#selectEnd', page).val(schedule.EndHour || 0).selectmenu('refresh');
+ }
+
+ function saveSchedule(page) {
+
+ var schedule = {
+ DayOfWeek: $('#selectDay', page).val(),
+ StartHour: $('#selectStart', page).val(),
+ EndHour: $('#selectEnd', page).val()
+ };
+
+ if (parseFloat(schedule.StartHour) >= parseFloat(schedule.EndHour)) {
+
+ alert(Globalize.translate('ErrorMessageStartHourGreaterThanEnd'));
+
+ return;
+ }
+
+ var schedules = getSchedulesFromPage(page);
+
+ var index = parseInt($('#fldScheduleIndex', page).val());
+
+ if (index == -1) {
+ index = schedules.length;
+ }
+
+ schedules[index] = schedule;
+
+ renderAccessSchedule(page, schedules);
+
+ $('#popupSchedule', page).popup('close');
+ }
+
+ function getSchedulesFromPage(page) {
+
+ return $('.liSchedule', page).map(function () {
+
+ return {
+ DayOfWeek: this.getAttribute('data-day'),
+ StartHour: this.getAttribute('data-start'),
+ EndHour: this.getAttribute('data-end')
+ };
+
+ }).get();
+ }
+
+ $(document).on('pageinit', "#userParentalControlPage", function () {
+
+ var page = this;
+
+
+ $('.btnAddSchedule', page).on('click', function () {
+
+ showSchedulePopup(page, {}, -1);
+ });
+
+ populateHours(page);
+
+ }).on('pageshow', "#userParentalControlPage", function () {
var page = this;
diff --git a/dashboard-ui/scripts/userprofilespage.js b/dashboard-ui/scripts/userprofilespage.js
index 490d97a705..9dd5fb4c73 100644
--- a/dashboard-ui/scripts/userprofilespage.js
+++ b/dashboard-ui/scripts/userprofilespage.js
@@ -36,10 +36,13 @@
html += '';
html += '';
diff --git a/dashboard-ui/userparentalcontrol.html b/dashboard-ui/userparentalcontrol.html
index 23809f1c57..9a9c912f7e 100644
--- a/dashboard-ui/userparentalcontrol.html
+++ b/dashboard-ui/userparentalcontrol.html
@@ -30,7 +30,22 @@
-
+
+
+
+
${HeaderAccessSchedule}
+
+
${HeaderAccessScheduleHelp}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dashboard-ui/userprofiles.html b/dashboard-ui/userprofiles.html
index 1ee3198970..17efa4b91d 100644
--- a/dashboard-ui/userprofiles.html
+++ b/dashboard-ui/userprofiles.html
@@ -22,9 +22,8 @@
-
-
+
-
-
+
${HeaderPendingInvitations}