Show human-readable object impact before technical review details
This commit is contained in:
parent
8e02e5326e
commit
386d5f4665
@ -11,11 +11,17 @@
|
||||
<TextBlock x:Name="WorkflowTitle" FontWeight="Bold" FontSize="18"/>
|
||||
<TextBox x:Name="Location" Grid.Row="1" IsReadOnly="True" BorderThickness="0" TextWrapping="Wrap" Margin="0,6"/>
|
||||
<TextBox x:Name="CheckResult" Grid.Row="2" IsReadOnly="True" MaxHeight="100" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" Margin="0,2,0,8"/>
|
||||
<DockPanel Grid.Row="3">
|
||||
<CheckBox x:Name="DetailsToggle" DockPanel.Dock="Top" Visibility="Collapsed" Content="查看字段差异、引用位置和文件路径" Margin="0,4,0,8" Checked="ToggleDetails" Unchecked="ToggleDetails"/>
|
||||
<ScrollViewer x:Name="SummaryPanel" Visibility="Collapsed" VerticalScrollBarVisibility="Auto">
|
||||
<TextBlock x:Name="ImpactSummary" TextWrapping="Wrap" FontSize="15" LineHeight="25"/>
|
||||
</ScrollViewer>
|
||||
<TextBox x:Name="CodeDiff" Grid.Row="3" AutomationProperties.Name="代码差异" IsReadOnly="True" FontFamily="Consolas"
|
||||
VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Padding="8"/>
|
||||
</DockPanel>
|
||||
<StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
|
||||
<Button x:Name="CancelChange" Content="取消" IsCancel="True" Width="84" Margin="0,0,8,0"/>
|
||||
<Button Content="确认保存" Click="Approve" Width="92"/>
|
||||
<Button x:Name="SaveChange" Content="确认保存" Click="Approve" Width="92"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@ -13,7 +13,8 @@ public partial class ScriptReviewWindow : Window
|
||||
{
|
||||
string action = edit.Action switch { "create" => "新增", "update" => "修改", _ => "删除" };
|
||||
Title = $"确认{(edit.UndoOf.HasValue ? "撤销 · " : "")}{action}工程对象";
|
||||
WorkflowTitle.Text = $"{edit.Kind} · {change.Name} · {edit.Id}";
|
||||
WorkflowTitle.Text = $"{action}{KindName(edit.Kind)}「{change.Name}」";
|
||||
SaveChange.Content = edit.UndoOf.HasValue ? "确认撤销" : $"确认{action}";
|
||||
Location.Text = System.IO.Path.Combine(root, edit.Path);
|
||||
CheckResult.Text = $"已编译工作流 {edit.Workflows.Count},工作流引用 {edit.WorkflowReferences.Count},配置引用 {edit.ConfigReferences.Count},待核对 {edit.ManualReferences.Count}";
|
||||
var lines = new List<string>();
|
||||
@ -27,14 +28,34 @@ public partial class ScriptReviewWindow : Window
|
||||
if (!System.Text.Json.Nodes.JsonNode.DeepEquals(edit.Before?[key], edit.After?[key]))
|
||||
lines.Add($"{key}:{edit.Before?[key]} → {edit.After?[key]}");
|
||||
CodeDiff.Text = string.Join("\n", lines);
|
||||
Location.Visibility = Visibility.Collapsed;
|
||||
DetailsToggle.Visibility = Visibility.Visible;
|
||||
ToggleDetails(this, null);
|
||||
CheckResult.Text = edit.Workflows.Count == 0 ? "本次未发现需要编译的工作流。" : $"{edit.Workflows.Count} 个相关工作流通过编译,尚未运行。";
|
||||
var summary = new List<string>();
|
||||
if (edit.UndoOf.HasValue) summary.Add($"这将撤销之前的操作,{WorkflowTitle.Text}。");
|
||||
if (edit.Action == "update")
|
||||
foreach (var field in edit.After.Where(p => !System.Text.Json.Nodes.JsonNode.DeepEquals(edit.Before[p.Key], p.Value)))
|
||||
{
|
||||
var label = field.Key switch { "Comment" => "备注", "Code" => "工作流脚本", "ControlName" => "绑定控件", "AutomaticExecution" => "自动运行", "CycleDelayTime" => "循环间隔", _ => field.Key };
|
||||
string Brief(System.Text.Json.Nodes.JsonNode value) => value == null ? "(空)" : value.ToString();
|
||||
var from = Brief(edit.Before[field.Key]);
|
||||
var to = Brief(field.Value);
|
||||
summary.Add(from.Length + to.Length < 100 ? $"{label}由「{from}」改为「{to}」。" : $"{label}已修改,完整内容可在字段差异中查看。");
|
||||
}
|
||||
foreach (var owned in edit.OwnedRows) summary.Add($"{(owned.Restore ? "一并恢复" : "一并删除")}{KindName(owned.Kind)}「{owned.Name}」。");
|
||||
foreach (var hit in edit.WorkflowReferences) summary.Add($"工作流「{hit["Name"]}」第 {hit["line"]} 行引用此对象。");
|
||||
foreach (var reference in edit.ConfigReferences) summary.Add($"{KindName((string)reference["table"])}配置中的 {reference["field"]} 引用了此对象。");
|
||||
if (edit.Action == "delete" && edit.WorkflowReferences.Count > 0)
|
||||
summary.Add("删除后,保留的工作流按原名称查找时可能找不到对象。");
|
||||
foreach (var hit in edit.ManualReferences)
|
||||
summary.Add($"需核对工作流「{hit["Name"]}」第 {hit["line"]} 行。目标名称取决于运行时的值。");
|
||||
if (summary.Count == 0) summary.Add("未发现关联的配置或工作流。");
|
||||
ImpactSummary.Text = string.Join("\n", summary);
|
||||
}
|
||||
else if (change.Rename is { } rename)
|
||||
{
|
||||
var subject = rename.Kind switch { "VisionLocalVariables" => "视觉局部变量", "ControlMeasurements" => "控件测量项",
|
||||
"InterpolationSegments" => "插补段", "InterpolationPoints" => "插补段内点", "Recipes" => "配方", "SystemVariables" => "系统变量", "CustomControls" => "主页控件",
|
||||
"Matrices" => "轴矩阵", "RobotMatrices" => "机器人矩阵", "InterpolationGroups" => "插补组", "Cameras" => "相机", "ImageDatas" => "视觉图像数据", "LocalImageDatas" => "本地图像数据", "Cylinders" => "气缸", "Robots" => "机器人", "Connects" => "通信连接",
|
||||
"DI" => "数字输入", "DQ" => "数字输出", "Axes" => "运动轴", "VisionFunctions" => "视觉功能", "Workflows" => "工作流",
|
||||
"AxisPoints" or "RobotPoints" => "点位", _ => "变量" };
|
||||
var subject = KindName(rename.Kind);
|
||||
Title = $"确认{(rename.UndoOf.HasValue ? "撤销" : "")}{subject}重命名";
|
||||
WorkflowTitle.Text = $"{rename.OldName} → {rename.NewName}";
|
||||
Location.Text = System.IO.Path.Combine(root, change.Path);
|
||||
@ -58,6 +79,19 @@ public partial class ScriptReviewWindow : Window
|
||||
Loaded += (_, _) => CancelChange.Focus();
|
||||
}
|
||||
|
||||
private static string KindName(string kind) => kind switch { "VisionLocalVariables" => "视觉局部变量", "ControlMeasurements" => "控件测量项",
|
||||
"InterpolationSegments" => "插补段", "InterpolationPoints" => "插补段内点", "Recipes" => "配方", "SystemVariables" => "系统变量", "CustomControls" => "主页控件",
|
||||
"Matrices" => "轴矩阵", "RobotMatrices" => "机器人矩阵", "InterpolationGroups" => "插补组", "Cameras" => "相机", "ImageDatas" => "视觉图像数据", "LocalImageDatas" => "本地图像数据", "Cylinders" => "气缸", "Robots" => "机器人", "Connects" => "通信连接",
|
||||
"DI" => "数字输入", "DQ" => "数字输出", "Axes" => "运动轴", "VisionFunctions" => "视觉功能", "Workflows" => "工作流",
|
||||
"AxisPoints" or "RobotPoints" => "点位", "Controllers" => "运动控制器", "CanvasConfigs" => "主页画布", "Variables" => "配方变量", _ => kind };
|
||||
|
||||
private void ToggleDetails(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool details = DetailsToggle.IsChecked == true;
|
||||
CodeDiff.Visibility = details ? Visibility.Visible : Visibility.Collapsed;
|
||||
SummaryPanel.Visibility = details ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
private void Approve(object sender, RoutedEventArgs e) => DialogResult = true;
|
||||
|
||||
public static bool Confirm(ProjectChange change, string root, Window owner)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user