diff --git a/PROMS/VEPROMS User Interface/frmProcedureProperties.cs b/PROMS/VEPROMS User Interface/frmProcedureProperties.cs index 2dd47112..ddc1c7d3 100644 --- a/PROMS/VEPROMS User Interface/frmProcedureProperties.cs +++ b/PROMS/VEPROMS User Interface/frmProcedureProperties.cs @@ -212,19 +212,11 @@ namespace VEPROMS ppCmbxStpEditorCols.ValueMember = "EValue"; ppCmbxStpEditorCols.SelectedIndex = -1; - // if the associated DocVersion has Enhanced, make the Enhanced checkbox visible + // the only time the create enhanced checkbox is visisble is if this is a 'New' procedure in a set that is the 'Source'. cbEnhanced.Visible = false; DocVersionConfig dvc = _ProcedureConfig.MyProcedure.MyProcedureInfo.MyDocVersion.MyConfig as DocVersionConfig; - if (dvc != null && dvc.MyEnhancedDocuments != null && dvc.MyEnhancedDocuments.Count > 0) - { - if (dvc.MyEnhancedDocuments.Count > 1 || dvc.MyEnhancedDocuments[0].Type != 0) - { - cbEnhanced.Visible = true; - // if this procedure has enhanced data, the checkbox should not be editable: - cbEnhanced.Enabled = !(_ProcedureConfig.MyEnhancedDocuments != null && _ProcedureConfig.MyEnhancedDocuments.Count > 0); - cbEnhanced.Checked = (_ProcedureConfig.MyEnhancedDocuments != null && _ProcedureConfig.MyEnhancedDocuments.Count > 0); - } - } + if (_ProcedureConfig.CreatingNew && dvc != null && dvc.MyEnhancedDocuments != null && dvc.MyEnhancedDocuments.Count > 0 && dvc.MyEnhancedDocuments[0].Type != 0) + cbEnhanced.Visible = true; _Initializing = false; } diff --git a/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs index 497d9b76..07642f66 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/ProcConfig.cs @@ -234,6 +234,12 @@ namespace VEPROMS.CSLA.Library } public Procedure MyProcedure { get { return _Procedure; } } + private bool _CreatingNew = false; + public bool CreatingNew + { + get { return _CreatingNew; } + set { _CreatingNew = value; } + } #endregion #region ToString public override string ToString() diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs index 4fd89539..3fe8ddbf 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs @@ -1016,6 +1016,28 @@ namespace VEPROMS.CSLA.Library // tmpCopyStartSourceItem is the item that was copied in source. ItemInfo tmpCopyStartSourceItem = ItemInfo.Get(copyStartID); + // if the copied step is not a 'source', then this really needs to be more of an insert for the enhanced steps. + StepConfig stepFromCfg = tmpCopyStartSourceItem.MyConfig as StepConfig; + if (stepFromCfg.MyEnhancedDocuments == null || stepFromCfg.MyEnhancedDocuments.Count==0) + { + // Insert the enhanced steps. Loop through all enhanced document types, insert from + // the paste item's linked step. + foreach (EnhancedDocument edSource in pasteFromItem.GetMyEnhancedDocuments()) + { + // create a new enhanced step and link it to this new source step. + // the new source step's item is used to know what type & what to link to. + // The ed.Type & ed.itemid show what type of enhanced document (use to create new + // config Type). + ItemInfo exEnh = ItemInfo.Get(edSource.ItemID); + ItemInfo newEnh = exEnh.InsertEnhancedSteps(tmpCopyStartSourceItem.MyContent.Text, null, addType, MyContent.Type, edSource.Type, this.ItemID); + if (newEnh == null) return null; + StepConfig sc = new StepConfig(MyContent.Config); + sc.AddEnhancedDocument(edSource.Type, newEnh.ItemID); + SaveConfig(sc.ToString()); + } + return null; + } + // loop through all enhanced document types, pasting in the copied item(s). // Note that the copy/paste finds the enhanced items that relate to source, // i.e. copied item & paste from, and uses those to do the copy/paste.