Browse Source

fix log amount not being accounted for in TaskResult.completedAmount, and fix being unable to remove secondary item.

main
Gisle Aune 4 years ago
parent
commit
02b0907598
  1. 2
      models/log.go
  2. 17
      services/loader.go
  3. 2
      svelte-ui/src/forms/LogForm.svelte

2
models/log.go

@ -57,7 +57,7 @@ type LogUpdate struct {
ItemAmount *int `json:"itemAmount"`
SecondaryItemID *string `json:"secondaryItemId"`
SecondaryItemAmount *int `json:"secondaryItemAmount"`
ClearSecondaryItem bool `json:"clearSecondaryItem"`
ClearSecondaryItem bool `json:"clearSecondaryItemId"`
}
type LogResult struct {

17
services/loader.go

@ -246,7 +246,9 @@ func (l *Loader) FindProject(ctx context.Context, id string) (*models.ProjectRes
break
}
}
result.Tasks[i].CompletedAmount = len(result.Tasks[i].Logs)
for _, log := range result.Tasks[i].Logs {
result.Tasks[i].CompletedAmount += log.Amount(result.Tasks[i].ItemID)
}
}
return result, nil
@ -317,8 +319,9 @@ func (l *Loader) ListProjects(ctx context.Context, filter models.ProjectFilter)
break
}
}
taskResult.CompletedAmount = len(taskResult.Logs)
for _, log := range taskResult.Logs {
taskResult.CompletedAmount += log.Amount(taskResult.ItemID)
}
results[i].Tasks = append(results[i].Tasks, taskResult)
}
}
@ -346,7 +349,9 @@ func (l *Loader) FindTask(ctx context.Context, id string) (*models.TaskResult, e
return nil, err
}
result.CompletedAmount = len(result.Logs)
for _, log := range result.Logs {
result.CompletedAmount += log.Amount(result.ItemID)
}
return result, nil
}
@ -421,7 +426,9 @@ func (l *Loader) ListTasks(ctx context.Context, filter models.TaskFilter) ([]*mo
}
}
result.CompletedAmount = len(result.Logs)
for _, log := range result.Logs {
result.CompletedAmount += log.Amount(result.ItemID)
}
results = append(results, result)
}

2
svelte-ui/src/forms/LogForm.svelte

@ -84,7 +84,7 @@ import ItemSelect from "../components/ItemSelect.svelte";
stuffLogClient.updateLog(log.id, {
loggedTime: new Date(loggedTime).toISOString(),
secondaryItemId: secondaryItemId || null,
clearSecondaryItemId: secondaryItemId == "",
clearSecondaryItemId: !secondaryItemId,
description, itemAmount, secondaryItemAmount
}).then(() => {
markStale("project", "task", "goal", "log");

Loading…
Cancel
Save