mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 02:44:52 +08:00
Moving the tag create from from its own page right up to the top-right of the tag management UI
--HG-- branch : dev
This commit is contained in:
@@ -93,7 +93,39 @@
|
||||
}
|
||||
// otherwise, make the autofocus attribute work
|
||||
var autofocus = _this.find(":input[autofocus]").first();
|
||||
return autofocus.focus();
|
||||
autofocus.focus();
|
||||
|
||||
return _this;
|
||||
},
|
||||
helpfullyPlacehold: function () {
|
||||
var _this = $(this);
|
||||
|
||||
// give it up to the browser to handle placeholder text
|
||||
if ('placeholder' in document.createElement('input')) {
|
||||
return;
|
||||
}
|
||||
// otherwise, make the placeholder attribute work
|
||||
$(":input[placeholder]")
|
||||
.each(function () {
|
||||
var _this = $(this);
|
||||
if (_this.val() === "") {
|
||||
_this.val(_this.attr("placeholder")).addClass("placeholderd");
|
||||
}
|
||||
})
|
||||
.live("focus", function () {
|
||||
var _this = $(this);
|
||||
if (_this.val() === _this.attr("placeholder")) {
|
||||
_this.val("").removeClass("placeholderd");
|
||||
}
|
||||
})
|
||||
.live("blur", function () {
|
||||
var _this = $(this);
|
||||
if (_this.val() === "") {
|
||||
_this.val(_this.attr("placeholder")).addClass("placeholderd");
|
||||
}
|
||||
});
|
||||
|
||||
return _this;
|
||||
},
|
||||
toggleWhatYouControl: function () {
|
||||
var _this = $(this);
|
||||
@@ -106,7 +138,7 @@
|
||||
//_controllees.slideUp(200); <- hook this back up when chrome behaves, or when I care less...or when chrome behaves
|
||||
_controllees.hide()
|
||||
}
|
||||
return this;
|
||||
return _this;
|
||||
}
|
||||
});
|
||||
// collapsable areas - anything with a data-controllerid attribute has its visibility controlled by the id-ed radio/checkbox
|
||||
@@ -131,7 +163,7 @@
|
||||
$(function () {
|
||||
$("form.inline.link").each(function () {
|
||||
var _this = $(this);
|
||||
console.log(_this.html())
|
||||
console.log(_this.html())
|
||||
var link = $("<a class='wasFormInlineLink' href='.'/>");
|
||||
var button = _this.children("button").first();
|
||||
link.text(button.text())
|
||||
@@ -143,9 +175,11 @@
|
||||
$("body").append(_this);
|
||||
});
|
||||
});
|
||||
// (do) a little better autofocus
|
||||
// some default value add behavior
|
||||
$(function () {
|
||||
$("body").helpfullyFocus();
|
||||
$("body").helpfullyFocus() // (do) a little better autofocus
|
||||
.helpfullyPlacehold(); // pick up on placeholders
|
||||
|
||||
});
|
||||
// UnsafeUrl links -> form POST
|
||||
//todo: need some real microdata support eventually (incl. revisiting usage of data-* attributes)
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Localization;
|
||||
using Orchard.ContentManagement;
|
||||
@@ -31,7 +32,9 @@ namespace Orchard.Tags.Controllers {
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Index(FormCollection input) {
|
||||
[FormValueRequired("submit.BulkEdit")]
|
||||
public ActionResult Index(FormCollection input)
|
||||
{
|
||||
var viewModel = new TagsAdminIndexViewModel {Tags = new List<TagEntry>(), BulkAction = new TagAdminIndexBulkAction()};
|
||||
|
||||
if ( !TryUpdateModel(viewModel) ) {
|
||||
@@ -58,16 +61,14 @@ namespace Orchard.Tags.Controllers {
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
public ActionResult Create() {
|
||||
return View(new TagsAdminCreateViewModel());
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Create(FormCollection input) {
|
||||
[HttpPost, ActionName("Index")]
|
||||
[FormValueRequired("submit.Create")]
|
||||
public ActionResult IndexCreatePOST() {
|
||||
var viewModel = new TagsAdminCreateViewModel();
|
||||
|
||||
if (!TryUpdateModel(viewModel)) {
|
||||
return View(viewModel);
|
||||
ViewData["CreateTag"] = viewModel;
|
||||
return Index();
|
||||
}
|
||||
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateTag, T("Couldn't create tag")))
|
||||
@@ -147,5 +148,18 @@ namespace Orchard.Tags.Controllers {
|
||||
IsChecked = false,
|
||||
};
|
||||
}
|
||||
|
||||
public class FormValueRequiredAttribute : ActionMethodSelectorAttribute {
|
||||
private readonly string _submitButtonName;
|
||||
|
||||
public FormValueRequiredAttribute(string submitButtonName) {
|
||||
_submitButtonName = submitButtonName;
|
||||
}
|
||||
|
||||
public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) {
|
||||
var value = controllerContext.HttpContext.Request.Form[_submitButtonName];
|
||||
return !string.IsNullOrEmpty(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -70,6 +70,7 @@
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Migrations.cs" />
|
||||
<Compile Include="Models\TagsContentItems.cs" />
|
||||
<Compile Include="ResourceManifest.cs" />
|
||||
<Compile Include="Services\ITagService.cs" />
|
||||
<Compile Include="ViewModels\EditTagsViewModel.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
@@ -91,7 +92,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Module.txt" />
|
||||
<Content Include="Views\Admin\Create.cshtml" />
|
||||
<Content Include="Styles\admin.css" />
|
||||
<Content Include="Views\Web.config" />
|
||||
<Content Include="Views\Admin\Edit.cshtml" />
|
||||
<Content Include="Views\Admin\Index.cshtml" />
|
||||
@@ -116,6 +117,12 @@
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Styles\Web.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<None Include="Views\EditorTemplates\Parts\CreateTag.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
9
src/Orchard.Web/Modules/Orchard.Tags/ResourceManifest.cs
Normal file
9
src/Orchard.Web/Modules/Orchard.Tags/ResourceManifest.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Orchard.UI.Resources;
|
||||
|
||||
namespace Orchard.Tags {
|
||||
public class ResourceManifest : IResourceManifestProvider {
|
||||
public void BuildManifests(ResourceManifestBuilder builder) {
|
||||
builder.Add().DefineStyle("TagsAdmin").SetUrl("admin.css");
|
||||
}
|
||||
}
|
||||
}
|
18
src/Orchard.Web/Modules/Orchard.Tags/Styles/Web.config
Normal file
18
src/Orchard.Web/Modules/Orchard.Tags/Styles/Web.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.web>
|
||||
<httpHandlers>
|
||||
<!-- iis6 - for any request in this location, return via managed static file handler -->
|
||||
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<handlers accessPolicy="Script,Read">
|
||||
<!--
|
||||
iis7 - for any request to a file exists on disk, return it via native http module.
|
||||
accessPolicy 'Script' is to allow for a managed 404 page.
|
||||
-->
|
||||
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
|
||||
</handlers>
|
||||
</system.webServer>
|
||||
</configuration>
|
11
src/Orchard.Web/Modules/Orchard.Tags/Styles/admin.css
Normal file
11
src/Orchard.Web/Modules/Orchard.Tags/Styles/admin.css
Normal file
@@ -0,0 +1,11 @@
|
||||
.orchard-tags #main .manage form {
|
||||
margin:0;
|
||||
}
|
||||
.orchard-tags .manage fieldset {
|
||||
display:inline;
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
.orchard-tags .manage label[for=TagName] {
|
||||
display:none;
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
@model Orchard.Tags.ViewModels.TagsAdminCreateViewModel
|
||||
|
||||
<h1>@Html.TitleForPage(T("Add a Tag").ToString()) </h1>
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
@Html.ValidationSummary()
|
||||
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.TagName, T("Tag Name"))
|
||||
@Html.TextBoxFor(m=>m.TagName, new { @class = "text" })
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<button class="primaryAction" type="submit">@T("Save")</button>
|
||||
</fieldset>
|
||||
}
|
@@ -3,11 +3,15 @@
|
||||
@using Orchard.Utility.Extensions;
|
||||
@{
|
||||
Script.Require("ShapesBase");
|
||||
Style.Require("TagsAdmin");
|
||||
}
|
||||
|
||||
<h1>@Html.TitleForPage(T("Manage Tags").ToString()) </h1>
|
||||
@Html.ValidationSummary()
|
||||
<div class="manage">
|
||||
@Display.EditorTemplate(TemplateName: "Parts/CreateTag", Model: View.CreateTag != null ? View.CreateTag : new TagsAdminCreateViewModel())
|
||||
</div>
|
||||
@using(Html.BeginFormAntiForgeryPost()) {
|
||||
@Html.ValidationSummary()
|
||||
<fieldset class="bulk-actions">
|
||||
<label for="publishActions">@T("Actions:")</label>
|
||||
<select id="publishActions" name="@Html.NameOf(m => m.BulkAction)">
|
||||
@@ -16,7 +20,6 @@
|
||||
</select>
|
||||
<button type="submit"name="submit.BulkEdit" value="@T("Apply")">@T("Apply")</button>
|
||||
</fieldset>
|
||||
<div class="manage">@Html.ActionLink(T("Add a tag").ToString(), "Create", new { }, new { @class = "button primaryAction" })</div>
|
||||
<fieldset>
|
||||
<table class="items" summary="@T("This is a table of the tags in your application")" >
|
||||
<colgroup>
|
||||
|
@@ -0,0 +1,13 @@
|
||||
@model Orchard.Tags.ViewModels.TagsAdminCreateViewModel
|
||||
@{
|
||||
Style.Require("TagsAdmin");
|
||||
}
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
<fieldset>
|
||||
@Html.LabelFor(m => m.TagName, T("New Tag Name"))
|
||||
@Html.TextBoxFor(m => m.TagName, new { @class = "text", placeholder = T("New Tag Name") })
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<button class="primaryAction" type="submit" name="submit.Create" value="yes">@T("Add Tag")</button>
|
||||
</fieldset>
|
||||
}
|
@@ -914,4 +914,8 @@ fieldset.publish-later-datetime input {
|
||||
/* todo: needed? */
|
||||
.clearBoth {
|
||||
clear:both;
|
||||
}
|
||||
.placeholderd {
|
||||
color:#ccc;
|
||||
font-style:italic;
|
||||
}
|
Reference in New Issue
Block a user