B2016-030: Crash when deleting a source (has linked enhanced) sections when all are displayed in editor.

B2016-029: Title of newly created enhanced section is not correct if source section not titled ‘New Section’.
B2016-031: Insert from tree of section after a non-linked section does not get inserted in enhanced procedure in correct location.
This commit is contained in:
Kathy Ruffing 2016-02-02 14:07:25 +00:00
parent ab76c69199
commit 596a59d0f6
2 changed files with 22 additions and 16 deletions

View File

@ -704,14 +704,17 @@ namespace Volian.Controls.Library
if (MyItemInfo.IsSection) if (MyItemInfo.IsSection)
{ {
SectionConfig secc = MyItemInfo.MyConfig as SectionConfig; SectionConfig secc = MyItemInfo.MyConfig as SectionConfig;
if (secc.Section_LnkEnh=="Y")thisEnhs = secc.MyEnhancedDocuments; if (secc.Section_LnkEnh == "Y") thisEnhs = secc.MyEnhancedDocuments;
} }
} }
List<int> enhIds = new List<int>(); List<int> enhIds = new List<int>();
foreach (EnhancedDocument ed in thisEnhs) if (thisEnhs != null)
{ {
if (ed.Type != 0) enhIds.Add(ed.ItemID); foreach (EnhancedDocument ed in thisEnhs)
{
if (ed.Type != 0) enhIds.Add(ed.ItemID);
}
} }
BeingRemoved = true; BeingRemoved = true;
MyStepPanel.SelectedEditItem = null; // Unselect the item to be deleted MyStepPanel.SelectedEditItem = null; // Unselect the item to be deleted
@ -723,7 +726,7 @@ namespace Volian.Controls.Library
pnl.Size = new Size(10, 10); pnl.Size = new Size(10, 10);
MyStepPanel.Controls.Add(pnl); MyStepPanel.Controls.Add(pnl);
pnl.BackColor = Color.Red; pnl.BackColor = Color.Red;
pnl.Location = new Point(xOffset += 15, MyStepPanel.ClientSize.Height+10); pnl.Location = new Point(xOffset += 15, MyStepPanel.ClientSize.Height + 10);
EditItem newFocus = DeleteItem(); EditItem newFocus = DeleteItem();
if (newFocus == null) if (newFocus == null)
{ {
@ -748,10 +751,10 @@ namespace Volian.Controls.Library
MyStepPanel.Controls.Remove(pnl); MyStepPanel.Controls.Remove(pnl);
foreach (int enhId in enhIds) foreach (int enhId in enhIds)
{ {
ItemInfo ii = ItemInfo.Get(enhId); ItemInfo ii = ItemInfo.Get(enhId);
bool success = this._MyStepPanel.MyStepTabPanel.MyDisplayTabControl.DeleteRTBItem(ii); bool success = this._MyStepPanel.MyStepTabPanel.MyDisplayTabControl.DeleteRTBItem(ii);
if (!success) // item was not displayed in editor, just delete from database (add tree if necessarY) if (!success)
Item.DeleteItemAndChildren(ii); Item.DeleteItemAndChildren(ii);
} }
} }

View File

