Use static function to check user’s security level in allowing changes to step properties

Use static function to check user’s security level in allowing the insert or change of a transition
Use static function to check user’s security level in allowing the user to edit a table cell
Use static function to check user’s security level in allowing text modifications when keyboard shortcuts are used
ROEditor only security is now also considered a Reviewer.  Don’t allow a Review goto an RO (run the RO editor), Don’t allow a Reviewer toggle out of view mode from the context menu, for Reviewers, don’t allow the Enter key enter new steps and substeps.
For Reviewers, when on a table (grid) have the Enter Key move down to the next step element, don’t allow Reviewers edit a table
This commit is contained in:
John Jenko 2015-12-09 21:04:02 +00:00
parent d8f7b0619c
commit bc6fcfd05b
6 changed files with 160 additions and 50 deletions

View File

@ -168,6 +168,15 @@ namespace Volian.Controls.Library
else
cbPageBreak.Checked = false; // Page Break is set to false
}
public DocVersionInfo Mydvi = null; // this is initialized in vlnTreeComboSetsFillIn()
private static UserInfo _MyUserInfo = null;
public static UserInfo MyUserInfo
{
get { return _MyUserInfo; }
set { _MyUserInfo = value; }
}
private void TagsFillIn()
{
_Initalizing = true;
@ -341,6 +350,8 @@ namespace Volian.Controls.Library
StepConfig sc2 = CurItemInfo.MyConfig as StepConfig;
tbRespons.Text = sc2.Step_Responsibility;
}
// diable fields if user is only a reviewer
groupPanelCheckoff.Enabled = groupPanelChgBar.Enabled = groupPanelChgStepType.Enabled = groupPanelIncludeOn.Enabled = groupPanelPaginate.Enabled = groupPanelWcnTrnResp.Enabled = UserInfo.CanEdit(MyUserInfo, Mydvi); // Can Change Tag Info
_Initalizing = false;
}
private int DoListStepTypes(FormatData fmtdata, StepData topType, string curType)

View File

@ -32,7 +32,8 @@ namespace Volian.Controls.Library
if (_CurTrans == value && _CurItemFrom == MyRTB.MyItemInfo) return;
_CurItemFrom = MyRTB.MyItemInfo;
_TranFmtIndx = 0;
btnTranSave.Enabled = btnTranCancel.Enabled = true;
btnTranSave.Enabled = UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
btnTranCancel.Enabled = true;
}
else // Modify a transition
{
@ -347,6 +348,7 @@ namespace Volian.Controls.Library
// so that the tree can be expanded highlighting (selecting) the current set.
List<FolderInfo> filist = new List<FolderInfo>();
DocVersionInfo mydocversion = prcitm.ActiveParent as DocVersionInfo;
Mydvi = mydocversion; // used for security check
FolderInfo tmpfi = mydocversion.ActiveParent as FolderInfo;
while (tmpfi != null)
{
@ -949,7 +951,7 @@ namespace Volian.Controls.Library
if (sectstartid == -1) btnTranSave.Enabled = false; // if there is an invalid section start - don't allow save.
IList chldrn = prcitm.GetChildren();
cbTranSectsFillIn((ItemInfo)chldrn[0], sectstartid, true);
btnTranSave.Enabled = true;
btnTranSave.Enabled = UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
SaveCancelEnabling();
}
private void tvTran_AfterSelect(object sender, TreeViewEventArgs e)
@ -958,7 +960,7 @@ namespace Volian.Controls.Library
E_TransUI etm = (E_TransUI)_CurItemFrom.ActiveFormat.PlantFormat.FormatData.TransData.TransTypeList[listBoxTranFmt.SelectedIndex].TransUI;
if ((etm & E_TransUI.StepAllowNone) == E_TransUI.StepAllowNone && tvTran.SelectedNode.Tag==null)
{
btnTranSave.Enabled = true;
btnTranSave.Enabled = UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
return;
}
// check if node is a true end-point, i.e. not a 'part' node. If part node, don't
@ -991,7 +993,7 @@ namespace Volian.Controls.Library
tvTranRangeHilites(true, _RangeNode1, _RangeNode2);
lblxTranRangeTip.Text = "Select First Transition\r\nfor Range";
lblxTranRangeTip.BackColor = Color.Yellow;
btnTranSave.Enabled = true;
btnTranSave.Enabled = UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
}
}
}
@ -1000,7 +1002,7 @@ namespace Volian.Controls.Library
//bool hasChanged = _CurItemFrom != _SavCurItemFrom || _TranFmtIndx != _SavTranFmtIndx
// || ( selii != null && _CurTrans.ToID != selii.ItemID);
bool hasChanged = SettingsChanged;
btnTranSave.Enabled = hasChanged;
btnTranSave.Enabled = hasChanged && UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
btnTranCancel.Enabled = _CurTrans != null && hasChanged;
//btnTranSave.Enabled = allowSave;
//if (CurTrans != null && selii != null)
@ -1280,6 +1282,15 @@ namespace Volian.Controls.Library
}
#endregion
public DocVersionInfo Mydvi = null; // this is initialized in vlnTreeComboSetsFillIn()
private static UserInfo _MyUserInfo = null;
public static UserInfo MyUserInfo
{
get { return _MyUserInfo; }
set { _MyUserInfo = value; }
}
private void cbIncStepNum_CheckedChanged(object sender, EventArgs e)
{
tvTran.Enabled=cbIncStepNum.Checked;
@ -1288,7 +1299,10 @@ namespace Volian.Controls.Library
private void cbPageNum_CheckedChanged(object sender, EventArgs e)
{
if (_ModExistingPageNum != cbPageNum.Checked)
btnTranCancel.Enabled = btnTranSave.Enabled = true;
{
btnTranCancel.Enabled = true;
btnTranSave.Enabled = UserInfo.CanEdit(MyUserInfo, Mydvi); //Can Insert Transitons
}
}
}
public class TransItem

