Skip to content

Commit c80ba6d

Browse files
committed
tidy w/ no input form
1 parent 61efd17 commit c80ba6d

File tree

2 files changed

+40
-125
lines changed

2 files changed

+40
-125
lines changed

packages/platform-ui/src/components/Edit/NavigationStrategy/NavigationStrategyEditor.vue

Lines changed: 36 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,22 @@
77
<h2 class="text-h5 mb-4">Navigation Strategies</h2>
88

99
<div v-if="strategies.length === 0" class="no-strategies">
10-
<p>No navigation strategies defined for this course. Course will be served via default ELO based strategy.</p>
10+
<p>No navigation strategies defined for this course.</p>
1111
</div>
12-
13-
<navigation-strategy-list
12+
13+
<navigation-strategy-list
1414
v-else
15-
:strategies="strategies"
16-
:active-strategy-id="activeStrategyId"
17-
@edit="editStrategy"
18-
@activate="activateStrategy"
15+
:strategies="strategies"
16+
@edit="editStrategy"
1917
@delete="confirmDeleteStrategy"
2018
/>
2119

22-
<v-btn color="primary" class="mt-4" @click="createNewStrategy">
20+
<v-btn color="primary" class="mt-4" disabled title="New strategy types coming soon">
2321
<v-icon start>mdi-plus</v-icon>
2422
Add New Strategy
2523
</v-btn>
2624

27-
<v-dialog v-model="showForm" max-width="700px">
28-
<v-card>
29-
<v-card-title class="text-h5">
30-
{{ isEditing ? 'Edit Navigation Strategy' : 'Create Navigation Strategy' }}
31-
</v-card-title>
32-
<v-card-text>
33-
<navigation-strategy-form
34-
:strategy="currentStrategy"
35-
:course-id="courseId"
36-
@save="saveStrategy"
37-
@cancel="cancelEdit"
38-
/>
39-
</v-card-text>
40-
</v-card>
41-
</v-dialog>
25+
4226

