From f8de4cb5a45dffaa72d1cd669558053479ee66c3 Mon Sep 17 00:00:00 2001 From: "DK\\vls" Date: Mon, 31 Jul 2017 16:55:52 +0300 Subject: [PATCH] Value mapping gutter --- .gitattributes | 5 ++ .../Sitecore.DataExchange.Gutters.config | 4 + .../CleanPipelineBatchSummaryCommand.cs | 2 +- .../Commands/GoToReferenceCommand.cs | 21 ++++++ .../Commands/ReferenceMenuCommand.cs | 35 +++++++++ .../ValueMappingContextMenuCommand.cs | 27 +++++++ .../Sitecore.DataExchange.Gutters.csproj | 7 +- .../ValueMappingGutter.cs | 26 +++++++ TDS.core/TDS.core.scproj | 9 ++- .../Gutters/DataExchange - Value Mapping.item | 73 +++++++++++++++++++ 10 files changed, 205 insertions(+), 4 deletions(-) create mode 100644 Sitecore.DataExchange.Gutters/Commands/GoToReferenceCommand.cs create mode 100644 Sitecore.DataExchange.Gutters/Commands/ReferenceMenuCommand.cs create mode 100644 Sitecore.DataExchange.Gutters/Commands/ValueMappingContextMenuCommand.cs create mode 100644 Sitecore.DataExchange.Gutters/ValueMappingGutter.cs create mode 100644 TDS.core/sitecore/content/Applications/Content Editor/Gutters/DataExchange - Value Mapping.item diff --git a/.gitattributes b/.gitattributes index 1ff0c42..6e242e6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -61,3 +61,8 @@ #*.PDF diff=astextplain #*.rtf diff=astextplain #*.RTF diff=astextplain + + + +# Do not adjust line endings on Sitecore .item files +*.item -text diff --git a/Sitecore.DataExchange.Gutters/App_Config/Include/Sitecore.DataExchange.Gutters.config b/Sitecore.DataExchange.Gutters/App_Config/Include/Sitecore.DataExchange.Gutters.config index b4694a2..d0613c5 100644 --- a/Sitecore.DataExchange.Gutters/App_Config/Include/Sitecore.DataExchange.Gutters.config +++ b/Sitecore.DataExchange.Gutters/App_Config/Include/Sitecore.DataExchange.Gutters.config @@ -6,6 +6,10 @@ + + + + diff --git a/Sitecore.DataExchange.Gutters/Commands/CleanPipelineBatchSummaryCommand.cs b/Sitecore.DataExchange.Gutters/Commands/CleanPipelineBatchSummaryCommand.cs index 53ea7e9..0a56f8f 100644 --- a/Sitecore.DataExchange.Gutters/Commands/CleanPipelineBatchSummaryCommand.cs +++ b/Sitecore.DataExchange.Gutters/Commands/CleanPipelineBatchSummaryCommand.cs @@ -27,7 +27,7 @@ public override void Execute(CommandContext context) item["{985BA535-0F3E-4DA8-A768-A469026DE9DB}"] = string.Empty; item["{6A2B2CBB-4338-4814-A8A9-9FECBB90456A}"] = string.Empty; item["{47F8050D-6EEE-423F-A9F0-3DC34948C365}"] = string.Empty; - item["{83E6292F-A00E-463D-A1C6-0FC25BC0FBAD}"] = string.Empty; + item["{2AA5C591-FF55-411D-96C0-978BB2C58B94}"] = string.Empty; } } } diff --git a/Sitecore.DataExchange.Gutters/Commands/GoToReferenceCommand.cs b/Sitecore.DataExchange.Gutters/Commands/GoToReferenceCommand.cs new file mode 100644 index 0000000..374d31f --- /dev/null +++ b/Sitecore.DataExchange.Gutters/Commands/GoToReferenceCommand.cs @@ -0,0 +1,21 @@ +namespace Sitecore.DataExchange.Gutters.Commands +{ + using System; + using Shell.Framework.Commands; + + [Serializable] + public class GoToReferenceCommand : Command + { + public override void Execute(CommandContext context) + { + var item = context.Items[0]; + string id = context.Parameters["id"]; + + //Sitecore.Context.ClientPage.ClientResponse.Timer(string.Format("item:load(id={0})", id), 100); + Sitecore.Text.UrlString parameters = new Sitecore.Text.UrlString(); + parameters.Add("id", id); + parameters.Add("fo", id); + Sitecore.Shell.Framework.Windows.RunApplication("Content Editor", parameters.ToString()); + } + } +} \ No newline at end of file diff --git a/Sitecore.DataExchange.Gutters/Commands/ReferenceMenuCommand.cs b/Sitecore.DataExchange.Gutters/Commands/ReferenceMenuCommand.cs new file mode 100644 index 0000000..b486be3 --- /dev/null +++ b/Sitecore.DataExchange.Gutters/Commands/ReferenceMenuCommand.cs @@ -0,0 +1,35 @@ +namespace Sitecore.DataExchange.Gutters.Commands +{ + using System; + using Shell.Framework.Commands; + using Web.UI.HtmlControls; + using Web.UI.Sheer; + + [Serializable] + public class ReferenceMenuCommand : Command + { + public override void Execute(CommandContext context) + { + var item = context.Items[0]; + string fieldName = context.Parameters["fieldName"]; + + Sitecore.Data.Fields.MultilistField multilistField = + (Sitecore.Data.Fields.MultilistField) item.Fields[fieldName]; + + var targetIDs = multilistField.TargetIDs; + + Menu menu = new Menu(); + SheerResponse.DisableOutput(); + + foreach (var targetID in targetIDs) + { + var item1 = item.Database.GetItem(targetID); + + menu.Add(item1.DisplayName, "Office/32x32/radio_button_selected.png", + string.Concat(new object[] { "dataExchange:goToReference(id=", targetID, ")" })); + } + SheerResponse.EnableOutput(); + SheerResponse.ShowContextMenu(Sitecore.Context.ClientPage.ClientRequest.Control, "right", menu); + } + } +} \ No newline at end of file diff --git a/Sitecore.DataExchange.Gutters/Commands/ValueMappingContextMenuCommand.cs b/Sitecore.DataExchange.Gutters/Commands/ValueMappingContextMenuCommand.cs new file mode 100644 index 0000000..718b808 --- /dev/null +++ b/Sitecore.DataExchange.Gutters/Commands/ValueMappingContextMenuCommand.cs @@ -0,0 +1,27 @@ +namespace Sitecore.DataExchange.Gutters.Commands +{ + using System; + using Shell.Framework.Commands; + using Sitecore.Diagnostics; + using Web.UI.HtmlControls; + using Web.UI.Sheer; + + [Serializable] + public class ValueMappingContextMenuCommand : Command + { + public override void Execute(CommandContext context) + { + Assert.ArgumentNotNull(context, nameof(context)); + + Menu menu = new Menu(); + SheerResponse.DisableOutput(); + menu.Add("Source Accessor", "Office/32x32/radio_button_selected.png", string.Concat(new object[] { "dataExchange:referenceMenu(fieldName=", "SourceAccessor", ")" })); + menu.Add("Target Accessor", "Office/32x32/radio_button_selected.png", string.Concat(new object[] { "dataExchange:referenceMenu(fieldName=", "TargetAccessor", ")" })); + menu.Add("Source Pre Transformer", "Office/32x32/graph_from.png", string.Concat(new object[] { "dataExchange:referenceMenu(fieldName=", "SourceValuePreTransformer", ")" })); + menu.Add("Source Transformer", "Office/32x32/graph_from.png", string.Concat(new object[] { "dataExchange:referenceMenu(fieldName=", "SourceValueTransformer", ")" })); + + SheerResponse.EnableOutput(); + SheerResponse.ShowContextMenu(Sitecore.Context.ClientPage.ClientRequest.Control, "right", menu); + } + } +} \ No newline at end of file diff --git a/Sitecore.DataExchange.Gutters/Sitecore.DataExchange.Gutters.csproj b/Sitecore.DataExchange.Gutters/Sitecore.DataExchange.Gutters.csproj index 86110f6..00f25b2 100644 --- a/Sitecore.DataExchange.Gutters/Sitecore.DataExchange.Gutters.csproj +++ b/Sitecore.DataExchange.Gutters/Sitecore.DataExchange.Gutters.csproj @@ -9,8 +9,9 @@ Properties Sitecore.DataExchange.Gutters Sitecore.DataExchange.Gutters - v4.5.2 + v4.6.2 512 + true @@ -53,13 +54,17 @@ + + + + diff --git a/Sitecore.DataExchange.Gutters/ValueMappingGutter.cs b/Sitecore.DataExchange.Gutters/ValueMappingGutter.cs new file mode 100644 index 0000000..917a82d --- /dev/null +++ b/Sitecore.DataExchange.Gutters/ValueMappingGutter.cs @@ -0,0 +1,26 @@ +namespace Sitecore.DataExchange.Gutters +{ + using Data; + using Data.Items; + using Data.Managers; + using Shell.Applications.ContentEditor.Gutters; + using Sitecore.Diagnostics; + + public class ValueMappingGutter : GutterRenderer + { + protected readonly ID ValueMappingTemplateId = new ID("{450C8F38-91C9-4896-957B-6F7DAF18CCFC}"); + + + protected override GutterIconDescriptor GetIconDescriptor(Item item) + { + Assert.ArgumentNotNull(item, nameof(item)); + if (item.TemplateID == this.ValueMappingTemplateId) + { + var gutterIconDescriptor = new GutterIconDescriptor() { Icon = TemplateManager.GetTemplate(item).Icon, Tooltip = item.DisplayName }; + gutterIconDescriptor.Click = "dataExchange:valueMappingContextMenu()"; + return gutterIconDescriptor; + } + return null; + } + } +} \ No newline at end of file diff --git a/TDS.core/TDS.core.scproj b/TDS.core/TDS.core.scproj index ce80adc..1fbc181 100644 --- a/TDS.core/TDS.core.scproj +++ b/TDS.core/TDS.core.scproj @@ -1,4 +1,5 @@ - + + Debug AnyCPU @@ -74,6 +75,10 @@ DeployOnce NoChildSynchronization + + DeployOnce + NoChildSynchronization + - + \ No newline at end of file diff --git a/TDS.core/sitecore/content/Applications/Content Editor/Gutters/DataExchange - Value Mapping.item b/TDS.core/sitecore/content/Applications/Content Editor/Gutters/DataExchange - Value Mapping.item new file mode 100644 index 0000000..ed8f0b1 --- /dev/null +++ b/TDS.core/sitecore/content/Applications/Content Editor/Gutters/DataExchange - Value Mapping.item @@ -0,0 +1,73 @@ +----item---- +version: 1 +id: {AB2C6026-635C-419A-AC2C-204D1A4F03D1} +database: core +path: /sitecore/content/Applications/Content Editor/Gutters/DataExchange - Value Mapping +parent: {59F37069-3118-4151-8C01-5DA0EF12CB4E} +name: DataExchange - Value Mapping +master: {00000000-0000-0000-0000-000000000000} +template: {F5D247E0-80E6-4F31-9921-D30D00B61B3C} +templatekey: Gutter Renderer +created: 20170731T113243Z + +----field---- +field: {7A108204-DC61-4D25-A138-FD6F53F48ABF} +name: Type +key: type +content-length: 78 + +Sitecore.DataExchange.Gutters.ValueMappingGutter,Sitecore.DataExchange.Gutters +----version---- +language: en +version: 1 +revision: c571d857-124a-4487-8f39-fea50a68667b + +----field---- +field: {5024402F-0B92-4C13-A7D2-86ED85FF3560} +name: Header +key: header +content-length: 29 + +Data Exchange - Value Mapping +----field---- +field: {52807595-0F8F-4B20-8D2A-CB71D28C6103} +name: __Owner +key: __owner +content-length: 14 + +sitecore\admin +----field---- +field: {25BED78C-4957-4165-998A-CA1B52F67497} +name: __Created +key: __created +content-length: 16 + +20170119T082920Z +----field---- +field: {5DD74568-4D4B-44C1-B513-0AF5F4CDA34F} +name: __Created by +key: __created by +content-length: 14 + +sitecore\admin +----field---- +field: {8CDC337E-A112-42FB-BBB4-4143751E123F} +name: __Revision +key: __revision +content-length: 36 + +c571d857-124a-4487-8f39-fea50a68667b +----field---- +field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522} +name: __Updated +key: __updated +content-length: 16 + +20170731T113340Z +----field---- +field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A} +name: __Updated by +key: __updated by +content-length: 14 + +sitecore\admin