Refactor match and predefined activity services for improved functionality and user experience
Removed unnecessary logging from the MatchService to streamline performance. Enhanced the PredefinedActivityService by implementing a more intelligent search feature that splits queries into individual terms, allowing for more precise filtering of activities. Updated the frontend PredefinedActivities.vue to include a search input with real-time results and a clear search button, improving user interaction and accessibility.
This commit is contained in:
@@ -6,10 +6,20 @@
|
||||
<div class="toolbar">
|
||||
<button @click="startCreate" class="btn-primary">Neu</button>
|
||||
<button @click="reload" class="btn-secondary">Neu laden</button>
|
||||
<div>
|
||||
</div>
|
||||
<div class="search-section">
|
||||
<input
|
||||
type="text"
|
||||
v-model="searchQuery"
|
||||
@input="onSearchInput"
|
||||
placeholder="Kürzel suchen (z.B. 'as vh us' oder 'vh as us')..."
|
||||
class="search-input"
|
||||
/>
|
||||
<button v-if="searchQuery" @click="clearSearch" class="btn-clear-search">✕</button>
|
||||
</div>
|
||||
<div>
|
||||
<button @click="deduplicate" class="btn-secondary">Doppelungen zusammenführen</button>
|
||||
</div
|
||||
</div>
|
||||
<div class="merge-tools">
|
||||
<select v-model="mergeSourceId">
|
||||
<option disabled value="">Quelle wählen…</option>
|
||||
@@ -22,7 +32,6 @@
|
||||
</select>
|
||||
<button class="btn-secondary" :disabled="!canMerge" @click="mergeSelected">Zusammenführen</button>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="items">
|
||||
<li v-for="a in sortedActivities" :key="a.id" :class="{ active: selectedActivity && selectedActivity.id === a.id }" @click="select(a)">
|
||||
<div class="title">
|
||||
@@ -167,11 +176,17 @@ export default {
|
||||
selectedDrawingData: null,
|
||||
mergeSourceId: '',
|
||||
mergeTargetId: '',
|
||||
searchQuery: '',
|
||||
searchResults: [],
|
||||
isSearching: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
sortedActivities() {
|
||||
return [...(this.activities || [])].sort((a, b) => {
|
||||
// Wenn gesucht wird, zeige Suchergebnisse, sonst alle Aktivitäten
|
||||
const activitiesToSort = this.searchQuery.trim() ? this.searchResults : this.activities;
|
||||
|
||||
return [...(activitiesToSort || [])].sort((a, b) => {
|
||||
const ac = (a.code || '').toLocaleLowerCase('de-DE');
|
||||
const bc = (b.code || '').toLocaleLowerCase('de-DE');
|
||||
const aEmpty = ac === '';
|
||||
@@ -221,6 +236,34 @@ export default {
|
||||
this.confirmDialog.isOpen = false;
|
||||
},
|
||||
|
||||
// Suchfunktionen
|
||||
async onSearchInput() {
|
||||
const query = this.searchQuery.trim();
|
||||
|
||||
if (!query || query.length < 2) {
|
||||
this.searchResults = [];
|
||||
return;
|
||||
}
|
||||
|
||||
this.isSearching = true;
|
||||
try {
|
||||
const response = await apiClient.get('/predefined-activities/search/query', {
|
||||
params: { q: query, limit: 50 }
|
||||
});
|
||||
this.searchResults = response.data || [];
|
||||
} catch (error) {
|
||||
console.error('Error searching activities:', error);
|
||||
this.searchResults = [];
|
||||
} finally {
|
||||
this.isSearching = false;
|
||||
}
|
||||
},
|
||||
|
||||
clearSearch() {
|
||||
this.searchQuery = '';
|
||||
this.searchResults = [];
|
||||
},
|
||||
|
||||
parseDrawingData(value) {
|
||||
if (!value) return null;
|
||||
if (typeof value === 'object') return value;
|
||||
@@ -556,5 +599,52 @@ input[type="text"], input[type="number"], textarea { width: 100%; }
|
||||
color: #333;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
/* Suchfeld Styles */
|
||||
.search-section {
|
||||
position: relative;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 100%;
|
||||
padding: 0.75rem 2.5rem 0.75rem 1rem;
|
||||
border: 2px solid #ddd;
|
||||
border-radius: var(--border-radius);
|
||||
font-size: 1rem;
|
||||
background: white;
|
||||
transition: border-color 0.3s ease;
|
||||
}
|
||||
|
||||
.search-input:focus {
|
||||
outline: none;
|
||||
border-color: #007bff;
|
||||
box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
|
||||
}
|
||||
|
||||
.btn-clear-search {
|
||||
position: absolute;
|
||||
right: 0.75rem;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: none;
|
||||
border: none;
|
||||
color: #666;
|
||||
font-size: 1.2rem;
|
||||
cursor: pointer;
|
||||
padding: 0.25rem;
|
||||
border-radius: 50%;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.btn-clear-search:hover {
|
||||
background: #f8f9fa;
|
||||
color: #333;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user