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 >
5943import { defineComponent } from ' vue' ;
6044import type { ContentNavigationStrategyData } from ' @vue-skuilder/db/src/core/types/contentNavigationStrategy' ;
6145import NavigationStrategyList from ' ./NavigationStrategyList.vue' ;
62- import NavigationStrategyForm from ' ./NavigationStrategyForm.vue' ;
6346import { getDataLayer , DocType , Navigators } from ' @vue-skuilder/db' ;
6447
6548export 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 ;
0 commit comments