Merge: project tab nil/empty list fix
This commit is contained in:
@@ -188,7 +188,7 @@ async function loadProject(id: string): Promise<boolean> {
|
||||
async function loadParties(id: string) {
|
||||
try {
|
||||
const resp = await fetch(`/api/projects/${id}/parties`);
|
||||
if (resp.ok) parties = await resp.json();
|
||||
if (resp.ok) parties = (await resp.json()) ?? [];
|
||||
} catch {
|
||||
parties = [];
|
||||
}
|
||||
@@ -198,7 +198,7 @@ async function loadEvents(id: string) {
|
||||
try {
|
||||
const resp = await fetch(`/api/projects/${id}/events?limit=${EVENTS_PAGE_SIZE}`);
|
||||
if (resp.ok) {
|
||||
events = await resp.json();
|
||||
events = (await resp.json()) ?? [];
|
||||
eventsHasMore = events.length === EVENTS_PAGE_SIZE;
|
||||
} else {
|
||||
events = [];
|
||||
@@ -243,7 +243,7 @@ async function loadMoreEvents(id: string) {
|
||||
async function loadDeadlines(id: string) {
|
||||
try {
|
||||
const resp = await fetch(`/api/projects/${id}/deadlines`);
|
||||
if (resp.ok) deadlines = await resp.json();
|
||||
if (resp.ok) deadlines = (await resp.json()) ?? [];
|
||||
} catch {
|
||||
deadlines = [];
|
||||
}
|
||||
@@ -252,7 +252,7 @@ async function loadDeadlines(id: string) {
|
||||
async function loadAppointments(id: string) {
|
||||
try {
|
||||
const resp = await fetch(`/api/projects/${id}/appointments`);
|
||||
if (resp.ok) appointments = await resp.json();
|
||||
if (resp.ok) appointments = (await resp.json()) ?? [];
|
||||
} catch {
|
||||
appointments = [];
|
||||
}
|
||||
@@ -651,8 +651,8 @@ async function loadAndRenderChecklistInstances(projectID: string) {
|
||||
fetch(`/api/projects/${projectID}/checklists`),
|
||||
fetch(`/api/checklists`),
|
||||
]);
|
||||
checklistInstances = instResp.ok ? await instResp.json() : [];
|
||||
const templates = tplResp.ok ? await tplResp.json() as ChecklistTemplateSummary[] : [];
|
||||
checklistInstances = instResp.ok ? ((await instResp.json()) ?? []) : [];
|
||||
const templates = tplResp.ok ? (((await tplResp.json()) as ChecklistTemplateSummary[]) ?? []) : [];
|
||||
checklistTemplates = {};
|
||||
for (const tpl of templates) checklistTemplates[tpl.slug] = tpl;
|
||||
} catch {
|
||||
@@ -951,7 +951,7 @@ function inheritedClientNumber(): string | null {
|
||||
async function loadAncestors(id: string) {
|
||||
try {
|
||||
const resp = await fetch(`/api/projects/${id}/ancestors`);
|
||||
if (resp.ok) ancestors = (await resp.json()) as ProjectMini[];
|
||||
if (resp.ok) ancestors = ((await resp.json()) as ProjectMini[]) ?? [];
|
||||
} catch {
|
||||
ancestors = [];
|
||||
}
|
||||
@@ -974,7 +974,7 @@ function renderBreadcrumb() {
|
||||
async function loadChildren(id: string) {
|
||||
try {
|
||||
const resp = await fetch(`/api/projects/${id}/children`);
|
||||
if (resp.ok) children = (await resp.json()) as ProjectMini[];
|
||||
if (resp.ok) children = ((await resp.json()) as ProjectMini[]) ?? [];
|
||||
} catch {
|
||||
children = [];
|
||||
}
|
||||
@@ -1015,7 +1015,7 @@ function initChildAddLink() {
|
||||
async function loadTeam(id: string) {
|
||||
try {
|
||||
const resp = await fetch(`/api/projects/${id}/team`);
|
||||
if (resp.ok) teamMembers = (await resp.json()) as ProjectTeamMember[];
|
||||
if (resp.ok) teamMembers = ((await resp.json()) as ProjectTeamMember[]) ?? [];
|
||||
} catch {
|
||||
teamMembers = [];
|
||||
}
|
||||
@@ -1024,7 +1024,7 @@ async function loadTeam(id: string) {
|
||||
async function loadUserList() {
|
||||
try {
|
||||
const resp = await fetch("/api/users");
|
||||
if (resp.ok) userOptions = (await resp.json()) as typeof userOptions;
|
||||
if (resp.ok) userOptions = ((await resp.json()) as typeof userOptions) ?? [];
|
||||
} catch {
|
||||
userOptions = [];
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ func (s *AppointmentService) ListVisibleForUser(ctx context.Context, userID uuid
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
var rows []models.AppointmentWithProject
|
||||
rows := []models.AppointmentWithProject{}
|
||||
if err := stmt.SelectContext(ctx, &rows, args); err != nil {
|
||||
return nil, fmt.Errorf("list appointments: %w", err)
|
||||
}
|
||||
@@ -154,7 +154,7 @@ func (s *AppointmentService) ListForProjekt(ctx context.Context, userID, projekt
|
||||
if _, err := s.projects.GetByID(ctx, userID, projektID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var rows []models.Appointment
|
||||
rows := []models.Appointment{}
|
||||
if err := s.db.SelectContext(ctx, &rows,
|
||||
`SELECT `+terminColumns+`
|
||||
FROM paliad.appointments
|
||||
|
||||
@@ -332,7 +332,7 @@ func (s *ChecklistInstanceService) listWithProjekt(ctx context.Context, query st
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
var rows []models.ChecklistInstanceWithProject
|
||||
rows := []models.ChecklistInstanceWithProject{}
|
||||
if err := stmt.SelectContext(ctx, &rows, args); err != nil {
|
||||
return nil, fmt.Errorf("list checklist_instances: %w", err)
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func (s *DeadlineService) ListVisibleForUser(ctx context.Context, userID uuid.UU
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
var rows []models.DeadlineWithProject
|
||||
rows := []models.DeadlineWithProject{}
|
||||
if err := stmt.SelectContext(ctx, &rows, args); err != nil {
|
||||
return nil, fmt.Errorf("list deadlines: %w", err)
|
||||
}
|
||||
@@ -151,7 +151,7 @@ func (s *DeadlineService) ListForProjekt(ctx context.Context, userID, projektID
|
||||
if _, err := s.projects.GetByID(ctx, userID, projektID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var rows []models.Deadline
|
||||
rows := []models.Deadline{}
|
||||
if err := s.db.SelectContext(ctx, &rows,
|
||||
`SELECT `+fristColumns+`
|
||||
FROM paliad.deadlines
|
||||
|
||||
@@ -45,7 +45,7 @@ type UpdateDepartmentInput struct {
|
||||
|
||||
// List returns every Dezernat (readable by any authenticated user — see RLS).
|
||||
func (s *DepartmentService) List(ctx context.Context) ([]models.Department, error) {
|
||||
var rows []models.Department
|
||||
rows := []models.Department{}
|
||||
err := s.db.SelectContext(ctx, &rows,
|
||||
`SELECT id, name, lead_user_id, office, created_at, updated_at
|
||||
FROM paliad.departments
|
||||
@@ -281,7 +281,7 @@ func (s *DepartmentService) ListWithMembers(ctx context.Context) ([]DepartmentWi
|
||||
// GetMembership returns the user's Dezernat memberships (zero or more).
|
||||
// Used by the settings page to render "Your Dezernat: <name>".
|
||||
func (s *DepartmentService) GetMembership(ctx context.Context, userID uuid.UUID) ([]models.Department, error) {
|
||||
var rows []models.Department
|
||||
rows := []models.Department{}
|
||||
err := s.db.SelectContext(ctx, &rows,
|
||||
`SELECT d.id, d.name, d.lead_user_id, d.office, d.created_at, d.updated_at
|
||||
FROM paliad.departments d
|
||||
|
||||
@@ -214,7 +214,7 @@ type noteParent struct {
|
||||
|
||||
func (s *NoteService) list(ctx context.Context, where string, arg any) ([]models.Note, error) {
|
||||
query := notizSelect + ` WHERE ` + where + ` ORDER BY n.created_at DESC`
|
||||
var rows []models.Note
|
||||
rows := []models.Note{}
|
||||
if err := s.db.SelectContext(ctx, &rows, query, arg); err != nil {
|
||||
return nil, fmt.Errorf("list notes: %w", err)
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func (s *PartyService) ListForProjekt(ctx context.Context, userID, projektID uui
|
||||
if _, err := s.projects.GetByID(ctx, userID, projektID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var rows []models.Party
|
||||
rows := []models.Party{}
|
||||
if err := s.db.SelectContext(ctx, &rows,
|
||||
`SELECT `+parteiColumns+`
|
||||
FROM paliad.parties
|
||||
|
||||
@@ -192,7 +192,7 @@ func (s *ProjectService) List(ctx context.Context, userID uuid.UUID, f ProjectFi
|
||||
}
|
||||
defer stmt.Close()
|
||||
|
||||
var rows []models.Project
|
||||
rows := []models.Project{}
|
||||
if err := stmt.SelectContext(ctx, &rows, args); err != nil {
|
||||
return nil, fmt.Errorf("list projects: %w", err)
|
||||
}
|
||||
@@ -269,7 +269,7 @@ func (s *ProjectService) ListAncestors(ctx context.Context, userID, id uuid.UUID
|
||||
for i, u := range ids {
|
||||
idStrs[i] = u.String()
|
||||
}
|
||||
var rows []models.Project
|
||||
rows := []models.Project{}
|
||||
if err := s.db.SelectContext(ctx, &rows, query, pq.StringArray(idStrs), userID, user.Role); err != nil {
|
||||
return nil, fmt.Errorf("list ancestors: %w", err)
|
||||
}
|
||||
@@ -309,7 +309,7 @@ func (s *ProjectService) BuildTree(ctx context.Context, userID uuid.UUID) ([]*Pr
|
||||
query := `SELECT ` + projektColumns + ` FROM paliad.projects p
|
||||
WHERE ` + visibilityPredicatePositional("p", 1, 2) + `
|
||||
ORDER BY p.path`
|
||||
var rows []models.Project
|
||||
rows := []models.Project{}
|
||||
if err := s.db.SelectContext(ctx, &rows, query, userID, user.Role); err != nil {
|
||||
return nil, fmt.Errorf("build tree list: %w", err)
|
||||
}
|
||||
@@ -401,7 +401,7 @@ func (s *ProjectService) GetTree(ctx context.Context, userID, id uuid.UUID) ([]m
|
||||
WHERE (p.path = $1 OR p.path LIKE $2)
|
||||
AND ` + visibilityPredicatePositional("p", 3, 4) + `
|
||||
ORDER BY p.path`
|
||||
var rows []models.Project
|
||||
rows := []models.Project{}
|
||||
if err := s.db.SelectContext(ctx, &rows, query, root.Path, prefix, userID, user.Role); err != nil {
|
||||
return nil, fmt.Errorf("get tree: %w", err)
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func (s *TeamService) ListDirectMembers(ctx context.Context, callerID, projektID
|
||||
if _, err := s.projects.GetByID(ctx, callerID, projektID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var rows []models.ProjectTeamMemberWithUser
|
||||
rows := []models.ProjectTeamMemberWithUser{}
|
||||
err := s.db.SelectContext(ctx, &rows,
|
||||
`SELECT pt.id, pt.project_id, pt.user_id, pt.role, pt.inherited,
|
||||
pt.added_by, pt.created_at,
|
||||
@@ -145,7 +145,7 @@ func (s *TeamService) ListEffectiveMembers(ctx context.Context, callerID, projek
|
||||
WHERE r.rn = 1
|
||||
ORDER BY r.inherited ASC, r.role, u.display_name`
|
||||
|
||||
var rows []models.ProjectTeamMemberWithUser
|
||||
rows := []models.ProjectTeamMemberWithUser{}
|
||||
if err := s.db.SelectContext(ctx, &rows, query, projektID, pq.StringArray(ancestorIDs)); err != nil {
|
||||
return nil, fmt.Errorf("list effective team: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user