Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 41 additions & 11 deletions src/app/components/dashboard/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,6 @@
place-items: center;
}

nav {
display: flex;
align-items: center;
gap: 20px;
}

.workspace-card-link {
text-decoration: none;
color: inherit;
}

.logout-btn {
border: 1px solid rgba(255, 255, 255, 0.24);
background: transparent;
Expand Down Expand Up @@ -158,6 +147,47 @@ nav {
letter-spacing: 0.04em;
}

.card-actions {
margin-top: 14px;
display: flex;
gap: 8px;
}

.action-btn {
text-decoration: none;
display: inline-flex;
align-items: center;
border-radius: 8px;
border: 1px solid #d0d0d0;
padding: 7px 12px;
font-size: 13px;
cursor: pointer;
background: #fff;
color: #111;
}

.open-btn {
background: #f3f3f3;
}

.open-btn:hover {
background: #e9e9e9;
}

.edit-btn:hover {
background: #f3f3f3;
}

.delete-btn {
border-color: #2b2b2b;
background: #111;
color: #fff;
}

.delete-btn:hover {
background: #000;
}

.empty-state {
border: 1px dashed #bcbcbc;
border-radius: 12px;
Expand Down
21 changes: 10 additions & 11 deletions src/app/components/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@ <h2>Your Workspaces</h2>
<a routerLink="/workspace/create" class="create-btn">Create Workspace</a>
</div>

<div class="workspace-list">
<a *ngFor="let ws of workspaces" [routerLink]="['/workspaces', ws.id]" class="workspace-card-link">
<div class="workspace-card">
<h3>{{ ws.name }}</h3>
<p>{{ ws.description }}</p>
<small>Created: {{ ws.createdDate | date }}</small>
<div class="workspace-list" *ngIf="workspaces.length > 0; else empty">
<article *ngFor="let ws of workspaces" class="workspace-card">
<h3>{{ ws.name }}</h3>
<p>{{ ws.description || 'No description yet.' }}</p>
<small>Created: {{ ws.createdDate | date: 'mediumDate' }}</small>
<div class="card-actions">
<a [routerLink]="['/workspaces', ws.id, 'decisions']" class="action-btn open-btn">Open</a>
<button type="button" class="action-btn edit-btn" (click)="editWorkspace(ws)">Edit</button>
<button type="button" class="action-btn delete-btn" (click)="deleteWorkspace(ws)">Delete</button>
</div>
</a>
</div>

<div *ngIf="workspaces.length === 0" class="empty-state">
<p>No workspaces found. Create one to get started!</p>
</article>
</div>

<ng-template #empty>
Expand Down
35 changes: 35 additions & 0 deletions src/app/components/dashboard/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,41 @@ export class Dashboard implements OnInit {
});
}

editWorkspace(workspace: Workspace) {
const updatedName = window.prompt('Edit workspace name', workspace.name)?.trim();
if (!updatedName) {
return;
}

const updatedDescriptionInput = window.prompt('Edit workspace description', workspace.description ?? '');
if (updatedDescriptionInput === null) {
return;
}

const updatedDescription = updatedDescriptionInput.trim();

this.workspaceService.updateWorkspace(workspace.id, updatedName, updatedDescription).subscribe(updatedWorkspace => {
if (!updatedWorkspace) {
return;
}
this.workspaces = this.workspaces.map(ws => ws.id === updatedWorkspace.id ? updatedWorkspace : ws);
});
}

deleteWorkspace(workspace: Workspace) {
const confirmed = window.confirm(`Delete workspace "${workspace.name}"?`);
if (!confirmed) {
return;
}

this.workspaceService.deleteWorkspace(workspace.id).subscribe(deleted => {
if (!deleted) {
return;
}
this.workspaces = this.workspaces.filter(ws => ws.id !== workspace.id);
});
}

