mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-11 02:47:22 +00:00
Added confirmed work states to the BeyondFacts Lab (#1182)
This commit is contained in:
1 parent
6d0052ecdf
commit
a9579dd282
39 files changed
+3160
-16
No files matched your search
+60
-1
@@ -7,6 +7,12 @@ public partial class BeyondFactsLabAssistant
|
||||
/// </summary>
|
||||
private Dictionary<BflStep, BflStepFormData> forms = [];
|
||||
|
||||
/// <summary>
|
||||
/// The work states of the preparation shown, by their steps. A step missing here has a work state this version
|
||||
/// cannot open.
|
||||
/// </summary>
|
||||
private Dictionary<BflStep, BflWorkState> workStates = [];
|
||||
|
||||
/// <summary>
|
||||
/// The step shown.
|
||||
/// </summary>
|
||||
@@ -28,15 +34,46 @@ public partial class BeyondFactsLabAssistant
|
||||
if (project?.Project is { } openedProject)
|
||||
{
|
||||
this.forms = new(await this.Store.LoadFormsAsync(openedProject.ProjectId));
|
||||
this.workStates = new(await this.Store.LoadWorkStatesAsync(openedProject.ProjectId));
|
||||
this.activeStep = openedProject.CurrentStep;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.forms = [];
|
||||
this.workStates = [];
|
||||
this.activeStep = BflStep.FRAMEWORK;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows a work state after the panel of its step stored it.
|
||||
/// </summary>
|
||||
/// <param name="project">The preparation with its new time of change.</param>
|
||||
private Task WorkStateStoredAsync(BflProject project)
|
||||
{
|
||||
this.ReplaceProject(project);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads the work states of the preparation shown again once the generator started, ended, or stored a draft.
|
||||
/// </summary>
|
||||
/// <param name="location">The step whose work state changed.</param>
|
||||
private Task OnWorkStateChangedAsync(BflStepThreadLocation location)
|
||||
{
|
||||
if (this.selectedProject?.ProjectId != location.ProjectId)
|
||||
return Task.CompletedTask;
|
||||
|
||||
return this.InvokeAsync(async () =>
|
||||
{
|
||||
this.workStates = new(await this.Store.LoadWorkStatesAsync(location.ProjectId));
|
||||
if (await this.Store.LoadAsync(location.ProjectId) is { } project)
|
||||
this.ReplaceProject(project);
|
||||
|
||||
this.StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the step the person chose in the stepper, and remembers it for the next time.
|
||||
/// </summary>
|
||||
@@ -112,6 +149,28 @@ public partial class BeyondFactsLabAssistant
|
||||
if (!this.forms.TryGetValue(step, out var form))
|
||||
return T("Cannot be opened");
|
||||
|
||||
return BflMissingDetails.Of(step, form).Count > 0 ? T("Details missing") : string.Empty;
|
||||
var notes = new List<string>(2);
|
||||
if (BflMissingDetails.Of(step, form).Count > 0)
|
||||
notes.Add(T("Details missing"));
|
||||
|
||||
switch (BflStaleness.Of(step, this.workStates, this.forms))
|
||||
{
|
||||
case BflWorkStateStatus.OUTDATED:
|
||||
notes.Add(T("Outdated"));
|
||||
break;
|
||||
|
||||
case BflWorkStateStatus.DETAILS_CHANGED:
|
||||
notes.Add(T("Details changed"));
|
||||
break;
|
||||
}
|
||||
|
||||
return string.Join(" · ", notes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tells whether the stepper shows a step as done: the person confirmed its work state, and no earlier step changed
|
||||
/// since.
|
||||
/// </summary>
|
||||
/// <param name="step">The step.</param>
|
||||
private bool IsStepCompleted(BflStep step) => BflStaleness.Of(step, this.workStates, this.forms) is BflWorkStateStatus.CONFIRMED or BflWorkStateStatus.DETAILS_CHANGED;
|
||||
}
|
||||
Reference in new issue
Block a user