From 9130604fa6acacd08b7d33527f1fa5de710365bf Mon Sep 17 00:00:00 2001 From: mschill Date: Thu, 25 Sep 2025 08:01:19 -0400 Subject: [PATCH] C2015-028 Add Editorial Mode to PROMS Step Editor --- .../VEPROMS.CSLA.Library/Config/StepConfig.cs | 27 ++++++++++ .../VEPROMS.CSLA.Library/Extension/ItemExt.cs | 23 ++++++--- .../Generated/ItemInfo.cs | 14 ++++-- .../DisplayTabControl.cs | 46 +++++++++++++----- PROMS/Volian.Controls.Library/RTBItem.cs | 28 ++++++++--- PROMS/Volian.Controls.Library/StepPanel.cs | 9 +++- PROMS/Volian.Controls.Library/StepRTB.cs | 7 ++- PROMS/Volian.Controls.Library/StepTabPanel.cs | 2 +- .../Volian.Controls.Library/StepTabRibbon.cs | 43 +++++++++++++--- .../StepTabRibbon.designer.cs | Bin 575428 -> 577962 bytes 10 files changed, 161 insertions(+), 38 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Config/StepConfig.cs b/PROMS/VEPROMS.CSLA.Library/Config/StepConfig.cs index 106e79a2..692a8db3 100644 --- a/PROMS/VEPROMS.CSLA.Library/Config/StepConfig.cs +++ b/PROMS/VEPROMS.CSLA.Library/Config/StepConfig.cs @@ -394,6 +394,33 @@ namespace VEPROMS.CSLA.Library OnPropertyChanged("Step_ChangeID"); } } + + // C2015-028 Add Editorial Mode to PROMS Step Editor + // was last change made in editorial mode and thus change bars should be disabled? + // will contain userid of user that made last change if it was in Editorial Mode + // if there was not a previous change that would have caused change bars + // will be blank/empty by default + // will get overwritten every time a change is made + public string Step_ChangeIDEditorialMode + { + get + { + string s = _Xp["Step", "ChangeIDEMode"]; + + if (s == string.Empty) return null; + return s; + } + set + { + string s = _Xp["Step", "ChangeIDEMode"]; + + if (value != null && value.ToString() == s) return; + if (value == null && s != null) _Xp["Step", "ChangeIDEMode"] = null; + else _Xp["Step", "ChangeIDEMode"] = value.ToString(); + OnPropertyChanged("Step_ChangeIDEMode"); + } + } + public string Step_Responsibility { get diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs index cc68f7d5..62e5ca4a 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemExt.cs @@ -3933,9 +3933,7 @@ namespace VEPROMS.CSLA.Library get { bool chg = HasChanges; - StepInfo si = this as StepInfo; - if (si == null) return false; - StepConfig sc = si.MyConfig as StepConfig; + StepConfig sc = this.MyConfig as StepConfig; if (sc == null) return false; // if there is no override & return whether there was a change to the text. if (chg && ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds && @@ -3943,6 +3941,21 @@ namespace VEPROMS.CSLA.Library return false; // No Change ID - No Change Bar if ((sc.Step_SpellCheckerChangedText ?? "") == "NoChangeBar") return false; // Spell Checker, in editorial mode (format flag EditoralSpellCheck) , made the change and there was no change bar prior to that change B2015-024 + // C2015-028 Add Editorial Mode to PROMS Step Editor + // last change was in editorial mode, so ignore it + if (!string.IsNullOrEmpty(sc.Step_ChangeIDEditorialMode)) + return false; + // C2015-028 Add Editorial Mode to PROMS Step Editor + // Add Check for enhanced docs + // If enhanced docs, need to check the step_config for the master + if (sc.MyEnhancedDocuments != null && sc.MyEnhancedDocuments.Count == 1 && sc.MyEnhancedDocuments[0].Type == 0) + { + ItemInfo ii = ItemInfo.Get(sc.MyEnhancedDocuments[0].ItemID, true); + if (ii == null) return false; // when deleting a source step, this was causing a crash (null ii) + return ii.HasChangeBar; + } + + if (sc.Step_CBOverride == null) return chg; return (sc.Step_CBOverride == "On"); @@ -3953,9 +3966,7 @@ namespace VEPROMS.CSLA.Library get { if (this.IsAccPages || this.IsProcedure || this.IsSection) return false; - StepInfo si = this as StepInfo; - if (si == null) return false; - StepConfig sc = si.MyConfig as StepConfig; + StepConfig sc = this.MyConfig as StepConfig; if (sc == null) return false; // go back to source & see what date it has: if (sc.MyEnhancedDocuments != null && sc.MyEnhancedDocuments.Count == 1 && sc.MyEnhancedDocuments[0].Type == 0) diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs index 9dd0926b..ba31fad0 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs @@ -606,12 +606,20 @@ namespace VEPROMS.CSLA.Library _ItemInfoExtension.Refresh(this); OnChange();// raise an event } - public static ItemInfo Get(int itemID) + public static ItemInfo Get(int itemID, bool forcerefresh = false) { - //if (!CanGetObject()) - // throw new System.Security.SecurityException("User not authorized to view a Item"); + try { + // C2015-028 Add Editorial Mode to PROMS Step Editor + // fixes caching issue + // item.myconfig was cached not containing the bypass changebar info + // so this forces a refresh of the cache + if (forcerefresh) + { + _CacheByPrimaryKey.Remove(itemID.ToString()); + } + ItemInfo tmp = GetCachedByPrimaryKey(itemID); if (tmp == null) { diff --git a/PROMS/Volian.Controls.Library/DisplayTabControl.cs b/PROMS/Volian.Controls.Library/DisplayTabControl.cs index c516993f..0b301aaf 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabControl.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabControl.cs @@ -11,6 +11,7 @@ using DevComponents.DotNetBar; using JR.Utils.GUI.Forms; using Volian.Base.Library; using Microsoft.Win32; +using System.Linq; namespace Volian.Controls.Library { @@ -261,24 +262,45 @@ namespace Volian.Controls.Library get { return _ChgId; } set { _ChgId = value; } } + + // C2015-028 Add Editorial Mode to PROMS Step Editor public bool EditorialChange { get { if (_ChgId == null) return true; if (_ChgId == "") return true; - if (_ChgId.ToUpper() == "EC") return true; - return false; - } - } - #endregion - #region Events - /// - /// This event is raised when a the "Tab" of a DisplayItem is clicked with a mouse. - /// So far this has just been used for demo purposes. It could be used to select a - /// step and it's children for the purpose of copying. - /// - public event StepPanelEvent ItemClick; + if (_ChgId.ToUpper() == "EC") { return true;} + + return IsInEditorialMode; + } + } + + // C2015-028 Add Editorial Mode to PROMS Step Editor + // property to hold if button in ribbon is toggled on or off + public bool IsInEditorialMode { get; set; } = false; + + // C2015-028 Add Editorial Mode to PROMS Step Editor + // This is used when button in the ribbon is toggled on/off + // It iterates through all previously opened tabs + // and updates the "Editorial Mode" button + // and background color to match those of the current tab + public void SetEdititorialModeForAllTabs(bool mode) + { + foreach (DisplayTabItem tabItem in _MyDisplayTabItems.Values.Where(tabItem => tabItem.MyStepTabPanel != null)) + { + tabItem.MyStepTabPanel.MyStepTabRibbon.SetEditorialMode(mode); + } + } + + #endregion + #region Events + /// + /// This event is raised when a the "Tab" of a DisplayItem is clicked with a mouse. + /// So far this has just been used for demo purposes. It could be used to select a + /// step and it's children for the purpose of copying. + /// + public event StepPanelEvent ItemClick; /// /// Checks to see if the ItemClick event is handled and launches it /// diff --git a/PROMS/Volian.Controls.Library/RTBItem.cs b/PROMS/Volian.Controls.Library/RTBItem.cs index 68ef343e..cb52e865 100644 --- a/PROMS/Volian.Controls.Library/RTBItem.cs +++ b/PROMS/Volian.Controls.Library/RTBItem.cs @@ -799,27 +799,41 @@ namespace Volian.Controls.Library // if the plant has the change id option, the change id was entered when the program started. // this should be saved for every piece of edited data. Note that the set of config // item Step_MultipleChangeID has the save built in to it. + if (sc == null) sc = new StepConfig(); if (MyStepRTB.MyItemInfo.IsStep && MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds && !this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.EditorialChange) { - //StepConfig sc = MyStepRTB.MyItemInfo.MyConfig as StepConfig; - if (sc == null) sc = new StepConfig(); sc.Step_ChangeID = this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.ChgId; - //if (MyStepRTB.MyItemInfo.MyConfig == null) itm.MyContent.Config = sc.ToString(); + } + // C2015-028 Add Editorial Mode to PROMS Step Editor + // if in Editorial Mode, treat it the same as if the ChangeIds are set in the Format file + if (MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsInEditorialMode && !existingChangeBar) + { + sc.Step_ChangeIDEditorialMode = Volian.Base.Library.VlnSettings.UserID; + } + else + { + sc.Step_ChangeIDEditorialMode = null; } // B2020-017: If making an editorial change, clear the Change id. Having the change id on // was adding/printing a change bar. + // C2015-028 Add Editorial Mode to PROMS Step Editor + // if in Editorial Mode, treat it the same as if the ChangeIds are set in the Format file if (MyStepRTB.MyItemInfo.IsStep && - MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds - && this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.EditorialChange - && hasChangeBar == false) + (MyStepRTB.MyItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds + || MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsInEditorialMode + ) + && MyStepPanel.MyStepTabPanel.MyDisplayTabControl.EditorialChange + && !hasChangeBar) { if (sc == null) sc = new StepConfig(); sc.Step_ChangeID = null; } // B2015-024 Have Spell Checker text changes be an editorial change (not assign a change bar but keep existing change bar) - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.EditData.EditoralSpellCheck) + // C2015-028 Add Editorial Mode to PROMS Step Editor + // if in Editorial Mode, treat it the same as if the Rditorial SprllCheck flag is set in the Format file + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.EditData.EditoralSpellCheck || this.MyStepPanel.MyStepTabPanel.MyDisplayTabControl.IsInEditorialMode) { if (StepRTB.DidEditorialSpellCheck) { diff --git a/PROMS/Volian.Controls.Library/StepPanel.cs b/PROMS/Volian.Controls.Library/StepPanel.cs index 728ad353..8f509a33 100644 --- a/PROMS/Volian.Controls.Library/StepPanel.cs +++ b/PROMS/Volian.Controls.Library/StepPanel.cs @@ -650,8 +650,13 @@ namespace Volian.Controls.Library /// public Color ActiveColor { - get { return _ActiveColor; } - set { _ActiveColor = value; } + get { + // C2015-028 Add Editorial Mode to PROMS Step Editor + // if in Editorial Mode, use LightGreen background + _ActiveColor = MyStepTabPanel != null && MyStepTabPanel.MyDisplayTabControl.IsInEditorialMode ? Color.LightGreen : Color.SkyBlue; + return _ActiveColor; + } + set { _ActiveColor = value; } } /// /// Gets or Sets the Annotation backcolor for StepRTBs in the Panel diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index dcd59514..cc20f092 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -3760,7 +3760,12 @@ namespace Volian.Controls.Library public bool SpellCheckNext() { int nBad = C1SpellChecker2.CheckControl(this, false, MySpellCheckDlg); - if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.EditData.EditoralSpellCheck) + + // C2015-028 Add Editorial Mode to PROMS Step Editor + // if in Editorial Mode, treat it the same as if the EditorialSpellCheck flag is set in the Format file + bool editorialmode = (this.Parent.Parent.Parent as StepTabPanel).MyDisplayTabControl.IsInEditorialMode; + + if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.EditData.EditoralSpellCheck || editorialmode) DidEditorialSpellCheck = MySpellCheckDlg.DidCorrectSpelling; // B2015-024 spell checker in editoral mode return (nBad >= 0); // nBad = -1 means user pressed Cancel button } diff --git a/PROMS/Volian.Controls.Library/StepTabPanel.cs b/PROMS/Volian.Controls.Library/StepTabPanel.cs index c895ed09..a6d501d0 100644 --- a/PROMS/Volian.Controls.Library/StepTabPanel.cs +++ b/PROMS/Volian.Controls.Library/StepTabPanel.cs @@ -120,7 +120,7 @@ namespace Volian.Controls.Library /// private void SetupStepTabRibbon() { - _MyStepTabRibbon = new StepTabRibbon(); + _MyStepTabRibbon = new StepTabRibbon(_MyDisplayTabControl.IsInEditorialMode); _MyStepTabRibbon.Dock = System.Windows.Forms.DockStyle.Top; _MyStepTabRibbon.Location = new System.Drawing.Point(0, 0); _MyStepTabRibbon.Name = "displayTabRibbon1"; diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index 37b57301..8a4a5f47 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -995,7 +995,7 @@ namespace Volian.Controls.Library // SetButtonAndMenuEnabling(true); //} #region Constructor - public StepTabRibbon() + public StepTabRibbon(bool? IsInEditorialMode = false) { InitializeComponent(); this.btnInsSupInfo.Tag = string.Format("{0} {1}", (int)E_FromTypes.SupInfos, 1040); // Make type of rno (40) & special case 1000 @@ -1021,8 +1021,16 @@ namespace Volian.Controls.Library // hide the import from Word file if not running in Debug mode if (!VlnSettings.DebugMode) rbnImpWrd.Visible = false; - } - void _RibbonControl_SizeChanged(object sender, EventArgs e) + + // C2015-028 Add Editorial Mode to PROMS Step Editor + // default Editorial Mode to what is set in the DisplayTabControl + SetEditorialMode(IsInEditorialMode != null && (bool) IsInEditorialMode); + + } + + public void SetEditorialMode(bool mode) => btnEditorialMode.Checked = btnCMEditorialMode.Checked = mode; + + void _RibbonControl_SizeChanged(object sender, EventArgs e) { this.Size = _RibbonControl.Size; } @@ -3125,7 +3133,7 @@ namespace Volian.Controls.Library btnCMRedo.Enabled = btnRedo.Enabled = _MyStepRTB.CanRedo; btnCMUndo.Enabled = btnUndo.Enabled = _MyStepRTB.CanUndo; } - private void btnGoTo_Click(object sender, EventArgs e) + private void btnGoTo_Click(object sender, EventArgs e) { // if on a transition, go to the selected transition 'to'. If on // a referenced object, bring up ReferencedObject Editor (for now, just put up a message box. @@ -3211,7 +3219,29 @@ namespace Volian.Controls.Library System.Diagnostics.Process.Start(roapp, args); } } - private void btnChgTyp_Click(object sender, EventArgs e) + + // C2015-028 Add Editorial Mode to PROMS Step Editor + private void btnEditorialMode_Click(object sender, EventArgs e) + { + //toggle button is selected + SetEditorialMode(!btnEditorialMode.Checked); + + //set the overall flag in the displaytabcontrol + StepTabPanel tmp = Parent as StepTabPanel; + tmp.MyDisplayTabControl.IsInEditorialMode = btnEditorialMode.Checked; + + //refresh the current item so the background color changes (LightGreen=Editorial Mode, SkyBlue=Normal Selected) + if (MyEditItem != null) + { + _MyEditItem.RefreshContent(); + Application.DoEvents(); + } + + //set other preciously opened tabs to match the state of Editorial Mode in the current tab + tmp.MyDisplayTabControl.SetEdititorialModeForAllTabs(btnEditorialMode.Checked); + } + + private void btnChgTyp_Click(object sender, EventArgs e) { StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Change Step Type"); MyEditItem.MyStepPanel.OnTabDisplay(sender, args); @@ -3279,7 +3309,8 @@ namespace Volian.Controls.Library rtabInsert.Visible = false; rtabAdmin.Visible = false; rtabReview.Select(); - btnCMEditMode1.Enabled = btnEditMode.Enabled = false; // don't allow reviewer toggle out of view mode + btnCMEditMode1.Enabled = btnEditMode.Enabled = btnCMEditorialMode.Enabled = false; // don't allow reviewer toggle out of view mode + btnCMEditorialMode.Visible = false; } } public void SetupROEditorMode() diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.designer.cs index 33fc65fe5b524d2adb6f050cb1c1792c6312116d..f374745296d67545dc0e0e3210589c9c65294b12 100644 GIT binary patch delta 944 zcmX@oue@rp@&-TU>Cf00HKspkXXW6}XDDLGWJqMlVenNDswC;-J|RlzKV zB!&`(JO)>W6rfW}fX+m5GD9jzB}C8khir_xSUon~(3?e37N-#mN?=FGG6OA~e!iVm z5)Fx3Av1H1np3tzGgLJ7HblZE)yfslgq4(+htvicY^{$HbuscNs$rFt}oX!KVO(;5Y^bIxb)E_p-)fcUhtn zqd02ZOuvxGB!?oT4oWp*?J7x3K+FupEZbF*SnphzE*8qBB#dwo%oRG*1w+~7!6|3E zi7{K9@ANmuY#c~|y0)Fwcv3$Pk_aT2>)C{m#3r_~ickOG$tHp|aU#Nm8{q8P5J zOv4=njz1YKr%woDW0|f4bY}am2Da_H8rV-P28Mya^dNqY7-@`1g9kV$g^Pj|B}|V2 e=AiBGR5G)>2~6ISRWRM4l!<5aJe8cH=>k@49FwPU< z4IA6^5Bh9e%^EYdYs_HGS~6Y2icM;IfjyJRb}3sXE4AqkwyX-%>lm3hrmxEb5-fSl z8X#kZ+8<;v0WmWWvuuBm!FuPybT4jpmFWu%*f_QWEot*@ujyplUen2bVexbc367NM a3#2*Nw)^REOwgQOA;`qHy&!_asuBQ