|
@@ -11,7 +11,7 @@ using InABox.Core;
|
|
|
|
|
|
namespace InABox.DynamicGrid;
|
|
|
|
|
|
-public class CodePopupEditorControl : DynamicEditorControl<Guid, CodePopupEditor>, IPopupEditorControl
|
|
|
+public class CodePopupEditorControl : DynamicEditorControl<Guid, CodePopupEditor>
|
|
|
{
|
|
|
static CodePopupEditorControl()
|
|
|
{
|
|
@@ -25,13 +25,6 @@ public class CodePopupEditorControl : DynamicEditorControl<Guid, CodePopupEditor
|
|
|
|
|
|
private string origvalue = "";
|
|
|
|
|
|
- public CodePopupEditorControl()
|
|
|
- {
|
|
|
- OtherColumns = new Dictionary<string, string>();
|
|
|
- }
|
|
|
-
|
|
|
- public Dictionary<string, string> OtherColumns { get; }
|
|
|
-
|
|
|
public string CodeColumn { get; set; }
|
|
|
|
|
|
protected override FrameworkElement CreateEditor()
|
|
@@ -182,9 +175,10 @@ public class CodePopupEditorControl : DynamicEditorControl<Guid, CodePopupEditor
|
|
|
if (_type != null)
|
|
|
{
|
|
|
var columns = LookupFactory.DefineLookupColumns(Host.GetEditorType(), _type, ColumnName);
|
|
|
- var cols = OtherColumns.Keys.Concat(columns.ColumnNames()).ToArray();
|
|
|
|
|
|
- var list = new PopupList(_type, _value, cols, new Dictionary<string, string> { { CodeColumn, code } });
|
|
|
+ var list = new PopupList(_type, _value,
|
|
|
+ columns.ColumnNames().Concat(CoreUtils.One(CodeColumn)).ToArray(),
|
|
|
+ new Dictionary<string, string> { { CodeColumn, code } });
|
|
|
|
|
|
list.OnDefineFilter += t => LookupFactory.DefineLookupFilter(Host.GetEditorType(), t, ColumnName, Host.GetItems());
|
|
|
|
|
@@ -211,8 +205,8 @@ public class CodePopupEditorControl : DynamicEditorControl<Guid, CodePopupEditor
|
|
|
|
|
|
_value = list.ID;
|
|
|
|
|
|
- foreach (var key in OtherColumns.Keys)
|
|
|
- OtherValues[OtherColumns[key]] = list.OtherValues[key];
|
|
|
+ foreach (var col in columns)
|
|
|
+ OtherValues[col.Property] = list.OtherValues[col.Property];
|
|
|
CheckChanged();
|
|
|
|
|
|
Editor.Text = string.Format("{0}", list.OtherValues[CodeColumn]);
|
|
@@ -229,18 +223,6 @@ public class CodePopupEditorControl : DynamicEditorControl<Guid, CodePopupEditor
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- //private void Clear_Click(object sender, RoutedEventArgs e)
|
|
|
- //{
|
|
|
- // if (_type != null)
|
|
|
- // {
|
|
|
- // _value = Guid.Empty;
|
|
|
- // foreach (var otherfield in OtherColumns.Keys)
|
|
|
- // OtherValues[OtherColumns[otherfield]] = null;
|
|
|
- // CheckChanged();
|
|
|
- // Editor.Text = "";
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
public override int DesiredHeight()
|
|
|
{
|
|
|
return 25;
|
|
@@ -279,8 +261,7 @@ public class CodePopupEditorControl : DynamicEditorControl<Guid, CodePopupEditor
|
|
|
{
|
|
|
var client = ClientFactory.CreateClient(_type);
|
|
|
var columns = LookupFactory.DefineLookupColumns(Host.GetEditorType(), _type, ColumnName);
|
|
|
- foreach (var key in OtherColumns)
|
|
|
- columns.Add(key.Key);
|
|
|
+
|
|
|
var sort = LookupFactory.DefineSort(_type);
|
|
|
var filter = Filter.Create(_type, column).IsEqualTo(value);
|
|
|
|
|
@@ -293,14 +274,15 @@ public class CodePopupEditorControl : DynamicEditorControl<Guid, CodePopupEditor
|
|
|
row ??= lookup.NewRow(true);
|
|
|
|
|
|
code = row[CodeColumn]?.ToString();
|
|
|
- id = (Guid)row["ID"];
|
|
|
+ id = row.Get<Guid>("ID");
|
|
|
|
|
|
foreach (var col in displaycols.Where(x => !x.Equals("ID") && !x.Equals(CodeColumn)))
|
|
|
display[col] = row[col];
|
|
|
-
|
|
|
- foreach (var key in OtherColumns.Keys)
|
|
|
- if (lookup.Columns.Any(x => x.ColumnName.Equals(key)))
|
|
|
- OtherValues[OtherColumns[key]] = row[key];
|
|
|
+
|
|
|
+ foreach(var col in columns)
|
|
|
+ {
|
|
|
+ OtherValues[col.Property] = row[col.Property];
|
|
|
+ }
|
|
|
|
|
|
_value = id;
|
|
|
Editor.Text = code;
|
|
@@ -321,9 +303,6 @@ public class CodePopupEditorControl : DynamicEditorControl<Guid, CodePopupEditor
|
|
|
{
|
|
|
_type = EditorDefinition.Type;
|
|
|
|
|
|
- Host.LoadColumns(ColumnName, OtherColumns);
|
|
|
- Host.LoadColumns(ColumnName, EditorDefinition.OtherColumns);
|
|
|
-
|
|
|
CodeColumn = !string.IsNullOrEmpty(EditorDefinition.CodeColumn) ? EditorDefinition.CodeColumn : GetCodeColumn(_type);
|
|
|
}
|
|
|
|