Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python
3.5 KB
Raw Blame
<!-- Add Speaker Modal (design system v1) -->
<div v-if="showAddSpeakerModal" @click.self="closeAddSpeakerModal" class="modal-overlay">
    <div class="modal-panel modal-panel--sm">
        <div class="modal-header">
            <h3 class="modal-title" v-text="t('modal.addSpeaker')"></h3>
            <button @click="closeAddSpeakerModal" class="modal-close" :title="t('buttons.close')"><i class="fas fa-times"></i></button>
        </div>
        <div class="modal-body">
            <!-- "This is Me" checkbox -->
            <div class="mb-4">
                <label class="flex items-center text-sm text-[var(--text-muted)] cursor-pointer hover:text-[var(--text-primary)] transition-colors">
                    <input type="checkbox" v-model="newSpeakerIsMe" class="speaker-checkbox">
                    <span class="ml-2 select-none" v-text="t('help.me')"></span>
                </label>
            </div>

            <!-- Speaker name input -->
            <div class="mb-2 relative">
                <label class="block text-sm font-medium text-[var(--text-secondary)] mb-2" v-text="t('help.speakerName')"></label>
                <input
                    type="text"
                    v-model="newSpeakerName"
                    @input="searchNewSpeaker"
                    @focus="showNewSpeakerSuggestions = true"
                    @blur="hideNewSpeakerSuggestionsDelayed"
                    :disabled="newSpeakerIsMe"
                    :placeholder="newSpeakerIsMe ? currentUserName : t('help.enterSpeakerName')"
                    class="field"
                    @keyup.enter="addNewSpeaker"
                    autocomplete="off">

                <div v-if="loadingNewSpeakerSuggestions && !newSpeakerIsMe" class="absolute right-3 top-[42px] transform -translate-y-1/2">
                    <div class="spinner"></div>
                </div>

                <div v-if="showNewSpeakerSuggestions && newSpeakerSuggestions.length > 0 && !newSpeakerIsMe"
                     @click.stop
                     class="absolute z-10 w-full mt-1 surface-raised max-h-48 overflow-y-auto">
                    <div class="py-1">
                        <div v-for="suggestion in newSpeakerSuggestions" :key="suggestion.id"
                             @click="selectNewSpeakerSuggestion(suggestion)"
                             class="px-3 py-2 cursor-pointer hover:bg-[var(--bg-tertiary)] flex items-center justify-between">
                            <div class="flex-grow">
                                <div class="t-body-strong">${ suggestion.name }</div>
                                <div class="t-meta">
                                    <span v-text="tc('speakerModal.usedTimes', suggestion.use_count, { count: suggestion.use_count })"></span>
                                    <span v-if="suggestion.last_used" v-text="' • ' + t('speakerModal.lastUsed', { date: parseServerInstant(suggestion.last_used).toLocaleDateString(uiLocale()) })"></span>
                                </div>
                            </div>
                            <i class="fas fa-user text-[var(--text-muted)] ml-2"></i>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <button @click="closeAddSpeakerModal" class="btn btn--ghost" v-text="t('common.cancel')"></button>
            <button @click="addNewSpeaker" class="btn btn--primary" v-text="t('buttons.addSpeaker')"></button>
        </div>
    </div>
</div>