diff --git a/Web/Resgrid.Web/Areas/User/Views/Groups/Geofence.cshtml b/Web/Resgrid.Web/Areas/User/Views/Groups/Geofence.cshtml
index 464d1182..f6cbc733 100644
--- a/Web/Resgrid.Web/Areas/User/Views/Groups/Geofence.cshtml
+++ b/Web/Resgrid.Web/Areas/User/Views/Groups/Geofence.cshtml
@@ -43,6 +43,9 @@
@Html.HiddenFor(m => m.Group.DepartmentGroupId)
@Model.Group.Name
diff --git a/Web/Resgrid.Web/wwwroot/js/app/internal/calendar/resgrid.calendar.editEntry.js b/Web/Resgrid.Web/wwwroot/js/app/internal/calendar/resgrid.calendar.editEntry.js
index 359abdb8..5bff419f 100644
--- a/Web/Resgrid.Web/wwwroot/js/app/internal/calendar/resgrid.calendar.editEntry.js
+++ b/Web/Resgrid.Web/wwwroot/js/app/internal/calendar/resgrid.calendar.editEntry.js
@@ -70,6 +70,24 @@ var resgrid;
$("#Item_RepeatOnDay").attr({ type: 'number', min: 1, max: 31, step: 1 });
+ // Toggle between "day of month" and "weekday occurrence" inputs
+ $('input[name="month"]').on('change', function () {
+ if ($(this).val() === 'weekday') {
+ $('#Item_RepeatOnDay').prop('disabled', true).removeAttr('min max');
+ $('#WeekdayOccurrence, #WeekdayDayOfWeek').prop('disabled', false);
+ } else {
+ $('#Item_RepeatOnDay').prop('disabled', false).attr({ min: 1, max: 31 });
+ $('#WeekdayOccurrence, #WeekdayDayOfWeek').prop('disabled', true);
+ }
+ });
+
+ // Determine initial radio state from existing data
+ if ($('#Item_RepeatOnWeek').length && parseInt($('#Item_RepeatOnWeek').val()) > 0) {
+ $('input[name="month"][value="weekday"]').prop('checked', true).trigger('change');
+ } else {
+ $('input[name="month"][value="monthday"]').prop('checked', true).trigger('change');
+ }
+
let quill = new Quill('#editor-container', {
placeholder: '',
theme: 'snow'
diff --git a/Web/Resgrid.Web/wwwroot/js/app/internal/calendar/resgrid.calendar.newEntry.js b/Web/Resgrid.Web/wwwroot/js/app/internal/calendar/resgrid.calendar.newEntry.js
index 8ad1058f..5eea4596 100644
--- a/Web/Resgrid.Web/wwwroot/js/app/internal/calendar/resgrid.calendar.newEntry.js
+++ b/Web/Resgrid.Web/wwwroot/js/app/internal/calendar/resgrid.calendar.newEntry.js
@@ -66,6 +66,20 @@ var resgrid;
$("#Item_RepeatOnDay").attr({ type: 'number', min: 1, max: 31, step: 1 });
+ // Toggle between "day of month" and "weekday occurrence" inputs
+ $('input[name="month"]').on('change', function () {
+ if ($(this).val() === 'weekday') {
+ $('#Item_RepeatOnDay').prop('disabled', true).removeAttr('min max');
+ $('#WeekdayOccurrence, #WeekdayDayOfWeek').prop('disabled', false);
+ } else {
+ $('#Item_RepeatOnDay').prop('disabled', false).attr({ min: 1, max: 31 });
+ $('#WeekdayOccurrence, #WeekdayDayOfWeek').prop('disabled', true);
+ }
+ });
+
+ // Default to "monthday" radio selected, weekday dropdowns disabled
+ $('input[name="month"][value="monthday"]').prop('checked', true).trigger('change');
+
var quill = new Quill('#editor-container', {
placeholder: '',
theme: 'snow'
diff --git a/Web/Resgrid.Web/wwwroot/js/app/internal/groups/resgrid.groups.geofence.js b/Web/Resgrid.Web/wwwroot/js/app/internal/groups/resgrid.groups.geofence.js
index 2c861a61..8a137fa1 100644
--- a/Web/Resgrid.Web/wwwroot/js/app/internal/groups/resgrid.groups.geofence.js
+++ b/Web/Resgrid.Web/wwwroot/js/app/internal/groups/resgrid.groups.geofence.js
@@ -94,6 +94,14 @@ var resgrid;
});
}
+ var groupId = $('#Group_DepartmentGroupId').val();
+ if (!groupId) {
+ $('#alertArea').html('
Unable to determine the group. Please reload the page and try again.
');
+ $('#successArea').hide();
+ $('#alertArea').show();
+ return;
+ }
+
$.ajax({
type: "POST",
async: true,
@@ -102,14 +110,20 @@ var resgrid;
cache: false,
processData: false,
data: JSON.stringify({
- DepartmentGroupId: $('#Group_DepartmentGroupId').val(),
+ DepartmentGroupId: parseInt(groupId, 10),
Color: $('#colorPicker').val(),
GeoFence: JSON.stringify(coords)
})
}).done(function (data) {
- $('#successArea').html('
Your geofence has been saved.
');
- $('#successArea').show();
- $('#alertArea').hide();
+ if (data && data.Success) {
+ $('#successArea').html('
' + (data.Message || 'Your geofence has been saved.') + '
');
+ $('#successArea').show();
+ $('#alertArea').hide();
+ } else {
+ $('#alertArea').html('
' + (data && data.Message ? data.Message : 'Your geofence could not be saved.') + '
');
+ $('#successArea').hide();
+ $('#alertArea').show();
+ }
}).fail(function (error) {
$('#alertArea').html('
Your geofence could not be saved. Please correct the errors and try again.
');
$('#successArea').hide();