C2020-003 Added logic to sort the checkoff list using both the Index and (if available) the OrderBy elements.
C2020-003 – Added the OderBy element to the Checkoff item
This commit is contained in:
parent
83ec578e88
commit
b9352fc0f5
@ -102,7 +102,6 @@ namespace VEPROMS
|
||||
rbStepSect.Enabled = (numStepSects > 0 && (isNewSection || ii.IsStepSection)); // there are step section types and current section is a step section or creating new section
|
||||
rbWordSect.Enabled = (numWordSects > 0 && (isNewSection || !ii.IsStepSection)); // there are word section types and current section is a word section or creating new section
|
||||
}
|
||||
|
||||
private void btnSectPropOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
sectionConfigBindingSource.EndEdit();
|
||||
@ -122,9 +121,10 @@ namespace VEPROMS
|
||||
CheckOffList chkoffList = pf.FormatData.ProcData.CheckOffData.CheckOffList;
|
||||
CheckOffHeaderList chkoffHeaderList = pf.FormatData.ProcData.CheckOffData.CheckOffHeaderList;
|
||||
int maxindx = pf.FormatData.ProcData.CheckOffUCF ? pf.FormatData.ProcData.CheckOffData.CheckOffList.MaxIndex : pf.FormatData.ProcData.CheckOffData.CheckOffList.MaxIndexNoInherit;
|
||||
// C2020-003 use the _CheckOffIndex dictionary to get and save the index of the selected checkoff from the sorted checkoff list
|
||||
if (ppGpbxSignoffCheckoff.Enabled && (chkoffList != null && maxindx > 1)
|
||||
&& (ppCmbxCheckoffType.SelectedIndex != _SectionConfig.Section_CheckoffListSelection - (_hasSectionCheckoffDefault? 1:0)))
|
||||
_SectionConfig.Section_CheckoffListSelection = ppCmbxCheckoffType.SelectedIndex + (_hasSectionCheckoffDefault? 1:0);
|
||||
&& (_CheckOffIndex[ppCmbxCheckoffType.SelectedIndex] != _SectionConfig.Section_CheckoffListSelection))
|
||||
_SectionConfig.Section_CheckoffListSelection = _CheckOffIndex[ppCmbxCheckoffType.SelectedIndex];
|
||||
if (ppCmbxCheckoffHeading.Enabled && chkoffHeaderList != null && chkoffHeaderList.MaxIndexNoInherit > 1)
|
||||
_SectionConfig.Section_CheckoffHeaderSelection = ppCmbxCheckoffHeading.SelectedIndex;
|
||||
|
||||
@ -732,7 +732,43 @@ namespace VEPROMS
|
||||
if (_isStepSection)
|
||||
SetupCheckoffsDropdowns();
|
||||
}
|
||||
// C2020-003 This is used to sort the checkoff list from the format file
|
||||
// if the checkoff has an OrderBy element, then use it for the sorting, otherwise use th checkoff Index element
|
||||
private static int CompareCheckoffUsingOrderBy(CheckOff ckf1, CheckOff ckf2)
|
||||
{
|
||||
if (ckf1.OrderBy == null)
|
||||
{
|
||||
if (ckf2.OrderBy == null) // neither ckf1 nor ckf2 uses OrderBy index
|
||||
{
|
||||
if (ckf1.Index > ckf2.Index) return 1; //ckf1 goes before ckf2
|
||||
if (ckf1.Index < ckf2.Index) return -1; // ckf1 goes after ckf2
|
||||
return 0; //ckf1 and ckf2 have the same index value
|
||||
}
|
||||
else // ckf1 does not have OrderBy index but ckf2 has OrderBy index
|
||||
{
|
||||
if (ckf1.Index > ckf2.OrderBy) return 1; //ckf1 goes before ckf2
|
||||
if (ckf1.Index < ckf2.OrderBy) return -1; // ckf1 goes after ckf2
|
||||
return 0; //ckf1 and ckf2 have the same index value
|
||||
}
|
||||
}
|
||||
else //ckf1 has orderBy
|
||||
{
|
||||
if (ckf2.OrderBy == null) // ckf1 has OrderBy index but ckf2 does not
|
||||
{
|
||||
if (ckf1.OrderBy > ckf2.Index) return 1; //ckf1 goes before ckf2
|
||||
if (ckf1.OrderBy < ckf2.Index) return -1; // ckf1 goes after ckf2
|
||||
return 0; //ckf1 and ckf2 have the same index value
|
||||
}
|
||||
else // both ckf1 and ckf2 has OrderBy index
|
||||
{
|
||||
if (ckf1.OrderBy > ckf2.OrderBy) return 1; //ckf1 goes before ckf2
|
||||
if (ckf2.OrderBy > ckf1.OrderBy) return -1; // ckf1 goes after ckf2
|
||||
return 0; //ckf1 and ckf2 have the same index value
|
||||
}
|
||||
}
|
||||
}
|
||||
private List<CheckOff> SectionPropertyCheckOffList = null;
|
||||
private Dictionary<int, int> _CheckOffIndex = new Dictionary<int, int>(); // C2020-003 translate the sorted index number to the actual checkoff index
|
||||
private void SetupCheckoffsDropdowns()
|
||||
{
|
||||
if (!_isStepSection) return; // not needed for accessory pages (word attachments)
|
||||
@ -740,6 +776,7 @@ namespace VEPROMS
|
||||
_Initializing = true;
|
||||
PlantFormat pf = _SectionConfig.MyFormat!=null?_SectionConfig.MyFormat.PlantFormat:_SectionConfig.MyDefaultFormat.PlantFormat;
|
||||
CheckOffList chkoffList = pf.FormatData.ProcData.CheckOffData.CheckOffList;
|
||||
if (chkoffList != null) chkoffList.Sort(CompareCheckoffUsingOrderBy); // C2020-003 sort the checkoff list via the Index and/or OrderBy elements
|
||||
CheckOffHeaderList chkoffHeaderList = pf.FormatData.ProcData.CheckOffData.CheckOffHeaderList;
|
||||
int maxindx = pf.FormatData.ProcData.CheckOffUCF ? pf.FormatData.ProcData.CheckOffData.CheckOffList.MaxIndex : pf.FormatData.ProcData.CheckOffData.CheckOffList.MaxIndexNoInherit;
|
||||
// B2019-013: was crashing on indexer of checkofflist. If there were UCF checkoffs but none in original format, the indexer
|
||||
@ -764,14 +801,23 @@ namespace VEPROMS
|
||||
SectionPropertyCheckOffList = new List<CheckOff>();
|
||||
// Don't put up the first item in the chkoffList, it is '{Section Default}'.
|
||||
//for (int i = 1; i < chkoffList.Count; i++)
|
||||
int idxcnt = 0;
|
||||
int translatedCfgIdx = 0;
|
||||
_CheckOffIndex.Clear();
|
||||
foreach (CheckOff co in chkoffList)
|
||||
{
|
||||
if (!co.MenuItem.ToUpper().Equals("{SECTION DEFAULT}"))
|
||||
{
|
||||
SectionPropertyCheckOffList.Add(co);
|
||||
_CheckOffIndex.Add(idxcnt, (int)co.Index); // C2020-003 dictionary of sorted indexes to format checkoff Index element
|
||||
if (_SectionConfig.Section_CheckoffListSelection == co.Index)
|
||||
translatedCfgIdx = idxcnt; // C2020-003 translate the previous checkoff select to the sorted checkoff list position
|
||||
idxcnt++;
|
||||
}
|
||||
}
|
||||
ppGpbxSignoffCheckoff.Enabled = true;
|
||||
ppCmbxCheckoffType.DataSource = SectionPropertyCheckOffList;
|
||||
ppCmbxCheckoffType.SelectedIndex = _SectionConfig.Section_CheckoffListSelection - (_hasSectionCheckoffDefault ? 1 : 0);
|
||||
ppCmbxCheckoffType.SelectedIndex = translatedCfgIdx; // C2020-003 save the actual checkoff index
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1940,6 +1940,14 @@ namespace VEPROMS.CSLA.Library
|
||||
return LazyLoad(ref _Index, "@Index");
|
||||
}
|
||||
}
|
||||
private LazyLoad<float?> _OrderBy; // C2020-003 used to sort list of checkoffs in the combo box
|
||||
public float? OrderBy
|
||||
{
|
||||
get
|
||||
{
|
||||
return LazyLoad(ref _OrderBy, "@OrderBy");
|
||||
}
|
||||
}
|
||||
private LazyLoad<int?> _UIMark;
|
||||
public int? UIMark
|
||||
{
|
||||
|
@ -188,7 +188,43 @@ namespace Volian.Controls.Library
|
||||
get { return _MyUserInfo; }
|
||||
set { _MyUserInfo = value; }
|
||||
}
|
||||
// C2020-003 This is used to sort the checkoff list from the format file
|
||||
// if the checkoff has an OrderBy element, then use it for the sorting, otherwise use th checkoff Index element
|
||||
private static int CompareCheckoffUsingOrderBy(CheckOff ckf1, CheckOff ckf2)
|
||||
{
|
||||
if (ckf1.OrderBy == null)
|
||||
{
|
||||
if (ckf2.OrderBy == null) // neither ckf1 nor ckf2 uses OrderBy index
|
||||
{
|
||||
if (ckf1.Index > ckf2.Index) return 1; //ckf1 goes before ckf2
|
||||
if (ckf1.Index < ckf2.Index) return -1; // ckf1 goes after ckf2
|
||||
return 0; //ckf1 and ckf2 have the same index value
|
||||
}
|
||||
else // ckf1 does not have OrderBy index but ckf2 has OrderBy index
|
||||
{
|
||||
if (ckf1.Index > ckf2.OrderBy) return 1; //ckf1 goes before ckf2
|
||||
if (ckf1.Index < ckf2.OrderBy) return -1; // ckf1 goes after ckf2
|
||||
return 0; //ckf1 and ckf2 have the same index value
|
||||
}
|
||||
}
|
||||
else //ckf1 has orderBy
|
||||
{
|
||||
if (ckf2.OrderBy == null) // ckf1 has OrderBy index but ckf2 does not
|
||||
{
|
||||
if (ckf1.OrderBy > ckf2.Index) return 1; //ckf1 goes before ckf2
|
||||
if (ckf1.OrderBy < ckf2.Index) return -1; // ckf1 goes after ckf2
|
||||
return 0; //ckf1 and ckf2 have the same index value
|
||||
}
|
||||
else // both ckf1 and ckf2 has OrderBy index
|
||||
{
|
||||
if (ckf1.OrderBy > ckf2.OrderBy) return 1; //ckf1 goes before ckf2
|
||||
if (ckf2.OrderBy > ckf1.OrderBy) return -1; // ckf1 goes after ckf2
|
||||
return 0; //ckf1 and ckf2 have the same index value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<int, int> _CheckOffIndex = new Dictionary<int, int>(); // C2020-003 translate the sorted index number to the actual checkoff index
|
||||
private void TagsFillIn()
|
||||
{
|
||||
_Initalizing = true;
|
||||
@ -277,10 +313,16 @@ namespace Volian.Controls.Library
|
||||
int maxindx = fmtdata.ProcData.CheckOffUCF ? fmtdata.ProcData.CheckOffData.CheckOffList.MaxIndex : fmtdata.ProcData.CheckOffData.CheckOffList.MaxIndexNoInherit;
|
||||
if (_checkoffsAllowed && !(fmtdata.ProcData.CheckOffData.CheckOffList == null) && !(maxindx == 0))
|
||||
{
|
||||
CheckOffList chkoffList = fmtdata.ProcData.CheckOffData.CheckOffList;
|
||||
if (chkoffList != null) chkoffList.Sort(CompareCheckoffUsingOrderBy); // C2020-003 sort the checkoff list via the Index and/or OrderBy elements
|
||||
cmbCheckoff.Items.Clear();
|
||||
foreach (CheckOff co in fmtdata.ProcData.CheckOffData.CheckOffList)
|
||||
_CheckOffIndex.Clear(); // C2020-003 clear the checkoff index dictionary
|
||||
int sortedIndx = 0;
|
||||
foreach (CheckOff co in chkoffList)
|
||||
{
|
||||
cmbCheckoff.Items.Add(co.MenuItem);
|
||||
_CheckOffIndex.Add(sortedIndx, (int)co.Index); // C2020-003 add the real index number for each sorted index
|
||||
sortedIndx++;
|
||||
}
|
||||
// bug fix B2015-186
|
||||
// the config had a really big number for the checkoff index.
|
||||
@ -654,9 +696,9 @@ namespace Volian.Controls.Library
|
||||
if (_Initalizing) return;
|
||||
MyEditItem.SaveContents();
|
||||
// set selected index in the step's config.
|
||||
int indx = cmbCheckoff.SelectedIndex;
|
||||
int indx = _CheckOffIndex[cmbCheckoff.SelectedIndex]; // C2020-003 get the non-sorted index from the sorted index
|
||||
// get index, if greater than 100, store that - otherwise store index down list.
|
||||
// if this format does not have ucf signoffs, indx is just the selected index from the combo mobx.
|
||||
// if this format does not have ucf signoffs, indx is just the selected index from the combo box.
|
||||
if (CurItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffUCF)
|
||||
{
|
||||
// get index, if greater than 100, store that - otherwise store index down list.
|
||||
|
Loading…
x
Reference in New Issue
Block a user