B2020-076: Create template steps when insert step from treeview with editor not open (made 2 methods public)

This commit is contained in:
Kathy Ruffing 2020-05-28 13:21:48 +00:00
parent 26d500a939
commit 834febf196
2 changed files with 48 additions and 25 deletions

View File

@ -358,7 +358,7 @@ namespace VEPROMS.CSLA.Library
((ItemInfo)ActiveParent).MyContent.RefreshContentParts();
return tmp;
}
private ItemInfo InsertSmartTemplateSubStep(string text, string number, ItemInfo tmp, EAddpingPart adPart, int type, E_FromType fromTypeTop)
public ItemInfo InsertSmartTemplateSubStep(string text, string number, ItemInfo tmp, EAddpingPart adPart, int type, E_FromType fromTypeTop)
{
int newItemID = 0;
int topType = GetSmartTemplateTopLevelIndxOfThisType(type);
@ -414,7 +414,7 @@ namespace VEPROMS.CSLA.Library
return tmp;
}
private ItemInfo InsertSmartTemplateSteps(string text, string number, ItemInfo tmp, EAddpingPart adPart, int type)
public ItemInfo InsertSmartTemplateSteps(string text, string number, ItemInfo tmp, EAddpingPart adPart, int type)
{
int newItemID = 0;
int topType = GetSmartTemplateTopLevelIndx();
@ -686,7 +686,7 @@ namespace VEPROMS.CSLA.Library
}
public ItemInfo InsertSiblingAfter(string text, string number, int? type)
{
ItemInfo tmp = null;
ItemInfo tmp = null; // KBR need template code in tree view?
if (!IsSection && (FormatStepData.UseSmartTemplate || (MyHLS != null && MyHLS.FormatStepData.UseSmartTemplate) || FormatStepData.UseOldTemplate))
tmp = InsertSmartTemplateSteps(text, number, tmp, EAddpingPart.After, (int)((type == null)? MyContent.Type : type)); // B2018-051 use the type passed in instead of current step type
if (tmp == null)

View File

@ -2803,21 +2803,33 @@ namespace Volian.Controls.Library
}
else
{
// The parent step was not open in the step editor, just create new step and add treenode.
// The parent step was not open in the step editor, just create new step(s) and add treenode.
int newId = -1;
// B2020-076: if this step has a template, insert template steps.
int topType = ii.GetSmartTemplateTopLevelIndxOfThisType(20002);
if (topType != -1)
{
ItemInfo tmp = null;
tmp = ii.InsertSmartTemplateSubStep("New Step", null, null, ItemInfo.EAddpingPart.Child, 20002, E_FromType.Step);
newId = tmp.ItemID;
}
else
{
// this line (below) adds the new step to the bottom of the section, the other line (not commented) adds it to the top. Bug fix B2016-002
//using (Step step = Step.MakeStep(_LastItemInfo, _LastItemInfo.LastChild(E_FromType.Step), null, "New Step", 20002, E_FromType.Step))
using (Step step = Step.MakeStep(_LastItemInfo, null, null, "New Step", 20002, E_FromType.Step))
{
ShowBrokenRules(step.BrokenRulesCollection);
SetLastValues(StepInfo.Get(step.ItemID));
newId = step.ItemID;
}
}
SetLastValues(StepInfo.Get(newId));
tn = new VETreeNode(_LastStepInfo);
//SelectedNode.Nodes.Add(tn); // add tree node to end of list.
_LastStepInfo.UpdateTransitionText();
_LastStepInfo.UpdateROText();
TreeNode par = SelectedNode;
par.Nodes.Insert(0, tn);
}
}
// see if enhanced related steps need created:
SectionConfig scfgE = _LastItemInfo.ActiveSection.MyConfig as SectionConfig; // C2018-003 fixed use of getting the active section
@ -2861,19 +2873,30 @@ namespace Volian.Controls.Library
{
// The parent step was not open in the step editor, just create new step and add treenode.
int tvindex = SelectedNode.Index;
// B2020-076: if this step has a template, insert template steps.
int newid = -1;
if (ii.FormatStepData.UseSmartTemplate || ii.FormatStepData.UseOldTemplate)
{
ItemInfo tmp = ii.InsertSmartTemplateSteps("New Step", null, null, newtype == MenuSelections.StepAfter ? ItemInfo.EAddpingPart.After : ItemInfo.EAddpingPart.Before, (int)ii.MyContent.Type);
newid = tmp.ItemID;
}
else
{
// if inserting before, the parent is set in case previous is null, i.e. beginning of the list.
ItemInfo parent = (newtype == MenuSelections.StepAfter) ? null : _LastStepInfo.MyParent;
using (Step step = Step.MakeStep(parent, (newtype == MenuSelections.StepAfter) ? _LastStepInfo : _LastStepInfo.MyPrevious, null, "New Step", (int)_LastStepInfo.MyContent.Type, (E_FromType)_LastStepInfo.FirstSibling.ItemParts[0].FromType))
{
ShowBrokenRules(step.BrokenRulesCollection);
SetLastValues(StepInfo.Get(step.ItemID));
newid = step.ItemID;
}
}
SetLastValues(StepInfo.Get(newid));
tn = new VETreeNode(_LastStepInfo);
_LastStepInfo.UpdateTransitionText();
_LastStepInfo.UpdateROText();
TreeNode par = SelectedNode.Parent;
par.Nodes.Insert(tvindex + ((newtype == MenuSelections.StepBefore) ? 0 : 1), tn);
}
}
if (tn != null)
{
// add enhanced steps if applicable (this code is only run if a step is inserted, not for a section).