From c8cb5b26b0e7b592a044c973f81914c2096bc506 Mon Sep 17 00:00:00 2001 From: Jeavon Leopold Date: Thu, 29 Oct 2015 17:14:45 +0000 Subject: [PATCH 1/2] Basic implementation for U4-4641 Feature Request: template and code editors should have insert Section, Define section buttons --- .../dialogs/template/snippet.controller.js | 7 +++ .../common/dialogs/template/snippet.html | 39 +++++++++++++++ .../Umbraco/Images/editor/renderbody.gif | Bin 0 -> 1336 bytes .../umbraco/settings/views/EditView.aspx.cs | 46 ++++++++++-------- .../umbraco_client/Editors/EditView.js | 35 +++++++++++++ 5 files changed, 106 insertions(+), 21 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/views/common/dialogs/template/snippet.controller.js create mode 100644 src/Umbraco.Web.UI.Client/src/views/common/dialogs/template/snippet.html create mode 100644 src/Umbraco.Web.UI/Umbraco/Images/editor/renderbody.gif diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/template/snippet.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/template/snippet.controller.js new file mode 100644 index 0000000000..dc0f2bead1 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/template/snippet.controller.js @@ -0,0 +1,7 @@ +angular.module("umbraco").controller('Umbraco.Dialogs.Template.SnippetController', + function($scope, $http, dialogService) { + $scope.type = $scope.dialogOptions.type; + $scope.section = {}; + $scope.section.name = ""; + $scope.section.required = false; + }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/template/snippet.html b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/template/snippet.html new file mode 100644 index 0000000000..1414a7471c --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/template/snippet.html @@ -0,0 +1,39 @@ +
+ + + +
+ +
+

Configure the section

+
+ + + + +
+
\ No newline at end of file diff --git a/src/Umbraco.Web.UI/Umbraco/Images/editor/renderbody.gif b/src/Umbraco.Web.UI/Umbraco/Images/editor/renderbody.gif new file mode 100644 index 0000000000000000000000000000000000000000..1a84493fe9d7668b782aee1e352f12970cc4bff2 GIT binary patch literal 1336 zcmZ?wbhEHb6k`x)I3mVy?Ha?)n+&gCGd_F9@c1#qrArL&-Z8&?$?*9z@7=o$4<0al z{K)?2&)+})|Ni)4@axat&tDCG{0jT^E9}possI1~Wnf_V|NlRb#03=pb4U0FD7Yk+ zBm!w0`-+0ZIIg#cFVINM%8)eo$(0erZv1Dp0vH$f^P>=c3falKi5O{QMkPCP( zUIa|kjQ{`r{qy_R&mZ5vef{$J)5j0*-@SeF`qj%9&!0Vg^7zri2lwyYy>t84%^TOR zUA=Po(!~qs&z(JU`qar2$B!L7a`@1}1N-;w-Lrew&K=vgZQZhY)5ZeMTG_VdAT{+S(zE>X{jm6Nr?&Zaj`McQIQehVWA9RT!WL(IBz?v24h5IWK private void InitializeEditorForTemplate() { - - //TODO: implement content placeholders, etc... just like we had in v5 - //Panel1.Menu.InsertSplitter(); + //TODO: implement content placeholders, etc... just like we had in v5 - //MenuIconI umbContainer = Panel1.Menu.NewIcon(); - //umbContainer.ImageURL = UmbracoPath + "/images/editor/masterpagePlaceHolder.gif"; - //umbContainer.AltText = ui.Text("template", "insertContentAreaPlaceHolder"); - //umbContainer.OnClickCommand = - // ClientTools.Scripts.OpenModalWindow( - // IOHelper.ResolveUrl(SystemDirectories.Umbraco) + - // "/dialogs/insertMasterpagePlaceholder.aspx?&id=" + _template.Id, - // ui.Text("template", "insertContentAreaPlaceHolder"), 470, 320); + editorSource.Menu.InsertSplitter(); - //MenuIconI umbContent = Panel1.Menu.NewIcon(); - //umbContent.ImageURL = UmbracoPath + "/images/editor/masterpageContent.gif"; - //umbContent.AltText = ui.Text("template", "insertContentArea"); - //umbContent.OnClickCommand = - // ClientTools.Scripts.OpenModalWindow( - // IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/dialogs/insertMasterpageContent.aspx?id=" + - // _template.Id, ui.Text("template", "insertContentArea"), 470, 300); - - } + MenuIconI umbRenderBody = editorSource.Menu.NewIcon(); + umbRenderBody.ImageURL = UmbracoPath + "/images/editor/renderbody.gif"; + //umbContainer.AltText = ui.Text("template", "insertContentAreaPlaceHolder"); + umbRenderBody.AltText = "Insert @RenderBody()"; - } + umbRenderBody.OnClickCommand = "editViewEditor.insertRenderBody()"; + + MenuIconI umbSection = editorSource.Menu.NewIcon(); + umbSection.ImageURL = UmbracoPath + "/images/editor/masterpagePlaceHolder.gif"; + //umbContainer.AltText = ui.Text("template", "insertContentAreaPlaceHolder"); + umbSection.AltText = "Insert Section"; + + umbSection.OnClickCommand = "editViewEditor.openSnippetModal('section')"; + + MenuIconI umbRenderSection = editorSource.Menu.NewIcon(); + umbRenderSection.ImageURL = UmbracoPath + "/images/editor/masterpageContent.gif"; + //umbContainer.AltText = ui.Text("template", "insertContentAreaPlaceHolder"); + umbRenderSection.AltText = "Insert @RenderSection"; + + umbRenderSection.OnClickCommand = "editViewEditor.openSnippetModal('rendersection')"; + + } + + } } \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js b/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js index 00fda4db21..00c5b488e7 100644 --- a/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js +++ b/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js @@ -36,6 +36,10 @@ UmbEditor.Insert("@Umbraco.RenderMacro(\"" + alias + "\")", "", this._opts.codeEditorElementId); }, + + insertRenderBody: function() { + UmbEditor.Insert("@RenderBody()", "", this._opts.codeEditorElementId); + }, openMacroModal: function (alias) { /// callback used to display the modal dialog to insert a macro with parameters @@ -54,6 +58,37 @@ }); }, + openSnippetModal: function (type) { + /// callback used to display the modal dialog to insert a macro with parameters + + var self = this; + + UmbClientMgr.openAngularModalWindow({ + template: "views/common/dialogs/template/snippet.html", + callback: function (data) { + + var code = ""; + + if (type === 'section') { + code = "\n@section " + data.name + "{\n"; + code += "\n" + + "}\n"; + } + + if (type === 'rendersection') { + if (data.required) { + code = "\n@RenderSection(\"" + data.name + "\", true);\n"; + } else { + code = "\n@RenderSection(\"" + data.name + "\");\n"; + } + } + + UmbEditor.Insert(code, '', self._opts.codeEditorElementId); + }, + type: type + }); + }, + openQueryModal: function () { /// callback used to display the modal dialog to insert a macro with parameters From 38b13bf6ce41e7312a06f342c8f40d180dc196d1 Mon Sep 17 00:00:00 2001 From: Jeavon Leopold Date: Thu, 29 Oct 2015 17:18:40 +0000 Subject: [PATCH 2/2] Basic implementation for U4-4641 --- src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js b/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js index 00c5b488e7..509de8ed28 100644 --- a/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js +++ b/src/Umbraco.Web.UI/umbraco_client/Editors/EditView.js @@ -79,7 +79,7 @@ if (data.required) { code = "\n@RenderSection(\"" + data.name + "\", true);\n"; } else { - code = "\n@RenderSection(\"" + data.name + "\");\n"; + code = "\n@RenderSection(\"" + data.name + "\" false);\n"; } }