Content is now saving properly in the editor.
This commit is contained in:
@@ -489,7 +489,7 @@ angular.module('umbraco.directives', [])
|
||||
if (!iAttrs.tabs)
|
||||
throw "a 'tabs' attribute must be set for umbHeader which represents the collection of tabs";
|
||||
|
||||
var hasProcessed = false;
|
||||
//var hasProcessed = false;
|
||||
|
||||
//when the tabs change, we need to hack the planet a bit and force the first tab content to be active,
|
||||
//unfortunately twitter bootstrap tabs is not playing perfectly with angular.
|
||||
@@ -497,10 +497,11 @@ angular.module('umbraco.directives', [])
|
||||
|
||||
//don't process if we cannot or have already done so
|
||||
if (!newValue) return;
|
||||
if (hasProcessed || !newValue.length || newValue.length == 0) return;
|
||||
//if (hasProcessed || !newValue.length || newValue.length == 0) return;
|
||||
if (!newValue.length || newValue.length == 0) return;
|
||||
|
||||
//set the flag
|
||||
hasProcessed = true;
|
||||
//hasProcessed = true;
|
||||
|
||||
var $panes = $('div.tab-content');
|
||||
var activeTab = _.find(newValue, function (item) {
|
||||
|
||||
@@ -141,6 +141,43 @@ define(['app', 'angular'], function (app, angular) {
|
||||
function getSaveUrl() {
|
||||
return Umbraco.Sys.ServerVariables.contentEditorApiBaseUrl + "PostSaveContent";
|
||||
}
|
||||
/** internal method process the saving of data and post processing the result */
|
||||
function saveContentItem(content, action) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
//save the active tab id so we can set it when the data is returned.
|
||||
var activeTab = _.find(content.tabs, function (item) {
|
||||
return item.active
|
||||
})
|
||||
var activeTabIndex = (activeTab == undefined ? 0 : _.indexOf(content.tabs, activeTab));
|
||||
|
||||
//save the data
|
||||
umbRequestHelper.postMultiPartRequest(
|
||||
getSaveUrl(content.id),
|
||||
{ key: "contentItem", value: umbDataFormatter.formatContentPostData(content, action) },
|
||||
function (data) {
|
||||
//TODO: transform the request callback and add the files associated with the request
|
||||
},
|
||||
function (data, status, headers, config) {
|
||||
//success callback
|
||||
|
||||
//reset the tabs and set the active one
|
||||
_.each(data.tabs, function (item) {
|
||||
item.active = false;
|
||||
});
|
||||
data.tabs[activeTabIndex].active = true;
|
||||
|
||||
//the data returned is the up-to-date data so the UI will refresh
|
||||
deferred.resolve(data);
|
||||
},
|
||||
function (data, status, headers, config) {
|
||||
//failure callback
|
||||
|
||||
deferred.reject('Failed to publish data for content id ' + content.id);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
return {
|
||||
getContent: function (id) {
|
||||
@@ -277,56 +314,12 @@ define(['app', 'angular'], function (app, angular) {
|
||||
|
||||
/** saves or updates a content object */
|
||||
saveContent: function (content) {
|
||||
|
||||
var deferred = $q.defer();
|
||||
|
||||
//save the data
|
||||
umbRequestHelper.postMultiPartRequest(
|
||||
getSaveUrl(content.id),
|
||||
umbDataFormatter.formatContentPostData(content, "save"),
|
||||
function (data) {
|
||||
//TODO: transform the request callback and add the files associated with the request
|
||||
},
|
||||
function (data, status, headers, config) {
|
||||
//success callback
|
||||
|
||||
//the data returned is the up-to-date data so the UI will refresh
|
||||
deferred.resolve(data);
|
||||
},
|
||||
function (data, status, headers, config) {
|
||||
//failure callback
|
||||
|
||||
deferred.reject('Failed to publish data for content id ' + content.id);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
return saveContentItem(content, "save");
|
||||
},
|
||||
|
||||
/** saves and publishes a content object */
|
||||
publishContent: function (content) {
|
||||
|
||||
var deferred = $q.defer();
|
||||
|
||||
//save the data
|
||||
umbRequestHelper.postMultiPartRequest(
|
||||
getSaveUrl(content.id),
|
||||
{ key: "contentItem", value: umbDataFormatter.formatContentPostData(content, "publish") },
|
||||
function (data) {
|
||||
//TODO: transform the request callback and add the files associated with the request
|
||||
},
|
||||
function (data, status, headers, config) {
|
||||
//success callback
|
||||
|
||||
//the data returned is the up-to-date data so the UI will refresh
|
||||
deferred.resolve(data);
|
||||
},
|
||||
function (data, status, headers, config) {
|
||||
//failure callback
|
||||
|
||||
deferred.reject('Failed to publish data for content id ' + content.id);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
return saveContentItem(content, "publish");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
50
src/Umbraco.Web/HttpCookieExtensions.cs
Normal file
50
src/Umbraco.Web/HttpCookieExtensions.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System.Web;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods used to check/set cookie values
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This should 100% supercede the StateManager.Cookies
|
||||
/// </remarks>
|
||||
internal static class HttpCookieExtensions
|
||||
{
|
||||
internal const string PreviewCookieName = "UMB_PREVIEW";
|
||||
|
||||
/// <summary>
|
||||
/// Does a preview cookie exist ?
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public static bool HasPreviewCookie(this HttpRequestBase request)
|
||||
{
|
||||
return request.Cookies[PreviewCookieName] != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does a cookie exist with the specified key ?
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static bool HasCookie(this HttpRequestBase request, string key)
|
||||
{
|
||||
return request.Cookies[key] != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is there a cookie with the key supplied and does it have a value that is not empty
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static bool HasCookieValue(this HttpRequestBase request, string key)
|
||||
{
|
||||
return request.Cookies[key] != null
|
||||
&& request.Cookies[key].Value != null
|
||||
&& request.Cookies[key].Value.IsNullOrWhiteSpace() == false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,51 +7,6 @@ using Umbraco.Core;
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods used to check/set cookie values
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This should 100% supercede the StateManager.Cookies
|
||||
/// </remarks>
|
||||
internal static class HttpCookieExtensions
|
||||
{
|
||||
internal const string PreviewCookieName = "UMB_PREVIEW";
|
||||
|
||||
/// <summary>
|
||||
/// Does a preview cookie exist ?
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public static bool HasPreviewCookie(this HttpRequestBase request)
|
||||
{
|
||||
return request.Cookies[PreviewCookieName] != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does a cookie exist with the specified key ?
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static bool HasCookie(this HttpRequestBase request, string key)
|
||||
{
|
||||
return request.Cookies[key] != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is there a cookie with the key supplied and does it have a value that is not empty
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static bool HasCookieValue(this HttpRequestBase request, string key)
|
||||
{
|
||||
return request.Cookies[key] != null
|
||||
&& request.Cookies[key].Value != null
|
||||
&& request.Cookies[key].Value.IsNullOrWhiteSpace() == false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for the HttpRequest and HttpRequestBase objects
|
||||
/// </summary>
|
||||
public static class HttpRequestExtensions
|
||||
|
||||
@@ -293,6 +293,7 @@
|
||||
<Compile Include="Cache\UserTypeCacheRefresher.cs" />
|
||||
<Compile Include="Configuration\WebRouting.cs" />
|
||||
<Compile Include="Editors\ContentTypeApiController.cs" />
|
||||
<Compile Include="HttpCookieExtensions.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentSaveAction.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentTypeBasic.cs" />
|
||||
<Compile Include="Models\ContentEditing\Tab.cs" />
|
||||
|
||||
Reference in New Issue
Block a user