This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
KnowledgeBase/files/client/custom/modules/knowledge-base/res/templates/kb/index.tpl
T
chaim db7b30e3c0 feat: Phase 4 — topic CRUD UI in 'ניהול' tab
Adds a topics-management panel above the sources table. Admins can
create new legal domains (דיני עבודה, דין פלילי, נדל"ן) without
running SQL — slug + name + description + system prompt addendum
all live in one inline form. Per-row actions:

  ✏ Edit          — opens inline form with all fields except slug
                    (slug is locked post-create — the S3 layout
                    depends on it)
  👁 Toggle active — soft-disable: hides the topic from the user-facing
                    <select> while keeping data intact. Eye icon
                    flips between "השבת" and "הפעל"
  🗑 Delete       — hard-delete; only allowed when source_count=0.
                    Otherwise the UI directs the user to soft-disable
                    instead

Any topic mutation (create / rename / toggle / delete) invalidates
the cached _topics list so the user-facing dropdown re-fetches
immediately — admins don't have to refresh the page to see their
own changes.

Service.request() now distinguishes 4xx from 5xx upstream errors:
4xx is rethrown as BadRequest (so the user sees "slug already exists"
instead of a generic 500), 5xx stays as Error.

Backend: depends on shira-hermes commit 49503ca (admin topic
endpoints). No new migration — kb_topic schema from migration 001
is sufficient.

Description field in manifest was rewritten to Hebrew to match the
in-CRM scopeNames label ("מאגר ידע").

Refs Task Master #15

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-25 17:46:51 +00:00

181 lines
10 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>
<li class="{{#ifEqual mode 'manage'}}active{{/ifEqual}}">
<a href="#" role="button" data-action="switchMode" data-mode="manage">ניהול</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>
<option value="caselaw">פסיקה</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}}
{{#ifEqual mode 'manage'}}
<div class="kb-manage" style="display:flex;flex-direction:column;gap:16px;">
<div class="panel panel-default kb-topics-panel" style="padding:12px;">
<div style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px;margin-bottom:8px;">
<h4 style="margin:0;">נושאים (תחומי משפט)</h4>
<div style="display:flex;gap:8px;">
<button type="button" class="btn btn-default btn-sm" data-action="refreshTopics" title="רענן">
<span class="glyphicon glyphicon-refresh"></span>
</button>
<button type="button" class="btn btn-primary btn-sm" data-action="newTopic">
<span class="glyphicon glyphicon-plus"></span> נושא חדש
</button>
</div>
</div>
<div class="kb-topics-table">
<div class="text-muted">טוען נושאים…</div>
</div>
</div>
<div class="panel panel-default kb-sources-panel" style="padding:12px;">
<div style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px;margin-bottom:8px;">
<h4 style="margin:0;">מקורות בנושא<span class="kb-topic-name-suffix"></span></h4>
<div style="display:flex;gap:8px;align-items:center;">
<select class="form-control kb-sources-kind-filter" style="width:auto;">
<option value="">כל הסוגים</option>
<option value="law">חוק</option>
<option value="regulation">תקנות</option>
<option value="circular">חוזרים</option>
<option value="caselaw">פסיקה</option>
</select>
<button type="button" class="btn btn-default btn-sm" data-action="refreshSources" title="רענן">
<span class="glyphicon glyphicon-refresh"></span>
</button>
</div>
</div>
<div class="kb-sources-table">
<div class="text-muted">טוען מקורות…</div>
</div>
</div>
<div class="panel panel-default" style="padding:12px;">
<h4 style="margin-top:0;">העלאת מסמך חדש</h4>
<form class="kb-upload-form" enctype="multipart/form-data"
style="display:flex;flex-direction:column;gap:10px;">
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap;">
<label for="kb-upload-file" class="text-muted" style="margin:0;font-weight:normal;min-width:80px;">קובץ:</label>
<input type="file" id="kb-upload-file" name="file"
accept=".pdf,.docx,.txt"
style="flex:1 1 280px;" />
</div>
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap;">
<label for="kb-upload-kind" class="text-muted" style="margin:0;font-weight:normal;min-width:80px;">סוג:</label>
<select id="kb-upload-kind" class="form-control" name="kind"
style="flex:0 0 auto;width:200px;">
<option value="law">חוק</option>
<option value="regulation">תקנות</option>
<option value="circular">חוזר</option>
<option value="caselaw">פסיקה</option>
</select>
</div>
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap;">
<label for="kb-upload-title" class="text-muted" style="margin:0;font-weight:normal;min-width:80px;">כותרת:</label>
<input type="text" id="kb-upload-title" class="form-control" name="title"
placeholder="ברירת מחדל: שם הקובץ"
style="flex:1 1 280px;" />
</div>
<details>
<summary class="text-muted" style="cursor:pointer;">מטא-דאטה נוסף (אופציונלי)</summary>
<div style="display:flex;flex-direction:column;gap:8px;margin-top:8px;padding-right:12px;">
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap;">
<label class="text-muted" style="margin:0;font-weight:normal;min-width:80px;">מזהה:</label>
<input type="text" class="form-control" name="identifier"
placeholder="למשל: ח'(353) 14.1.2018"
style="flex:1 1 280px;" />
</div>
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap;">
<label class="text-muted" style="margin:0;font-weight:normal;min-width:80px;">פורסם ב:</label>
<input type="date" class="form-control" name="published_at"
style="flex:0 0 auto;width:200px;" />
<label class="text-muted" style="margin:0;font-weight:normal;">תוקף מ:</label>
<input type="date" class="form-control" name="effective_at"
style="flex:0 0 auto;width:200px;" />
</div>
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap;">
<label class="text-muted" style="margin:0;font-weight:normal;min-width:80px;">קישור מקור:</label>
<input type="url" class="form-control" name="source_url"
placeholder="https://…"
style="flex:1 1 280px;" />
</div>
</div>
</details>
<div style="display:flex;gap:8px;align-items:center;">
<button type="button" class="btn btn-primary" data-action="submitUpload">העלה</button>
<span class="kb-upload-hint text-muted small">מקסימום 50MB. PDF / DOCX / TXT.</span>
</div>
</form>
</div>
<div class="panel panel-default" style="padding:12px;">
<h4 style="margin-top:0;">משימות אחרונות</h4>
<div class="kb-jobs-list">
<div class="text-muted">טוען…</div>
</div>
</div>
</div>
{{/ifEqual}}
<div class="kb-results" style="margin-top:12px;"></div>
</div>