Cleanup of partial view macro templates for consistency

This commit is contained in:
Callum Whyte
2018-09-20 14:00:01 +01:00
parent 4976ffc106
commit 35227a8d58
19 changed files with 61 additions and 68 deletions

View File

@@ -389,9 +389,6 @@
<Content Include="Umbraco\PartialViewMacros\Templates\Login.cshtml" />
<Content Include="Umbraco\PartialViewMacros\Templates\LoginStatus.cshtml" />
<Content Include="Umbraco\PartialViewMacros\Templates\RegisterMember.cshtml" />
<Content Include="Umbraco\PartialViewMacros\Templates\Empty %28ForUseWithCustomViews%29.cshtml">
<SubType>Code</SubType>
</Content>
<Content Include="Umbraco\PartialViewMacros\Templates\ListAncestorsFromCurrentPage.cshtml" />
<Content Include="Umbraco\PartialViewMacros\Templates\Breadcrumb.cshtml" />
<Content Include="Umbraco\PartialViewMacros\Templates\Gallery.cshtml" />

View File

@@ -1,5 +1,6 @@
@using Umbraco.Web
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
This snippet makes a breadcrumb of parents using an unordered HTML list.
@@ -22,4 +23,4 @@
@* Display the current page as the last item in the list *@
<li class="active">@Model.Content.Name</li>
</ul>
}
}

View File

@@ -1,9 +1,8 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using System.Web.Mvc.Html
@using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc
@using Umbraco.Web
@using Umbraco.Web.Controllers
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
var profileModel = Members.GetCurrentMemberProfileModel();
@@ -11,8 +10,8 @@
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
Html.RequiresJs("/umbraco/lib/jquery/jquery.min.js");
Html.RequiresJs("/Umbraco/lib/jquery-validate/jquery.validate.min.js");
Html.RequiresJs("/Umbraco/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js");
Html.RequiresJs("/umbraco/lib/jquery-validate/jquery.validate.min.js");
Html.RequiresJs("/umbraco/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js");
var success = TempData["ProfileUpdateSuccess"] != null;
}
@@ -21,18 +20,18 @@
@Html.RenderJsHere()
@if (Members.IsLoggedIn() && profileModel != null)
{
{
if (success)
{
@* This message will show if RedirectOnSucces is set to false (default) *@
<p>Profile updated</p>
}
using (Html.BeginUmbracoForm<UmbProfileController>("HandleUpdateProfile"))
{
<fieldset>
<legend>Edit profile</legend>
@Html.ValidationSummary("profileModel", true)
@Html.LabelFor(m => profileModel.Name)
@@ -48,10 +47,10 @@
@for (var i = 0; i < profileModel.MemberProperties.Count; i++)
{
@Html.LabelFor(m => profileModel.MemberProperties[i].Value, profileModel.MemberProperties[i].Name)
@*
By default this will render a textbox but if you want to change the editor template for this property you can
@*
By default this will render a textbox but if you want to change the editor template for this property you can
easily change it. For example, if you wanted to render a custom editor for this field called "MyEditor" you would
create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to
create a file at ~/Views/Shared/EditorTemplates/MyEditor.cshtml", then you will change the next line of code to
render your specific editor template like:
@Html.EditorFor(m => profileModel.MemberProperties[i].Value, "MyEditor")
*@
@@ -62,5 +61,5 @@
<button>Save</button>
</fieldset>
}
}
}

View File

@@ -1 +0,0 @@
@inherits Umbraco.Web.Mvc.UmbracoViewPage<dynamic>

View File

@@ -1 +1 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@inherits Umbraco.Web.Macros.PartialViewMacroPage

View File

@@ -1,6 +1,7 @@
@using Umbraco.Core.Models.PublishedContent
@using Umbraco.Web
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
Macro to display a gallery of images from the Media section.
Works with either a 'Single Media Picker' or a 'Multiple Media Picker' macro parameter (see below).
@@ -46,4 +47,4 @@
<img src="@item.GetCropUrl(width:200, height:200)" alt="@item.Name" />
</a>
</div>
}
}

View File

@@ -1,5 +1,6 @@
@using Umbraco.Web
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
This snippet makes a list of links to the of parents of the current page using an unordered HTML list.

View File

@@ -20,4 +20,4 @@
<li><a href="@item.Url">@item.Name</a></li>
}
</ul>
}
}

View File

