Urgent fixes for inability to create policy with blank Db

also inability to save policy.
This commit is contained in:
chris.watts90@outlook.com 2020-02-26 08:31:39 +00:00
parent e504a09522
commit 1ab31f6d75
7 changed files with 42 additions and 29 deletions

View File

@ -2,7 +2,7 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Bundle Name="FlexiTimeSystemInstaller"
Version="0.2.1.0"
Version="0.2.3.0"
Manufacturer="Chris Watts"
UpgradeCode="d38e92db-48f9-40c3-9a6f-d76fbd07326e">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">

View File

@ -527,7 +527,18 @@ namespace SQLiteRepository
var query = $"select * from {nameof(PolicyDb)}";
var policies = _connection.Query<PolicyDb>(query);
if (!policies.Any())
{
return new Policy()
{
ChangeAuthor = string.Empty,
ChangeDate = DateTime.UtcNow,
ChangeDescription = string.Empty,
Html=string.Empty,
Markdown = string.Empty,
Version = "0"
};
}
return PolicyConverter.ConvertToPolicyDto(policies.OrderByDescending(x => x.Version).FirstOrDefault());
}

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.2.2.0")]
[assembly: AssemblyFileVersion("0.2.2.0")]
[assembly: AssemblyVersion("0.2.3.0")]
[assembly: AssemblyFileVersion("0.2.3.0")]

View File

@ -119,7 +119,7 @@
<textarea id="policyEditor"></textarea>
</div>
<div id="preview" class="tab-pane fade in">
<div data-bind="html: policyData.html" class="well-lg"></div>
<div data-bind="html: policyData.Html" class="well-lg"></div>
</div>
</div>
<button class="btn btn-primary pull-right" data-toggle="modal" data-target="#saveDialog">Save</button><!--data-bind="click: $root.policySave"-->

View File

@ -22,7 +22,7 @@
var escaped = "unknown";
if (parserHandler.dom.length > 0) {
escaped = parserHandler.dom[0].raw.toLowerCase().trim().replace(/ /g, "-");
escaped = parserHandler.dom[0].raw.toLowerCase().trim().replace(/ /g, "-").replace(/#+/g,"");
}
return "<h" + level + " id=\"" + escaped + "\">"
@ -66,7 +66,7 @@
});
self.editor.codemirror.on("changes",
function () {
self.policyData.html(self.editor.options.previewRender(self.editor.value()));
self.policyData.Html(self.editor.options.previewRender(self.editor.value()));
});
self.uiPages = {
overview: "overview",
@ -169,8 +169,9 @@
self.policySave = function () {
var url = self.helpers.createRequestUrl(self.apiEndpoints.savePolicy, null, false);
self.policyData.Markdown(self.editor.value()); //make sure we update it, as it doesnt push the value back into the variable
//console.log(self.policyData());
$.post(url, self.policyData(), function() {
//console.log(self.policyData();)rea#
var data = ko.toJS(self.policyData);
$.post(url, data, function() {
}, "json") //todo: check this serialisation as the object is now complex.
.done(function() {
self.policyReload();

File diff suppressed because one or more lines are too long

View File

@ -3,28 +3,29 @@
if (typeof data === "undefined") {
data = createDefaultPolicy();
}
self.changeDate = ko.observable(data.changeDate);
self.description = ko.observable(data.description);
self.changeAuthor = ko.observable(data.changeAuthor);
self.version = ko.observable(data.version);
self.markdown = ko.observable(data.markdown);
self.html = ko.observable(data.html);
self.ChangeDate = ko.observable(data.ChangeDate);
self.ChangeDescription = ko.observable(data.ChangeDescription);
self.ChangeAuthor = ko.observable(data.ChangeAuthor);
self.Version = ko.observable(data.Version);
self.Markdown = ko.observable(data.Markdown);
self.Html = ko.observable(data.Html);
function createDefaultPolicy() {
return {
changeDate: moment().format(),
description: "",
changeAuthor: "",
version: -1,
markdown: "",
html: ""
ChangeDate: moment().toISOString(),
Description: "",
ChangeAuthor: "",
Version: -1,
Markdown: "",
Html: ""
};
}
self.update = function (data) {
self.changeDate(data.changeDate);
self.description(data.description);
self.changeAuthor(data.changeAuthor);
self.version(data.version);
self.markdown(data.markdown);
self.html(data.html);
if (!data) return;
self.ChangeDate(data.ChangeDate);
self.ChangeDescription(data.ChangeDescription);
self.ChangeAuthor(data.ChangeAuthor);
self.Version(data.Version);
self.Markdown(data.Markdown);
self.Html(data.Html);
}
}