|
@@ -646,96 +646,78 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
|
|
|
#region HelpPages
|
|
#region HelpPages
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
- /// Basic helpPage view function
|
|
|
|
|
|
|
+ /// Default fileSaveSettings for the image uploader of the htmlEditor
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- [FunctionAuthorize(true, "Misc-HelpPages")]
|
|
|
|
|
- public ActionResult ViewHelpPages()
|
|
|
|
|
- {
|
|
|
|
|
- var helpPages = _miscService.GetAllHelpPages();
|
|
|
|
|
- var helpPageModels = helpPages
|
|
|
|
|
- .Select(u => HelpPageDataModel.FromHelpPage(u, false))
|
|
|
|
|
- .ToList();
|
|
|
|
|
- var helpPageTreeModelList = new List<HelpPageTreeModel>();
|
|
|
|
|
-
|
|
|
|
|
- var categoryPageModels = helpPageModels
|
|
|
|
|
- .Where(p => String.IsNullOrEmpty(p.Category))
|
|
|
|
|
- .OrderBy(p => p.DisplayIndex)
|
|
|
|
|
- .ToList();
|
|
|
|
|
|
|
+ private static HtmlEditorFileSaveSettings fileSaveSettings;
|
|
|
|
|
|
|
|
- foreach (var categoryPageModel in categoryPageModels)
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Default fileSaveSettings for the image uploader of the htmlEditor
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ public static HtmlEditorFileSaveSettings FileSaveSettings
|
|
|
|
|
+ {
|
|
|
|
|
+ get
|
|
|
{
|
|
{
|
|
|
- helpPageTreeModelList.Add(new HelpPageTreeModel
|
|
|
|
|
|
|
+ if (fileSaveSettings == null)
|
|
|
{
|
|
{
|
|
|
- Text = categoryPageModel.Title,
|
|
|
|
|
- HelpPageId = categoryPageModel.Id
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ fileSaveSettings = new HtmlEditorFileSaveSettings();
|
|
|
|
|
+ fileSaveSettings.FileSystemSettings.UploadFolder = "~/Content/Images/HelpPages/";
|
|
|
|
|
+ }
|
|
|
|
|
+ return fileSaveSettings;
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- var categoryModels = helpPageModels
|
|
|
|
|
- .Where(p => !String.IsNullOrEmpty(p.Category))
|
|
|
|
|
- .OrderBy(p => p.DisplayIndex)
|
|
|
|
|
- .GroupBy(p => p.Category)
|
|
|
|
|
- .ToList();
|
|
|
|
|
-
|
|
|
|
|
- foreach (var categoryModel in categoryModels)
|
|
|
|
|
- {
|
|
|
|
|
- var categoryTreeModel = new HelpPageTreeModel
|
|
|
|
|
- {
|
|
|
|
|
- Text = categoryModel.Key
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- helpPageTreeModelList.Add(categoryTreeModel);
|
|
|
|
|
-
|
|
|
|
|
- var subcategoryPageModels = helpPageModels
|
|
|
|
|
- .Where(p => p.Category == categoryModel.Key && String.IsNullOrEmpty(p.Subcategory))
|
|
|
|
|
- .OrderBy(p => p.DisplayIndex)
|
|
|
|
|
- .ToList();
|
|
|
|
|
-
|
|
|
|
|
- foreach (var subcategoryPageModel in subcategoryPageModels)
|
|
|
|
|
- {
|
|
|
|
|
- var subcategoryTreePageModel = new HelpPageTreeModel
|
|
|
|
|
- {
|
|
|
|
|
- Text = subcategoryPageModel.Title,
|
|
|
|
|
- HelpPageId = subcategoryPageModel.Id
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Default validationSettings for the image uploader of the htmlEditor
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ public static readonly UploadControlValidationSettings ImageUploadValidationSettings = new UploadControlValidationSettings
|
|
|
|
|
+ {
|
|
|
|
|
+ AllowedFileExtensions = new string[] { ".jpg", ".jpeg", ".jpe", ".gif", ".png" },
|
|
|
|
|
+ MaxFileSize = 4000000
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- categoryTreeModel.Elements.Add(subcategoryTreePageModel);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Creates the helpPage tree recursively
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="models">Full helpPage model list.</param>
|
|
|
|
|
+ /// <param name="nodesCollection">Parent node collection.</param>
|
|
|
|
|
+ /// <param name="parentID">Parent node id.</param>
|
|
|
|
|
+ public static void CreateHelpPageTree(IEnumerable<HelpPageDataModel> models, MVCxTreeViewNodeCollection nodesCollection,
|
|
|
|
|
+ int? parentID)
|
|
|
|
|
+ {
|
|
|
|
|
+ var children = models
|
|
|
|
|
+ .Where(p => p.ParentId == parentID);
|
|
|
|
|
|
|
|
- var subcategoryModels = helpPageModels
|
|
|
|
|
- .Where(p => p.Category == categoryModel.Key && !String.IsNullOrEmpty(p.Subcategory))
|
|
|
|
|
- .OrderBy(p => p.DisplayIndex)
|
|
|
|
|
- .GroupBy(p => p.Subcategory)
|
|
|
|
|
- .ToList();
|
|
|
|
|
|
|
+ foreach (var model in children)
|
|
|
|
|
+ {
|
|
|
|
|
+ var node = nodesCollection.Add(model.Title, model.Id.ToString());
|
|
|
|
|
+ node.Expanded = true;
|
|
|
|
|
|
|
|
- foreach (var subcategoryModel in subcategoryModels)
|
|
|
|
|
- {
|
|
|
|
|
- var subcategoryTreeModel = new HelpPageTreeModel
|
|
|
|
|
- {
|
|
|
|
|
- Text = subcategoryModel.Key
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ CreateHelpPageTree(models, node.Nodes, model.Id);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- categoryTreeModel.Elements.Add(subcategoryTreeModel);
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Basic helpPage view function
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ /// <param name="id">Id of initial editing helpPage.</param>
|
|
|
|
|
+ [FunctionAuthorize(true, "Misc-HelpPages")]
|
|
|
|
|
+ public ActionResult ViewHelpPages(int id = -1)
|
|
|
|
|
+ {
|
|
|
|
|
+ var helpPages = _miscService.GetAllHelpPagesWithoutContent();
|
|
|
|
|
+ var helpPageModels = helpPages
|
|
|
|
|
+ .Select(u => HelpPageDataModel.FromHelpPage(u, false))
|
|
|
|
|
+ .OrderBy(u => u.DisplayIndex)
|
|
|
|
|
+ .ToList();
|
|
|
|
|
|
|
|
- var subcategoryHelpPageModels = helpPageModels
|
|
|
|
|
- .Where(p => p.Category == categoryModel.Key && p.Subcategory == subcategoryModel.Key)
|
|
|
|
|
- .OrderBy(p => p.DisplayIndex)
|
|
|
|
|
- .ToList();
|
|
|
|
|
|
|
+ var initialHelpPageModelExists = helpPageModels
|
|
|
|
|
+ .Any(p => p.Id == id);
|
|
|
|
|
|
|
|
- foreach (var subcategoryHelpPageModel in subcategoryHelpPageModels)
|
|
|
|
|
- {
|
|
|
|
|
- var helpPageTreeModel = new HelpPageTreeModel
|
|
|
|
|
- {
|
|
|
|
|
- Text = subcategoryHelpPageModel.Title,
|
|
|
|
|
- HelpPageId = subcategoryHelpPageModel.Id
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ if (initialHelpPageModelExists)
|
|
|
|
|
+ ViewData["InitialEditHelpPage"] = id;
|
|
|
|
|
|
|
|
- subcategoryTreeModel.Elements.Add(helpPageTreeModel);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ViewData["IsHelpPageSelectionTree"] = false;
|
|
|
|
|
|
|
|
- return View("~/Views/Misc/HelpPages.cshtml", helpPageTreeModelList);
|
|
|
|
|
|
|
+ return View("~/Views/Misc/HelpPages.cshtml", helpPageModels);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -747,6 +729,32 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
|
|
|
return PartialView("~/Views/Misc/_HelpPageHtmlEditPartial.cshtml", helpPageModel);
|
|
return PartialView("~/Views/Misc/_HelpPageHtmlEditPartial.cshtml", helpPageModel);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
|
+ /// Callback result for processing the upload of an image for a helpPage
|
|
|
|
|
+ /// </summary>
|
|
|
|
|
+ public ActionResult UploadProcessingImageUpload()
|
|
|
|
|
+ {
|
|
|
|
|
+ FileSavingEventHandler onFileSaving = (s, e) => {
|
|
|
|
|
+ using (var fileContent = e.UploadedFile.FileContent)
|
|
|
|
|
+ {
|
|
|
|
|
+ using (var image = System.Drawing.Image.FromStream(fileContent))
|
|
|
|
|
+ {
|
|
|
|
|
+ var memoryStream = new MemoryStream();
|
|
|
|
|
+
|
|
|
|
|
+ image.Save(memoryStream, image.RawFormat);
|
|
|
|
|
+
|
|
|
|
|
+ e.OutputStream = memoryStream;
|
|
|
|
|
+
|
|
|
|
|
+ e.FileName = e.UploadedFile.FileName;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ HtmlEditorExtension.SaveUploadedFile(FileSaveSettings, ImageUploadValidationSettings, onFileSaving);
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Get JSON data of specific helpPage
|
|
/// Get JSON data of specific helpPage
|
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -791,9 +799,17 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
|
|
|
/// <param name="id">Id for existing helpPage, otherweise -1.</param>
|
|
/// <param name="id">Id for existing helpPage, otherweise -1.</param>
|
|
|
public ActionResult EditHelpPage(int id = -1)
|
|
public ActionResult EditHelpPage(int id = -1)
|
|
|
{
|
|
{
|
|
|
|
|
+ var helpPages = _miscService.GetAllHelpPages();
|
|
|
|
|
+ var helpPageModels = helpPages
|
|
|
|
|
+ .Select(u => HelpPageDataModel.FromHelpPage(u, false))
|
|
|
|
|
+ .ToList();
|
|
|
|
|
+
|
|
|
var helpPage = _miscService.GetHelpPageById(id);
|
|
var helpPage = _miscService.GetHelpPageById(id);
|
|
|
var helpPageModel = HelpPageDataModel.FromHelpPage(helpPage, true);
|
|
var helpPageModel = HelpPageDataModel.FromHelpPage(helpPage, true);
|
|
|
|
|
|
|
|
|
|
+ ViewData["AllHelpPages"] = helpPageModels;
|
|
|
|
|
+ ViewData["IsHelpPageSelectionTree"] = true;
|
|
|
|
|
+
|
|
|
return PartialView("~/Views/Misc/_HelpPageEditPartial.cshtml", helpPageModel);
|
|
return PartialView("~/Views/Misc/_HelpPageEditPartial.cshtml", helpPageModel);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -809,8 +825,6 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
|
|
|
if (!ModelState.IsValid)
|
|
if (!ModelState.IsValid)
|
|
|
return PartialView("~/Views/Misc/_HelpPageEditPartial.cshtml", helpPageModel);
|
|
return PartialView("~/Views/Misc/_HelpPageEditPartial.cshtml", helpPageModel);
|
|
|
|
|
|
|
|
- var html = HtmlEditorExtension.GetHtml("HelpPageHtmlContentEditor");
|
|
|
|
|
-
|
|
|
|
|
if (helpPageModel.Id == -1)
|
|
if (helpPageModel.Id == -1)
|
|
|
{
|
|
{
|
|
|
var helpPage = helpPageModel.ToHelpPage();
|
|
var helpPage = helpPageModel.ToHelpPage();
|
|
@@ -818,6 +832,11 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
|
|
|
_miscService.InsertHelpPage(helpPage);
|
|
_miscService.InsertHelpPage(helpPage);
|
|
|
|
|
|
|
|
_logger.Entity(helpPage, Core.Domain.Logging.LogEntityActivity.Insert, _userHelper.FromCookies());
|
|
_logger.Entity(helpPage, Core.Domain.Logging.LogEntityActivity.Insert, _userHelper.FromCookies());
|
|
|
|
|
+
|
|
|
|
|
+ return new JsonResult
|
|
|
|
|
+ {
|
|
|
|
|
+ Data = String.Format("success-{0}", helpPage.Id)
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -825,19 +844,18 @@ namespace GreenTree.Nachtragsmanagement.Web.Controllers
|
|
|
|
|
|
|
|
helpPage.Title = helpPageModel.Title;
|
|
helpPage.Title = helpPageModel.Title;
|
|
|
helpPage.Content = helpPageModel.Content;
|
|
helpPage.Content = helpPageModel.Content;
|
|
|
- helpPage.Category = helpPage.Category;
|
|
|
|
|
- helpPage.Subcategory = helpPage.Subcategory;
|
|
|
|
|
- helpPage.DisplayIndex = helpPage.DisplayIndex;
|
|
|
|
|
|
|
+ helpPage.ParentId = helpPageModel.ParentId;
|
|
|
|
|
+ helpPage.DisplayIndex = helpPageModel.DisplayIndex;
|
|
|
|
|
|
|
|
_miscService.UpdateHelpPage(helpPage);
|
|
_miscService.UpdateHelpPage(helpPage);
|
|
|
|
|
|
|
|
_logger.Entity(helpPage, Core.Domain.Logging.LogEntityActivity.Update, _userHelper.FromCookies());
|
|
_logger.Entity(helpPage, Core.Domain.Logging.LogEntityActivity.Update, _userHelper.FromCookies());
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- return new JsonResult
|
|
|
|
|
- {
|
|
|
|
|
- Data = "success"
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ return new JsonResult
|
|
|
|
|
+ {
|
|
|
|
|
+ Data = String.Format("success-{0}", helpPage.Id)
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
|
{
|
|
{
|