ba75463661
Wires the EspoCRM extension to the multi-topic backend introduced in
shira-hermes commit f03721e. The KB page header now shows a topic
<select> ('נושא:'); the user's selection persists in localStorage
('kb-topic') and is sent with every search/ask/sources call so cross-
domain bleed-over is impossible. Single seeded topic ('ביטוח לאומי')
means existing users see no functional change until a second topic is
added in Phase 4 (Task Master #15).
- Resources/routes.json: GET /KnowledgeBase/action/topics.
- Controllers/KnowledgeBase.php: actionTopics + topicId passthrough on
search/sources/ask. Numeric coercion for the request payload.
- Services/KnowledgeBaseService.php: listTopics(); search/listSources/
ask take an optional topicId and forward it as topic_id to upstream.
- EntryPoints/KnowledgeBaseAskStream.php: ?topicId=N becomes topic_id
in the JSON body sent to /kb/ask/stream.
- res/templates/kb/index.tpl: topic <select> in the page header,
with a kb-topic-name-suffix span that JS fills with the active name.
- src/views/kb/index.js: module-level _topics cache + LS_TOPIC. setup
reads localStorage; afterRender gates the picker fill + sources fetch
on topics being loaded so a stale id from a deleted topic doesn't
fire a 400-ing /sources call. switchTopic clears _activeAsk/Search +
_lastAsk/Search + sessionStorage entries + this._sources, then
reRenders. Cross-topic guard in afterRender drops cached state whose
topicId !== this.topicId. _activeAsk / _lastAsk / _activeSearch /
_lastSearch all carry topicId. EventSource URL gains &topicId.
Refs Task Master #12.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
71 lines
3.6 KiB
Smarty
71 lines
3.6 KiB
Smarty
<div class="kb-page" dir="rtl">
|
|
<div class="page-header" style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:12px;">
|
|
<h3 style="margin:0;">בסיס ידע<span class="kb-topic-name-suffix"></span></h3>
|
|
<div class="kb-topic-picker" style="display:flex;align-items:center;gap:8px;">
|
|
<label for="kb-topic-select" class="text-muted" style="margin:0;font-weight:normal;">נושא:</label>
|
|
<select id="kb-topic-select" class="form-control kb-topic-select" data-name="topic"
|
|
style="min-width:180px;">
|
|
<option value="">טוען…</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<ul class="nav nav-tabs" style="margin-bottom:12px;">
|
|
<li class="{{#ifEqual mode 'search'}}active{{/ifEqual}}">
|
|
<a href="#" role="button" data-action="switchMode" data-mode="search">חיפוש</a>
|
|
</li>
|
|
<li class="{{#ifEqual mode 'ask'}}active{{/ifEqual}}">
|
|
<a href="#" role="button" data-action="switchMode" data-mode="ask">שאל את שירה</a>
|
|
</li>
|
|
<li class="{{#ifEqual mode 'browse'}}active{{/ifEqual}}">
|
|
<a href="#" role="button" data-action="switchMode" data-mode="browse">עיון</a>
|
|
</li>
|
|
</ul>
|
|
|
|
{{#ifEqual mode 'search'}}
|
|
<div class="kb-search-box" style="margin-bottom:12px;">
|
|
<div class="form-inline" style="display:flex;gap:8px;flex-wrap:wrap;">
|
|
<input type="text" class="form-control" data-name="query"
|
|
placeholder="מונחי חיפוש…"
|
|
style="flex:1 1 320px;min-width:280px;" />
|
|
<select class="form-control" data-name="kind" style="flex:0 0 auto;">
|
|
<option value="any">כל הסוגים</option>
|
|
<option value="law">חוק</option>
|
|
<option value="regulation">תקנות</option>
|
|
<option value="circular">חוזרים</option>
|
|
</select>
|
|
<button type="button" class="btn btn-primary" data-action="submit">חפש</button>
|
|
<button type="button" class="btn btn-default" data-action="clearResults"
|
|
title="התחל חיפוש חדש (מנקה את התוצאות הקודמות)">חיפוש חדש</button>
|
|
</div>
|
|
<div class="small text-muted" style="margin-top:6px;">
|
|
חיפוש Hybrid: וקטורי + מילולי + rerank. מחזיר עד 8 קטעים רלוונטיים.
|
|
</div>
|
|
</div>
|
|
{{/ifEqual}}
|
|
|
|
{{#ifEqual mode 'ask'}}
|
|
<div class="kb-search-box" style="margin-bottom:12px;">
|
|
<div class="form-inline" style="display:flex;gap:8px;flex-wrap:wrap;">
|
|
<input type="text" class="form-control" data-name="query"
|
|
placeholder="שאלה בשפה חופשית…"
|
|
style="flex:1 1 320px;min-width:280px;" />
|
|
<button type="button" class="btn btn-primary" data-action="submit">שאל את שירה</button>
|
|
<button type="button" class="btn btn-default" data-action="clearResults"
|
|
title="התחל שאלה חדשה (מנקה את התשובה הקודמת)">שאלה חדשה</button>
|
|
</div>
|
|
<div class="small text-muted" style="margin-top:6px;">
|
|
שירה תחפש בבסיס הידע ותחזיר תשובה מסוכמת עם ציטוטים.
|
|
</div>
|
|
</div>
|
|
{{/ifEqual}}
|
|
|
|
{{#ifEqual mode 'browse'}}
|
|
<div class="kb-sources panel panel-default" style="padding:12px;">
|
|
<div class="text-muted">טוען מקורות…</div>
|
|
</div>
|
|
{{/ifEqual}}
|
|
|
|
<div class="kb-results" style="margin-top:12px;"></div>
|
|
</div>
|