Repository navigation
Expand file tree
/
Copy path.cursorrules
More file actions
842 lines (710 loc) · 17.3 KB
/
Copy path.cursorrules
File metadata and controls
842 lines (710 loc) · 17.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
# Task Manager UI - Cursor Rules
## Project Overview
Vue 3 + Vite SPA for task management system with time tracking capabilities.
## Tech Stack
- **Framework**: Vue 3 with Options API (primary) and Composition API (selective)
- **Build Tool**: Vite
- **Language**: TypeScript for types/actions/utilities, JavaScript for components/store/routes
- **State Management**: Vuex
- **Styling**: Tailwind CSS + SCSS
- **UI Components**: shadcn-vue, Radix Vue (headless components)
- **Icons**: lucide-vue-next
- **HTTP Client**: Axios
- **Rich Text**: Editor.js
- **Real-time**: Pusher
## Core Principles
- Do NOT write comments unless necessary for complex logic
- Examine project structure before making changes
- Do NOT rename existing methods and fields
- Do NOT perform major refactoring unless explicitly requested
- Prefer explicit over implicit code
- Follow existing naming conventions
## Component Structure
### Options API (Primary Pattern)
Use Options API with `defineComponent` for most components:
```vue
<template>
<!-- Template code -->
</template>
<script>
import { defineComponent } from 'vue';
export default defineComponent({
name: 'ComponentName',
components: {},
props: {
propName: {
type: String,
required: true
}
},
emits: ['event-name'],
data() {
return {
localState: null
};
},
computed: {
computedValue() {
return this.propName.toUpperCase();
}
},
watch: {
propName: {
handler(newVal, oldVal) {
// Watch logic
},
immediate: false,
deep: false
}
},
methods: {
handleAction() {
this.$emit('event-name', data);
}
},
created() {},
mounted() {},
unmounted() {}
});
</script>
<style lang="scss" scoped>
/* Component styles */
</style>
```
### Composition API (For Composables & Advanced Reactivity)
Use `setup()` function (NOT `<script setup>`) for advanced reactivity needs:
```vue
<script>
import { defineComponent, ref, computed, watch, onMounted } from 'vue';
export default defineComponent({
name: 'ComponentName',
setup() {
const state = ref(null);
const computed = computed(() => state.value?.property);
watch(state, (newVal) => {
// Watch logic
});
onMounted(() => {
// Mount logic
});
return {
state,
computed
};
}
});
</script>
```
**IMPORTANT**: Never use `<script setup>` syntax - this project uses explicit Options API/Composition API patterns.
## File Organization
### Directory Structure
```
src/
├── actions/ # API calls (TypeScript)
│ └── tmgr/ # Task manager API actions
├── components/ # Reusable components
│ ├── ui/ # shadcn-vue components
│ ├── general/ # General app components
│ ├── dashboard/ # Dashboard-specific components
│ ├── tasks/ # Task-specific components
│ └── modals/ # Modal components
├── composable/ # Composable functions (TypeScript)
├── pages/ # Route/page components
├── router/ # Route configuration
├── store/ # Vuex store modules
├── types/ # TypeScript type definitions
├── utils/ # Utility functions
├── assets/ # Static assets (styles, images)
└── plugins/ # Plugin configurations
```
### Naming Conventions
- **Components**: PascalCase (e.g., `TaskCard.vue`, `ActivityFeed.vue`)
- **Composables**: camelCase with 'use' prefix (e.g., `useDashboard.ts`, `useActivityFeed.ts`)
- **Actions**: camelCase (e.g., `fetchTasks.ts`, `updateTask.ts`)
- **Types**: PascalCase for interfaces/types (e.g., `Task`, `Workspace`)
- **Store modules**: camelCase (e.g., `filters.js`, `pusher.js`)
## TypeScript Usage
### API Actions Pattern
Place in `src/actions/tmgr/`:
```typescript
import { $axios } from '@/plugins/axios';
import type { AxiosResponse } from 'axios';
export interface TaskResponse {
id: number;
title: string;
status: string;
}
export interface CreateTaskPayload {
title: string;
workspace_id: number;
}
export async function fetchTasks(workspaceId: number): Promise<TaskResponse[]> {
const response: AxiosResponse<TaskResponse[]> = await $axios.get(
`/workspaces/${workspaceId}/tasks`
);
return response.data;
}
export async function createTask(payload: CreateTaskPayload): Promise<TaskResponse> {
const response: AxiosResponse<TaskResponse> = await $axios.post('/tasks', payload);
return response.data;
}
```
### Type Definitions
Place in `src/types/`:
```typescript
export interface Task {
id: number;
title: string;
description: string | null;
status_id: number;
workspace_id: number;
created_at: string;
updated_at: string;
}
export interface Workspace {
id: number;
name: string;
code: string;
created_at: string;
}
```
### Composables Pattern
Place in `src/composable/`:
```typescript
import { ref, computed, type Ref } from 'vue';
import { fetchTasks, type TaskResponse } from '@/actions/tmgr/tasks';
export function useTasks(workspaceId: Ref<number> | number) {
const tasks = ref<TaskResponse[]>([]);
const loading = ref(false);
const error = ref<Error | null>(null);
const taskCount = computed(() => tasks.value.length);
async function loadTasks() {
loading.value = true;
error.value = null;
try {
const id = typeof workspaceId === 'number' ? workspaceId : workspaceId.value;
tasks.value = await fetchTasks(id);
} catch (e) {
error.value = e as Error;
} finally {
loading.value = false;
}
}
return {
tasks,
loading,
error,
taskCount,
loadTasks
};
}
```
## State Management (Vuex)
### Store Structure
```
store/
├── index.js # Root store
├── filters.js # Filter state module
├── pusher.js # Pusher/real-time module
└── ...
```
### Accessing Store
In components:
```javascript
// Get state
this.$store.state.propertyName
// Get getters
this.$store.getters.getterName
// Commit mutations (synchronous)
this.$store.commit('mutationName', payload)
// Dispatch actions (asynchronous)
this.$store.dispatch('actionName', payload)
```
### Module Pattern
```javascript
export default {
state: {
items: []
},
getters: {
itemCount: (state) => state.items.length
},
mutations: {
SET_ITEMS(state, items) {
state.items = items;
}
},
actions: {
async loadItems({ commit }) {
const items = await fetchItems();
commit('SET_ITEMS', items);
}
}
};
```
### Persisted State
Critical state persisted to localStorage:
- Authentication token
- Color scheme (dark/light mode)
- Current workspace
- User preferences
## Styling Guidelines
### Tailwind CSS (Primary)
Use utility classes as the primary styling method:
```vue
<template>
<div class="flex items-center gap-4 p-4 bg-white dark:bg-gray-800 rounded-lg shadow-md">
<h2 class="text-xl font-semibold text-gray-900 dark:text-white">
Title
</h2>
<button class="px-4 py-2 bg-tmgr-blue text-white rounded hover:bg-tmgr-light-blue">
Action
</button>
</div>
</template>
```
### Custom Colors
Defined in `tailwind.config.js`:
- `tmgr-blue`: Primary brand color
- `tmgr-light-blue`: Secondary/hover states
- `tmgr-gray`: Neutral tones
### Dark Mode
Always support dark mode using `dark:` prefix:
```html
<div class="bg-white dark:bg-gray-900 text-gray-900 dark:text-white">
Content
</div>
```
Dark mode toggle managed via Vuex store and persisted to localStorage.
### SCSS (For Complex Styles)
Use scoped SCSS for component-specific complex styles:
```vue
<style lang="scss" scoped>
.component-wrapper {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 1rem;
.item {
transition: transform 0.2s ease;
&:hover {
transform: translateY(-2px);
}
}
}
</style>
```
### Global Styles
Import from `src/assets/styles/`:
- Base styles
- Typography
- Utilities
## Routing
### Route Definition
In `src/router/`:
```javascript
{
path: '/:workspace_code/tasks/:id',
name: 'task-detail',
component: () => import('@/pages/TaskDetailPage.vue'),
meta: {
requiresAuth: true,
title: 'Task Details',
transition: 'slide-left'
}
}
```
### Route Guards
```javascript
router.beforeEach((to, from, next) => {
if (to.meta.requiresAuth && !isAuthenticated()) {
next({ name: 'login' });
} else {
next();
}
});
```
### Navigation
```javascript
// Programmatic navigation
this.$router.push({ name: 'task-detail', params: { id: 123 } });
// With query params
this.$router.push({
name: 'tasks',
query: { status: 'active' }
});
```
## API Integration
### Axios Configuration
Use the configured instance:
```javascript
import { $axios } from '@/plugins/axios';
// GET request
const response = await $axios.get('/endpoint');
// POST request
const response = await $axios.post('/endpoint', payload);
// With params
const response = await $axios.get('/endpoint', {
params: { filter: 'active' }
});
```
### Error Handling
```typescript
async function fetchData() {
try {
const response = await $axios.get('/endpoint');
return response.data;
} catch (error) {
if (error.response) {
console.error('API Error:', error.response.data);
throw new Error(error.response.data.message);
} else if (error.request) {
console.error('Network Error:', error.request);
throw new Error('Network error occurred');
} else {
console.error('Error:', error.message);
throw error;
}
}
}
```
## Project-Specific Patterns
### Workspace Context
Always include workspace context in URLs and API calls:
```javascript
// URL pattern
`/${this.$store.state.currentWorkspace.code}/tasks`
// API call
await $axios.get(`/workspaces/${workspaceId}/tasks`);
```
### Modal System
Modal state controlled via Vuex:
```javascript
// Open modal
this.$store.commit('SET_CURRENT_TASK_ID_FOR_MODAL', taskId);
// Close modal
this.$store.commit('SET_CURRENT_TASK_ID_FOR_MODAL', null);
// Get modal state
this.$store.state.currentTaskIdForModal
```
Sync with browser URL:
```javascript
if (taskId) {
history.replaceState(null, '', `#task-${taskId}`);
} else {
history.replaceState(null, '', location.pathname);
}
```
### Active Task Timer
Track running timers globally:
```javascript
// Check if task is running
this.$store.getters.isTaskRunning(taskId)
// Get active task
this.$store.state.activeTaskId
// Update active task
this.$store.commit('SET_ACTIVE_TASK', taskId);
```
### Theme Toggle
```javascript
// Get current theme
this.$store.state.colorScheme // 'light' or 'dark'
// Toggle theme
this.$store.dispatch('toggleColorScheme');
// Apply to HTML element
document.documentElement.classList.toggle('dark', isDark);
```
### Pusher Integration
Real-time updates via Vuex module:
```javascript
// Subscribe to channel
this.$store.dispatch('pusher/subscribe', {
channel: `workspace.${workspaceId}`,
event: 'TaskUpdated',
handler: this.handleTaskUpdate
});
// Unsubscribe
this.$store.dispatch('pusher/unsubscribe', {
channel: `workspace.${workspaceId}`
});
```
## UI Components
### shadcn-vue Components
Import from `src/components/ui/`:
```vue
<script>
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Select } from '@/components/ui/select';
export default defineComponent({
components: {
Button,
Input,
Select
}
});
</script>
```
### Icons (lucide-vue-next)
```vue
<template>
<Plus :size="20" :stroke-width="2" />
<Check class="w-5 h-5 text-green-500" />
</template>
<script>
import { Plus, Check } from 'lucide-vue-next';
export default defineComponent({
components: { Plus, Check }
});
</script>
```
### Accessibility
- Use semantic HTML elements
- Include ARIA labels where needed
- Support keyboard navigation
- Maintain focus management in modals
- Test with screen readers
## Performance Optimization
### Lazy Loading Routes
```javascript
component: () => import('@/pages/TaskDetailPage.vue')
```
### Virtual Scrolling
For large lists, use vue-virtual-scroller or similar:
```vue
<RecycleScroller
:items="tasks"
:item-size="80"
key-field="id"
v-slot="{ item }"
>
<TaskCard :task="item" />
</RecycleScroller>
```
### Debouncing
For search inputs and frequent operations:
```javascript
import { debounce } from 'lodash-es';
export default defineComponent({
methods: {
handleSearch: debounce(function(query) {
this.search(query);
}, 300)
}
});
```
### Computed Properties
Memoize expensive computations:
```javascript
computed: {
filteredTasks() {
return this.tasks.filter(task =>
task.status === this.selectedStatus
);
}
}
```
### Watchers
Use wisely with immediate and deep options:
```javascript
watch: {
'filter.status': {
handler(newVal) {
this.loadTasks();
},
immediate: false
},
filterObject: {
handler(newVal) {
this.applyFilters();
},
deep: true
}
}
```
## Testing
### Jest Configuration
Tests located near components or in `tests/` folder.
### Component Testing
```javascript
import { mount } from '@vue/test-utils';
import TaskCard from '@/components/tasks/TaskCard.vue';
describe('TaskCard', () => {
it('renders task title', () => {
const wrapper = mount(TaskCard, {
props: {
task: { id: 1, title: 'Test Task' }
}
});
expect(wrapper.text()).toContain('Test Task');
});
});
```
### Mock API Calls
```javascript
jest.mock('@/actions/tmgr/tasks', () => ({
fetchTasks: jest.fn().mockResolvedValue([
{ id: 1, title: 'Task 1' }
])
}));
```
## Development Commands
```bash
# Install dependencies
npm install
# Development server
npm run dev
# Production build
npm run build
# Preview production build
npm run preview
# Run tests
npm run test
# Format code
npm run format
```
## Common Patterns
### Loading States
```vue
<template>
<div v-if="loading">Loading...</div>
<div v-else-if="error">Error: {{ error.message }}</div>
<div v-else>
<!-- Content -->
</div>
</template>
<script>
export default defineComponent({
data() {
return {
loading: false,
error: null
};
}
});
</script>
```
### Form Handling
```vue
<template>
<form @submit.prevent="handleSubmit">
<input v-model="form.title" type="text" required />
<button type="submit" :disabled="submitting">
{{ submitting ? 'Saving...' : 'Save' }}
</button>
</form>
</template>
<script>
export default defineComponent({
data() {
return {
form: {
title: ''
},
submitting: false
};
},
methods: {
async handleSubmit() {
this.submitting = true;
try {
await this.saveTask(this.form);
this.$emit('saved');
} catch (error) {
console.error('Save failed:', error);
} finally {
this.submitting = false;
}
}
}
});
</script>
```
### Conditional Rendering
```vue
<template>
<div v-if="hasPermission">Admin Content</div>
<div v-else-if="isAuthenticated">User Content</div>
<div v-else>Guest Content</div>
<div v-show="isVisible">Toggle Visibility</div>
</template>
```
### List Rendering
```vue
<template>
<div v-for="task in tasks" :key="task.id">
<TaskCard :task="task" @click="handleTaskClick(task)" />
</div>
</template>
```
## Security Considerations
- Never commit sensitive data (API keys, tokens)
- Validate user input before sending to API
- Sanitize rich text content (Editor.js)
- Use HTTPS for all API calls
- Implement CSRF protection
- Check authentication status before sensitive operations
- Validate workspace access before displaying data
## Code Quality Standards
### DO
- Follow existing patterns and conventions
- Use TypeScript for type definitions and API actions
- Implement proper error handling
- Test critical user flows
- Maintain accessibility standards
- Support dark mode in all components
- Keep components focused and reusable
- Use proper prop validation
- Emit events for parent communication
- Clean up event listeners in unmounted()
### DO NOT
- Write comments unless absolutely necessary
- Use `<script setup>` syntax
- Rename existing methods/fields without good reason
- Perform major refactoring without explicit request
- Skip form validation
- Ignore loading/error states
- Create components without proper types
- Mix TypeScript and JavaScript in same file
- Use `var` keyword (use `const` or `let`)
- Mutate props directly
- Access parent data directly (use props/events)
## Editor.js Integration
For rich text editing:
```javascript
import EditorJS from '@editorjs/editorjs';
const editor = new EditorJS({
holder: 'editorjs',
tools: {
// Configure tools
},
data: existingContent,
onChange: async () => {
const content = await editor.save();
this.handleContentChange(content);
}
});
```
## PWA Support
Service worker configured for offline capabilities:
- Cache static assets
- Cache API responses
- Handle offline/online status
- Show update prompts
## Multi-language Ready
Translation structure prepared in resources/lang:
```javascript
// Future i18n integration
this.$t('tasks.title')
this.$t('common.save')
```
## Debugging Tools
### Vue Devtools
Use Vue Devtools browser extension for:
- Component inspection
- Vuex state tracking
- Event monitoring
- Performance profiling
### Network Monitoring
Monitor API calls via browser DevTools Network tab.
### Error Tracking
Sentry integration available for production error tracking.