This commit is contained in:
2022-05-16 15:01:01 +01:00
parent 4cc1185c3c
commit d17cce340e
18 changed files with 318 additions and 203 deletions
@@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
@@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
@@ -12,7 +12,7 @@
<div class="sax-content">
<div class="spacer4"></div>
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmChangePassword", @class = "sax-form" }))
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmChangePassword", @class = "sax-form", @onsubmit = "return false;" }))
{
@if (!Model.RequestPasswordMode)
@@ -12,7 +12,7 @@
<div class="sax-content">
<div class="spacer4"></div>
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmRequestPassword", @class = "sax-form" }))
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmRequestPassword", @class = "sax-form", @onsubmit = "return false;" }))
{
<div class="sax-form-control EmailAddress">
@@ -13,7 +13,7 @@
<div class="sax-content">
<div class="spacer4"></div>
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmSignIn", @class = "sax-form" }))
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmSignIn", @class = "sax-form", @onsubmit = "return false;" }))
{
<div class="sax-form-control EmailAddress">
@@ -25,33 +25,32 @@
</div>
<div class="sax-message"></div>
</div>
<div class="spacer2"></div>
<div class="sax-form-control Password">
<div class="row">
<div class="col-6">
<div class="sax-label">
<label for="ifPassword"><span><span class="required">*</span> @Localiser["label.password"]</span></label>
</div>
</div>
<div class="col-6 right">
<div class="sax-action-link" style="font-size:12px;" onclick="sax.goToPage('Security/RequestPassword');">@Localiser["label.forgotten.password"]</div>
</div>
</div>
<div class="sax-control">
@Html.PasswordFor(model => model.Password, new { @id = "ifPassword", @class = "sax-input", @maxlength = @Model.PasswordMaxLength })
</div>
<div class="sax-message"></div>
</div>
<div class="spacer4"></div>
<div class="spacer2"></div>
<div class="sax-form-control">
<div class="">
<div class="row">
<div class="col-6">
@Html.CheckBoxFor(model => model.KeepMeSignedIn, new { @id = "chkKeepMeSignedIn" })
&nbsp;
<span class="sax-label pointer" onclick="$('#chkKeepMeSignedIn').click()">@Localiser["label.keep.signed.in"]</span>
</div>
<div class="col-6 right">
<div class="sax-action-link" style="font-size:12px;" onclick="sax.goToPage('Security/RequestPassword');">@Localiser["label.forgotten.password"]</div>
</div>
</div>
</div>
<div class="spacer2"></div>
<div class="">
<div id="pbSignIn" class="sax-button-action fullwidth pointer" style="margin:16px 0;">@Localiser["security.caption.signin"]</div>
@@ -30,7 +30,7 @@
sax.onScorePassword = function (response)
{
var score = (response || {}).score || 0;
sax.$prgPasswordStrength.progressbar("option", "value", score).removeClass('amber green').addClass(score > 3 ? 'green' : score > 2 ? 'amber' : '');
sax.$prgPwordStrength.progressbar("option", "value", score).removeClass('amber green').addClass(score > 3 ? 'green' : score > 2 ? 'amber' : '');
}
//--------------------------------------------------------------
@@ -74,16 +74,20 @@
{
$(':input:enabled:visible:first').focus();
$('#ifEmailAddress,#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm').on('input', function () { sax.clearControlError(this); });
$('#frmChangePassword #ifPassword').on('keyup', sax.doScorePassword);
sax.$prgPasswordStrength = $('#frmChangePassword #prgPasswordStrength').progressbar({ 'max': 5 });
$('#ifEmailAddress,#ifPassword', $('#frmSignIn')).on('keypress', function (e) { if (e.which == 13) sax.doSignin(); });
$('#frmSignIn #pbSignIn').on('click', function () { sax.doSignin(); });
$('#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm', $('#frmChangePassword')).on('keypress', function (e) { if (e.which == 13) sax.doChangePassword(); });
$('#frmChangePassword #pbChangePassword').on('click', function () { sax.doChangePassword(); });
$('#ifEmailAddress', $('#frmRequestPassword')).on('keypress', function (e) { if (e.which == 13) sax.doRequestPassword(); });
$('#frmRequestPassword #pbRequestPassword').on('click', function () { sax.doRequestPassword(); });
sax.$frm.signIn = $('#frmSignIn');
sax.$frm.signIn.on('keypress', '#ifEmailAddress,#ifPassword,#chkKeepMeSignedIn', function (e) { if (e.which == 13 && $('#ifEmailAddress', sax.$frm.signIn).val() && $('#ifPassword', sax.$frm.signIn).val()) sax.doSignin(); });
sax.$frm.signIn.on('click', '#pbSignIn', function () { sax.doSignin(); }).on('keypress', '#pbSignIn', function (e) { if (e.which == 13) sax.doSignin(); });;
sax.$frm.chgPword = $('#frmChangePassword');
sax.$frm.chgPword.on('keypress', '#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm', function (e) { if (e.which == 13) sax.doChangePassword(); });
sax.$frm.chgPword.on('keyup', '#ifPassword', sax.doScorePassword);
sax.$prgPwordStrength = $('#prgPasswordStrength', sax.$frm.chgPword).progressbar({ 'max': 5 });
$('#pbChangePassword', sax.$frm.chgPword).on('click', function () { sax.doChangePassword(); }).on('keypress', function (e) { if (e.which == 13) sax.doChangePassword(); });
sax.$frm.reqPword = $('#frmRequestPassword');
sax.$frm.reqPword.on('keypress', '#ifEmailAddress', function (e) { if (e.which == 13) sax.doRequestPassword(); });
$('#pbRequestPassword', sax.$frm.reqPword).on('click', function () { sax.doRequestPassword(); }).on('keypress', function (e) { if (e.which == 13) sax.doRequestPassword(); });
});
//--------------------------------------------------------------
}(window, window.document));
/* The End */
@@ -635,6 +635,15 @@ You will then be able to publicise your sporting activities.</value>
<data name="msg.upload.image.invalid" xml:space="preserve">
<value>Invalid image file uploaded</value>
</data>
<data name="msg.upload.image.invalid.content.type" xml:space="preserve">
<value>Invalid image content type.</value>
</data>
<data name="msg.upload.image.invalid.mime" xml:space="preserve">
<value>Invalid image mime type.</value>
</data>
<data name="msg.upload.image.resize.failed" xml:space="preserve">
<value>Image resize failed.</value>
</data>
<data name="msg.upload.image.single" xml:space="preserve">
<value>Only one image can be uploaded.</value>
</data>
@@ -89,6 +89,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
// Reference data.
public List<CodeDesc> Genders { get; } = new List<CodeDesc>();
public List<CodeDesc> Months { get; } = new List<CodeDesc>();
public List<String> ImageContentTypes { get; set; }
}
// Ajax request.
[HttpPost]
@@ -113,6 +114,9 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
for (int month = 1; month <= 12; month++)
responseData.Months.Add(month.ToString(), DateUtil.Format(new DateTime(DateTime.Today.Year, month, 1), "MMMM", SessionCulture));
// Profile image content types.
responseData.ImageContentTypes = SaxItemImage.GetValidContentTypes(Sax.DataItemType.UserAccount);
// Retrieve user details.
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(UserAccountId);
if (userAccount == null)
@@ -190,6 +194,18 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (!imageConfig.ValidImage)
return Json(responseData.SetControlError("AccountContactImage", Localiser["msg.upload.image.invalid"]));
// Validate mime type.
if (!SaxItemImage.GetValidMimeTypes(Sax.DataItemType.UserAccount).Contains(imageConfig.MimeType))
return Json(responseData.SetControlError("AccountContactImage", Localiser["msg.upload.image.invalid.mime"]));
// Validate content type.
if (StringUtil.IsEmpty(file.ContentType) || !SaxItemImage.GetValidContentTypes(Sax.DataItemType.UserAccount).ContainsCI(file.ContentType))
return Json(responseData.SetControlError("AccountContactImage", Localiser["msg.upload.image.invalid.content.type"]));
// Resize the image if required.
if (!ImageUtils.ConstrainImage(imageConfig, Sax.Config.Online.Profile.User.Image.WidthMax, Sax.Config.Online.Profile.User.Image.HeightMax))
return Json(responseData.SetControlError("AccountContactImage", Localiser["msg.upload.image.resize.failed"]));
// Image belongs to the user's account.
ItemId userItemId = GetUserItemId(UserAccountId);
@@ -200,9 +216,9 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
itemImage.Filename = file.FileName;
itemImage.Mime = SacsContentTypeHelper.GetMimeTypeFromContentType(file.ContentType).ToString().ToLower();
itemImage.ContentType = file.ContentType;
itemImage.ImageData = imageConfig.ImageData;
itemImage.Width = imageConfig.Width;
itemImage.Height = imageConfig.Height;
itemImage.ImageData = imageData;
itemImage.Status = SaxItemImage.DefaultStatus;
if (!SysId.IsValid(itemImage.Id))
@@ -155,8 +155,9 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
public List<ArticleData_List> Articles { get; } = new List<ArticleData_List>();
/// <summary>Organisations that the user has rights to author articles for.</summary>
public List<OrganisationData> Organisations { get; set; }
public ItemIdName defaultSport { get; set; }
public ItemIdName defaultRegion { get; set; }
public ItemIdName DefaultSport { get; set; }
public ItemIdName DefaultRegion { get; set; }
public List<String> ImageContentTypes { get; set; }
}
//-------------------------------------------------------------------
[HttpPost]
@@ -215,7 +216,7 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
SysId defaultSportId = organisation?.SportIdPrimary ?? null;
if (SysId.IsValid(defaultSportId))
{
responseData.defaultSport = new AjaxResponse_Data.ItemIdName()
responseData.DefaultSport = new AjaxResponse_Data.ItemIdName()
{
Id = model.GetEncryptedSportId(defaultSportId),
Name = model.GetSportCaption(defaultSportId)
@@ -226,13 +227,16 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
SysId defaultRegionId = organisation?.RegionIdPrimary ?? userAccount?.RegionIdCountry ?? null;
if (SysId.IsValid(defaultRegionId))
{
responseData.defaultRegion = new AjaxResponse_Data.ItemIdName()
responseData.DefaultRegion = new AjaxResponse_Data.ItemIdName()
{
Id = model.GetEncryptedRegionId(defaultRegionId),
Name = model.GetRegionCaption(defaultRegionId)
};
}
// Article image content types.
responseData.ImageContentTypes = SaxItemImage.GetValidContentTypes(Sax.DataItemType.Article);
// Item filter.
SaxArticle.Params prmArticle = new SaxArticle.Params();
prmArticle.UserAccountIdsAuthorIncluded.Add(sessionData.User.UserAccountId);
@@ -445,6 +449,18 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
if (!imageConfig.ValidImage)
return Json(responseData.SetControlError("ArticleImage", Localiser["msg.upload.image.invalid"]));
// Validate mime type.
if (!SaxItemImage.GetValidMimeTypes(Sax.DataItemType.Article).Contains(imageConfig.MimeType))
return Json(responseData.SetControlError("ArticleImage", Localiser["msg.upload.image.invalid.mime"]));
// Validate content type.
if (StringUtil.IsEmpty(file.ContentType) || !SaxItemImage.GetValidContentTypes(Sax.DataItemType.Article).ContainsCI(file.ContentType))
return Json(responseData.SetControlError("ArticleImage", Localiser["msg.upload.image.invalid.content.type"]));
// Resize the image if required.
if (!ImageUtils.ConstrainImage(imageConfig, Sax.Config.Online.Articles.Images.WidthMax, Sax.Config.Online.Articles.Images.HeightMax))
return Json(responseData.SetControlError("ArticleImage", Localiser["msg.upload.image.resize.failed"]));
// Image belongs to the article.
// If the article doesn't yet exist, it will need to be uploaded to the user first and later transferred.
SysId articleId = model.ExtractSysId(model.ArticleId);
@@ -470,9 +486,9 @@ namespace Saxonite.Net.Core.Web.Online.Controllers
itemImage.Filename = file.FileName;
itemImage.Mime = SacsContentTypeHelper.GetMimeTypeFromContentType(file.ContentType).ToString().ToLower();
itemImage.ContentType = file.ContentType;
itemImage.ImageData = imageConfig.ImageData;
itemImage.Width = imageConfig.Width;
itemImage.Height = imageConfig.Height;
itemImage.ImageData = imageData;
itemImage.SessionUid = sessionData.SessionIdx;
itemImage.ImageUid = sessionData.NextItemIdx;
itemImage.Status = SaxItemImage.DefaultStatus;
@@ -20,16 +20,16 @@
@* Article dialog and form *@
<div id="dlgArticle" class="sax-dialog" title="">
<div class="spacer2"></div>
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmArticle", @class = "sax-form", @onSubmit = "return false;" }))
{
@Html.HiddenFor(model => model.ArticleId, new { @id = "ifArticleId", @class = "ArticleId" })
@Html.HiddenFor(model => model.ArticleExists, new { @id = "ifArticleExists", @class = "ArticleExists" })
@Html.HiddenFor(model => model.ArticleOrganisationId, new { @id = "ifArticleOrganisationId", @class = "ArticleOrganisationId" })
<div class="sax-article ArticleHeader-xxx">
<div class="sax-article">
<div class="sax-article-panel sax-article-header">
<div class="spacer2"></div>
@* Organisation *@
<div class="sax-form-control ArticleOrganisation">
@@ -138,6 +138,7 @@
</div>
</div>
<div class="spacer2"></div>
</div>
<div class="sax-article-panel sax-article-content">
@@ -182,8 +183,6 @@
</div>
}
<div class="spacer2"></div>
</div>
@* Article Image upload dialog and form *@
@@ -11,11 +11,11 @@
<div class="sax-header"><div class="sax-caption">@Localiser["security.caption.signin"]</div></div>
<div class="sax-content">
<div class="spacer4"></div>
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmSignIn", @class = "sax-form", @onsubmit = "return false;" }))
{
<div class="spacer4"></div>
<div class="sax-form-control EmailAddress">
<div class="sax-label">
<label for="ifEmailAddress"><span>@Localiser["label.email.address"]</span><span class="required">&nbsp;*</span></label>
@@ -25,23 +25,19 @@
</div>
<div class="sax-message"></div>
</div>
<div class="spacer4"></div>
<div class="sax-form-control Password">
<div class="row">
<div class="col-6">
<div class="sax-label">
<label for="ifPassword"><span>@Localiser["label.password"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
</div>
<div class="sax-control">
@Html.PasswordFor(model => model.Password, new { @id = "ifPassword", @class = "sax-input", @maxlength = @Model.PasswordMaxLength })
</div>
<div class="sax-message"></div>
</div>
<div class="spacer4"></div>
<div class="sax-form-control">
<div class="row">
<div class="col-6">
@@ -53,16 +49,13 @@
</div>
</div>
</div>
<div class="spacer4"></div>
<div class="">
<div id="pbSignIn" class="sax-button-action fullwidth pointer" style="margin:16px 0;">@Localiser["security.caption.signin"]</div>
</div>
}
</div>
</div>
</div>
+20 -5
View File
@@ -35,6 +35,7 @@
sax.data.articleOrganisations = response.organisations;
sax.data.defaultSport = response.defaultSport;
sax.data.defaultRegion = response.defaultRegion;
sax.data.imageContentTypes = response.imageContentTypes;
sax.refreshPaging(response, '#frmArticleFilter', am.refreshResults);
// Menu.
let $mnu = $('.sax-burger ul.sax-dropdown-menu', $pnl.filter).empty();
@@ -165,9 +166,8 @@
sax.clearControlErrors();
am.switchArticleHeader();
$dlg.article.dialog('option', 'title', title);
sax.openDialog($dlg.article, 600, 800);
$('.ArticleHeadline.sax-input', $frm.article).trigger("input");
$('.ArticleSummary.sax-textarea', $frm.article).trigger("input");
sax.openDialog($dlg.article, 800, 1200);
$('.ArticleHeadline.sax-input,.ArticleSummary.sax-textarea', $frm.article).trigger("input");
}
//--------------------------------------------------------------
@@ -304,6 +304,20 @@
{
ed.notificationManager.close();
});
/*
ed.on('paste', function (e)
{
sax.debug('segment.paste');
let paste = (event.clipboardData || window.clipboardData).getData('text');
paste = paste.toUpperCase();
sax.debug(paste);
const selection = window.getSelection();
if (!selection.rangeCount) return false;
selection.deleteFromDocument();
selection.getRangeAt(0).insertNode(document.createTextNode(paste));
event.preventDefault();
});
*/
ed.on('blur', function (e)
{
let ed = tinymce.get(e.target.id);
@@ -315,6 +329,7 @@
});
},
plugins: [
'paste'
//'paste image'
//'link',
//'lists',
@@ -330,7 +345,7 @@
*/
toolbar: [
'undo redo | bold italic underline | fontselect fontsizeselect',
'forecolor backcolor | alignleft aligncenter alignright alignfull | numlist bullist outdent indent'
'forecolor backcolor | alignleft aligncenter alignright alignfull | numlist bullist outdent indent | pastetext'
],
valid_elements: 'p[style],strong,em,span[style],a[href],ul,ol,li',
valid_styles: { '*': 'font-size,font-family,color,background-color,text-decoration,text-align' },
@@ -417,7 +432,7 @@
//sax.debug('onDropArticleImageFile', file, context);
ac.segIdxAddImage = idx;
if (file.size > sax.maxProfileImageSize) return sax.doAlert(sax.dlg.title.imageUpload, sax.msg.uploadFileSizeMax.format(sax.formatFileSize(sax.maxProfileImageSize)));
if (file.type != 'image/jpg' && file.type != 'image/jpeg' && file.type != 'image/png') return sax.doAlert(sax.dlg.title.imageUpload, sax.msg.uploadFileTypeInvalid.format(sax.getFileType(file)));
if (sax.data.imageContentTypes.indexOf(file.type) < 0) return sax.doAlert(sax.dlg.title.imageUpload, sax.msg.uploadFileTypeInvalid.format(sax.getFileType(file)));
$(".UploadMessage", context).text(sax.msg.uploadingFile.format(file.name));
$('img.ArticleImageUploadProgress', context).fadeIn(200);
sax.clearControlError();
@@ -29,7 +29,7 @@
sax.onScorePassword = function (response)
{
var score = (response || {}).score || 0;
sax.$prgPasswordStrength.progressbar("option", "value", score).removeClass('amber green').addClass(score > 3 ? 'green' : score > 2 ? 'amber' : '');
sax.$prgPwordStrength.progressbar("option", "value", score).removeClass('amber green').addClass(score > 3 ? 'green' : score > 2 ? 'amber' : '');
}
//--------------------------------------------------------------
@@ -76,16 +76,17 @@
$('#ifEmailAddress,#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm').on('input', function () { sax.clearControlError(this); });
sax.$frm.signIn.on('keypress', '#ifEmailAddress,#ifPassword,#chkKeepMeSignedIn', function (e) { if (e.which == 13 && $('#ifEmailAddress', sax.$frm.signIn).val() && $('#ifPassword', sax.$frm.signIn).val()) sax.doSignin(); });
sax.$frm.signIn.on('click', '#pbSignIn', function () { sax.doSignin(); }).on('keypress', '#pbSignIn', function (e) { if (e.which == 13) sax.doSignin(); });
sax.$frm.changePassword = $('#frmChangePassword');
sax.$frm.changePassword.on('keypress', '#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm', function (e) { if (e.which == 13) sax.doChangePassword(); });
sax.$frm.changePassword.on('keyup', '#ifPassword', sax.doScorePassword);
sax.$prgPasswordStrength = $('#prgPasswordStrength', sax.$frm.changePassword).progressbar({ 'max': 5 });
sax.$frm.changePassword.on('click', '#pbChangePassword', function () { sax.doChangePassword(); }).on('keypress', '#pbChangePassword', function (e) { if (e.which == 13) sax.doChangePassword(); });
sax.$frm.chgPword = $('#frmChangePassword');
sax.$frm.chgPword.on('keypress', '#ifPasswordCurrent,#ifPassword,#ifPasswordConfirm', function (e) { if (e.which == 13) sax.doChangePassword(); });
sax.$frm.chgPword.on('keyup', '#ifPassword', sax.doScorePassword);
sax.$prgPwordStrength = $('#prgPasswordStrength', sax.$frm.chgPword).progressbar({ 'max': 5 });
$('#pbChangePassword', sax.$frm.chgPword).on('click', function () { sax.doChangePassword(); }).on('keypress', function (e) { if (e.which == 13) sax.doChangePassword(); });
sax.$frm.reqPword = $('#frmRequestPassword');
sax.$frm.reqPword.on('keypress', '#ifEmailAddress', function (e) { if (e.which == 13) sax.doRequestPassword(); });
sax.$frm.reqPword.on('click', '#pbRequestPassword', function () { sax.doRequestPassword(); });
$('#pbRequestPassword', sax.$frm.reqPword).on('click', function () { sax.doRequestPassword(); }).on('keypress', function (e) { if (e.which == 13) sax.doRequestPassword(); });
});
//--------------------------------------------------------------
}(window, window.document));
/* The End */
@@ -48,6 +48,7 @@
if (!response || !response.success) return;
sax.data.genders = response.genders;
sax.data.months = response.months;
sax.data.imageContentTypes = response.imageContentTypes;
$('.sax-message', $pnl.proCon).stop(true, false).fadeOut(200).empty();
sax.refreshInput($pnl.proConFrm, 'AccountEmailAddress', response.contact.emailAddress);
sax.refreshSelect($pnl.proConFrm, 'AccountTitle', response.contact.title);
@@ -148,7 +149,7 @@
{
//sax.debug('onDropContactImageFile', file, context);
if (file.size > sax.maxProfileImageSize) return sax.doAlert(sax.dlg.title.imageUpload, sax.msg.uploadFileSizeMax.format(sax.formatFileSize(sax.maxProfileImageSize)));
if (file.type != 'image/jpg' && file.type != 'image/jpeg' && file.type != 'image/png') return sax.doAlert(sax.dlg.title.imageUpload, sax.msg.uploadFileTypeInvalid.format(sax.getFileType(file)));
if ((sax.data.imageContentTypes||[]).indexOf(file.type) < 0) return sax.doAlert(sax.dlg.title.imageUpload, sax.msg.uploadFileTypeInvalid.format(sax.getFileType(file)));
$(".UploadMessage", context).text(sax.msg.uploadingFile.format(file.name));
$('img.ContactImageUploadProgress', context).fadeIn(200);
sax.clearControlError($pnl.contactImageDrag);
@@ -73,8 +73,29 @@ namespace Saxonite.Net.Standard.Base.App
public static int Periodic { get; } = SacsSystem.DebugMode ? 120 : 1800;
}
}
public static class Profile
{
public static class User
{
public static class Image
{
public static ushort WidthMax { get; } = 320;
public static ushort HeightMax { get; } = 400;
}
}
}
public static class Articles
{
public static class Segments
{
public static ushort Max { get; } = 12;
public static ushort CharsMax { get; } = 8000;
}
public static class Images
{
public static ushort WidthMax { get; } = 800;
public static ushort HeightMax { get; } = 640;
}
public static ushort PublishMaxDaysBefore { get; } = 7;
public static ushort PublishMaxDaysAhead { get; } = 10;
}
+3 -1
View File
@@ -18,7 +18,7 @@ namespace Saxonite.Net.Standard.Base.App
//-------------------------------------------------------------------
public static class Version
{
private static String version { get; } = "1.2.5.1";
private static String version { get; } = "1.2.6.0";
// Retrieve version.
public static String GetFullVersion () { return version; }
public static String GetAppVersion ()
@@ -40,6 +40,8 @@ namespace Saxonite.Net.Standard.Base.App
//-------------------------------------------------------------------
// Version history.
//-------------------------------------------------------------------
// 1.2.6 ??-May-2022 Image resizing
// - Profile and article images resized to maximum width/height.
// 1.2.5 20-Apr-2022 Article feedback
// - Online Activity/Article feedback 5 stars, summary on Article list/popup.
// - Online Activity filter.
@@ -211,6 +211,37 @@ namespace Saxonite.Net.Standard.Base.Bus
return new ItemId((short)Sax.DataItemType.ItemImage, Id);
}
// Validation.
public static List<Sax.DataItemType> ValidItemTypes
{
get
{
return new List<Sax.DataItemType> { Sax.DataItemType.UserAccount, Sax.DataItemType.Organisation, Sax.DataItemType.Article };
}
}
public static List<Sacs.MimeType> GetValidMimeTypes(Sax.DataItemType itemType)
{
switch (itemType)
{
case Sax.DataItemType.UserAccount:
case Sax.DataItemType.Organisation:
case Sax.DataItemType.Article:
return new List<Sacs.MimeType> { Sacs.MimeType.Jpeg, Sacs.MimeType.Webp, Sacs.MimeType.Png };
}
return new List<Sacs.MimeType>();
}
public static List<String> GetValidContentTypes(Sax.DataItemType itemType)
{
switch (itemType)
{
case Sax.DataItemType.UserAccount:
case Sax.DataItemType.Organisation:
case Sax.DataItemType.Article:
return new List<string> { "image/jpg", "image/jpeg", "image/webp", "image/png" };
}
return new List<string>();
}
//-------------------------------------------------------------------
// Properties.
public Data GetData() { return data.Clone(); }
@@ -72,11 +72,19 @@ namespace Saxonite.Net.Standard.Base.Mgr
//---------------------------------------------------------------
// Item Id.
if (errField.ItemId != SacsHierarchyItem.ValidValue.Ignore && !ItemId.IsValid(data.ItemId))
if (errField.ItemId != SacsHierarchyItem.ValidValue.Ignore)
{
if (!ItemId.IsValid(data.ItemId))
{
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Item Id must be specified");
}
if (!SaxItemImage.ValidItemTypes.Contains((Sax.DataItemType)data.ItemId.Type))
{
errField.ItemId = SacsHierarchyItem.ValidValue.Invalid;
return SetErrorState("Invalid item type specified");
}
}
// Image type.
if (errField.ImageType != SacsHierarchyItem.ValidValue.Ignore && (int)data.ImageType < 1)
{