@asd20/ui 3.8.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asd20/ui",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "sideEffects": [
@@ -18,7 +18,7 @@
18
18
  idTag="-question"
19
19
  ref="question"
20
20
  v-model="questionText"
21
- @keyup.enter.stop.prevent="onAskQuestion"
21
+ @keyup.enter.native.stop.prevent="onAskQuestion"
22
22
  placeholder="Ask a question (preview)"
23
23
  />
24
24
  <asd20-button
@@ -73,32 +73,36 @@
73
73
  title="Ask a Question, or Search by Keyword"
74
74
  description="Use the top input for plain-language questions, then press 'Ask'; or search by keyword in the lower input box."
75
75
  />
76
- <div class="disclaimer">
77
- <p>
78
- AI generated answers can have errors. Please contact our
79
- <a href="www.asd20.org/help-desk">Help Desk</a> if you need
80
- additional information.
81
- </p>
82
- </div>
83
76
 
84
77
  <!-- Answers tab -->
85
78
  <div v-show="currentTab === 'Answers'" scrollable>
79
+ <div v-if="aiAnswer" class="disclaimer">
80
+ <p>
81
+ AI generated answers can have errors. Please contact our
82
+ <a href="www.asd20.org/help-desk">Help Desk</a> if you need
83
+ additional information.
84
+ </p>
85
+ </div>
86
+
86
87
  <div v-if="aiAnswer" class="asd20-site-search__ai-result">
87
88
  <h3>Answer</h3>
88
89
  <div class="asd20-site-search__ai-answer" v-html="aiAnswer" />
89
90
 
90
91
  <div
91
- v-if="aiUiSources.length"
92
+ v-if="aiGroupedSources.length"
92
93
  class="asd20-site-search__ai-sources"
93
94
  >
94
95
  <h4>Sources</h4>
95
96
  <ul>
96
- <li v-for="src in aiUiSources" :key="src.url || src.id">
97
- <strong>Content from: {{ src.hostLabel }}</strong
98
- ><br />
99
- <a :href="src.url" target="_blank" rel="noreferrer">
100
- {{ src.title }}
101
- </a>
97
+ <li v-for="group in aiGroupedSources" :key="group.hostLabel">
98
+ <strong>Content from: {{ group.hostLabel }}</strong>
99
+ <ul class="asd20-site-search__ai-source-list">
100
+ <li v-for="src in group.sources" :key="src.url || src.id">
101
+ <a :href="src.url" target="_blank" rel="noreferrer">
102
+ {{ src.title }}
103
+ </a>
104
+ </li>
105
+ </ul>
102
106
  </li>
103
107
  </ul>
104
108
  </div>
@@ -345,9 +349,39 @@ export default {
345
349
  aiUiSources() {
346
350
  return (this.aiSources || []).map(src => ({
347
351
  ...src,
348
- hostLabel: this.labelFromUrl(src.url),
352
+ hostLabel:
353
+ this.resolveOrgTitleFromUrl(src.url) || this.labelFromUrl(src.url),
349
354
  }))
350
355
  },
356
+ aiGroupedSources() {
357
+ const groups = new Map()
358
+ this.aiUiSources.forEach(src => {
359
+ const key = src.hostLabel || 'Academy District 20'
360
+ if (!groups.has(key)) {
361
+ groups.set(key, { hostLabel: key, sources: [] })
362
+ }
363
+ const group = groups.get(key)
364
+ const exists = group.sources.find(
365
+ s => (s.url && src.url && s.url === src.url) || (s.id && src.id && s.id === src.id)
366
+ )
367
+ if (!exists) {
368
+ group.sources.push(src)
369
+ }
370
+ })
371
+ const currentOrgTitle =
372
+ (this.organization && this.organization.title) || 'Academy District 20'
373
+ const currentLower = currentOrgTitle.toLowerCase()
374
+
375
+ return Array.from(groups.values()).sort((a, b) => {
376
+ const aIsCurrent =
377
+ (a.hostLabel || '').toLowerCase() === currentLower
378
+ const bIsCurrent =
379
+ (b.hostLabel || '').toLowerCase() === currentLower
380
+ if (aIsCurrent && !bIsCurrent) return -1
381
+ if (bIsCurrent && !aIsCurrent) return 1
382
+ return (a.hostLabel || '').localeCompare(b.hostLabel || '')
383
+ })
384
+ },
351
385
  },
352
386
 
353
387
  watch: {
@@ -447,6 +481,12 @@ export default {
447
481
  return 'Rampart High School'
448
482
  case 'pinecreek':
449
483
  return 'Pine Creek High School'
484
+ case 'dcchigh':
485
+ return 'Discovery Canyon Campus High School'
486
+ case 'liberty':
487
+ return 'Liberty High School'
488
+ case 'd20online':
489
+ return 'Academy Online High School'
450
490
  // add more mappings as needed
451
491
  default:
452
492
  return subdomain.charAt(0).toUpperCase() + subdomain.slice(1)
@@ -459,6 +499,26 @@ export default {
459
499
  }
460
500
  },
461
501
 
502
+ // Try to resolve the full organization title from organizationOptions by URL
503
+ resolveOrgTitleFromUrl(url) {
504
+ if (!url || !Array.isArray(this.organizationOptions)) return null
505
+ try {
506
+ const host = new URL(url).hostname.toLowerCase()
507
+ const match = this.organizationOptions.find((org) => {
508
+ if (!org || !org.website) return false
509
+ try {
510
+ const orgHost = new URL(org.website).hostname.toLowerCase()
511
+ return host === orgHost || host.endsWith(orgHost)
512
+ } catch {
513
+ return false
514
+ }
515
+ })
516
+ return match && match.title ? match.title : null
517
+ } catch {
518
+ return null
519
+ }
520
+ },
521
+
462
522
  // Called when user clicks Ask or presses Enter in question field
463
523
  onAskQuestion() {
464
524
  const q = (this.questionText || '').trim()
@@ -658,6 +718,22 @@ export default {
658
718
 
659
719
  &__ai-answer {
660
720
  margin-bottom: space(0.5);
721
+
722
+ ::v-deep ol,
723
+ ::v-deep ul {
724
+ display: block !important;
725
+ list-style-position: inside;
726
+ padding-left: 0;
727
+ margin-left: 0;
728
+ flex: 0 0 auto;
729
+ flex-wrap: nowrap;
730
+ }
731
+
732
+ ::v-deep li {
733
+ display: list-item;
734
+ flex: 0 0 auto;
735
+ width: auto;
736
+ }
661
737
  }
662
738
 
663
739
  &__ai-sources {
@@ -681,6 +757,19 @@ export default {
681
757
  }
682
758
  }
683
759
 
760
+ &__ai-source-list {
761
+ list-style: disc;
762
+ list-style-position: inside;
763
+ padding-left: 0;
764
+ margin: space(0.25) 0 0.35rem 0;
765
+
766
+ li {
767
+ display: list-item;
768
+ margin: 0;
769
+ padding: 0;
770
+ }
771
+ }
772
+
684
773
  &__ai-snippet {
685
774
  margin: 0;
686
775
  opacity: 0.85;