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) 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 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. // to simulate replacing an existing step - otherwise we will get null references.
if (MyStepPanel.SelectedEditItem != null && MyStepPanel.SelectedEditItem.Empty) 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 if (gotoFirstTrans) //B2017-179 could not replace step, we are positioning onto the first transition that needs resolved
{ {
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(newItemInfo); MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OpenItem(newItemInfo);
if (this is RTBItem) (this as RTBItem).DoingPasteReplace = true;
return null; return null;
} }
if (newItemInfo == 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 return this; // aborted the replace so just return to the step we were trying to replace
} }
}
//catch (System.Data.SqlClient.SqlException ex) //catch (System.Data.SqlClient.SqlException ex)
catch (Exception ex) catch (Exception ex)
{ {
if (HandleSqlExceptionOnCopy(ex)) return this; if (HandleSqlExceptionOnCopy(ex)) return this;
HandleSqlExceptionOnDelete(ex); HandleSqlExceptionOnDelete(ex);
if (this is RTBItem) (this as RTBItem).DoingPasteReplace = true;
return this; return this;
} }
// Remove the EditItem that was the replaced item. // Remove the EditItem that was the replaced item.
@ -1906,9 +1912,7 @@ namespace Volian.Controls.Library
} }
MyStepPanel.SelectedEditItem = newEditItem; //Update Screen MyStepPanel.SelectedEditItem = newEditItem; //Update Screen
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Replace, newItemInfo.MyContent.Type)); 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. if (this is RTBItem) (this as RTBItem).DoingPasteReplace = true;
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!!
return newEditItem; return newEditItem;
} }
private bool HandleSqlExceptionOnCopy(Exception ex) private bool HandleSqlExceptionOnCopy(Exception ex)

View File

@ -241,7 +241,12 @@ namespace Volian.Controls.Library
get { return _EnhAddFromItemInfo; } get { return _EnhAddFromItemInfo; }
set { _EnhAddFromItemInfo = value; } set { _EnhAddFromItemInfo = value; }
} }
private ItemInfo _EnhCopiedItemInfo = null; private bool _DoingPasteReplace = false;
public bool DoingPasteReplace
{
get { return _DoingPasteReplace; }
set { _DoingPasteReplace = value; }
}
#endregion #endregion
#region Constructors #region Constructors
public RTBItem(ItemInfo itemInfo, StepPanel myStepPanel, EditItem myParentEditItem, ChildRelation myChildRelation, bool expand) 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; ItemInfo.EAddpingPart addpart = ItemInfo.EAddpingPart.After;
if (EnhAddType == EnhancedAddTypes.Before) addpart = ItemInfo.EAddpingPart.Before; if (EnhAddType == EnhancedAddTypes.Before) addpart = ItemInfo.EAddpingPart.Before;
else if (EnhAddType == EnhancedAddTypes.Child) addpart = ItemInfo.EAddpingPart.Child; 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); ItemInfo newEnh = MyItemInfo.DoAddEnhancedSteps(ed.Type, ed.ItemID, addpart);
if (newEnh != null) AddEnhancedItemToDisplayTabItem(newEnh); if (newEnh != null) AddEnhancedItemToDisplayTabItem(newEnh);
} }
}
EnhAddType = EnhancedAddTypes.No; EnhAddType = EnhancedAddTypes.No;
} }
} }