U4-5222 Rollback Feature fails to update the UI to show the rolled back content - requires refresh

This commit is contained in:
Shannon
2017-09-28 02:38:53 +10:00
parent 4b581a2182
commit d2d43255aa
5 changed files with 70 additions and 50 deletions

View File

@@ -361,11 +361,29 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
rootScope : function(){
return getRootScope();
},
reloadLocation: function() {
var injector = getRootInjector();
var $route = injector.get("$route");
$route.reload();
/**
This will reload the content frame based on it's current route, if pathToMatch is specified it will only reload it if the current
location matches the path
*/
reloadLocation: function(pathToMatch) {
var injector = getRootInjector();
var doChange = true;
if (pathToMatch) {
var $location = injector.get("$location");
var path = $location.path();
if (path != pathToMatch) {
doChange = false;
}
}
if (doChange) {
var $route = injector.get("$route");
$route.reload();
var $rootScope = injector.get("$rootScope");
$rootScope.$apply();
}
},
closeModalWindow: function(rVal) {

View File

@@ -172,9 +172,9 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
},
reloadLocation: function () {
reloadLocation: function (pathToMatch) {
if (this.mainWindow().UmbClientMgr) {
this.mainWindow().UmbClientMgr.reloadLocation();
this.mainWindow().UmbClientMgr.reloadLocation(pathToMatch);
}
},

View File

@@ -3,6 +3,7 @@ using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
@@ -117,36 +118,23 @@ namespace umbraco.presentation.dialogs
if (!IsPostBack) {
allVersions.Items.Add(new ListItem(ui.Text("rollback", "selectVersion")+ "...", ""));
foreach (DocumentVersionList dl in currentDoc.GetVersions()) {
foreach (DocumentVersionList dl in currentDoc.GetVersions())
{
//we don't need to show the current version
if (dl.Version == currentDoc.Version)
continue;
allVersions.Items.Add(new ListItem(dl.Text + " (" + ui.Text("content", "createDate") + ": " + dl.Date.ToShortDateString() + " " + dl.Date.ToShortTimeString() + ")", dl.Version.ToString()));
}
Button1.Text = ui.Text("actions", "rollback");
}
}
#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()
{
}
#endregion
protected void doRollback_Click(object sender, System.EventArgs e)
{
if (allVersions.SelectedValue.Trim() != "") {
if (allVersions.SelectedValue.Trim() != "")
{
Document d = new Document(int.Parse(helper.Request("nodeId")));
d.RollBack(new Guid(allVersions.SelectedValue), base.getUser());
@@ -159,6 +147,8 @@ namespace umbraco.presentation.dialogs
feedBackMsg.Text = ui.Text("rollback", "documentRolledBack", vars, new global::umbraco.BusinessLogic.User(0)) + "</p><p><a href='#' onclick='" + ClientTools.Scripts.CloseModalWindow() + "'>" + ui.Text("closeThisWindow") + "</a>";
diffPanel.Visible = false;
pl_buttons.Visible = false;
ClientTools.ReloadLocationIfMatched(string.Format("/content/content/edit/{0}", d.Id));
}
}
}

View File

@@ -52,7 +52,8 @@ namespace umbraco.BasePages
public static string ReloadContentFrameUrlIfPathLoaded(string url) {
return string.Format(ClientMgrScript + ".reloadContentFrameUrlIfPathLoaded('{0}');", url);
}
public static string ReloadLocation { get { return string.Format(ClientMgrScript + ".reloadLocation();"); } }
public static string ReloadLocation { get { return ClientMgrScript + ".reloadLocation();"; } }
public static string ReloadLocationIfMatched { get { return ClientMgrScript + ".reloadLocation('{0}');"; } }
public static string ChildNodeCreated = GetMainTree + ".childNodeCreated();";
public static string SyncTree { get { return GetMainTree + ".syncTree('{0}', {1});"; } }
public static string ClearTreeCache { get { return GetMainTree + ".clearTreeCache();"; } }
@@ -277,21 +278,33 @@ namespace umbraco.BasePages
RegisterClientScript(string.Format(Scripts.ReloadActionNode, (!reselect).ToString().ToLower(), (!reloadChildren).ToString().ToLower()));
return this;
}
/// <summary>
/// When the application searches for a node, it searches for nodes in specific tree types.
/// If SyncTree is used, it will sync the tree nodes with the active tree type, therefore if
/// a developer wants to sync a specific tree, they can call this method to set the type to sync.
/// </summary>
/// <remarks>
/// Each branch of a particular tree should theoretically be the same type, however, developers can
/// override the type of each branch in their BaseTree's but this is not standard practice. If there
/// are multiple types of branches in one tree, then only those branches that have the Active tree type
/// will be searched for syncing.
/// </remarks>
/// <param name="treeType"></param>
/// <returns></returns>
public ClientTools SetActiveTreeType(string treeType)
public ClientTools ReloadLocationIfMatched(string routePath)
{
RegisterClientScript(string.Format(Scripts.ReloadLocationIfMatched, routePath));
return this;
}
public ClientTools ReloadLocation()
{
RegisterClientScript(Scripts.ReloadLocation);
return this;
}
/// <summary>
/// When the application searches for a node, it searches for nodes in specific tree types.
/// If SyncTree is used, it will sync the tree nodes with the active tree type, therefore if
/// a developer wants to sync a specific tree, they can call this method to set the type to sync.
/// </summary>
/// <remarks>
/// Each branch of a particular tree should theoretically be the same type, however, developers can
/// override the type of each branch in their BaseTree's but this is not standard practice. If there
/// are multiple types of branches in one tree, then only those branches that have the Active tree type
/// will be searched for syncing.
/// </remarks>
/// <param name="treeType"></param>
/// <returns></returns>
public ClientTools SetActiveTreeType(string treeType)
{
RegisterClientScript(string.Format(Scripts.SetActiveTreeType, treeType));
return this;

View File

@@ -276,13 +276,12 @@ namespace umbraco.cms.businesslogic
{
if (_version == Guid.Empty)
{
string sql = "Select versionId from cmsContentVersion where contentID = " + this.Id +
" order by id desc ";
var sql = string.Format("SELECT versionId FROM cmsDocument where nodeid={0} AND newest = 1 ORDER BY updateDate desc", this.Id);
using (var sqlHelper = Application.SqlHelper)
using (IRecordsReader dr = sqlHelper.ExecuteReader(sql))
{
if (!dr.Read())
if (dr.Read() == false)
_version = Guid.Empty;
else
_version = dr.GetGuid("versionId");