Implemented Data export step matrix behavior.

This commit is contained in:
Sipke Schoorstra
2015-07-14 18:04:04 +01:00
parent 04c193afd1
commit 18469ad462
5 changed files with 115 additions and 27 deletions

View File

@@ -8,3 +8,4 @@ OrchardVersion: 1.9
Description: Provides content item data import and export capability.
FeatureDescription: Imports and exports content item data
Category: Content
Dependencies: Orchard.jQuery

View File

@@ -108,6 +108,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Scripts\exportstep-data.js" />
<Content Include="Styles\images\menu.importexport.png" />
<Content Include="Styles\exportstep-data.css" />
<Content Include="Styles\menu.importexport-admin.css" />
@@ -136,6 +137,11 @@
<ItemGroup>
<Content Include="Views\EditorTemplates\ExportSteps\SetupRecipe.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Scripts\Web.config">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
<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>

View File

@@ -0,0 +1,63 @@
(function($) {
$(function() {
$("table.items").each(function() {
var table = $(this);
table.on("click", ".check-schema, .check-data", function (e) {
updateState();
});
table.on("click", ".check-both", function (e) {
var sender = $(this);
var isChecked = sender.is(":checked");
var row = sender.closest("tr");
row.find(".check-schema, .check-data").prop("checked", isChecked);
updateState();
});
table.on("click", ".check-all-schema", function (e) {
var sender = $(this);
var isChecked = sender.is(":checked");
table.find(".check-schema").prop("checked", isChecked);
updateState();
});
table.on("click", ".check-all-data", function (e) {
var sender = $(this);
var isChecked = sender.is(":checked");
table.find(".check-data").prop("checked", isChecked);
updateState();
});
table.on("click", ".check-all-both", function (e) {
var sender = $(this);
var isChecked = sender.is(":checked");
table.find(".check-schema").prop("checked", isChecked);
table.find(".check-data").prop("checked", isChecked);
updateState();
});
var updateState = function () {
table.find("tbody tr").each(function() {
var tr = $(this);
var checkSchema = tr.find(".check-schema").is(":checked");
var checkData = tr.find(".check-data").is(":checked");
tr.find(".check-both").prop("checked", checkSchema && checkData);
});
var allBothChecked = table.find(".check-both").not(":checked").length === 0;
var allSchemaChecked = table.find(".check-schema").not(":checked").length === 0;
var allDataChecked = table.find(".check-data").not(":checked").length === 0;
table.find(".check-all-both").prop("checked", allBothChecked);
table.find(".check-all-schema").prop("checked", allSchemaChecked);
table.find(".check-all-data").prop("checked", allDataChecked);
};
});
});
})(jQuery);

View File

@@ -1,6 +1,8 @@
@model Orchard.ImportExport.ViewModels.DataExportStepViewModel
@{
Style.Include("exportstep-data.css");
Script.Require("jQuery");
Script.Include("exportstep-data.js");
}
<div>
<table class="items">
@@ -13,9 +15,9 @@
</tr>
<tr class="sub">
<th>&nbsp;</th>
<th><input type="checkbox"/></th>
<th><input type="checkbox"/></th>
<th><input type="checkbox"/></th>
<th><input type="checkbox" class="check-all-schema" /></th>
<th><input type="checkbox" class="check-all-data" /></th>
<th><input type="checkbox" class="check-all-both" /></th>
</tr>
</thead>
<tbody>
@@ -24,13 +26,13 @@
<tr>
<td>@contentType.DisplayName</td>
<td>
<input type="hidden" name="@Html.NameFor(m => m.ContentTypes[contentTypeIndex].Name)" value="@Model.ContentTypes[contentTypeIndex].Name"/>
<input type="checkbox" name="@Html.NameFor(m => m.ContentTypes[contentTypeIndex].ExportSchema)" value="true"/>
<input type="hidden" name="@Html.NameFor(m => m.ContentTypes[contentTypeIndex].Name)" value="@Model.ContentTypes[contentTypeIndex].Name" />
<input type="checkbox" class="check-schema" name="@Html.NameFor(m => m.ContentTypes[contentTypeIndex].ExportSchema)" value="true" />
</td>
<td>
<input type="checkbox" name="@Html.NameFor(m => m.ContentTypes[contentTypeIndex].ExportData)" value="true"/>
<input type="checkbox" class="check-data" name="@Html.NameFor(m => m.ContentTypes[contentTypeIndex].ExportData)" value="true" />
</td>
<td><input type="checkbox"/></td>
<td><input type="checkbox" class="check-both" /></td>
</tr>
contentTypeIndex++;
}