From c3a749e78030da1fd0780077f1b7382cbd96f8bd Mon Sep 17 00:00:00 2001 From: Kathy Date: Tue, 26 Jan 2016 11:46:00 +0000 Subject: [PATCH] =?UTF-8?q?only=20display=20=E2=80=98Create=20Enhanced?= =?UTF-8?q?=E2=80=99=20checkbox=20on=20=E2=80=98new=E2=80=99=20if=20copied?= =?UTF-8?q?=20item=20is=20not=20source=20or=20enhanced,=20pasting=20info?= =?UTF-8?q?=20a=20source=20is=20more=20like=20an=20=E2=80=98insert?= =?UTF-8?q?=E2=80=99=20into=20enhanced.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frmProcedureProperties.cs | 14 +++--------- .../VEPROMS.CSLA.Library/Config/ProcConfig.cs | 6 +++++ .../Extension/ItemInsertExt.cs | 22 +++++++++++++++++++ 3 files changed, 31 insertions(+), 11 deletions(-) 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.