Rewrite exportdocumenttype.aspx to Angular
This commit is contained in:
@@ -307,8 +307,21 @@ function contentTypeResource($q, $http, umbRequestHelper, umbDataFormatter) {
|
||||
"Failed to rename the folder with id " + id
|
||||
);
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
export: function (id) {
|
||||
if (!id) {
|
||||
throw "id cannot be null";
|
||||
}
|
||||
|
||||
return window.open(umbRequestHelper.getApiUrl("contentTypeApiBaseUrl",
|
||||
"Export",
|
||||
{
|
||||
id: id
|
||||
}),
|
||||
'_blank',
|
||||
'');
|
||||
}
|
||||
};
|
||||
}
|
||||
angular.module('umbraco.resources').factory('contentTypeResource', contentTypeResource);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
angular.module("umbraco")
|
||||
.controller("Umbraco.Editors.DocumentTypes.ExportController",
|
||||
function ($scope, contentTypeResource, navigationService) {
|
||||
|
||||
$scope.export = function () {
|
||||
contentTypeResource.export($scope.currentNode.id);
|
||||
navigationService.hideMenu();
|
||||
};
|
||||
|
||||
$scope.cancel = function () {
|
||||
navigationService.hideDialog();
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
<div class="umb-dialog umb-pane" ng-controller="Umbraco.Editors.DocumentTypes.ExportController">
|
||||
<div class="umb-dialog-footer btn-toolbar umb-btn-toolbar">
|
||||
<a class="btn btn-link" ng-click="nav.hideDialog()">
|
||||
<localize key="general_cancel">Cancel</localize>
|
||||
</a>
|
||||
<button class="btn btn-primary" ng-click="export()">
|
||||
<localize key="actions_export">Export</localize>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -401,7 +401,6 @@
|
||||
<Content Include="Umbraco\Developer\Packages\directoryBrowser.aspx" />
|
||||
<Content Include="Umbraco\Developer\Packages\editPackage.aspx" />
|
||||
<Content Include="Umbraco\Dialogs\create.aspx" />
|
||||
<Content Include="Umbraco\Dialogs\exportDocumenttype.aspx" />
|
||||
<Content Include="Umbraco\Dialogs\importDocumenttype.aspx" />
|
||||
<Content Include="Umbraco\Dialogs\notifications.aspx" />
|
||||
<Content Include="Umbraco\Dialogs\protectPage.aspx" />
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<%@ Page language="c#" Codebehind="exportDocumenttype.aspx.cs" AutoEventWireup="false" Inherits="umbraco.presentation.dialogs.exportDocumenttype" %>
|
||||
@@ -302,14 +302,6 @@ Umbraco.Application.Actions = function() {
|
||||
}
|
||||
},
|
||||
|
||||
actionExport: function() {
|
||||
/// <summary></summary>
|
||||
|
||||
if (UmbClientMgr.mainTree().getActionNode().nodeType != '') {
|
||||
this.openDialog("Export", "dialogs/exportDocumentType.aspx?nodeId=" + UmbClientMgr.mainTree().getActionNode().nodeId + "&rnd=" + this._utils.generateRandom(), 320, 205);
|
||||
}
|
||||
},
|
||||
|
||||
actionAudit: function() {
|
||||
/// <summary></summary>
|
||||
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Web.Http;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
using Umbraco.Core.Services;
|
||||
using System.Net.Http;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.WebApi;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Web.Composing;
|
||||
using ContentVariation = Umbraco.Core.Models.ContentVariation;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
@@ -353,6 +354,35 @@ namespace Umbraco.Web.Editors
|
||||
copy,
|
||||
getContentType: i => Services.ContentTypeService.Get(i),
|
||||
doCopy: (type, i) => Services.ContentTypeService.Copy(type, i));
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public HttpResponseMessage Export(int id)
|
||||
{
|
||||
var contentType = Services.ContentTypeService.Get(id);
|
||||
if (contentType == null) throw new NullReferenceException("No content type found with id " + id);
|
||||
|
||||
var serializer = new EntityXmlSerializer();
|
||||
var xml = serializer.Serialize(
|
||||
Services.DataTypeService,
|
||||
Services.ContentTypeService,
|
||||
contentType);
|
||||
var response = new HttpResponseMessage
|
||||
{
|
||||
Content = new StringContent(xml.ToDataString())
|
||||
{
|
||||
Headers =
|
||||
{
|
||||
ContentDisposition = new ContentDispositionHeaderValue("attachment")
|
||||
{
|
||||
FileName = $"{contentType.Alias}.udt"
|
||||
},
|
||||
ContentType = new MediaTypeHeaderValue( "application/octet-stream")
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using System;
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Formatting;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
@@ -132,13 +132,7 @@ namespace Umbraco.Web.Trees
|
||||
}
|
||||
}
|
||||
menu.Items.Add<ActionCopy>(Services.TextService.Localize(string.Format("actions/{0}", ActionCopy.Instance.Alias)));
|
||||
menu.Items.Add<ActionExport>(Services.TextService.Localize(string.Format("actions/{0}", ActionExport.Instance.Alias)), true).ConvertLegacyMenuItem(new EntitySlim
|
||||
{
|
||||
Id = int.Parse(id),
|
||||
Level = 1,
|
||||
ParentId = Constants.System.Root,
|
||||
Name = ""
|
||||
}, "documenttypes", "settings");
|
||||
menu.Items.Add<ActionExport>(Services.TextService.Localize(string.Format("actions/{0}", ActionExport.Instance.Alias)), true);
|
||||
menu.Items.Add<ActionDelete>(Services.TextService.Localize(string.Format("actions/{0}", ActionDelete.Instance.Alias)), true);
|
||||
if (enableInheritedDocumentTypes)
|
||||
menu.Items.Add<RefreshNode, ActionRefresh>(Services.TextService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias)), true);
|
||||
|
||||
@@ -2,22 +2,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Formatting;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Http.Routing;
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
using umbraco;
|
||||
|
||||
using umbraco.cms.presentation.Trees;
|
||||
using umbraco.controls.Tree;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web._Legacy.Actions;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Models.Trees;
|
||||
|
||||
namespace Umbraco.Web.Trees
|
||||
{
|
||||
@@ -280,11 +273,6 @@ namespace Umbraco.Web.Trees
|
||||
new LegacyUrlAction(
|
||||
"dialogs/importDocumentType.aspx",
|
||||
Current.Services.TextService.Localize("actions/importDocumentType")));
|
||||
case "UmbClientMgr.appActions().actionExport()":
|
||||
return Attempt.Succeed(
|
||||
new LegacyUrlAction(
|
||||
"dialogs/exportDocumentType.aspx?nodeId=" + nodeId + "&rnd=" + DateTime.UtcNow.Ticks,
|
||||
""));
|
||||
case "UmbClientMgr.appActions().actionAudit()":
|
||||
return Attempt.Succeed(
|
||||
new LegacyUrlAction(
|
||||
|
||||
@@ -1291,10 +1291,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\developer\Packages\editPackage.aspx.designer.cs">
|
||||
<DependentUpon>editPackage.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\dialogs\exportDocumenttype.aspx.cs">
|
||||
<DependentUpon>exportDocumenttype.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\dialogs\importDocumenttype.aspx.cs">
|
||||
<DependentUpon>importDocumenttype.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@@ -1492,7 +1488,6 @@
|
||||
<Content Include="umbraco.presentation\umbraco\developer\Packages\editPackage.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\exportDocumenttype.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\importDocumenttype.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\dialogs\notifications.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
|
||||
namespace Umbraco.Web._Legacy.Actions
|
||||
{
|
||||
@@ -38,10 +37,7 @@ namespace Umbraco.Web._Legacy.Actions
|
||||
|
||||
public string JsFunctionName
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format("{0}.actionExport()", ClientTools.Scripts.GetAppActions);
|
||||
}
|
||||
get { return ""; }
|
||||
}
|
||||
|
||||
public string JsSource
|
||||
@@ -56,7 +52,7 @@ namespace Umbraco.Web._Legacy.Actions
|
||||
{
|
||||
get
|
||||
{
|
||||
return "exportDocumentType";
|
||||
return "export";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<%@ Page language="c#" Codebehind="exportDocumenttype.aspx.cs" AutoEventWireup="false" Inherits="umbraco.presentation.dialogs.exportDocumenttype" %>
|
||||
@@ -1,59 +0,0 @@
|
||||
using System;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace umbraco.presentation.dialogs
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for exportDocumenttype.
|
||||
/// </summary>
|
||||
public class exportDocumenttype : Umbraco.Web.UI.Pages.UmbracoEnsuredPage
|
||||
{
|
||||
public exportDocumenttype()
|
||||
{
|
||||
CurrentApp = Constants.Applications.Settings.ToString();
|
||||
|
||||
}
|
||||
private void Page_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
int documentTypeId = Request.GetItemAs<int>("nodeID");
|
||||
if (documentTypeId > 0)
|
||||
{
|
||||
var contentType = Services.ContentTypeService.Get(documentTypeId);
|
||||
if (contentType == null) throw new NullReferenceException("No content type found with id " + documentTypeId);
|
||||
|
||||
Response.AddHeader("Content-Disposition", "attachment;filename=" + contentType.Alias + ".udt");
|
||||
Response.ContentType = "application/octet-stream";
|
||||
|
||||
var serializer = new EntityXmlSerializer();
|
||||
var xml = serializer.Serialize(
|
||||
Services.DataTypeService,
|
||||
Services.ContentTypeService,
|
||||
contentType);
|
||||
|
||||
xml.Save(Response.OutputStream);
|
||||
}
|
||||
}
|
||||
|
||||
#region Web Form Designer generated code
|
||||
override protected void OnInit(EventArgs e)
|
||||
{
|
||||
//
|
||||
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
|
||||
//
|
||||
InitializeComponent();
|
||||
base.OnInit(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.Load += new System.EventHandler(this.Page_Load);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user