View File

@ -17,6 +17,27 @@ namespace Volian.Controls.Library
public partial class GridItem : EditItem
{
#region Fields
private DocVersionInfo _MyDVI = null;
public DocVersionInfo MyDVI
{
get
{
ItemInfo procInfo = MyItemInfo.MyProcedure as ItemInfo;
if (procInfo == null)
_MyDVI = null;
else
_MyDVI = procInfo.ActiveParent as DocVersionInfo;
return _MyDVI;
}
}
private static UserInfo _MyUserInfo = null;
public static UserInfo MyUserInfo
{
get { return _MyUserInfo; }
set { _MyUserInfo = value; }
}
private bool _IsSaving;
public bool IsSaving
{
@ -62,7 +83,7 @@ namespace Volian.Controls.Library
if (MyStepPanel.DisplayItemChanging) return;
MyStepRTB.MyItemInfo = MyItemInfo; // should be in vlnFlexGrid
MyStepPanel.SelectedEditItem = this;
if (MyFlexGrid.IsRoTable)
if (MyFlexGrid.IsRoTable || !UserInfo.CanEdit(MyUserInfo,MyDVI));//(!MyUserInfo.IsAdministrator() && ! MyUserInfo.IsSetAdministrator(MyDVI) && !MyUserInfo.IsWriter(MyDVI)))
{
MyFlexGrid.Cols.Fixed = MyFlexGrid.Cols.Count;
MyFlexGrid.Rows.Fixed = MyFlexGrid.Rows.Count;
@ -784,7 +805,7 @@ namespace Volian.Controls.Library
{
Focus();
MyFlexGrid.Focus();
if (!MyFlexGrid.IsRoTable) // Table ROs are none editable - don't select a table cell
if (!MyFlexGrid.IsRoTable) // Table ROs are not editable - don't select a table cell
{
try
{

View File

@ -232,6 +232,27 @@ namespace Volian.Controls.Library
OnEditModeChanged(this, new EventArgs());
}
}
private DocVersionInfo _MyDVI = null;
public DocVersionInfo MyDVI
{
get
{
ItemInfo procInfo = _MyItemInfo.MyProcedure as ItemInfo;
if (procInfo == null)
_MyDVI = null;
else
_MyDVI = procInfo.ActiveParent as DocVersionInfo;
return _MyDVI;
}
}
private static UserInfo _MyUserInfo = null;
public static UserInfo MyUserInfo
{
get { return _MyUserInfo; }
set { _MyUserInfo = value; }
}
private static string _MySymbolFontName;
public static string MySymbolFontName
{
@ -1881,7 +1902,7 @@ namespace Volian.Controls.Library
if (newend > 0) SetSelection(SelectionStart, newend - SelectionStart);
break;
case Keys.Space:
if (e.Control) // Hardspace - Ctrl+Shift+Space
if (e.Control && MyDVI!= null && UserInfo.CanEdit(MyUserInfo,MyDVI)); // Hardspace - Ctrl+Shift+Space
InsertSymbol(@"\u160?");
break;
case Keys.F3: // shift F3
@ -2283,12 +2304,21 @@ namespace Volian.Controls.Library
case Keys.Enter:
if (!e.Control && !e.Shift && !e.Alt)
{
if (UserInfo.CanEdit(MyUserInfo,MyItemInfo.MyDocVersion))
OnEnterKeyPressed(sender, e);
else
{
// user cannot change data so just move to the next step element
StepRTB_ArrowPressed(E_ArrowKeys.CtrlDown); // perform a <Ctrl><DownArrow>
HandleLocalSelectionChange();
e.Handled = true;
}
}
break;
case Keys.F2:
if (e.Alt && !e.Control && !e.Shift) // toggle change bar
{
if (MyUserInfo.IsAdministrator() || MyUserInfo.IsSetAdministrator(MyDVI) || MyUserInfo.IsWriter(MyDVI))
OnToggleChangeBar(this, new EventArgs());
e.Handled = true;
}

View File

@ -71,23 +71,23 @@ namespace Volian.Controls.Library
}
// added jcb 20121221 to support set ro from word doc
private ROFSTLookup MyLookup;
private DocVersionInfo _MyDVI;
public DocVersionInfo MyDVI
private DocVersionInfo _Mydvi;
public DocVersionInfo Mydvi
{
get
{
if (_MyDVI != null) return _MyDVI;
if (_Mydvi != null) return _Mydvi;
if (_MyEditItem != null)
{
ItemInfo procInfo = _MyEditItem.MyItemInfo.MyProcedure as ItemInfo;
if (procInfo == null) return null;
_MyDVI = procInfo.ActiveParent as DocVersionInfo;
_Mydvi = procInfo.ActiveParent as DocVersionInfo;
// added jcb 20121221 to support set ro from word doc
if (_MyDVI.DocVersionAssociations != null && _MyDVI.DocVersionAssociations.Count > 0)
MyLookup = _MyDVI.DocVersionAssociations[0].MyROFst.GetROFSTLookup(_MyDVI);
if (_Mydvi.DocVersionAssociations != null && _Mydvi.DocVersionAssociations.Count > 0)
MyLookup = _Mydvi.DocVersionAssociations[0].MyROFst.GetROFSTLookup(_Mydvi);
else
MyLookup = null;
return _MyDVI;
return _Mydvi;
}
return null;
}
@ -318,7 +318,7 @@ namespace Volian.Controls.Library
{
bool rv = false;
MyAvailableROs = new Dictionary<string, string>();
if (MyDVI != null)
if (Mydvi != null)
{
#region force arp without hi or lo jcb 20121221
//if (data == "<ARP CDS-LT002-1-MED-LO1 \\s\\l\\1>")
@ -328,7 +328,7 @@ namespace Volian.Controls.Library
//}
#endregion
string accPageID = GetAccPageID(data);
ROFSTLookup.rochild? roc = MyLookup.GetRoChildByAccPagID(accPageID, MyDVI.DocVersionConfig.RODefaults_setpointprefix, MyDVI.DocVersionConfig.RODefaults_graphicsprefix);
ROFSTLookup.rochild? roc = MyLookup.GetRoChildByAccPagID(accPageID, Mydvi.DocVersionConfig.RODefaults_setpointprefix, Mydvi.DocVersionConfig.RODefaults_graphicsprefix);
if (roc != null)
{
int index = GetROValueIndex(data);
@ -354,7 +354,7 @@ namespace Volian.Controls.Library
for (int i = 1; i < 4; i++)
{
tmpAccPageID = accPageID + suffix + i.ToString();
roc = MyLookup.GetRoChildByAccPagID(tmpAccPageID, MyDVI.DocVersionConfig.RODefaults_setpointprefix, MyDVI.DocVersionConfig.RODefaults_graphicsprefix);
roc = MyLookup.GetRoChildByAccPagID(tmpAccPageID, Mydvi.DocVersionConfig.RODefaults_setpointprefix, Mydvi.DocVersionConfig.RODefaults_graphicsprefix);
if (roc != null)
{
int index = GetROValueIndex(data);
@ -370,7 +370,7 @@ namespace Volian.Controls.Library
for (int i = 1; i < 4; i++)
{
tmpAccPageID = accPageID + suffix + i.ToString();
roc = MyLookup.GetRoChildByAccPagID(tmpAccPageID, MyDVI.DocVersionConfig.RODefaults_setpointprefix, MyDVI.DocVersionConfig.RODefaults_graphicsprefix);
roc = MyLookup.GetRoChildByAccPagID(tmpAccPageID, Mydvi.DocVersionConfig.RODefaults_setpointprefix, Mydvi.DocVersionConfig.RODefaults_graphicsprefix);
if (roc != null)
{
int index = GetROValueIndex(data);
@ -392,7 +392,7 @@ namespace Volian.Controls.Library
//<STP L19 \\v \\E \\H \\P \\S >
//<ARP FWS-MP-02C-TMP1 \\s \\h \\1>
txt = txt.Replace("<MEL ", "MEL-");
txt = txt.Replace("<STP ", MyDVI.DocVersionConfig.RODefaults_setpointprefix + "-");
txt = txt.Replace("<STP ", Mydvi.DocVersionConfig.RODefaults_setpointprefix + "-");
txt = txt.Replace("<ARP ", "ARP-");
int i = txt.IndexOf(" ");
txt = txt.Substring(0, i);
@ -831,16 +831,10 @@ namespace Volian.Controls.Library
btnCMEditRO.Enabled = false;
}
}
private bool CanEditROs()
{
// Test to see if the user is allowed to run the RO Edior
// writers and reviewers are not allowed to run the RO Editor
return MyUserInfo.IsAdministrator() || MyUserInfo.IsSetAdministrator(MyDVI) || MyUserInfo.IsROEditor(MyDVI);
}
private void SetupGoToButton()
{
if (MyEditItem is GridItem && (MyEditItem as GridItem).MyFlexGrid.IsRoTable)
btnCMGoTo.Enabled = btnGoTo.Enabled = CanEditROs();//Don't allow Writers and Reviews run the RO Editor
btnCMGoTo.Enabled = btnGoTo.Enabled = UserInfo.CanEditROs(MyUserInfo, Mydvi);//Don't allow Writers and Reviews run the RO Editor
else
{
if (_MyStepRTB == null) return;
@ -848,7 +842,7 @@ namespace Volian.Controls.Library
{
// if selected text = ?, i.e. a missing/undefined destination, don't allow go to
// if the selected link is an RO then check to see if the user is allowed to run the RO Editor (writers and reviewers cannot run the RO Editor)
btnCMGoTo.Enabled = btnGoTo.Enabled = !_MyStepRTB.SelectedText.StartsWith("?") && (_MyStepRTB.SelectedText.Contains("Transition") || (_MyStepRTB.SelectedText.Contains("ReferencedObject") && CanEditROs()));
btnCMGoTo.Enabled = btnGoTo.Enabled = !_MyStepRTB.SelectedText.StartsWith("?") && (_MyStepRTB.SelectedText.Contains("Transition") || (_MyStepRTB.SelectedText.Contains("ReferencedObject") && UserInfo.CanEditROs(MyUserInfo, Mydvi)));
}
else
btnCMGoTo.Enabled = btnGoTo.Enabled = false;
@ -2071,12 +2065,22 @@ 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
}
}
public void SetupROEditorMode()
{
if (MyEditItem != null && MyEditItem.MyStepPanel.VwMode == E_ViewMode.Edit)
{
// bug fix B2015-188
// user with ROEditor only security also has Review privledges
btnToggleEditView_Click(null, new EventArgs());
rtabView.Visible = false;
rtabHome.Visible = false;
rtabInsert.Visible = false;
rtabAdmin.Select();
btnCMEditMode1.Enabled = btnEditMode.Enabled = false;
}
}
public void SetupWriterMode()
{
@ -2132,15 +2136,15 @@ namespace Volian.Controls.Library
// MessageBox.Show("Could not find path to Ro Editor, check 'roapp' environment variable");
// return;
//}
if (MyDVI == null || MyDVI.DocVersionAssociationCount < 1)
if (Mydvi == null || Mydvi.DocVersionAssociationCount < 1)
{
MessageBox.Show("Could not find associated path for ro data.", "No RO Data", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
string roloc = "\"" + MyDVI.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath + "\"";
if (!Directory.Exists(MyDVI.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath))
string roloc = "\"" + Mydvi.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath + "\"";
if (!Directory.Exists(Mydvi.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath))
{
MessageBox.Show(string.Format("RO Database directory does not exist: {0}", MyDVI.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath));
MessageBox.Show(string.Format("RO Database directory does not exist: {0}", Mydvi.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath));
return;
}
System.Diagnostics.Process.Start(roapp, roloc);
@ -2151,13 +2155,13 @@ namespace Volian.Controls.Library
InitialProgressBarMessage = "Updating ROs";
// use rodb directory path of the first rofst for the this document version. Later, will need
// to modify code to get which one (when there is more than one)
if (MyDVI.DocVersionAssociations.Count < 1)
if (Mydvi.DocVersionAssociations.Count < 1)
{
FinalProgressBarMessage = "No ROs associated";
MessageBox.Show("Error Updating ro.fst. No associated ro.fst");
return;
}
ROFstInfo roFstInfo = MyDVI.DocVersionAssociations[0].MyROFst;
ROFstInfo roFstInfo = Mydvi.DocVersionAssociations[0].MyROFst;
string rofstPath = roFstInfo.MyRODb.FolderPath + @"\ro.fst";
if (!File.Exists(rofstPath))
@ -2181,7 +2185,7 @@ namespace Volian.Controls.Library
}
Cursor = Cursors.WaitCursor;
using (DocVersion dv = DocVersion.Get(MyDVI.VersionID))
using (DocVersion dv = DocVersion.Get(Mydvi.VersionID))
{
roFstInfo.ROTableUpdate += new ROFstInfoROTableUpdateEvent(roFstInfo_ROTableUpdate);
ROFst newrofst = ROFstInfo.UpdateRoFst(roFstInfo.MyRODb, dv.DocVersionAssociations[0], dv, roFstInfo, DoProgressBarRefresh);
@ -2278,7 +2282,7 @@ namespace Volian.Controls.Library
{
ribbonTab_SingleClick(sender, e);
btnUpdROVal.Enabled = false;
if (MyDVI.DocVersionAssociations == null || MyDVI.DocVersionAssociations.Count < 1)
if (Mydvi.DocVersionAssociations == null || Mydvi.DocVersionAssociations.Count < 1)
{
btnROEdit.Enabled = false;
return;
@ -2289,8 +2293,8 @@ namespace Volian.Controls.Library
}
public bool NewerRoFst()
{
if (_MyDVI == null)return false;
return _MyDVI.NewerRoFst;
if (_Mydvi == null)return false;
return _Mydvi.NewerRoFst;
}
public void SetUpdRoValBtn(bool en)
{
@ -2483,7 +2487,7 @@ namespace Volian.Controls.Library
_ContextMenuBar.SetContextMenuEx(_MyStepRTB, btnCMStepPaste);
break;
}
if (displayMenu)
if (displayMenu && UserInfo.CanEdit(MyUserInfo, Mydvi));
{
SendKeys.Send("+{F10}{DOWN}"); // Display Context menu
while (moveDown > 0) // position to current type

View File

@ -112,6 +112,30 @@ namespace Volian.Controls.Library
// }
// return sb.ToString();
//}
private DocVersionInfo _MyDVI = null;
public DocVersionInfo MyDVI
{
get
{
ItemInfo procInfo = _MyItemInfo.MyProcedure as ItemInfo; //_MyEditItem.MyItemInfo.MyProcedure as ItemInfo;
if (procInfo == null)
_MyDVI = null;
else
_MyDVI = procInfo.ActiveParent as DocVersionInfo;
return _MyDVI;
}
}
private static UserInfo _MyUserInfo = null;
public static UserInfo MyUserInfo
{
get { return _MyUserInfo; }
set
{
_MyUserInfo = value;
GridItem.MyUserInfo = value;
}
}
public bool IsDirty
{
get
@ -1170,13 +1194,17 @@ namespace Volian.Controls.Library
e.Handled = true;
break;
case Keys.Enter:
//if (e.Shift) return;
//Select(Rows.Count - 1, 0);
//_tableCellEditor.StepRTB_ArrowPressed(E_ArrowKeys.Down);
//e.Handled = true;
if (!e.Control && !e.Shift && !e.Alt)
{
if (MyDVI != null && UserInfo.CanEdit(MyUserInfo,MyDVI))
OnEnterKeyPressed(sender, e);
else
{
// if a Reviewer, then do a <Ctrl><DownArrow>. Don't allow changes to a table
if (IsRoTable) Select(Rows.Count - 1, 0);
_tableCellEditor.StepRTB_ArrowPressed(e.Control ? E_ArrowKeys.CtrlDown : E_ArrowKeys.Down);
e.Handled = true;
}
}
break;
}
@ -4571,8 +4599,10 @@ namespace Volian.Controls.Library
// start editing: move to cell and activate
public void StartEditing(int row, int col)
{
ItemInfo pinfo = MyItemInfo.MyProcedure as ItemInfo;
DocVersionInfo dvi = (pinfo == null) ? null : pinfo.ActiveParent as DocVersionInfo;
_initializingEdit = true;
ReadOnly = IsRoTable;
ReadOnly = IsRoTable || !UserInfo.CanEdit(MyUserInfo, dvi); // reviewer cannot make changes to a table
// save coordinates of cell being edited
_row = row;
_col = col;