@ -2278,7 +2278,7 @@ namespace Volian.Controls.Library
// Enhanced section: // Enhanced section:
Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem. Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem.
if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y") if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y")
CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo); CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo, sectiontmp.DisplayNumber, sectiontmp.MyContent.Text);
sectiontmp.Dispose(); sectiontmp.Dispose();
OnNodeSelect(this, new vlnTreeEventArgs(tn)); OnNodeSelect(this, new vlnTreeEventArgs(tn));
} }
@ -2327,7 +2327,7 @@ namespace Volian.Controls.Library
// Enhanced section: // Enhanced section:
Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem. Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem.
if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y") if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y")
CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo); CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo, sectiontmp.DisplayNumber, sectiontmp.MyContent.Text);
sectiontmp.Dispose(); sectiontmp.Dispose();
} }
} }
@ -2368,7 +2368,7 @@ namespace Volian.Controls.Library
// Enhanced section: // Enhanced section:
Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem. Section sectiontmp = Section.Get(section.ItemID); // need to do this because of 'caching' problem.
if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y") if (sectiontmp.SectionConfig.LinkEnhanced == "T" || sectiontmp.SectionConfig.LinkEnhanced == "Y")
CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo); CreateEnhancedForSection(newtype, sectiontmp, savLastSectionInfo, sectiontmp.DisplayNumber, sectiontmp.MyContent.Text);
sectiontmp.Dispose(); sectiontmp.Dispose();
} }
} }
@ -2480,8 +2480,9 @@ namespace Volian.Controls.Library
cs.Save(); cs.Save();
} }
} }
private void CreateEnhancedForSection(MenuSelections typ, Section sourceSect, SectionInfo lastSectionInfo) private void CreateEnhancedForSection(MenuSelections typ, Section sourceSect, SectionInfo lastSectionInfo, string num, string title)
{ {
MenuSelections tmptyp = typ;
if (typ == MenuSelections.SectionAfter || typ == MenuSelections.SectionBefore) if (typ == MenuSelections.SectionAfter || typ == MenuSelections.SectionBefore)
{ {
ItemInfo tmpSI = lastSectionInfo; ItemInfo tmpSI = lastSectionInfo;
@ -2494,6 +2495,8 @@ namespace Volian.Controls.Library
eds = sc.MyEnhancedDocuments; eds = sc.MyEnhancedDocuments;
break; break;
} }
// if had to skip unlinked sections, it becomes an 'after' a linked one:
tmptyp = MenuSelections.SectionAfter;
tmpSI = tmpSI.MyPrevious; tmpSI = tmpSI.MyPrevious;
} }
if (eds != null) // found valid enhanced ids to insert from: if (eds != null) // found valid enhanced ids to insert from:
@ -2501,7 +2504,7 @@ namespace Volian.Controls.Library
foreach (EnhancedDocument sed in eds) foreach (EnhancedDocument sed in eds)
{ {
SectionInfo esi = SectionInfo.Get(sed.ItemID); SectionInfo esi = SectionInfo.Get(sed.ItemID);
using (Section newenhSection = Section.MakeSection((typ == MenuSelections.SectionAfter) ? null : esi.ActiveParent, (typ == MenuSelections.SectionAfter) ? esi : esi.MyPrevious, null, "New Section", 10000)) using (Section newenhSection = Section.MakeSection((tmptyp == MenuSelections.SectionAfter) ? null : esi.ActiveParent, (tmptyp == MenuSelections.SectionAfter) ? esi : esi.MyPrevious, num, title, 10000))
{ {
SaveEnhancedForSection(sourceSect, newenhSection, sed.Type); SaveEnhancedForSection(sourceSect, newenhSection, sed.Type);
RefreshRelatedNode(SectionInfo.Get(newenhSection.ItemID)); RefreshRelatedNode(SectionInfo.Get(newenhSection.ItemID));
@ -2521,7 +2524,7 @@ namespace Volian.Controls.Library
ProcedureInfo enhInfo = ProcedureInfo.Get(ed.ItemID); ProcedureInfo enhInfo = ProcedureInfo.Get(ed.ItemID);
if (enhInfo.LastChild(E_FromType.Section) != null) if (enhInfo.LastChild(E_FromType.Section) != null)
{ {
using (Section newenhSection = Section.MakeSection(enhInfo, (enhInfo.Sections != null && enhInfo.Sections.Count != 0) ? enhInfo.Sections[enhInfo.Sections.Count - 1] : null, null, "New Section", 10000)) using (Section newenhSection = Section.MakeSection(enhInfo, (enhInfo.Sections != null && enhInfo.Sections.Count != 0) ? enhInfo.Sections[enhInfo.Sections.Count - 1] : null, num, title, 10000))
{ {
SaveEnhancedForSection(sourceSect, newenhSection, ed.Type); SaveEnhancedForSection(sourceSect, newenhSection, ed.Type);
RefreshRelatedNode(SectionInfo.Get(newenhSection.ItemID)); RefreshRelatedNode(SectionInfo.Get(newenhSection.ItemID));
@ -2529,7 +2532,7 @@ namespace Volian.Controls.Library
} }
else else
{ {
ItemInfo newenhSectionII = enhInfo.InsertChild(E_FromType.Section, 10000, "New Section", null); ItemInfo newenhSectionII = enhInfo.InsertChild(E_FromType.Section, 10000, title, num);
using (Section newenhSect = Section.Get(newenhSectionII.ItemID)) using (Section newenhSect = Section.Get(newenhSectionII.ItemID))
{ {
SaveEnhancedForSection(sourceSect, newenhSect, ed.Type); SaveEnhancedForSection(sourceSect, newenhSect, ed.Type);