Skip to content

Commit

Permalink
add event calendar - ported from webforms edition
Browse files Browse the repository at this point in the history
add pascal spaced extension to grid for better headings
  • Loading branch information
ninianne98 committed Jul 26, 2023
1 parent cb816cb commit 0795b7b
Show file tree
Hide file tree
Showing 104 changed files with 8,179 additions and 40 deletions.
2 changes: 1 addition & 1 deletion CMSCore/SiteContent/SiteBasicInfo.cs
Expand Up @@ -63,7 +63,7 @@ public class SiteBasicInfo : ICarrotSite {
}
}

public Guid SiteID { get; set; }
public Guid SiteID { get; set; } = Guid.Empty;
public string? SiteName { get; set; }
public string? SiteTagline { get; set; }
public string? TimeZoneIdentifier { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion CMSInterfaces/Controllers/BaseWidgetController.cs
Expand Up @@ -28,7 +28,7 @@ public class BaseWidgetController : Controller, IWidgetController {
get {
return CarrotHttpHelper.Configuration.GetValue<string>("TestSiteID") != null
? CarrotHttpHelper.Configuration.GetValue<string>("TestSiteID").ToString()
: Guid.NewGuid().ToString();
: Guid.Empty.ToString();
}
}

Expand Down
6 changes: 6 additions & 0 deletions CarrotCakeCoreMVC_All.sln
Expand Up @@ -27,6 +27,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LoremIpsum", "LoremIpsum\Lo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginCalendarModule", "PluginCalendarModule\PluginCalendarModule.csproj", "{4D6C0257-7BD1-4FBA-84B2-E4715F51BDAE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginEventCalendarModule", "PluginEventCalendarModule\PluginEventCalendarModule.csproj", "{FAE2EA4A-771E-49B4-BA88-7B230254CFBA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -79,6 +81,10 @@ Global
{4D6C0257-7BD1-4FBA-84B2-E4715F51BDAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D6C0257-7BD1-4FBA-84B2-E4715F51BDAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D6C0257-7BD1-4FBA-84B2-E4715F51BDAE}.Release|Any CPU.Build.0 = Release|Any CPU
{FAE2EA4A-771E-49B4-BA88-7B230254CFBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FAE2EA4A-771E-49B4-BA88-7B230254CFBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FAE2EA4A-771E-49B4-BA88-7B230254CFBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FAE2EA4A-771E-49B4-BA88-7B230254CFBA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion Northwind/Views/Admin/Employees.cshtml
Expand Up @@ -4,7 +4,7 @@
ViewBag.Title = "Employees";

var grid = Html.CarrotWeb().CarrotWebGrid<Employee>(Model);

grid.PrettifyHeadings = true;
grid.SetTableAttributes(new { @class = "datatable table" }, new { @class = "tablehead thead" }, null);
grid.SetupFooter("ul", new { @class = "tablepager ui-widget ui-helper-clearfix ui-widget-content ui-corner-all" }, "li", new { @class = "ui-state-default ui-state-active ui-corner-all" }, new { @class = "ui-state-default ui-corner-all" });

Expand Down
1 change: 1 addition & 0 deletions Northwind/Views/Admin/Products.cshtml
Expand Up @@ -29,6 +29,7 @@
@Html.AntiForgeryToken()

var grid = Html.CarrotWeb().CarrotWebGrid<Product>(Model);
grid.PrettifyHeadings = true;
grid.HtmlFormId = "frmNorthwindProducts";
grid.SetTableAttributes(new { @class = "datatable table" }, new { @class = "tablehead thead" }, null);
grid.SetupFooter("ul", new { @class = "tablepager ui-widget ui-helper-clearfix ui-widget-content ui-corner-all" }, "li", new { @class = "ui-state-default ui-state-active ui-corner-all" }, new { @class = "ui-state-default ui-corner-all" });
Expand Down
2 changes: 1 addition & 1 deletion Northwind/Views/Admin/Products2.cshtml
Expand Up @@ -8,7 +8,7 @@
@Html.AntiForgeryToken()

var grid = Html.CarrotWeb().CarrotWebDataTable(Model);

grid.PrettifyHeadings = true;
grid.SetTableAttributes(new { @class = "datatable table" }, new { @class = "tablehead thead" }, null);
grid.SetupFooter("ul", new { @class = "tablepager ui-widget ui-helper-clearfix ui-widget-content ui-corner-all" }, "li", new { @class = "ui-state-default ui-state-active ui-corner-all" }, new { @class = "ui-state-default ui-corner-all" });

Expand Down
2 changes: 1 addition & 1 deletion Northwind/Views/Admin/Products3.cshtml
Expand Up @@ -8,7 +8,7 @@
@Html.AntiForgeryToken()

var grid = Html.CarrotWeb().CarrotWebDataTable(Model);

grid.PrettifyHeadings = true;
grid.SetTableAttributes(new { @class = "datatable table" }, new { @class = "tablehead thead" }, null);
grid.SetupFooter("ul", new { @class = "tablepager ui-widget ui-helper-clearfix ui-widget-content ui-corner-all" }, "li", new { @class = "ui-state-default ui-state-active ui-corner-all" }, new { @class = "ui-state-default ui-corner-all" });

Expand Down
24 changes: 11 additions & 13 deletions Northwind/Views/Admin/Suppliers.cshtml
Expand Up @@ -10,39 +10,37 @@
@Html.AntiForgeryToken()

var grid = Html.CarrotWeb().CarrotWebGrid<Supplier>(Model);

grid.PrettifyHeadings = true;
grid.SetTableAttributes(new { @class = "datatable table" }, new { @class = "tablehead thead" }, null);
grid.SetupFooter("ul", new { @class = "tablepager ui-widget ui-helper-clearfix" }, "li", new { @class = "ui-state-default ui-state-active ui-corner-all" }, new { @class = "ui-state-default ui-corner-all" });

grid.ConfigName(Html.NameFor(x => x));

grid
.AddColumn(x => x.SupplierId, new CarrotGridColumn { HeaderText = "ID", Sortable = true })
.AddColumn(new CarrotGridTemplateColumn<Supplier> {
HeaderText = "ID",
HeaderText = "Edit",
FormatTemplate = @<text> @Html.CarrotWeb().ActionImage("ViewSupplier", "Admin", new { @id = @item.SupplierId, @area=ViewBag.WidgetAssemblyName }, "~/assets/admin/images/pencil.png", @item.SupplierId.ToString(), null, null) </text>
})
.AddColumn(new CarrotGridTemplateColumn<Supplier> {
HeaderText = "Company",
FormatTemplate = @<text> @grid.FormFieldFor(m => m.CompanyName, GridFormFieldType.TextBox, new { maxlength = "64", @class = "form-control" }) </text>
})
.AddColumn(new CarrotGridTemplateColumn<Supplier> {
HeaderText = "Contact",
FormatTemplate = @<text> @grid.FormFieldFor(m => m.ContactName, GridFormFieldType.TextBox, new { maxlength = "64", @class = "form-control" }) </text>
})

.AddColumn(x => x.CompanyName, new CarrotGridColumn { HeaderText = "Company Name", Sortable = true })
.AddColumn(x => x.ContactName, new CarrotGridColumn { HeaderText = "Contact Name", Sortable = true })
.AddColumn(x => x.CompanyName, new CarrotGridColumn { Sortable = true })
.AddColumn(x => x.ContactName, new CarrotGridColumn { Sortable = true })
.AddColumn(x => x.Address, new CarrotGridColumn { Sortable = true })
.AddColumn(x => x.City, new CarrotGridColumn { Sortable = true })
.AddColumn(x => x.Country, new CarrotGridColumn { Sortable = true })
.AddColumn(x => x.Phone, new CarrotGridColumn { Sortable = true });

@grid.OutputHtmlBody()
@grid.OutputHtmlBody()

<nav>
@{
@grid.OutputFooter()
}
</nav>
<nav>
@{
@grid.OutputFooter()
}
</nav>

}
14 changes: 14 additions & 0 deletions PluginCalendarModule/Controllers/AdminController.cs
Expand Up @@ -4,6 +4,16 @@
using Carrotware.CMS.Interface.Controllers;
using Microsoft.AspNetCore.Mvc;

/*
* CarrotCake CMS (MVC Core)
* http://www.carrotware.com/
*
* Copyright 2015, 2023, Samantha Copeland
* Dual licensed under the MIT or GPL Version 3 licenses.
*
* Date: June 2023
*/

namespace CarrotCake.CMS.Plugins.CalendarModule.Controllers {

[WidgetController(typeof(AdminController))]
Expand All @@ -16,6 +26,10 @@ public class AdminController : BaseAdminWidgetController {
public AdminController(IWebHostEnvironment environment, ICarrotSite site) {
_site = site;
_webenv = environment;

if (_site != null) {
this.SiteID = _site.SiteID;
}
}

[HttpGet]
Expand Down
10 changes: 10 additions & 0 deletions PluginCalendarModule/Controllers/BaseController.cs
@@ -1,5 +1,15 @@
using Carrotware.CMS.Interface.Controllers;

/*
* CarrotCake CMS (MVC Core)
* http://www.carrotware.com/
*
* Copyright 2015, 2023, Samantha Copeland
* Dual licensed under the MIT or GPL Version 3 licenses.
*
* Date: June 2023
*/

namespace CarrotCake.CMS.Plugins.CalendarModule.Controllers {

public class BaseController : BaseDataWidgetController {
Expand Down
10 changes: 10 additions & 0 deletions PluginCalendarModule/Controllers/HomeController.cs
Expand Up @@ -3,6 +3,16 @@
using Carrotware.CMS.Interface;
using Microsoft.AspNetCore.Mvc;

/*
* CarrotCake CMS (MVC Core)
* http://www.carrotware.com/
*
* Copyright 2015, 2023, Samantha Copeland
* Dual licensed under the MIT or GPL Version 3 licenses.
*
* Date: June 2023
*/

namespace CarrotCake.CMS.Plugins.CalendarModule.Controllers {

[WidgetController(typeof(HomeController))]
Expand Down
23 changes: 17 additions & 6 deletions PluginCalendarModule/Controllers/TestController.cs
Expand Up @@ -4,6 +4,16 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

/*
* CarrotCake CMS (MVC Core)
* http://www.carrotware.com/
*
* Copyright 2015, 2023, Samantha Copeland
* Dual licensed under the MIT or GPL Version 3 licenses.
*
* Date: June 2023
*/

namespace CarrotCake.CMS.Plugins.CalendarModule.Controllers {

public class TestController : BaseController {
Expand All @@ -30,18 +40,19 @@ public class TestController : BaseController {
string controller = vals["controller"].ToString().ToLowerInvariant();

// since there are different models, set them up as needed to match the test

if (action.ToLowerInvariant() == "testview1") {
var settings = new CalendarDisplaySettings();
var settings = new CalendarUpcomingSettings();
settings.SiteID = new Guid(siteId);
settings.DaysInPast = -21;
settings.DaysInFuture = 14;

this.WidgetPayload = settings;
}

if (action.ToLowerInvariant() == "testview2") {
var settings = new CalendarUpcomingSettings();
var settings = new CalendarDisplaySettings();
settings.SiteID = new Guid(siteId);
settings.DaysInPast = -21;
settings.DaysInFuture = 14;

this.WidgetPayload = settings;
}
Expand All @@ -61,7 +72,7 @@ public class TestController : BaseController {
public ActionResult TestView1() {
var model = new TestModel();

var ctrl = RenderWidgetHelper.CreateController(typeof(HomeController), this, "CalendarDisplay", this.AreaName, this.WidgetPayload);
var ctrl = RenderWidgetHelper.CreateController(typeof(HomeController), this, "CalendarUpcoming", this.AreaName, this.WidgetPayload);
model.PartialResult = RenderWidgetHelper.ExecuteAction(ctrl);
model.RenderedContent = new HtmlString(RenderWidgetHelper.ResultToString(ctrl, model.PartialResult));

Expand All @@ -73,7 +84,7 @@ public class TestController : BaseController {
public ActionResult TestView2() {
var model = new TestModel();

var ctrl = RenderWidgetHelper.CreateController(typeof(HomeController), this, "CalendarUpcoming", this.AreaName, this.WidgetPayload);
var ctrl = RenderWidgetHelper.CreateController(typeof(HomeController), this, "CalendarDisplay", this.AreaName, this.WidgetPayload);
model.PartialResult = RenderWidgetHelper.ExecuteAction(ctrl);
model.RenderedContent = new HtmlString(RenderWidgetHelper.ResultToString(ctrl, model.PartialResult));

Expand Down
3 changes: 3 additions & 0 deletions PluginCalendarModule/Data/CalendarEntry.cs
@@ -1,6 +1,9 @@
using CarrotCake.CMS.Plugins.CalendarModule.Code;
using System.ComponentModel.DataAnnotations;

namespace CarrotCake.CMS.Plugins.CalendarModule.Data {

[MetadataType(typeof(ICalendar))]
public partial class CalendarEntry : ICalendar {
public Guid CalendarID { get; set; }
public DateTime? EventDate { get; set; }
Expand Down
45 changes: 45 additions & 0 deletions PluginEventCalendarModule/Code/CalendarDisplaySettings.cs
@@ -0,0 +1,45 @@
using Carrotware.CMS.Interface;
using System;
using System.ComponentModel;

/*
* CarrotCake CMS (MVC Core)
* http://www.carrotware.com/
*
* Copyright 2015, 2023, Samantha Copeland
* Dual licensed under the MIT or GPL Version 3 licenses.
*
* Date: June 2023
*/

namespace CarrotCake.CMS.Plugins.EventCalendarModule {

public class CalendarDisplaySettings : WidgetActionSettingModel {

public CalendarDisplaySettings()
: base() {
this.GenerateCss = true;
}

public override bool EnableEdit {
get {
return true;
}
}

[Widget(WidgetAttribute.FieldMode.TextBox)]
[Description("Specify CSS file to load")]
public string SpecifiedCssFile { get; set; }

[Widget(WidgetAttribute.FieldMode.CheckBox)]
[Description("Auto generate CSS for calendar")]
public bool GenerateCss { get; set; }

public override void LoadData() {
base.LoadData();

this.GenerateCss = Convert.ToBoolean(this.GetParmValue("GenerateCss", "true"));
this.SpecifiedCssFile = this.GetParmValue("SpecifiedCssFile", String.Empty);
}
}
}

0 comments on commit 0795b7b

Please sign in to comment.