Admin fixes

Add meta description counter; Fix bug #39
This commit is contained in:
Thomas Hounsell 2016-01-06 11:54:32 +00:00
parent 2585ff4a4e
commit 723e048a4d
2 changed files with 29 additions and 4 deletions

View File

@ -22,9 +22,12 @@
@Html.TextAreaFor(model => model.MetaDescription, new { @class = "form-control", rows = "2" })
</div>
</div>
<div class="help-block">
<span id="meta-count">0</span> characters
@Html.ValidationMessageFor(model => model.MetaDescription)
</div>
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.PageContent, new { @class = "control-label col-sm-2" })
@ -34,9 +37,11 @@
@Html.TextAreaFor(model => model.PageContent, new { @class = "form-control" })
</div>
</div>
<div class="help-block">
@Html.ValidationMessageFor(model => model.PageContent)
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
@ -54,6 +59,20 @@
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
function updateMetaCount() {
var count = document.getElementById("@Html.IdFor(model => model.MetaDescription)").value.length;
$("#meta-count").text(count.toFixed(0));
if (count == 0) {
$("#meta-count").attr("class", "");
}
else if (count < 160) {
$("#meta-count").attr("class", "text-success");
}
else {
$("#meta-count").attr("class", "text-danger");
}
}
$(function () {
var btnsGrps = $.trumbowyg.btnsGrps;
@ -66,6 +85,12 @@
'|', btnsGrps.justify,
'|', btnsGrps.lists]
});
})
$("#@Html.IdFor(model => model.MetaDescription)").keyup(function () {
updateMetaCount();
});
updateMetaCount();
});
</script>
}

View File

@ -180,7 +180,7 @@ public override MembershipUser CreateUser(string username, string password, stri
public override bool DeleteUser(string username, bool deleteAllRelatedData)
{
var task = _memberCollection
.DeleteOneAsync(m => m.UserName.ToLower() == username);
.DeleteOneAsync(m => m.UserName.ToLower() == username.ToLower());
task.Wait();
return task.Result.IsAcknowledged && task.Result.DeletedCount == 1;