removed id from rubric

This commit is contained in:
2023-10-24 14:59:36 -06:00
parent 3086775cdf
commit 7477cf8e06
3 changed files with 12 additions and 11 deletions

View File

@@ -48,7 +48,6 @@
{
rubric = rubric.Append(new RubricItem
{
Id = Guid.NewGuid().ToString(),
Label = "",
Points = 0
});
@@ -62,11 +61,11 @@
save();
}
}
private void editItem(RubricItem newItem)
private void editItem(RubricItem newItem, int index)
{
if (assignmentContext.Assignment != null)
{
rubric = rubric.Select(i => i.Id == newItem.Id ? newItem : i);
rubric = rubric.Select((r, i) => i == index ? newItem : r);
save();
}
}
@@ -85,6 +84,7 @@
rubric = rubricList;
save();
}
StateHasChanged();
}
}
private void MoveDown(RubricItem item)
@@ -102,6 +102,7 @@
rubric = rubricList;
save();
}
StateHasChanged();
}
}
@@ -129,11 +130,12 @@
</div>
<ul class="list-group">
@foreach (var rubricItem in rubric)
@foreach (var (rubricItem, index) in rubric.Select((r, i) => (r, i)))
{
<RubricEditorItem
<RubricEditorItem
@key="@(rubricItem with {Label = ""})"
RubricItem="rubricItem"
OnUpdate="editItem"
OnUpdate="(newItem) => editItem(newItem, index)"
MoveUp="() => MoveUp(rubricItem)"
MoveDown="() => MoveDown(rubricItem)"
/>

View File

@@ -15,17 +15,18 @@
private int points { get; set; }
private string label { get; set; }
private string lastRubricItemId { get; set; }
private bool firstLoad = true;
protected override void OnParametersSet()
{
if(RubricItem.Id != lastRubricItemId)
if(firstLoad)
{
lastRubricItemId = RubricItem.Id;
firstLoad = false;
points = RubricItem.Points;
label = RubricItem.Label;
}
}
private void editItem(string label, int points)
{
var newRubricItem = RubricItem with