|
|
@@ -118,9 +118,6 @@ public partial class DigitalFormsDashboard : UserControl,
|
|
|
|
|
|
public DashboardHeader Header { get; set; } = new();
|
|
|
|
|
|
- private bool IsQAForm = false;
|
|
|
- private List<QAQuestion> Questions = new();
|
|
|
-
|
|
|
private bool IsSetup = false;
|
|
|
|
|
|
public DigitalFormsDashboard()
|
|
|
@@ -508,6 +505,8 @@ public partial class DigitalFormsDashboard : UserControl,
|
|
|
private void DateTypeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
var filterType = (DateFilterType)DateTypeBox.SelectedValue;
|
|
|
+ if (Properties.DateFilterType == filterType) return;
|
|
|
+
|
|
|
Properties.DateFilterType = filterType;
|
|
|
if (filterType == DateFilterType.Custom)
|
|
|
{
|
|
|
@@ -534,14 +533,26 @@ public partial class DigitalFormsDashboard : UserControl,
|
|
|
|
|
|
private void FromPicker_SelectedDateChanged(object? sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
- Properties.FromDate = FromPicker.SelectedDate ?? DateTime.Today;
|
|
|
- Refresh();
|
|
|
+ var value = FromPicker.SelectedDate ?? DateTime.Today;
|
|
|
+ if (Properties.FromDate == value) return;
|
|
|
+
|
|
|
+ Properties.FromDate = value;
|
|
|
+ if(Properties.DateFilterType == DateFilterType.Custom)
|
|
|
+ {
|
|
|
+ Refresh();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void ToPicker_SelectedDateChanged(object? sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
- Properties.ToDate = ToPicker.SelectedDate ?? DateTime.Today;
|
|
|
- Refresh();
|
|
|
+ var value = ToPicker.SelectedDate ?? DateTime.Today;
|
|
|
+ if (Properties.ToDate == value) return;
|
|
|
+
|
|
|
+ Properties.ToDate = value;
|
|
|
+ if(Properties.DateFilterType == DateFilterType.Custom)
|
|
|
+ {
|
|
|
+ Refresh();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private bool _changing = false;
|
|
|
@@ -829,7 +840,6 @@ public partial class DigitalFormsDashboard : UserControl,
|
|
|
|
|
|
public void BuildActionsMenu(ContextMenu menu)
|
|
|
{
|
|
|
- menu.AddItem("Export", InABox.Wpf.Resources.doc_xls, Export_Click, Form is not null && Form.ID != Guid.Empty);
|
|
|
var loadingModules = menu.AddItem("Loading Modules...", null, null, false);
|
|
|
Task.Run(() =>
|
|
|
{
|
|
|
@@ -918,54 +928,6 @@ public partial class DigitalFormsDashboard : UserControl,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void Export_Click()
|
|
|
- {
|
|
|
- // var formName = Regex.Replace(Form?.Description ?? "", "[^ a-zA-Z0-9]", "");
|
|
|
- // var filename = string.Format("{0} - {1} - {2:yyyy-MM-dd} - {3:yyyy-MM-dd}.xlsx", ParentType!.Name, formName, From, To);
|
|
|
-
|
|
|
- // var options = new ExcelExportingOptions();
|
|
|
- // options.ExcelVersion = ExcelVersion.Excel2013;
|
|
|
- // options.ExportStackedHeaders = true;
|
|
|
- // var excelEngine = DataGrid.ExportToExcel(DataGrid.View, options);
|
|
|
- // var workBook = excelEngine.Excel.Workbooks[0];
|
|
|
- // var sheet = workBook.Worksheets[0];
|
|
|
- // sheet.Name = "Summary";
|
|
|
- // sheet.UsedRange.AutofitRows();
|
|
|
- // sheet.UsedRange.AutofitColumns();
|
|
|
-
|
|
|
- // sheet = workBook.Worksheets.Create("Questions");
|
|
|
- // sheet.Move(0);
|
|
|
- // var questions = new Client<QAQuestion>().Query(Filter<QAQuestion>.Where(x => x.Form.ID).IsEqualTo(Form!.ID));
|
|
|
- // sheet.Range[1, 1].Text = Form?.Description ?? "";
|
|
|
- // sheet.Range[1, 1, 1, 3].Merge();
|
|
|
- // var i = 1;
|
|
|
- // foreach (var row in questions.Rows)
|
|
|
- // if (!row.Get<QAQuestion, QAAnswer>(x => x.Answer).Equals(QAAnswer.Comment))
|
|
|
- // {
|
|
|
- // sheet.Range[i + 2, 1].Text = string.Format("{0}.", i);
|
|
|
- // sheet.Range[i + 2, 2].Text = string.Format("{0}", row.Get<QAQuestion, string>(x => x.Question));
|
|
|
- // sheet.Range[i + 2, 3].Text = string.Format("[{0}]", row.Get<QAQuestion, string>(x => x.Code));
|
|
|
- // i++;
|
|
|
- // }
|
|
|
-
|
|
|
- // sheet.UsedRange.AutofitRows();
|
|
|
- // sheet.UsedRange.AutofitColumns();
|
|
|
-
|
|
|
- // try
|
|
|
- // {
|
|
|
- // workBook.SaveAs(filename);
|
|
|
-
|
|
|
- // var startInfo = new ProcessStartInfo(filename);
|
|
|
- // startInfo.Verb = "open";
|
|
|
- // startInfo.UseShellExecute = true;
|
|
|
- // Process.Start(startInfo);
|
|
|
- // }
|
|
|
- // catch
|
|
|
- // {
|
|
|
- // MessageBox.Show(string.Format("Unable to Save/Launch [{0}]!\n\nIs the file already open?", filename));
|
|
|
- // }
|
|
|
- }
|
|
|
-
|
|
|
private void ManageFilters_Click()
|
|
|
{
|
|
|
var filters = Properties.Filters.GetValueOrDefault(ParentType!.Name) ?? new List<DFFilter>();
|
|
|
@@ -1372,7 +1334,7 @@ public partial class DigitalFormsDashboard : UserControl,
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
- private void LoadDataIntoGrid(List<DigitalFormVariable> variables, List<QAQuestion> questions, CoreTable formData, List<string> additionalColumns, CoreTable? jobITPs)
|
|
|
+ private void LoadDataIntoGrid(List<DigitalFormVariable> variables, CoreTable formData, List<string> additionalColumns, CoreTable? jobITPs)
|
|
|
{
|
|
|
var cData = new CoreTable();
|
|
|
cData.AddColumn<Guid>("ID");
|
|
|
@@ -1436,27 +1398,6 @@ public partial class DigitalFormsDashboard : UserControl,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if (questions.Count != 0)
|
|
|
- {
|
|
|
- Questions = questions;
|
|
|
- Progress.SetMessage("Loading Checks");
|
|
|
- QAGrid.Clear();
|
|
|
- QAGrid.LoadChecks(Form!.Description, Questions, new Dictionary<Guid, object>());
|
|
|
- QAGrid.CollapseMargins();
|
|
|
-
|
|
|
- var i = 1;
|
|
|
- foreach (var question in Questions)
|
|
|
- {
|
|
|
- var id = question.ID.ToString();
|
|
|
- if (!question.Answer.Equals(QAAnswer.Comment))
|
|
|
- {
|
|
|
- cData.AddColumn<string>(id);
|
|
|
- var code = question.Code;
|
|
|
- Grid.QuestionCodes[id] = string.IsNullOrEmpty(code) ? string.Format("{0}.", i) : code;
|
|
|
- i++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
foreach (var row in formData.Rows)
|
|
|
{
|
|
|
@@ -1564,8 +1505,6 @@ public partial class DigitalFormsDashboard : UserControl,
|
|
|
}
|
|
|
Grid.ItemsSource = cData;
|
|
|
|
|
|
- IsQAForm = variables.Count == 0 && questions.Count != 0;
|
|
|
- QAGrid.Visibility = IsQAForm ? Visibility.Visible : Visibility.Collapsed;
|
|
|
Grid.Visibility = Visibility.Visible;
|
|
|
}
|
|
|
|
|
|
@@ -1576,9 +1515,8 @@ public partial class DigitalFormsDashboard : UserControl,
|
|
|
|
|
|
var queries = new List<IKeyedQueryDef>()
|
|
|
{
|
|
|
- new KeyedQueryDef<QAQuestion>(Filter<QAQuestion>.Where(x => x.Form.ID).IsEqualTo(Form!.ID)),
|
|
|
new KeyedQueryDef<DigitalFormVariable>(
|
|
|
- Filter<DigitalFormVariable>.Where(x => x.Form.ID).IsEqualTo(Form.ID),
|
|
|
+ Filter<DigitalFormVariable>.Where(x => x.Form.ID).IsEqualTo(Form!.ID),
|
|
|
null,
|
|
|
new SortOrder<DigitalFormVariable>(x => x.Sequence)),
|
|
|
formQuery
|
|
|
@@ -1592,12 +1530,11 @@ public partial class DigitalFormsDashboard : UserControl,
|
|
|
|
|
|
var results = Client.QueryMultiple(queries);
|
|
|
|
|
|
- var questions = results.Get<QAQuestion>().ToObjects<QAQuestion>().ToList();
|
|
|
var variables = results.Get<DigitalFormVariable>().ToObjects<DigitalFormVariable>().ToList();
|
|
|
var formData = results.Get(formQuery.Key);
|
|
|
|
|
|
LoadDataIntoGrid(
|
|
|
- variables, questions,
|
|
|
+ variables,
|
|
|
formData,
|
|
|
formQuery.Columns!.ColumnNames().Where(x => x.StartsWith("Parent.")).ToList(),
|
|
|
ParentType == typeof(JobITP) ? results.Get<JobITP>() : null);
|
|
|
@@ -1607,13 +1544,8 @@ public partial class DigitalFormsDashboard : UserControl,
|
|
|
{
|
|
|
if (!IsSetup) return;
|
|
|
|
|
|
- Questions.Clear();
|
|
|
- QAGrid.Clear();
|
|
|
- QAGrid.LoadChecks("", Array.Empty<QAQuestion>(), new Dictionary<Guid, object>());
|
|
|
-
|
|
|
if (ParentType is null || FormType is null || Form is null || Form.ID == Guid.Empty)
|
|
|
{
|
|
|
- QAGrid.Visibility = Visibility.Collapsed;
|
|
|
Grid.Visibility = Visibility.Collapsed;
|
|
|
return;
|
|
|
}
|
|
|
@@ -1672,27 +1604,6 @@ public partial class DigitalFormsDashboard : UserControl,
|
|
|
|
|
|
if (FormType is null) return;
|
|
|
|
|
|
- if (IsQAForm)
|
|
|
- {
|
|
|
- var values = new Dictionary<Guid, object>();
|
|
|
- var formData = Serialization.Deserialize<Dictionary<string, object>>(formdata);
|
|
|
- if (formData is not null)
|
|
|
- {
|
|
|
- foreach (var (idStr, value) in formData)
|
|
|
- {
|
|
|
- if (Guid.TryParse(idStr, out var codeID))
|
|
|
- {
|
|
|
- values[codeID] = value;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- QAGrid.Clear();
|
|
|
- QAGrid.LoadChecks(Form!.Description, Questions, values);
|
|
|
- QAGrid.CollapseMargins();
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
var entityForm = typeof(DigitalFormsDashboard)
|
|
|
.GetMethod(nameof(GetEntityForm), BindingFlags.NonPublic | BindingFlags.Instance)!
|
|
|
.MakeGenericMethod(FormType)
|
|
|
@@ -1702,10 +1613,6 @@ public partial class DigitalFormsDashboard : UserControl,
|
|
|
if (DynamicFormEditWindow.EditDigitalForm(entityForm, out var dataModel))
|
|
|
{
|
|
|
dataModel.Update(null);
|
|
|
- /*typeof(QADashboard)
|
|
|
- .GetMethod(nameof(SaveEntityForm), System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!
|
|
|
- .MakeGenericMethod(formType)
|
|
|
- .Invoke(this, new object[] { entityForm });*/
|
|
|
Refresh();
|
|
|
}
|
|
|
}
|