@@ -14,6 +14,7 @@
*@
@{ var propertyAlias = Model.MacroParameters["propertyAlias"]; }
@if (propertyAlias != null)
{
var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderBy(x => x.GetPropertyValue(propertyAlias.ToString())).ToArray();

View File

@@ -37,16 +37,15 @@
</ul>
}
@helper ChildPages(IPublishedContent[] selection)
{
@* Ensure that we have a collection of pages *@
if (selection.Length > 0)
{
@* Get the first page in pages and get the level *@
@* Get the first page in pages and get the level *@
var naviLevel = selection[0].Level;
@* Add in level for a CSS hook *@
@* Add in level for a CSS hook *@
<ul class="level-@(naviLevel)">
@foreach (var item in selection)
{
@@ -58,7 +57,7 @@
var children = item.Children.Where(x => x.IsVisible()).ToArray();
if (children.Length > 0)
{
@* Recurse and call our helper to display the children *@
@* Recurse and call our helper to display the children *@
@ChildPages(children)
}
}
@@ -66,4 +65,4 @@
}
</ul>
}
}
}

View File

@@ -13,6 +13,7 @@
*@
@{ var mediaId = Model.MacroParameters["mediaId"]; }
@if (mediaId != null)
{
@* Get the media item associated with the id passed in *@

View File

@@ -1,10 +1,9 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using System.Web.Mvc.Html
@using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc
@using Umbraco.Web
@using Umbraco.Web.Models
@using Umbraco.Web.Controllers
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
var loginModel = new LoginModel();
@@ -12,8 +11,8 @@
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
Html.RequiresJs("/umbraco/lib/jquery/jquery.min.js");
Html.RequiresJs("/Umbraco/lib/jquery-validate/jquery.validate.min.js");
Html.RequiresJs("/Umbraco/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js");
Html.RequiresJs("/umbraco/lib/jquery-validate/jquery.validate.min.js");
Html.RequiresJs("/umbraco/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js");
}
@* NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed *@
@@ -23,7 +22,7 @@
{
<fieldset>
<legend>Login</legend>
@Html.ValidationSummary("loginModel", true)
@Html.LabelFor(m => loginModel.Username)
@@ -37,5 +36,5 @@
<br />
<button>Login</button>
</fieldset>
</fieldset>
}

View File

@@ -1,9 +1,9 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using System.Web.Mvc.Html
@using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc
@using Umbraco.Web
@using Umbraco.Web.Models
@using Umbraco.Web.Controllers
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
var loginStatusModel = Members.GetCurrentLoginStatus();
@@ -19,8 +19,8 @@
@*
Here you can specify a redirect URL for after logging out, by default umbraco will simply
redirect to the current page. Example to redirect to the home page:
logoutModel.RedirectUrl = "/";
logoutModel.RedirectUrl = "/";
*@
}
@@ -33,11 +33,11 @@
using (Html.BeginUmbracoForm<UmbLoginStatusController>("HandleLogout"))
{
<fieldset>
<legend>Logout</legend>
<button>Logout</button>
</fieldset>
<fieldset>
<legend>Logout</legend>
<button>Logout</button>
</fieldset>
@Html.HiddenFor(m => logoutModel.RedirectUrl)
}
}

View File

@@ -1,51 +1,50 @@
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using System.Web.Mvc.Html
@using System.Web.Mvc.Html
@using ClientDependency.Core.Mvc
@using Umbraco.Web
@using Umbraco.Web.Controllers
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
@*
You can specify a custom member type alias in the constructor, the default is 'Member'
You can specify a custom member type alias in the constructor, the default is 'Member'
for example, to use 'Custom Member' you'd use this syntax:
var registerModel = Members.CreateRegistrationModel("Custom Member");
*@
var registerModel = Members.CreateRegistrationModel();
@*
Configurable here:
registerModel.RedirectUrl - Optional. What path to redirect to if registration is successful.
By default the member will be redirected to the current umbraco page
Configurable here:
registerModel.RedirectUrl - Optional. What path to redirect to if registration is successful.
By default the member will be redirected to the current umbraco page
unless this is specified.
registerModel.UsernameIsEmail - the default is true
if you want the username to be different from the email
address, set this to true and add a new Username field in
the form below
@Html.LabelFor(m => registerModel.Username)
@Html.TextBoxFor(m => registerModel.Username)
@Html.ValidationMessageFor(m => registerModel.Username)
*@
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
Html.RequiresJs("/umbraco/lib/jquery/jquery.min.js");
Html.RequiresJs("/Umbraco/lib/jquery-validate/jquery.validate.min.js");
Html.RequiresJs("/Umbraco/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js");
Html.RequiresJs("/umbraco/lib/jquery-validate/jquery.validate.min.js");
Html.RequiresJs("/umbraco/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js");
var success = TempData["FormSuccess"] != null;
}
@*NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed*@
@Html.RenderJsHere()
@if (success)
{
@if (success)
{
@* This message will show if RedirectOnSucces is set to false (default) *@
<p>Registration succeeded.</p>
}

View File

@@ -16,7 +16,6 @@
@Traverse(selection)
</div>
@* Helper method to traverse through all descendants *@
@helper Traverse(IPublishedContent node)
{
@@ -41,4 +40,4 @@
}
</ul>
}
}
}