add coarse option for project requirement.
This commit is contained in:
@@ -36,6 +36,7 @@ type Requirement struct {
|
||||
ProjectID int `json:"projectId"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
IsCoarse bool `json:"isCoarse"`
|
||||
Status models.Status `json:"status"`
|
||||
}
|
||||
|
||||
@@ -49,6 +50,9 @@ func (requirement *Requirement) Update(update models.RequirementUpdate) {
|
||||
if update.Status != nil && update.Status.Valid() {
|
||||
requirement.Status = *update.Status
|
||||
}
|
||||
if update.IsCoarse != nil {
|
||||
requirement.IsCoarse = *update.IsCoarse
|
||||
}
|
||||
}
|
||||
|
||||
type RequirementStat struct {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { getScopeContext } from "$lib/components/contexts/ScopeContext.svelte";
|
||||
import StatInput from "$lib/components/controls/StatInput.svelte";
|
||||
import StatusSelect from "$lib/components/controls/StatusSelect.svelte";
|
||||
import Checkbox from "$lib/components/layout/Checkbox.svelte";
|
||||
import type { ProjectEntry, Requirement, RequirementInput } from "$lib/models/project";
|
||||
import Status from "$lib/models/status";
|
||||
import { statDiff } from "$lib/utils/stat";
|
||||
@@ -49,23 +50,25 @@ import { statDiff } from "$lib/utils/stat";
|
||||
description: "",
|
||||
stats: [],
|
||||
status: Status.Available,
|
||||
isCoarse: false,
|
||||
}
|
||||
|
||||
projectId = project.id;
|
||||
show = true;
|
||||
}
|
||||
|
||||
function initEdit(prev: Requirement, project: ProjectEntry) {
|
||||
function initEdit(current: Requirement, project: ProjectEntry) {
|
||||
requirement = {
|
||||
name: prev.name,
|
||||
description: prev.description,
|
||||
status: prev.status,
|
||||
stats: prev.stats.map(s => ({acquired: s.acquired, required: s.required, statId: s.id})),
|
||||
name: current.name,
|
||||
description: current.description,
|
||||
status: current.status,
|
||||
stats: current.stats.map(s => ({acquired: s.acquired, required: s.required, statId: s.id})),
|
||||
isCoarse: current.isCoarse,
|
||||
}
|
||||
|
||||
oldStats = [...requirement.stats];
|
||||
projectId = project.id;
|
||||
requirementId = prev.id;
|
||||
requirementId = current.id;
|
||||
show = true;
|
||||
}
|
||||
|
||||
@@ -118,6 +121,7 @@ import { statDiff } from "$lib/utils/stat";
|
||||
<StatusSelect bind:status={requirement.status} />
|
||||
<label for="stats">Stats</label>
|
||||
<StatInput showRequired bind:value={requirement.stats} />
|
||||
<Checkbox bind:checked={requirement.isCoarse} label="Hide 0-requirement stats." />
|
||||
</ModalBody>
|
||||
</Modal>
|
||||
</form>
|
||||
@@ -37,6 +37,7 @@ export interface Requirement {
|
||||
totalAcquired: number
|
||||
totalRequired: number
|
||||
totalPlanned: number
|
||||
isCoarse: boolean
|
||||
stats: StatProgressWithPlanned[]
|
||||
items: Item[]
|
||||
}
|
||||
@@ -45,5 +46,6 @@ export interface RequirementInput {
|
||||
name: string
|
||||
description: string
|
||||
status: Status
|
||||
isCoarse: boolean
|
||||
stats: StatValueInput[]
|
||||
}
|
||||
@@ -11,4 +11,5 @@ type RequirementUpdate struct {
|
||||
Name *string `json:"name"`
|
||||
Description *string `json:"description"`
|
||||
Status *Status `json:"status"`
|
||||
IsCoarse *bool `json:"isCoarse"`
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ type ProjectRequirement struct {
|
||||
Name string
|
||||
Status int
|
||||
Description string
|
||||
IsCoarse bool
|
||||
}
|
||||
|
||||
type ProjectRequirementStat struct {
|
||||
|
||||
@@ -156,8 +156,8 @@ func (q *Queries) InsertProject(ctx context.Context, arg InsertProjectParams) (s
|
||||
}
|
||||
|
||||
const insertProjectRequirement = `-- name: InsertProjectRequirement :execresult
|
||||
INSERT INTO project_requirement (scope_id, project_id, name, status, description)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
INSERT INTO project_requirement (scope_id, project_id, name, status, description, is_coarse)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
`
|
||||
|
||||
type InsertProjectRequirementParams struct {
|
||||
@@ -166,6 +166,7 @@ type InsertProjectRequirementParams struct {
|
||||
Name string
|
||||
Status int
|
||||
Description string
|
||||
IsCoarse bool
|
||||
}
|
||||
|
||||
func (q *Queries) InsertProjectRequirement(ctx context.Context, arg InsertProjectRequirementParams) (sql.Result, error) {
|
||||
@@ -175,11 +176,12 @@ func (q *Queries) InsertProjectRequirement(ctx context.Context, arg InsertProjec
|
||||
arg.Name,
|
||||
arg.Status,
|
||||
arg.Description,
|
||||
arg.IsCoarse,
|
||||
)
|
||||
}
|
||||
|
||||
const listProjectRequirements = `-- name: ListProjectRequirements :many
|
||||
SELECT id, scope_id, project_id, name, status, description FROM project_requirement WHERE project_id = ?
|
||||
SELECT id, scope_id, project_id, name, status, description, is_coarse FROM project_requirement WHERE project_id = ?
|
||||
`
|
||||
|
||||
func (q *Queries) ListProjectRequirements(ctx context.Context, projectID int) ([]ProjectRequirement, error) {
|
||||
@@ -198,6 +200,7 @@ func (q *Queries) ListProjectRequirements(ctx context.Context, projectID int) ([
|
||||
&i.Name,
|
||||
&i.Status,
|
||||
&i.Description,
|
||||
&i.IsCoarse,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -326,7 +329,8 @@ const updateProjectRequirement = `-- name: UpdateProjectRequirement :exec
|
||||
UPDATE project_requirement
|
||||
SET name = ?,
|
||||
status = ?,
|
||||
description = ?
|
||||
description = ?,
|
||||
is_coarse = ?
|
||||
WHERE id = ? AND scope_id = ?
|
||||
`
|
||||
|
||||
@@ -334,6 +338,7 @@ type UpdateProjectRequirementParams struct {
|
||||
Name string
|
||||
Status int
|
||||
Description string
|
||||
IsCoarse bool
|
||||
ID int
|
||||
ScopeID int
|
||||
}
|
||||
@@ -343,6 +348,7 @@ func (q *Queries) UpdateProjectRequirement(ctx context.Context, arg UpdateProjec
|
||||
arg.Name,
|
||||
arg.Status,
|
||||
arg.Description,
|
||||
arg.IsCoarse,
|
||||
arg.ID,
|
||||
arg.ScopeID,
|
||||
)
|
||||
|
||||
@@ -139,7 +139,7 @@ func (r *projectRepository) FetchRequirements(ctx context.Context, scopeID int,
|
||||
return []entities.Requirement{}, []entities.RequirementStat{}, nil
|
||||
}
|
||||
|
||||
query, args, err := squirrel.Select("id, scope_id, project_id, name, status, description").
|
||||
query, args, err := squirrel.Select("id, scope_id, project_id, name, status, description, is_coarse").
|
||||
From("project_requirement").
|
||||
Where(squirrel.Eq{"scope_id": scopeID}).
|
||||
Where(squirrel.Eq{"id": requirementIDs}).
|
||||
@@ -162,6 +162,7 @@ func (r *projectRepository) FetchRequirements(ctx context.Context, scopeID int,
|
||||
&requirement.Name,
|
||||
&requirement.Status,
|
||||
&requirement.Description,
|
||||
&requirement.IsCoarse,
|
||||
); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -217,6 +218,7 @@ func (r *projectRepository) ListRequirements(ctx context.Context, projectID int)
|
||||
ProjectID: row.ProjectID,
|
||||
Name: row.Name,
|
||||
Description: row.Description,
|
||||
IsCoarse: row.IsCoarse,
|
||||
Status: models.Status(row.Status),
|
||||
})
|
||||
}
|
||||
@@ -240,6 +242,7 @@ func (r *projectRepository) CreateRequirement(ctx context.Context, requirement e
|
||||
Name: requirement.Name,
|
||||
Status: int(requirement.Status),
|
||||
Description: requirement.Description,
|
||||
IsCoarse: requirement.IsCoarse,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -261,6 +264,7 @@ func (r *projectRepository) UpdateRequirement(ctx context.Context, requirement e
|
||||
Name: requirement.Name,
|
||||
Status: int(requirement.Status),
|
||||
Description: requirement.Description,
|
||||
IsCoarse: requirement.IsCoarse,
|
||||
ID: requirement.ID,
|
||||
ScopeID: requirement.ScopeID,
|
||||
})
|
||||
|
||||
@@ -23,14 +23,15 @@ DELETE FROM project WHERE id = ? AND scope_id = ?;
|
||||
SELECT * FROM project_requirement WHERE project_id = ?;
|
||||
|
||||
-- name: InsertProjectRequirement :execresult
|
||||
INSERT INTO project_requirement (scope_id, project_id, name, status, description)
|
||||
VALUES (?, ?, ?, ?, ?);
|
||||
INSERT INTO project_requirement (scope_id, project_id, name, status, description, is_coarse)
|
||||
VALUES (?, ?, ?, ?, ?, ?);
|
||||
|
||||
-- name: UpdateProjectRequirement :exec
|
||||
UPDATE project_requirement
|
||||
SET name = ?,
|
||||
status = ?,
|
||||
description = ?
|
||||
description = ?,
|
||||
is_coarse = ?
|
||||
WHERE id = ? AND scope_id = ?;
|
||||
|
||||
-- name: DeleteProjectRequirement :exec
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE project_requirement ADD COLUMN is_coarse BOOLEAN NOT NULL DEFAULT 0;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
ALTER TABLE project_requirement DROP COLUMN IF EXISTS is_coarse;
|
||||
-- +goose StatementEnd
|
||||
@@ -60,6 +60,7 @@ type RequirementResult struct {
|
||||
TotalAcquired int `json:"totalAcquired"`
|
||||
TotalRequired int `json:"totalRequired"`
|
||||
TotalPlanned int `json:"totalPlanned"`
|
||||
IsCoarse bool `json:"isCoarse"`
|
||||
Stats []RequirementResultStat `json:"stats"`
|
||||
Items []items.Result `json:"items"`
|
||||
|
||||
@@ -150,6 +151,7 @@ func generateRequirementResult(req entities.Requirement, scope scopes.Result, re
|
||||
Description: req.Description,
|
||||
Status: req.Status,
|
||||
StatusName: scope.StatusName(req.Status),
|
||||
IsCoarse: req.IsCoarse,
|
||||
Stats: make([]RequirementResultStat, 0, 8),
|
||||
Items: make([]items.Result, 0, 8),
|
||||
|
||||
@@ -199,9 +201,11 @@ func generateRequirementResult(req entities.Requirement, scope scopes.Result, re
|
||||
resReq.Stats = append(resReq.Stats, *rs)
|
||||
}
|
||||
}
|
||||
for _, stat := range scope.Stats {
|
||||
if rs := resStats[stat.ID]; rs != nil && rs.Required == 0 {
|
||||
resReq.Stats = append(resReq.Stats, *rs)
|
||||
if !req.IsCoarse {
|
||||
for _, stat := range scope.Stats {
|
||||
if rs := resStats[stat.ID]; rs != nil && rs.Required == 0 {
|
||||
resReq.Stats = append(resReq.Stats, *rs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user