B2017-222: Don’t create enhanced links for paste replaced steps

This commit is contained in:
Kathy Ruffing 2017-09-26 14:33:42 +00:00
parent fbedffd01d
commit 54f1be3ba1
2 changed files with 20 additions and 6 deletions

View File

@ -1821,6 +1821,7 @@ namespace Volian.Controls.Library
}
public EditItem PasteReplace(int copyStartID)
{
if (this is RTBItem) (this as RTBItem).DoingPasteReplace = true;
// To allow a Paste Step into an empty (new) step/substep, we need to add a character to the the Text field
// to simulate replacing an existing step - otherwise we will get null references.
if (MyStepPanel.SelectedEditItem != null && MyStepPanel.SelectedEditItem.Empty)
@ -1844,16 +1845,21 @@ namespace Volian.Controls.Library
if (gotoFirstTrans) //B2017-179 could not replace step, we are positioning onto the first transition that needs resolved
{
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(newItemInfo);
if (this is RTBItem) (this as RTBItem).DoingPasteReplace = true;
return null;
}
if (newItemInfo == null)
{
if (this is RTBItem) (this as RTBItem).DoingPasteReplace = true;
return this; // aborted the replace so just return to the step we were trying to replace
}
}
//catch (System.Data.SqlClient.SqlException ex)
catch (Exception ex)
{
if (HandleSqlExceptionOnCopy(ex)) return this;
HandleSqlExceptionOnDelete(ex);
if (this is RTBItem) (this as RTBItem).DoingPasteReplace = true;
return this;
}
// Remove the EditItem that was the replaced item.
@ -1906,9 +1912,7 @@ namespace Volian.Controls.Library
}
MyStepPanel.SelectedEditItem = newEditItem; //Update Screen
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Replace, newItemInfo.MyContent.Type));
// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
ItemInfo newEnh = newItemInfo.PasteEnhancedItems(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.Replace, GetChangeId(MyItemInfo));
if (newEnh != null) AddAllEnhancedItemsToDisplay(newItemInfo); // KBR - I think this won't work for replace!!
if (this is RTBItem) (this as RTBItem).DoingPasteReplace = true;
return newEditItem;
}
private bool HandleSqlExceptionOnCopy(Exception ex)

View File

@ -241,7 +241,12 @@ namespace Volian.Controls.Library
get { return _EnhAddFromItemInfo; }
set { _EnhAddFromItemInfo = value; }
}
private ItemInfo _EnhCopiedItemInfo = null;
private bool _DoingPasteReplace = false;
public bool DoingPasteReplace
{
get { return _DoingPasteReplace; }
set { _DoingPasteReplace = value; }
}
#endregion
#region Constructors
public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand)
@ -825,9 +830,14 @@ namespace Volian.Controls.Library
ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.After;
if (EnhAddType == EnhancedAddTypes.Before) addpart = ItemInfo.EAddpingPart.Before;
else if (EnhAddType == EnhancedAddTypes.Child) addpart = ItemInfo.EAddpingPart.Child;
// B2017-222: if replacing, don't do the enhanced links. The past replace button isn't active for enhanced,
// however, paste replace was accessed when creating a new HLS/Caution/Note and then replacing into it.
if (MyItemInfo.MyContent.Text != "" && !DoingPasteReplace)
{
ItemInfo newEnh = MyItemInfo.DoAddEnhancedSteps(ed.Type, ed.ItemID, addpart);
if (newEnh != null) AddEnhancedItemToDisplayTabItem(newEnh);
}
}
EnhAddType = EnhancedAddTypes.No;
}
}