|
85 | 85 | <div v-if="c.isOpen" class="px-4 py-2 bg-blue-grey-lighten-5"> |
86 | 86 | <card-loader :qualified_id="idQualify(c.id)" :view-lookup="viewLookup" class="elevation-1" /> |
87 | 87 |
|
| 88 | + <!-- Tags display for readonly mode --> |
| 89 | + <div v-if="editMode === 'readonly' && cardTags[idParse(c.id)]" class="mt-4"> |
| 90 | + <v-chip-group> |
| 91 | + <v-chip |
| 92 | + v-for="tag in cardTags[idParse(c.id)]" |
| 93 | + :key="tag.name" |
| 94 | + size="small" |
| 95 | + color="primary" |
| 96 | + variant="outlined" |
| 97 | + > |
| 98 | + {{ tag.name }} |
| 99 | + </v-chip> |
| 100 | + </v-chip-group> |
| 101 | + </div> |
| 102 | + |
88 | 103 | <tags-input |
89 | 104 | v-show="internalEditMode === 'tags' && editMode === 'full'" |
90 | 105 | :course-i-d="courseId" |
|
120 | 135 | <script lang="ts"> |
121 | 136 | import { defineComponent, PropType } from 'vue'; |
122 | 137 | import { displayableDataToViewData, Status, CourseElo } from '@vue-skuilder/common'; |
123 | | -import { getDataLayer, CourseDBInterface, CardData, DisplayableData, Tag } from '@vue-skuilder/db'; |
| 138 | +import { getDataLayer, CourseDBInterface, CardData, DisplayableData, Tag, TagStub } from '@vue-skuilder/db'; |
124 | 139 | // local imports |
125 | 140 | import TagsInput from './TagsInput.vue'; |
126 | 141 | import PaginatingToolbar from './PaginatingToolbar.vue'; |
@@ -173,6 +188,7 @@ export default defineComponent({ |
173 | 188 | cardData: {} as { [card: string]: string[] }, |
174 | 189 | cardPreview: {} as { [card: string]: string }, |
175 | 190 | cardElos: {} as Record<string, CourseElo>, |
| 191 | + cardTags: {} as Record<string, TagStub[]>, |
176 | 192 | internalEditMode: 'none' as 'tags' | 'flag' | 'none', |
177 | 193 | delBtn: false, |
178 | 194 | updatePending: true, |
@@ -244,6 +260,32 @@ export default defineComponent({ |
244 | 260 | this.page = n; |
245 | 261 | this.populateTableData(); |
246 | 262 | }, |
| 263 | + async loadCardTags(cardIds: string[]) { |
| 264 | + try { |
| 265 | + // Get all tags for the course |
| 266 | + const allTags = await this.courseDB!.getCourseTagStubs(); |
| 267 | + |
| 268 | + // For each card, find tags that include this card |
| 269 | + cardIds.forEach(cardId => { |
| 270 | + const cardTags: TagStub[] = []; |
| 271 | + |
| 272 | + // Check each tag to see if it contains this card |
| 273 | + allTags.rows.forEach(tagRow => { |
| 274 | + if (tagRow.doc && tagRow.doc.taggedCards.includes(cardId)) { |
| 275 | + cardTags.push({ |
| 276 | + name: tagRow.doc.name, |
| 277 | + snippet: tagRow.doc.snippet, |
| 278 | + count: tagRow.doc.taggedCards.length |
| 279 | + }); |
| 280 | + } |
| 281 | + }); |
| 282 | + |
| 283 | + this.cardTags[cardId] = cardTags; |
| 284 | + }); |
| 285 | + } catch (error) { |
| 286 | + console.error('Error loading card tags:', error); |
| 287 | + } |
| 288 | + }, |
247 | 289 | clearSelections(exception: string = '') { |
248 | 290 | this.cards.forEach((card) => { |
249 | 291 | if (card.id !== exception) { |
@@ -360,6 +402,9 @@ export default defineComponent({ |
360 | 402 | cardIds.forEach((cardId, index) => { |
361 | 403 | this.cardElos[cardId] = eloData[index]; |
362 | 404 | }); |
| 405 | +
|
| 406 | + // Load tags for each card |
| 407 | + await this.loadCardTags(cardIds); |
363 | 408 | } catch (error) { |
364 | 409 | console.error('Error populating table data:', error); |
365 | 410 | } finally { |
|
0 commit comments