B2024-075 Correct Linking and Numbering when utilizing Paste Before and Paste After with Enhanced Steps as well as some related UI refresh issues. #415

Merged
jjenko merged 1 commits from B2024-075 into Development 2024-10-02 11:48:59 -04:00
3 changed files with 132 additions and 22 deletions

View File

@ -1876,6 +1876,10 @@ namespace VEPROMS.CSLA.Library
if (IsCaution) enhType = 20006; if (IsCaution) enhType = 20006;
return enhType; return enhType;
} }
// B2024-075: Paste Before/After with Enhanced Documents is creating situation
//where Background item is linked to Source but Source is not linked to Background
//When Fixing the linking, need to not create a duplicate link if one already exists
public void DoCreateLinksEnhancedSingleItem(ItemInfo enhii, int enhtype) public void DoCreateLinksEnhancedSingleItem(ItemInfo enhii, int enhtype)
{ {
// Link the 2 items, srcII & enhii: // Link the 2 items, srcII & enhii:
@ -1893,12 +1897,15 @@ namespace VEPROMS.CSLA.Library
using (Item ei = Item.Get(enhii.ItemID)) using (Item ei = Item.Get(enhii.ItemID))
{ {
StepConfig sc = enhii.MyConfig as StepConfig; StepConfig sc = enhii.MyConfig as StepConfig;
sc.AddEnhancedDocument(0, this.ItemID); if (!sc.MyEnhancedDocuments.Exists(x => x.Type == 0))
sc.SaveEnhancedDocuments(); {
ei.MyContent.Text = DisplayText; sc.AddEnhancedDocument(0, this.ItemID);
ei.MyContent.Config = sc.ToString(); sc.SaveEnhancedDocuments();
ei.Save(); ei.MyContent.Text = DisplayText;
enhii.RefreshConfig(); ei.MyContent.Config = sc.ToString();
ei.Save();
enhii.RefreshConfig();
}
} }
} }
else if (IsSection) else if (IsSection)
@ -1916,12 +1923,15 @@ namespace VEPROMS.CSLA.Library
using (Item ei = Item.Get(enhii.ItemID)) using (Item ei = Item.Get(enhii.ItemID))
{ {
SectionConfig sc = enhii.MyConfig as SectionConfig; SectionConfig sc = enhii.MyConfig as SectionConfig;
sc.AddEnhancedDocument(0, this.ItemID); if (!sc.MyEnhancedDocuments.Exists(x => x.Type == 0))
sc.SaveEnhancedDocuments(); {
ei.MyContent.Text = DisplayText; sc.AddEnhancedDocument(0, this.ItemID);
ei.MyContent.Config = sc.ToString(); sc.SaveEnhancedDocuments();
ei.Save(); ei.MyContent.Text = DisplayText;
enhii.RefreshConfig(); ei.MyContent.Config = sc.ToString();
ei.Save();
enhii.RefreshConfig();
}
} }
} }
else if (IsProcedure) else if (IsProcedure)
@ -1942,11 +1952,14 @@ namespace VEPROMS.CSLA.Library
using (Item ii = this.Get()) using (Item ii = this.Get())
{ {
ProcedureConfig sc = this.MyConfig as ProcedureConfig; ProcedureConfig sc = this.MyConfig as ProcedureConfig;
sc.AddEnhancedDocument(enhtype, enhii.ItemID); if (!sc.MyEnhancedDocuments.Exists(x => x.Type == 0))
sc.SaveEnhancedDocuments(); {
ii.MyContent.Config = sc.ToString(); sc.AddEnhancedDocument(enhtype, enhii.ItemID);
ii.Save(); sc.SaveEnhancedDocuments();
RefreshConfig(); ii.MyContent.Config = sc.ToString();
ii.Save();
RefreshConfig();
}
} }
} }
} }

View File