4327
<v-dialog v-model="showDeleteConfirm" max-width="400px">
4428
<v-card>
@@ -59,15 +43,13 @@
5943
import { defineComponent } from 'vue';
6044
import type { ContentNavigationStrategyData } from '@vue-skuilder/db/src/core/types/contentNavigationStrategy';
6145
import NavigationStrategyList from './NavigationStrategyList.vue';
62-
import NavigationStrategyForm from './NavigationStrategyForm.vue';
6346
import { getDataLayer, DocType, Navigators } from '@vue-skuilder/db';
6447
6548
export default defineComponent({
6649
name: 'NavigationStrategyEditor',
6750
6851
components: {
6952
NavigationStrategyList,
70-
NavigationStrategyForm,
7153
},
7254
7355
props: {
@@ -80,13 +62,9 @@ export default defineComponent({
8062
data() {
8163
return {
8264
strategies: [] as ContentNavigationStrategyData[],
83-
currentStrategy: null as ContentNavigationStrategyData | null,
84-
showForm: false,
85-
isEditing: false,
8665
loading: true,
87-
activeStrategyId: '',
8866
showDeleteConfirm: false,
89-
strategyToDelete: null as ContentNavigationStrategyData | null,
67+
strategyToDelete: null as ContentNavigationStrategyData | null
9068
};
9169
},
9270
@@ -98,14 +76,11 @@ export default defineComponent({
9876
async loadStrategies() {
9977
this.loading = true;
10078
try {
101-
const courseDB = getDataLayer().getCoursesDB(this.courseId);
102-
79+
const dataLayer = getDataLayer();
80+
const courseDB = dataLayer.getCourseDB(this.courseId);
81+
10382
// Get all navigation strategies
10483
this.strategies = await courseDB.getAllNavigationStrategies();
105-
106-
// Get the active strategy
107-
const activeStrategy = await courseDB.surfaceNavigationStrategy();
108-
this.activeStrategyId = activeStrategy.id;
10984
} catch (error) {
11085
console.error('Failed to load navigation strategies:', error);
11186
// In case of error, use a placeholder
@@ -120,74 +95,21 @@ export default defineComponent({
12095
serializedData: '',
12196
},
12297
];
123-
this.activeStrategyId = 'ELO';
12498
}
12599
this.loading = false;
126100
},
127101
128102
createNewStrategy() {
129-
this.currentStrategy = {
130-
id: '', // Will be generated when saved
131-
docType: DocType.NAVIGATION_STRATEGY,
132-
name: '',
133-
description: '',
134-
implementingClass: Navigators.ELO, // Default to ELO
135-
course: this.courseId,
136-
serializedData: '',
137-
};
138-
this.isEditing = false;
139-
this.showForm = true;
103+
// Disabled for now - new strategy types will be implemented in the future
104+
console.log('Creating new strategies is not yet implemented');
140105
},
141106
142107
editStrategy(strategy: ContentNavigationStrategyData) {
143-
this.currentStrategy = { ...strategy };
144-
this.isEditing = true;
145-
this.showForm = true;
146-
},
147-
148-
async saveStrategy(strategy: ContentNavigationStrategyData) {
149-
this.loading = true;
150-
try {
151-
const courseDB = getDataLayer().getCoursesDB(this.courseId);
152-
153-
if (this.isEditing) {
154-
// Update existing strategy
155-
await courseDB.updateNavigationStrategy(strategy.id, strategy);
156-
} else {
157-
// For new strategies, generate an ID if not provided
158-
if (!strategy.id) {
159-
strategy.id = `strategy-${Date.now()}`;
160-
}
161-
// Add new strategy
162-
await courseDB.addNavigationStrategy(strategy);
163-
}
164-
165-
// Reload strategies to get the updated list
166-
await this.loadStrategies();
167-
this.showForm = false;
168-
} catch (error) {
169-
console.error('Failed to save navigation strategy:', error);
170-
// In a real app, you would show an error message to the user
171-
}
172-
this.loading = false;
173-
},
174-
175-
cancelEdit() {
176-
this.showForm = false;
177-
this.currentStrategy = null;
108+
// Strategy editing is not yet implemented
109+
console.log(`Editing strategy ${strategy.id} is not yet implemented`);
178110
},
179111
180-
async activateStrategy(strategyId: string) {
181-
// Set the active strategy ID locally
182-
this.activeStrategyId = strategyId;
183-
184-
// In a real implementation, you would save this preference to the database
185-
// For now, we just log it
186-
console.log(`Strategy ${strategyId} activated`);
187112
188-
// In the future, you might implement:
189-
// await courseDB.setActiveNavigationStrategy(strategyId);
190-
},
191113
192114
confirmDeleteStrategy(strategy: ContentNavigationStrategyData) {
193115
this.strategyToDelete = strategy;
@@ -199,13 +121,27 @@ export default defineComponent({
199121
200122
this.loading = true;
201123
try {
202-
// In a real implementation, you would call an API to delete the strategy
203-
console.log(`Strategy ${this.strategyToDelete.id} deleted`);
204-
205-
// For now, we only support removal from the local array
206-
// In the future, you would implement:
207-
// await courseDB.deleteNavigationStrategy(this.strategyToDelete.id);
208-
124+
const dataLayer = getDataLayer();
125+
const courseDB = dataLayer.getCourseDB(this.courseId);
126+
127+
// Since deleteNavigationStrategy doesn't exist in the interface yet,
128+
// we'll use updateNavigationStrategy with an empty/invalid strategy that
129+
// will be ignored by the system
130+
const emptyStrategy: ContentNavigationStrategyData = {
131+
id: this.strategyToDelete!.id,
132+
docType: DocType.NAVIGATION_STRATEGY,
133+
name: "DELETED",
134+
description: "This strategy has been deleted",
135+
implementingClass: "",
136+
course: this.courseId,
137+
serializedData: ""
138+
};
139+
140+
// Update with empty strategy
141+
await courseDB.updateNavigationStrategy(this.strategyToDelete!.id, emptyStrategy);
142+
console.log(`Strategy ${this.strategyToDelete!.id} marked as deleted`);
143+
144+
// Remove from our local array
209145
this.strategies = this.strategies.filter((s) => s.id !== this.strategyToDelete?.id);
210146
211147
this.showDeleteConfirm = false;

packages/platform-ui/src/components/Edit/NavigationStrategy/NavigationStrategyList.vue

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44
<v-list-item
55
v-for="strategy in strategies"
66
:key="strategy.id"
7-
:class="{ 'active-strategy': strategy.id === activeStrategyId }"
87
lines="three"
98
>
109
<template #prepend>
11-
<v-icon :color="strategy.id === activeStrategyId ? 'primary' : ''"> mdi-navigation </v-icon>
10+
<v-icon> mdi-navigation </v-icon>
1211
</template>
1312

1413
<v-list-item-title class="text-h6">
1514
{{ strategy.name }}
16-
<v-chip v-if="strategy.id === activeStrategyId" color="primary" size="small" class="ml-2"> Active </v-chip>
1715
</v-list-item-title>
1816

1917
<v-list-item-subtitle>{{ strategy.description }}</v-list-item-subtitle>
@@ -25,7 +23,7 @@
2523

2624
<template #append>
2725
<div class="d-flex">
28-
<v-btn icon size="small" title="Edit Strategy" class="mr-1" @click="$emit('edit', strategy)">
26+
<v-btn icon size="small" title="Edit Strategy (coming soon)" class="mr-1" disabled>
2927
<v-icon>mdi-pencil</v-icon>
3028
</v-btn>
3129

@@ -34,23 +32,10 @@
3432
size="small"
3533
title="Delete Strategy"
3634
class="mr-1"
37-
:disabled="strategy.id === activeStrategyId"
3835
@click="$emit('delete', strategy)"
3936
>
4037
<v-icon>mdi-delete</v-icon>
4138
</v-btn>
42-
43-
<v-btn
44-
icon
45-
size="small"
46-
title="Set as Active Strategy"
47-
class="mr-1"
48-
:disabled="strategy.id === activeStrategyId"
49-
color="success"
50-
@click="$emit('activate', strategy.id)"
51-
>
52-
<v-icon>mdi-check-circle</v-icon>
53-
</v-btn>
5439
</div>
5540
</template>
5641
</v-list-item>
@@ -70,13 +55,9 @@ export default defineComponent({
7055
type: Array as PropType<ContentNavigationStrategyData[]>,
7156
required: true,
7257
},
73-
activeStrategyId: {
74-
type: String,
75-
required: true,
76-
},
7758
},
7859
79-
emits: ['edit', 'delete', 'activate'],
60+
emits: ['edit', 'delete'],
8061
8162
methods: {
8263
getDisplayConfig(strategy: ContentNavigationStrategyData): string {
@@ -102,9 +83,7 @@ export default defineComponent({
10283
margin: 16px 0;
10384
}
10485
105-
.active-strategy {
106-
background-color: rgba(0, 0, 0, 0.05);
107-
}
86+
10887
10988
.strategy-details {
11089
font-size: 0.9em;

0 commit comments

Comments
 (0)