logout() {
this.authService.logout();
this.router.navigate(['/login']);
Expand Down
55 changes: 39 additions & 16 deletions src/app/components/decision-form/decision-form.component.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
.form-container {
max-width: 600px;
margin: 20px auto;
margin: 8px auto 20px;
padding: 20px;
border: 1px solid #ddd;
border-radius: 4px;
border-radius: 12px;
background-color: #fff;
}

.form-header {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
margin-bottom: 16px;
}

.form-header h2 {
margin: 0;
}

.form-group {
margin-bottom: 15px;
}
Expand All @@ -19,9 +31,9 @@

.form-control {
width: 100%;
padding: 8px;
padding: 10px 11px;
border: 1px solid #ced4da;
border-radius: 4px;
border-radius: 8px;
box-sizing: border-box;
/* Ensures padding doesn't increase width */
}
Expand All @@ -44,24 +56,35 @@
}

.btn-primary {
background-color: #007bff;
color: white;
padding: 8px 16px;
border: none;
border-radius: 4px;
background-color: #111;
color: #fff;
padding: 8px 14px;
border: 1px solid #111;
border-radius: 8px;
cursor: pointer;
}

.btn-primary:disabled {
background-color: #a0c4ff;
background-color: #888;
border-color: #888;
cursor: not-allowed;
}

.btn-secondary {
background-color: #6c757d;
color: white;
padding: 8px 16px;
border: none;
border-radius: 4px;
background-color: #fff;
color: #111;
padding: 8px 14px;
border: 1px solid #cfcfcf;
border-radius: 8px;
cursor: pointer;
}
}

.btn-ghost {
background: #fff;
color: #111;
padding: 8px 12px;
text-decoration: none;
border-radius: 8px;
border: 1px solid #cfcfcf;
font-size: 13px;
}
9 changes: 6 additions & 3 deletions src/app/components/decision-form/decision-form.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<div class="form-container">
<h2>{{ isEditMode ? 'Edit Decision' : 'Create New Decision' }}</h2>
<div class="form-header">
<h2>{{ isEditMode ? 'Edit Decision' : 'Create New Decision' }}</h2>
<a routerLink="/dashboard" class="btn-ghost">Back to Dashboard</a>
</div>

<form [formGroup]="decisionForm" (ngSubmit)="onSubmit()">
<div class="form-group">
Expand Down Expand Up @@ -27,10 +30,10 @@ <h2>{{ isEditMode ? 'Edit Decision' : 'Create New Decision' }}</h2>
</div>

<div class="form-actions">
<button type="button" routerLink="../" class="btn-secondary">Cancel</button>
<button type="button" routerLink="../" class="btn-secondary">Back</button>
<button type="submit" [disabled]="decisionForm.invalid || isLoading" class="btn-primary">
{{ isEditMode ? 'Update Decision' : 'Create Decision' }}
</button>
</div>
</form>
</div>
</div>
27 changes: 17 additions & 10 deletions src/app/components/decision-form/decision-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class DecisionFormComponent implements OnInit {
isEditMode = false;
decisionId: string | null = null;
isLoading = false;
workspaceId: string | null = null;

constructor(
private fb: FormBuilder,
Expand All @@ -32,13 +33,7 @@ export class DecisionFormComponent implements OnInit {
}

ngOnInit(): void {
// Get workspaceId from parent
this.route.parent?.paramMap.subscribe(params => {
const workspaceId = params.get('id');
if (workspaceId) {
this.decisionForm.patchValue({ workspaceId });
}
});
this.workspaceId = this.getWorkspaceIdFromRoute();

// Get decisionId from current route
this.route.paramMap.subscribe(params => {
Expand Down Expand Up @@ -78,11 +73,23 @@ export class DecisionFormComponent implements OnInit {
this.router.navigate(['../../'], { relativeTo: this.route });
});
} else {
// Include workspaceId from parent route if available
const workspaceId = this.route.parent?.snapshot.paramMap.get('id');
this.decisionService.createDecision({ ...formValue, workspaceId }).subscribe(() => {
if (!this.workspaceId) {
return;
}

this.decisionService.createDecision({ ...formValue, workspaceId: this.workspaceId }).subscribe(() => {
this.router.navigate(['../'], { relativeTo: this.route });
});
}
}

private getWorkspaceIdFromRoute(): string | null {
for (const route of this.route.pathFromRoot) {
const id = route.snapshot.paramMap.get('id');
if (id) {
return id;
}
}
return null;
}
}
Loading