@ -9,6 +9,7 @@ using System.Text.RegularExpressions;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
using Volian.Base.Library; using Volian.Base.Library;
using JR.Utils.GUI.Forms; using JR.Utils.GUI.Forms;
using System.Linq;
namespace Volian.Controls.Library namespace Volian.Controls.Library
{ {
@ -893,6 +894,18 @@ namespace Volian.Controls.Library
b4topadjust -= newFocus.Top; b4topadjust -= newFocus.Top;
TopMostYBefore -= b4topadjust; TopMostYBefore -= b4topadjust;
//B2024-075: If Deleting an item in a Source Document that is unlinked
//and the overall procedure has connected Background Documents
//and a window is open containing the background documents
//then need to force a refresh on that window as
//step numbering will shift
EnhancedDocuments ProcEnh = MyItemInfo.MyProcedure.GetMyEnhancedDocuments();
if (ProcEnh.Count > 0)
{
DisplayTabItem wndowToRefresh = MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyBar.Items.Cast<DisplayTabItem>().FirstOrDefault(x => x.MyKey == $"Item - {ProcEnh[0].ItemID}");
wndowToRefresh?.MyStepTabPanel.MyStepPanel.Reset(wndowToRefresh.MyItemInfo);
}
//_MyTimer.ActiveProcess = "Dispose"; //_MyTimer.ActiveProcess = "Dispose";
Dispose(); Dispose();
//_MyTimer.ActiveProcess = "SetAllTabs"; //_MyTimer.ActiveProcess = "SetAllTabs";
@ -1634,10 +1647,54 @@ namespace Volian.Controls.Library
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Before, newItemInfo.MyContent.Type)); MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Before, newItemInfo.MyContent.Type));
// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced. // MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
ItemInfo newEnh = newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.Before, GetChangeId(MyItemInfo)); //if doing a paste before/after and item being copied is unlinked, item pasted should also be unlinked.
ItemInfo tmpCopyStartSourceItem = ItemInfo.Get(copyStartID);
ItemInfo newEnh = null;
if (tmpCopyStartSourceItem.GetMyEnhancedDocuments().Count > 0)
{
newEnh = newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.Before, GetChangeId(MyItemInfo));
}
//B2024-075: When doing Paste Before / After with Enhanced Documents only link from Background document to source was created
//since source is done first
//this is so that after the steps are created in the enhanced, go back and update the link in the source to point to the correct item
if (newEditItem != null && newEnh != null)
{
FixEnhanceLinkOnSource(newEditItem.MyItemInfo, newEnh, MyItemInfo.GetMyEnhancedDocuments());
}
else if (newEnh == null && newEditItem != null && newEditItem.MyItemInfo.IsEnhancedStep)
{
UnlinkEnhanced(newEditItem);
}
else if (newEnh == null && newEditItem != null)
{
//if did a paste before/after in a source document that contains enhanced steps
//but step being pasted was non-enhanced (unlinked)
//then look to see if the background page is open
//and if it is, do a refresh so that step numbers update appropriately
//without having to close and re-open the background steps
foreach (EnhancedDocument edSource in MyItemInfo.GetMyEnhancedDocuments())
{
ItemInfo exEnh = ItemInfo.Get(edSource.ItemID);
DisplayTabItem wndowToRefresh = newEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyBar.Items.Cast<DisplayTabItem>().FirstOrDefault(x => x.MyKey == $"Item - {exEnh.MyProcedure.ItemID}");
wndowToRefresh?.MyStepTabPanel.MyStepPanel.Reset(wndowToRefresh.MyItemInfo);
}
}
// if enhanced items were created, then see if they need displayed: // if enhanced items were created, then see if they need displayed:
if (newEnh != null) AddAllEnhancedItemsToDisplay(newItemInfo); if (newEnh != null) AddAllEnhancedItemsToDisplay(newItemInfo);
} }
//B2024-075: When doing Paste Before / After with Enhanced Documents only link from Background document to source was created
//since source is done first
//this is so that after the steps are created in the enhanced, go back and update the link in the source to point to the correct item
//if enhanced document wasn't created then paste happened inside a enhanced Step/background step - so remove any links that shouldn't be there
//and don't have a corresponding spot in the Source
private void FixEnhanceLinkOnSource(ItemInfo SourceItem, ItemInfo newEnhItem, EnhancedDocuments enhancedDocuments)
{
if (enhancedDocuments.Count > 0)
CreateLinksEnhancedSingleItem(SourceItem, newEnhItem, enhancedDocuments[0].Type);
}
private void AddAllEnhancedItemsToDisplay(ItemInfo newItemInfo) private void AddAllEnhancedItemsToDisplay(ItemInfo newItemInfo)
{ {
EnhancedDocuments eds = newItemInfo.GetMyEnhancedDocuments(); EnhancedDocuments eds = newItemInfo.GetMyEnhancedDocuments();
@ -1684,12 +1741,15 @@ namespace Volian.Controls.Library
} }
} }
} }
public void UnlinkEnhanced(ItemInfo enhII) public void UnlinkEnhanced(EditItem enhII)
{ {
// B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced // B2022-049: Copy/paste of enhanced procedure and bad links between source and enhanced
// Pass in to unlink as before this change // Pass in to unlink as before this change
enhII.DoUnlinkEnhanced(enhII, 0, false); // B2024 - 075: Change made to pass in an EditTem instead of a ItemInfo
//so can refresh the UI
enhII.MyItemInfo.DoUnlinkEnhanced(enhII.MyItemInfo, 0, false);
SetFocus(); SetFocus();
enhII.MyStepPanel.Reset(enhII.MyItemInfo); //need to reset parts so refreshes display to show as unlinked
} }
public ItemInfo AddMissingEnhancedStep(ItemInfo ii, int EnhType) public ItemInfo AddMissingEnhancedStep(ItemInfo ii, int EnhType)
{ {
@ -1753,7 +1813,42 @@ namespace Volian.Controls.Library
MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.After, newItemInfo.MyContent.Type)); MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.After, newItemInfo.MyContent.Type));
// MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced. // MyItemInfo is the 'paste from' item, if it has enhanced need to copy and paste the steps in enhanced.
ItemInfo newEnh = newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.After, GetChangeId(MyItemInfo)); //if doing a paste before/after and item being copied is unlinked, item pasted should also be unlinked.
ItemInfo tmpCopyStartSourceItem = ItemInfo.Get(copyStartID);
ItemInfo newEnh = null;
if (tmpCopyStartSourceItem.GetMyEnhancedDocuments().Count > 0)
{
newEnh = newItemInfo.EnhancedPasteItem(copyStartID, MyItemInfo, ItemInfo.EAddpingPart.After, GetChangeId(MyItemInfo));
}
//B2024-075: When doing Paste Before / After with Enhanced Documents only link from Background document to source was created
//since source is done first
//this is so that after the steps are created in the enhanced, go back and update the link in the source to point to the correct item
//if enhanced document wasn't created then paste happened inside a enhanced Step/background step - so remove any links that shouldn't be there
//and don't have a cooresponding spot in the Source
if (newEditItem != null && newEnh != null)
{
FixEnhanceLinkOnSource(newEditItem.MyItemInfo, newEnh, MyItemInfo.GetMyEnhancedDocuments());
}
else if (newEnh == null && newEditItem != null && newEditItem.MyItemInfo.IsEnhancedStep)
{
UnlinkEnhanced(newEditItem);
}
else if (newEnh == null && newEditItem != null)
{
//if did a paste before/after in a source document that contains enhanced steps
//but step being pasted was non-enhanced (unlinked)
//then look to see if the background page is open
//and if it is, do a refresh so that step numbers update appropriately
//without having to close and re-open the background steps
foreach (EnhancedDocument edSource in MyItemInfo.GetMyEnhancedDocuments())
{
ItemInfo exEnh = ItemInfo.Get(edSource.ItemID);
DisplayTabItem wndowToRefresh = newEditItem.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.MyBar.Items.Cast<DisplayTabItem>().FirstOrDefault(x => x.MyKey == $"Item - {exEnh.MyProcedure.ItemID}");
wndowToRefresh?.MyStepTabPanel.MyStepPanel.Reset(wndowToRefresh.MyItemInfo);
}
}
if (newEnh != null) AddAllEnhancedItemsToDisplay(newItemInfo); if (newEnh != null) AddAllEnhancedItemsToDisplay(newItemInfo);
} }
public void PasteChild(int copyStartID) public void PasteChild(int copyStartID)

View File

@ -337,8 +337,10 @@ namespace Volian.Controls.Library
else if (btn.Name.Contains("Unlink")) else if (btn.Name.Contains("Unlink"))
{ {
// C2019=003: add a confirmation dialog before unlinking a step: // C2019=003: add a confirmation dialog before unlinking a step:
// B2024 - 075: Change made to pass in an EditTem instead of a ItemInfo
//so can refresh the UI
if (FlexibleMessageBox.Show(this, "Do you want to unlink this step?", "Confirm Enhanced Step Unlink", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) if (FlexibleMessageBox.Show(this, "Do you want to unlink this step?", "Confirm Enhanced Step Unlink", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
MyEditItem.UnlinkEnhanced(MyEditItem.MyItemInfo); MyEditItem.UnlinkEnhanced(MyEditItem);
} }
} }
else else