Skip to content

Commit

Permalink
Merge pull request #188 from hargata/Hargata/parse.url
Browse files Browse the repository at this point in the history
added setting to automatically load parsed markdown.
  • Loading branch information
hargata authored Jan 30, 2024
2 parents c49c8a5 + 04ce448 commit 4a00753
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 5 deletions.
1 change: 1 addition & 0 deletions Helper/ConfigHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public UserConfig GetUserConfig(ClaimsPrincipal user)
EnableAuth = bool.Parse(_config[nameof(UserConfig.EnableAuth)]),
HideZero = bool.Parse(_config[nameof(UserConfig.HideZero)]),
UseUKMPG = bool.Parse(_config[nameof(UserConfig.UseUKMPG)]),
UseMarkDownOnSavedNotes = bool.Parse(_config[nameof(UserConfig.UseMarkDownOnSavedNotes)]),
UseThreeDecimalGasCost = bool.Parse(_config[nameof(UserConfig.UseThreeDecimalGasCost)]),
EnableAutoReminderRefresh = bool.Parse(_config[nameof(UserConfig.EnableAutoReminderRefresh)]),
EnableAutoOdometerInsert = bool.Parse(_config[nameof(UserConfig.EnableAutoOdometerInsert)]),
Expand Down
1 change: 1 addition & 0 deletions Models/UserConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class UserConfig
public bool HideZero { get; set; }
public bool UseUKMPG {get;set;}
public bool UseThreeDecimalGasCost { get; set; }
public bool UseMarkDownOnSavedNotes { get; set; }
public bool EnableAutoReminderRefresh { get; set; }
public bool EnableAutoOdometerInsert { get; set; }
public string UserNameHash { get; set; }
Expand Down
5 changes: 5 additions & 0 deletions Views/Home/_Settings.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
<input class="form-check-input" onChange="updateSettings()" type="checkbox" role="switch" id="useThreeDecimal" checked="@Model.UseThreeDecimalGasCost">
<label class="form-check-label" for="useThreeDecimal">Use Three Decimals For Fuel Cost</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input" onChange="updateSettings()" type="checkbox" role="switch" id="useMarkDownOnSavedNotes" checked="@Model.UseMarkDownOnSavedNotes">
<label class="form-check-label" for="useMarkDownOnSavedNotes">Display Saved Notes in Markdown</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input" onChange="updateSettings()" type="checkbox" role="switch" id="enableAutoReminderRefresh" checked="@Model.EnableAutoReminderRefresh">
<label class="form-check-label" for="enableAutoReminderRefresh">Auto Refresh Lapsed Recurring Reminders</label>
Expand Down Expand Up @@ -212,6 +216,7 @@
hideZero: $("#hideZero").is(":checked"),
useUKMpg: $("#useUKMPG").is(":checked"),
useThreeDecimalGasCost: $("#useThreeDecimal").is(":checked"),
useMarkDownOnSavedNotes: $("#useMarkDownOnSavedNotes").is(":checked"),
enableAutoReminderRefresh: $("#enableAutoReminderRefresh").is(":checked"),
enableAutoOdometerInsert: $("#enableAutoOdometerInsert").is(":checked"),
visibleTabs: visibleTabs,
Expand Down
4 changes: 3 additions & 1 deletion Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
var userConfig = config.GetUserConfig(User);
var useDarkMode = userConfig.UseDarkMode;
var enableCsvImports = userConfig.EnableCsvImports;
var useMarkDown = userConfig.UseMarkDownOnSavedNotes;
var shortDatePattern = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
var numberFormat = System.Globalization.CultureInfo.CurrentCulture.NumberFormat;
shortDatePattern = shortDatePattern.ToLower();
Expand Down Expand Up @@ -47,7 +48,8 @@
function getGlobalConfig() {
return {
useDarkMode : "@useDarkMode" == "True",
enableCsvImport : "@enableCsvImports" == "True"
enableCsvImport : "@enableCsvImports" == "True",
useMarkDown: "@useMarkDown" == "True"
}
}
function getShortDatePattern() {
Expand Down
1 change: 1 addition & 0 deletions appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"EnableAutoOdometerInsert": false,
"UseUKMPG": false,
"UseThreeDecimalGasCost": true,
"UseMarkDownOnSavedNotes": false,
"VisibleTabs": [ 0, 1, 4, 2, 3, 6, 5, 8 ],
"DefaultTab": 8,
"UserNameHash": "",
Expand Down
5 changes: 5 additions & 0 deletions wwwroot/js/collisionrecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ function showEditCollisionRecordModal(collisionRecordId) {
//initiate datepicker
initDatePicker($('#collisionRecordDate'));
$('#collisionRecordModal').modal('show');
$('#collisionRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("collisionRecordNotes");
}
});
}
});
}
Expand Down
5 changes: 5 additions & 0 deletions wwwroot/js/gasrecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ function showEditGasRecordModal(gasRecordId) {
//initiate datepicker
initDatePicker($('#gasRecordDate'));
$('#gasRecordModal').modal('show');
$('#gasRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("gasRecordNotes");
}
});
}
});
}
Expand Down
5 changes: 5 additions & 0 deletions wwwroot/js/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ function showEditNoteModal(noteId) {
if (data) {
$("#noteModalContent").html(data);
$('#noteModal').modal('show');
$('#noteModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("noteTextArea");
}
});
}
});
}
Expand Down
5 changes: 5 additions & 0 deletions wwwroot/js/odometerrecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ function showEditOdometerRecordModal(odometerRecordId) {
//initiate datepicker
initDatePicker($('#odometerRecordDate'));
$('#odometerRecordModal').modal('show');
$('#odometerRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("odometerRecordNotes");
}
});
}
});
}
Expand Down
5 changes: 5 additions & 0 deletions wwwroot/js/planrecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ function showEditPlanRecordModal(planRecordId) {
//initiate datepicker
initDatePicker($('#planRecordDate'));
$('#planRecordModal').modal('show');
$('#planRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("planRecordNotes");
}
});
}
});
}
Expand Down
5 changes: 5 additions & 0 deletions wwwroot/js/reminderrecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
$("#reminderRecordModalContent").html(data);
initDatePicker($('#reminderDate'), true);
$("#reminderRecordModal").modal("show");
$('#reminderRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("reminderNotes");
}
});
}
});
}
Expand Down
5 changes: 5 additions & 0 deletions wwwroot/js/servicerecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ function showEditServiceRecordModal(serviceRecordId) {
//initiate datepicker
initDatePicker($('#serviceRecordDate'));
$('#serviceRecordModal').modal('show');
$('#serviceRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("serviceRecordNotes");
}
});
}
});
}
Expand Down
5 changes: 5 additions & 0 deletions wwwroot/js/supplyrecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ function showEditSupplyRecordModal(supplyRecordId) {
//initiate datepicker
initDatePicker($('#supplyRecordDate'));
$('#supplyRecordModal').modal('show');
$('#supplyRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("supplyRecordNotes");
}
});
}
});
}
Expand Down
5 changes: 5 additions & 0 deletions wwwroot/js/taxrecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ function showEditTaxRecordModal(taxRecordId) {
//initiate datepicker
initDatePicker($('#taxRecordDate'));
$('#taxRecordModal').modal('show');
$('#taxRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("taxRecordNotes");
}
});
}
});
}
Expand Down
5 changes: 5 additions & 0 deletions wwwroot/js/upgraderecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ function showEditUpgradeRecordModal(upgradeRecordId) {
//initiate datepicker
initDatePicker($('#upgradeRecordDate'));
$('#upgradeRecordModal').modal('show');
$('#upgradeRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("upgradeRecordNotes");
}
});
}
});
}
Expand Down
11 changes: 7 additions & 4 deletions wwwroot/js/vehicle.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,7 @@ function moveRecord(recordId, source, dest) {
}
});
}
function showLinks(e) {
var textAreaName = $(e.parentElement).attr("for");
function toggleMarkDownOverlay(textAreaName) {
var textArea = $(`#${textAreaName}`);
if ($(".markdown-overlay").length > 0) {
$(".markdown-overlay").remove();
Expand All @@ -429,7 +428,11 @@ function showLinks(e) {
if (text.length > 0) {
var formatted = markdown(text);
//var overlay div
var overlayDiv = `<div class='markdown-overlay' style="position:absolute; top:${textArea.css('top')}; left:${textArea.css('left')}; width:${textArea.css('width')}; height:${textArea.css('height')}; padding:${textArea.css('padding')}; overflow-y:auto; background-color:var(--bs-modal-bg);">${formatted}</div>`;
$(e.parentElement).append(overlayDiv);
var overlayDiv = `<div class='markdown-overlay' style="z-index: 1060; position:absolute; top:${textArea.css('top')}; left:${textArea.css('left')}; width:${textArea.css('width')}; height:${textArea.css('height')}; padding:${textArea.css('padding')}; overflow-y:auto; background-color:var(--bs-modal-bg);">${formatted}</div>`;
textArea.parent().children(`label[for=${textAreaName}]`).append(overlayDiv);
}
}
function showLinks(e) {
var textAreaName = $(e.parentElement).attr("for");
toggleMarkDownOverlay(textAreaName);
}

0 comments on commit 4a00753

Please sign in to comment.