/// <summary> /// Method that renders the components attached to a specific render placeholder by its key /// </summary> /// <param name="placeholder">name of the placeholder</param> /// <param name="model">varies based on the current placeholder logic</param> /// <param name="pageModel">current page model</param> /// <returns></returns> public async Task <IViewComponentResult> InvokeAsync(string placeholder, BaseErpPageModel pageModel, dynamic model = null) { if (pageModel == null) { return(await Task.FromResult <IViewComponentResult>(Content(""))); } if (componentsDict == null) { componentsDict = Init(); } ViewBag.PageModel = pageModel; ViewBag.ComponentNames = null; if (componentsDict.ContainsKey(placeholder)) { ViewBag.ComponentNames = componentsDict[placeholder]; } if (componentsDict.ContainsKey(placeholder) && componentsDict[placeholder].Count > 0) { pageModel.HttpContext.Items[placeholder + "-render-hook-has-components"] = true; } return(await Task.FromResult <IViewComponentResult>(View("RenderHook"))); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.LinkTags = new List <LinkTagInclude>(); #region === <style> === { var linkTagsToInclude = new List <LinkTagInclude>(); //Your includes below >>>> #region << style.css >> { //Always include linkTagsToInclude.Add(new LinkTagInclude() { InlineContent = FileService.GetEmbeddedTextResource("styles.css", "WebVella.Erp.Plugins.Next.Theme", "WebVella.Erp.Plugins.Next") }); } #endregion //<<<< Your includes up ViewBag.LinkTags = linkTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Next_HookMetaHead"))); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ScriptTags = new List <ScriptTagInclude>(); #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> #region << globals >> { //Always include var globalScript = $"var SiteLang=\"{ErpSettings.Lang}\";"; globalScript += $"moment.locale(\"{ErpSettings.Lang}\");"; scriptTagsToInclude.Add(new ScriptTagInclude() { InlineContent = globalScript }); } #endregion //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
public IActionResult OnPost(BaseErpPageModel pageModel) { //User menu items new RenderService().UserMenuItemsManagement(pageModel); return(null); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { var areaList = pageModel.ApplicationMenu; foreach (var area in areaList) { area.Nodes = new RenderService().ConvertListToTree(area.Nodes, new List <MenuItem>(), null); } ViewBag.ApplicationMenu = areaList; return(await Task.FromResult <IViewComponentResult>(View("ApplicationMenu"))); }
public EntityRecord GetPageHookLogic(BaseErpPageModel pageModel, EntityRecord record) { if (record == null) { record = new EntityRecord(); } //Preselect owner ErpUser currentUser = (ErpUser)pageModel.DataModel.GetProperty("CurrentUser"); if (currentUser != null) { record["owner_id"] = currentUser.Id; } //$project_nn_task.id //Preselect project if (pageModel.HttpContext.Request.Query.ContainsKey("projectId")) { var projectQueryId = pageModel.HttpContext.Request.Query["projectId"].ToString(); if (Guid.TryParse(projectQueryId, out Guid outGuid)) { var projectIdList = new List <Guid>(); projectIdList.Add(outGuid); record["$project_nn_task.id"] = projectIdList; } } else { var eqlCommand = "SELECT created_on,type_id,$project_nn_task.id FROM task WHERE created_by = @currentUserId ORDER BY created_on DESC PAGE 1 PAGESIZE 1"; var eqlParams = new List <EqlParameter>() { new EqlParameter("currentUserId", currentUser.Id) }; var eqlResult = new EqlCommand(eqlCommand, eqlParams).Execute(); if (eqlResult != null && eqlResult is EntityRecordList && eqlResult.Count > 0) { var relatedProjects = (List <EntityRecord>)eqlResult[0]["$project_nn_task"]; if (relatedProjects.Count > 0) { var projectIdList = new List <Guid>(); projectIdList.Add((Guid)relatedProjects[0]["id"]); record["$project_nn_task.id"] = projectIdList; } record["type_id"] = (Guid?)eqlResult[0]["type_id"]; } } //Preset start date record["start_time"] = DateTime.Now.Date.ClearKind(); record["end_time"] = DateTime.Now.Date.ClearKind().AddDays(1); return(record); }
public void UserMenuItemsManagement(BaseErpPageModel pageModel) { if (pageModel.AppName == "projects") { var createTask = new MenuItem() { IsHtml = true, Content = "<div class'menu-nav-wrapper'><div class='menu-nav'><a href='/projects/tasks/tasks/c/create'><i class='fa fa-plus'></i> Create Task</a></div></div>", isDropdownRight = false, RenderWrapper = false, SortOrder = 1 }; pageModel.AddUserMenu(createTask); } }
public object Evaluate(BaseErpPageModel pageModel) { try { if (pageModel == null) { return(""); } return("Success DS boz"); } catch (Exception ex) { return("Error: " + ex.Message); } }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ScriptTags = new List <ScriptTagInclude>(); if (pageModel.AppName == "sdk") { #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> #region << wv-pb-manager >> { //Always add scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/js/wv-pb-manager/wv-pb-manager.js" }); } #endregion #region << wv-sitemap-manager >> { //Always add scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/js/wv-sitemap-manager/wv-sitemap-manager.js" }); } #endregion //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion } return(await Task.FromResult <IViewComponentResult>(View("Sdk_Default"))); }
public IActionResult OnGet(BaseErpPageModel pageModel) { var page = pageModel.ErpRequestContext.Page; // Init task create form if (page != null && page.Id == CREATE_TASK_PAGE_ID) { EntityRecord record = (EntityRecord)pageModel.DataModel.GetProperty("Record"); var resultRecord = new TaskService().GetPageHookLogic(pageModel, record); pageModel.DataModel.SetRecord(resultRecord); } //User menu items new RenderService().UserMenuItemsManagement(pageModel); return(null); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ScriptTags = new List <ScriptTagInclude>(); var cacheKey = new RenderService().GetCacheKey(); #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
public IActionResult OnGet(BaseErpPageModel pageModel) { var page = (ErpPage)pageModel.DataModel.GetProperty("Page"); if (page != null && page.Id == CREATE_TASK_PAGE_ID) { EntityRecord record = (EntityRecord)pageModel.DataModel.GetProperty("Record"); #region << Init fields >> if (record == null) { record = new EntityRecord(); } //Preselect owner ErpUser currentUser = (ErpUser)pageModel.DataModel.GetProperty("CurrentUser"); if (currentUser != null) { record["owner_id"] = currentUser.Id; } //Preselect project if (pageModel.HttpContext.Request.Query.ContainsKey("projectId")) { var projectQueryId = pageModel.HttpContext.Request.Query["projectId"].ToString(); if (Guid.TryParse(projectQueryId, out Guid outGuid)) { record["project_id"] = outGuid; } } #endregion pageModel.DataModel.SetRecord(record); } return(null); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ScriptTags = new List <ScriptTagInclude>(); ViewBag.LinkTags = new List <LinkTagInclude>(); var cacheKey = new RenderService().GetCacheKey(); #region === <link> === { var includedLinkTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <LinkTagInclude>)) ? (List <LinkTagInclude>)pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] : new List <LinkTagInclude>(); var linkTagsToInclude = new List <LinkTagInclude>(); //Your includes below >>>> #region << core plugin >> { //Always include linkTagsToInclude.Add(new LinkTagInclude() { Href = "/api/v3.0/p/core/styles.css?cb=" + cacheKey, CacheBreaker = pageModel.ErpAppContext.StylesHash, CrossOrigin = CrossOriginType.Anonymous, Integrity = $"sha256-{pageModel.ErpAppContext.StylesHash}" }); } #endregion //<<<< Your includes up includedLinkTags.AddRange(linkTagsToInclude); pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] = includedLinkTags; ViewBag.LinkTags = linkTagsToInclude; } #endregion #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> //#region << jquery >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/jquery"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/jquery/jquery.min.js?cb=" + cacheKey // }); // } //} //#endregion #region << site.js >> { //Always include scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/webvella-erp-web/js/site.js?cb=" + cacheKey }); } #endregion //#region << bootstrap >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/bootstrap"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/twitter-bootstrap/js/bootstrap.bundle.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << uri.js >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/uri"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/URI.js/URI.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << moment >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/moment"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/moment.js/moment.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << ckeditor >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/ckeditor"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/ckeditor/ckeditor.js?cb=" + cacheKey // }); // } //} //#endregion //#region << lodash >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/lodash"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/lodash.js/lodash.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << flatpickr >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/flatpickr"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/flatpickr/flatpickr.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << select2 >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/select2"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/select2/js/select2.min.js?cb=" + cacheKey // }); // } //} //#endregion #region << js-cookie >> { if (!includedScriptTags.Any(x => x.Src.Contains("/js-cookie"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/webvella-erp-web/lib/js-cookie/js.cookie.min.js?cb=" + cacheKey }); } } #endregion //#region << decimal >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/decimal"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/decimal.js/decimal.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << toastr >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/toastr"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/toastr.js/toastr.min.js?cb=" + cacheKey // }); // } //} //#endregion //#region << colorpicker >> //{ // if (!includedScriptTags.Any(x => x.Src.Contains("/colorpicker"))) // { // scriptTagsToInclude.Add(new ScriptTagInclude() // { // Src = "/webvella-erp-web/lib/spectrum/spectrum.min.js?cb=" + cacheKey // }); // } //} //#endregion #region << wv-lazyload >> { ////Always add //scriptTagsToInclude.Add(new ScriptTagInclude() //{ // Src = "/js/stencil/wv-lazyload.esm.js", // Type = "module" //}); //scriptTagsToInclude.Add(new ScriptTagInclude() //{ // Src = "/js/stencil/wv-lazyload.js", // IsNomodule = true //}); //scriptTagsToInclude.Add(new ScriptTagInclude() //{ // Src = "/js/stencil/wv-lazyload.js" //}); } #endregion var stencilComponents = new List <string>() { "wv-lazyload", "wv-timelog-list", "wv-pb-manager", "wv-sitemap-manager", "wv-datasource-manage", "wv-post-list", "wv-feed-list", "wv-recurrence-template" }; foreach (var componentName in stencilComponents) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = $"/webvella-erp-web/js/{componentName}/{componentName}.esm.js", Type = "module" }); scriptTagsToInclude.Add(new ScriptTagInclude() { Src = $"/webvella-erp-web/js/{componentName}/{componentName}.js", IsNomodule = true }); } //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.MetaTags = new List <MetaTagInclude>(); ViewBag.LinkTags = new List <LinkTagInclude>(); ViewBag.ScriptTags = new List <ScriptTagInclude>(); var cacheKey = new RenderService().GetCacheKey(); #region == <title> == var includedTitle = pageModel.HttpContext.Items.ContainsKey("<title>") ? (string)pageModel.HttpContext.Items["<title>"] : ""; ViewBag.Title = ""; if (string.IsNullOrWhiteSpace(includedTitle)) { var titleTag = "<title>" + pageModel.PageContext.ViewData["Title"] + "</title>"; ViewBag.Title = titleTag; pageModel.HttpContext.Items["<title>"] = titleTag; } #endregion #region === <meta> === { var includedMetaTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <MetaTagInclude>)) ? (List <MetaTagInclude>)pageModel.HttpContext.Items[typeof(List <MetaTagInclude>)] : new List <MetaTagInclude>(); var metaTagsToInclude = new List <MetaTagInclude>(); //Your includes below >>>> #region << viewport >> { var tagName = "viewpost"; if (!includedMetaTags.Any(x => x.Name == tagName)) { metaTagsToInclude.Add(new MetaTagInclude() { Name = tagName, Content = "width=device-width, initial-scale=1, shrink-to-fit=no" }); } } #endregion #region << charset >> { var tagName = "charset"; if (!includedMetaTags.Any(x => x.Name == tagName)) { metaTagsToInclude.Add(new MetaTagInclude() { Charset = "utf-8" }); } } #endregion //<<<< Your includes up includedMetaTags.AddRange(metaTagsToInclude); pageModel.HttpContext.Items[typeof(List <MetaTagInclude>)] = includedMetaTags; ViewBag.MetaTags = metaTagsToInclude; } #endregion #region === <link> === { var includedLinkTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <LinkTagInclude>)) ? (List <LinkTagInclude>)pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] : new List <LinkTagInclude>(); var linkTagsToInclude = new List <LinkTagInclude>(); //Your includes below >>>> #region << favicon >> { if (!includedLinkTags.Any(x => x.Href.Contains("favicon"))) { linkTagsToInclude.Add(new LinkTagInclude() { Href = $"/webvella-erp-web/assets/favicon.png", Rel = RelType.Icon, Type = "image/png" }); } } #endregion //#region << framework >> //{ // //Always include // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/api/v3.0/p/core/framework.css", // CacheBreaker = pageModel.ErpAppContext.StyleFrameworkHash, // CrossOrigin = CrossOriginType.Anonymous, // Integrity = $"sha256-{pageModel.ErpAppContext.StyleFrameworkHash}" // }); //} //#endregion //#region << bootstrap.css >> //{ // if (!includedLinkTags.Any(x => x.Href.Contains("/bootstrap.css"))) // { // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/webvella-erp-web/lib/twitter-bootstrap/css/bootstrap.css?cb=" + cacheKey // }); // } //} //#endregion //#region << flatpickr >> //{ // if (!includedLinkTags.Any(x => x.Href.Contains("/flatpickr"))) // { // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/webvella-erp-web/lib/flatpickr/flatpickr.min.css?cb=" + cacheKey // }); // } //} //#endregion //#region << select2 >> //{ // if (!includedLinkTags.Any(x => x.Href.Contains("/select2"))) // { // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/webvella-erp-web/lib/select2/css/select2.min.css?cb=" + cacheKey // }); // } //} //#endregion //#region << font-awesome >> //{ // if (!includedLinkTags.Any(x => x.Href.Contains("/font-awesome"))) // { // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/webvella-erp-web/css/font-awesome-5.10.2/css/all.min.css?cb=" + cacheKey // }); // } //} //#endregion //#region << toastr >> //{ // if (!includedLinkTags.Any(x => x.Href.Contains("/toastr"))) // { // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/webvella-erp-web/lib/toastr.js/toastr.min.css?cb=" + cacheKey // }); // } //} //#endregion //#region << colorpicker >> //{ // if (!includedLinkTags.Any(x => x.Href.Contains("/colorpicker"))) // { // linkTagsToInclude.Add(new LinkTagInclude() // { // Href = "/webvella-erp-web/lib/spectrum/spectrum.min.css?cb=" + cacheKey // }); // } //} //#endregion //<<<< Your includes up includedLinkTags.AddRange(linkTagsToInclude); pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] = includedLinkTags; ViewBag.LinkTags = linkTagsToInclude; } #endregion #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ScriptTags = new List <ScriptTagInclude>(); #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> #region << bootstrap >> { if (!includedScriptTags.Any(x => x.Src.Contains("/bootstrap"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/twitter-bootstrap/js/bootstrap.bundle.min.js" }); } } #endregion #region << uri.js >> { if (!includedScriptTags.Any(x => x.Src.Contains("/uri"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/URI.js/URI.min.js" }); } } #endregion #region << moment >> { if (!includedScriptTags.Any(x => x.Src.Contains("/moment"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/moment.js/moment.min.js" }); } } #endregion #region << ckeditor >> { if (!includedScriptTags.Any(x => x.Src.Contains("/ckeditor"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/ckeditor/ckeditor.js" }); } } #endregion #region << lodash >> { if (!includedScriptTags.Any(x => x.Src.Contains("/lodash"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/lodash.js/lodash.min.js" }); } } #endregion #region << flatpickr >> { if (!includedScriptTags.Any(x => x.Src.Contains("/flatpickr"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/flatpickr/flatpickr.min.js" }); } } #endregion #region << select2 >> { if (!includedScriptTags.Any(x => x.Src.Contains("/select2"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/select2/js/select2.min.js" }); } } #endregion #region << js-cookie >> { if (!includedScriptTags.Any(x => x.Src.Contains("/js-cookie"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/js-cookie/js.cookie.min.js" }); } } #endregion #region << decimal >> { if (!includedScriptTags.Any(x => x.Src.Contains("/decimal"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/decimal.js/decimal.min.js" }); } } #endregion #region << toastr >> { if (!includedScriptTags.Any(x => x.Src.Contains("/toastr"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/toastr.js/toastr.min.js" }); } } #endregion #region << colorpicker >> { if (!includedScriptTags.Any(x => x.Src.Contains("/colorpicker"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/spectrum/spectrum.min.js" }); } } #endregion #region << wv-lazyload >> { //Always add scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/js/wv-lazyload/wv-lazyload.js" }); } #endregion //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { var appContext = ErpAppContext.Current; var currentApp = ErpRequestContext.App; ViewBag.CurrentApp = currentApp; ViewBag.CurrentArea = ErpRequestContext.SitemapArea; ViewBag.CurrentNode = ErpRequestContext.SitemapNode; var theme = appContext.Theme; ViewBag.Theme = theme; ViewBag.BrandLogo = theme.BrandLogo; if (!String.IsNullOrWhiteSpace(ErpSettings.NavLogoUrl)) { ViewBag.BrandLogo = ErpSettings.NavLogoUrl; } ViewBag.AppShortName = ""; ViewBag.AppDefaultLink = "/"; if (currentApp != null) { ViewBag.AppShortName = currentApp.Name.Replace("_", ""); if (currentApp.HomePages.Count > 0) { var homePages = currentApp.HomePages.OrderBy(x => x.Weight).ToList(); ViewBag.AppDefaultLink = $"/{currentApp.Name}/a/{homePages[0].Name}"; } else if (currentApp.Sitemap.Areas.Count > 0) { var currentAreas = currentApp.Sitemap.Areas.OrderBy(x => x.Weight).ToList(); foreach (var area in currentAreas) { if (area.Nodes.Count > 0) { var currentNode = area.Nodes[0]; switch (currentNode.Type) { case SitemapNodeType.ApplicationPage: ViewBag.AppDefaultLink = $"/{currentApp.Name}/{area.Name}/{currentNode.Name}/a/"; break; case SitemapNodeType.EntityList: ViewBag.AppDefaultLink = $"/{currentApp.Name}/{area.Name}/{currentNode.Name}/l/"; break; case SitemapNodeType.Url: ViewBag.AppDefaultLink = currentNode.Url; break; default: throw new Exception("Type not found"); } break; } } } } ViewBag.EmbedJs = ""; #region << Generate js script >> var jsCompressor = new JavaScriptCompressor(); #region << Init Scripts >> var fileName = "script.js"; var scriptEl = "<script type=\"text/javascript\">"; var scriptTemplate = FileService.GetEmbeddedTextResource(fileName, "WebVella.Erp.Web.Components.Nav"); scriptEl += jsCompressor.Compress(scriptTemplate); scriptEl += "</script>"; ViewBag.EmbededJs = scriptEl; #endregion #endregion ViewBag.PageModel = pageModel; return(await Task.FromResult <IViewComponentResult>(View("Nav.Default"))); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ScriptTags = new List <ScriptTagInclude>(); ViewBag.LinkTags = new List <LinkTagInclude>(); #region === <link> === { var includedLinkTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <LinkTagInclude>)) ? (List <LinkTagInclude>)pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] : new List <LinkTagInclude>(); var linkTagsToInclude = new List <LinkTagInclude>(); //Your includes below >>>> #region << core plugin >> { //Always include linkTagsToInclude.Add(new LinkTagInclude() { Href = "/api/v3.0/p/core/styles.css", CacheBreaker = pageModel.ErpAppContext.StylesHash, CrossOrigin = CrossOriginType.Anonymous, Integrity = $"sha256-{pageModel.ErpAppContext.StylesHash}" }); } #endregion //<<<< Your includes up includedLinkTags.AddRange(linkTagsToInclude); pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] = includedLinkTags; ViewBag.LinkTags = linkTagsToInclude; } #endregion #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> #region << jquery >> { if (!includedScriptTags.Any(x => x.Src.Contains("/jquery"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/jquery/jquery.min.js" }); } } #endregion #region << site.js >> { //Always include scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/js/site.js" }); } #endregion //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
public IActionResult OnPost(BaseErpPageModel pageModel) { var page = (ErpPage)pageModel.DataModel.GetProperty("Page"); var currentUser = SecurityContext.CurrentUser; if (page != null && page.Id == TIMETRACK_PAGE_ID && currentUser != null) { var postForm = pageModel.PageContext.HttpContext.Request.Form; if (String.IsNullOrWhiteSpace(postForm["task_id"])) { throw new Exception("Task Id is required"); } if (String.IsNullOrWhiteSpace(postForm["minutes"])) { throw new Exception("Minutes is required"); } if (String.IsNullOrWhiteSpace(postForm["logged_on"])) { throw new Exception("Logged on is required"); } Guid taskId = Guid.Empty; DateTime loggedOn = DateTime.MinValue; string body = !String.IsNullOrWhiteSpace(postForm["body"]) ? postForm["body"].ToString() : ""; bool isBillable = true; int minutes = 0; if (Guid.TryParse(postForm["task_id"].ToString(), out Guid outTaskId)) { taskId = outTaskId; } if (DateTime.TryParse(postForm["logged_on"].ToString(), out DateTime outLoggedOn)) { loggedOn = outLoggedOn; } if (Boolean.TryParse(postForm["is_billable"].ToString(), out Boolean outBillable)) { isBillable = outBillable; } if (int.TryParse(postForm["minutes"].ToString(), out int outMinutes)) { minutes = outMinutes; } var eqlCommand = " SELECT *,$project_nn_task.id from task WHERE id = @taskId"; var eqlParams = new List <EqlParameter>() { new EqlParameter("taskId", taskId) }; var eqlResult = new EqlCommand(eqlCommand, eqlParams).Execute(); if (!eqlResult.Any()) { throw new Exception("Task with taskId not found"); } var taskRecord = eqlResult[0]; var scope = new List <string>() { "projects" }; var relatedRecords = new List <Guid>() { (Guid)taskRecord["id"] }; if (taskRecord.Properties.ContainsKey("$project_nn_task") && ((List <EntityRecord>)taskRecord["$project_nn_task"]).Any()) { var projectRecord = ((List <EntityRecord>)taskRecord["$project_nn_task"]).First(); relatedRecords.Add((Guid)projectRecord["id"]); } using (var connection = DbContext.Current.CreateConnection()){ try { connection.BeginTransaction(); new TimeLogService().Create(null, currentUser.Id, DateTime.Now, loggedOn, minutes, isBillable, body, scope, relatedRecords); connection.CommitTransaction(); return(new RedirectResult("/projects/track-time/track-time/a/track-time")); } catch (Exception ex) { connection.RollbackTransaction(); throw ex; } } } return(null); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ScriptTags = new List <ScriptTagInclude>(); ViewBag.LinkTags = new List <LinkTagInclude>(); var cacheKey = new RenderService().GetCacheKey(); #region === <link> === { var includedLinkTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <LinkTagInclude>)) ? (List <LinkTagInclude>)pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] : new List <LinkTagInclude>(); var linkTagsToInclude = new List <LinkTagInclude>(); //Your includes below >>>> #region << core plugin >> { //Always include if (pageModel != null && pageModel.ErpAppContext != null && !String.IsNullOrEmpty(pageModel.ErpAppContext.StylesHash)) { linkTagsToInclude.Add(new LinkTagInclude() { Href = "/api/v3.0/p/core/styles.css?cb=" + cacheKey, CacheBreaker = pageModel.ErpAppContext.StylesHash, CrossOrigin = CrossOriginType.Anonymous, Integrity = $"sha256-{pageModel.ErpAppContext.StylesHash}" }); } else { linkTagsToInclude.Add(new LinkTagInclude() { Href = "/api/v3.0/p/core/styles.css?cb=" + cacheKey }); } } #endregion //<<<< Your includes up includedLinkTags.AddRange(linkTagsToInclude); pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] = includedLinkTags; ViewBag.LinkTags = linkTagsToInclude; } #endregion #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> #region << site.js >> { //Always include scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/_content/WebVella.Erp.Web/js/site.js?cb=" + cacheKey }); } #endregion #region << js-cookie >> { if (!includedScriptTags.Any(x => x.Src.Contains("/js-cookie"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/_content/WebVella.Erp.Web/lib/js-cookie/js.cookie.min.js?cb=" + cacheKey }); } } #endregion //var stencilComponents = new List<string>(){"wv-lazyload", "wv-timelog-list", "wv-pb-manager", // "wv-sitemap-manager", "wv-datasource-manage","wv-post-list", "wv-feed-list", "wv-recurrence-template"}; var stencilComponents = new List <string>() { "wv-lazyload" }; foreach (var componentName in stencilComponents) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = $"/_content/WebVella.Erp.Web/js/{componentName}/{componentName}.esm.js", Type = "module" }); scriptTagsToInclude.Add(new ScriptTagInclude() { Src = $"/_content/WebVella.Erp.Web/js/{componentName}/{componentName}.js", IsNomodule = true }); } //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ScriptTags = new List <ScriptTagInclude>(); ViewBag.LinkTags = new List <LinkTagInclude>(); var cacheKey = new RenderService().GetCacheKey(); #region === <link> === { var includedLinkTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <LinkTagInclude>)) ? (List <LinkTagInclude>)pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] : new List <LinkTagInclude>(); var linkTagsToInclude = new List <LinkTagInclude>(); //Your includes below >>>> #region << core plugin >> { //Always include linkTagsToInclude.Add(new LinkTagInclude() { Href = "/api/v3.0/p/core/styles.css?cb=" + cacheKey, CacheBreaker = pageModel.ErpAppContext.StylesHash, CrossOrigin = CrossOriginType.Anonymous, Integrity = $"sha256-{pageModel.ErpAppContext.StylesHash}" }); } #endregion //<<<< Your includes up includedLinkTags.AddRange(linkTagsToInclude); pageModel.HttpContext.Items[typeof(List <LinkTagInclude>)] = includedLinkTags; ViewBag.LinkTags = linkTagsToInclude; } #endregion #region === <script> === { var includedScriptTags = pageModel.HttpContext.Items.ContainsKey(typeof(List <ScriptTagInclude>)) ? (List <ScriptTagInclude>)pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] : new List <ScriptTagInclude>(); var scriptTagsToInclude = new List <ScriptTagInclude>(); //Your includes below >>>> #region << jquery >> { if (!includedScriptTags.Any(x => x.Src.Contains("/jquery"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/jquery/jquery.min.js?cb=" + cacheKey }); } } #endregion #region << site.js >> { //Always include scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/js/site.js?cb=" + cacheKey }); } #endregion #region << bootstrap >> { if (!includedScriptTags.Any(x => x.Src.Contains("/bootstrap"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/twitter-bootstrap/js/bootstrap.bundle.min.js?cb=" + cacheKey }); } } #endregion #region << uri.js >> { if (!includedScriptTags.Any(x => x.Src.Contains("/uri"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/URI.js/URI.min.js?cb=" + cacheKey }); } } #endregion #region << moment >> { if (!includedScriptTags.Any(x => x.Src.Contains("/moment"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/moment.js/moment.min.js?cb=" + cacheKey }); } } #endregion #region << ckeditor >> { if (!includedScriptTags.Any(x => x.Src.Contains("/ckeditor"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/ckeditor/ckeditor.js?cb=" + cacheKey }); } } #endregion #region << lodash >> { if (!includedScriptTags.Any(x => x.Src.Contains("/lodash"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/lodash.js/lodash.min.js?cb=" + cacheKey }); } } #endregion #region << flatpickr >> { if (!includedScriptTags.Any(x => x.Src.Contains("/flatpickr"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/flatpickr/flatpickr.min.js?cb=" + cacheKey }); } } #endregion #region << select2 >> { if (!includedScriptTags.Any(x => x.Src.Contains("/select2"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/select2/js/select2.min.js?cb=" + cacheKey }); } } #endregion #region << js-cookie >> { if (!includedScriptTags.Any(x => x.Src.Contains("/js-cookie"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/js-cookie/js.cookie.min.js?cb=" + cacheKey }); } } #endregion #region << decimal >> { if (!includedScriptTags.Any(x => x.Src.Contains("/decimal"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/decimal.js/decimal.min.js?cb=" + cacheKey }); } } #endregion #region << toastr >> { if (!includedScriptTags.Any(x => x.Src.Contains("/toastr"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/toastr.js/toastr.min.js?cb=" + cacheKey }); } } #endregion #region << colorpicker >> { if (!includedScriptTags.Any(x => x.Src.Contains("/colorpicker"))) { scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/lib/spectrum/spectrum.min.js?cb=" + cacheKey }); } } #endregion #region << wv-lazyload >> { //Always add scriptTagsToInclude.Add(new ScriptTagInclude() { Src = "/js/wv-lazyload/wv-lazyload.js?cb=" + cacheKey }); } #endregion //<<<< Your includes up includedScriptTags.AddRange(scriptTagsToInclude); pageModel.HttpContext.Items[typeof(List <ScriptTagInclude>)] = includedScriptTags; ViewBag.ScriptTags = scriptTagsToInclude; } #endregion return(await Task.FromResult <IViewComponentResult>(View("Default"))); }
public async Task<IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.ApplicationMenu = pageModel.ApplicationMenu; return await Task.FromResult<IViewComponentResult>(View("ApplicationMenu")); }
public async Task <IViewComponentResult> InvokeAsync(BaseErpPageModel pageModel) { ViewBag.UserMenu = pageModel.UserMenu; return(await Task.FromResult <IViewComponentResult>(View("UserMenu"))); }
public static object Evaluate(string sourceCode, BaseErpPageModel pageModel) { ICodeVariable script = GetScriptObject(sourceCode); return(script.Evaluate(pageModel)); }
public IActionResult OnPost(BaseErpPageModel pageModel) { return(null); }