[FIX] Fix the issue withe percu.
This commit is contained in:
@@ -203,9 +203,17 @@
|
||||
</td>
|
||||
<td class="px-3 py-4 text-sm text-gray-500">{score.compositor || '-'}</td>
|
||||
<td class="whitespace-nowrap px-3 py-4 text-right text-sm">
|
||||
<div class="flex justify-end gap-2">
|
||||
<a href="/admin/{score.id}" class="btn btn-ghost px-2 py-1">
|
||||
Voir
|
||||
<div class="flex justify-end gap-1">
|
||||
<a
|
||||
href="/admin/{score.id}"
|
||||
class="rounded-full p-1.5 text-ohmj-primary hover:bg-ohmj-light"
|
||||
title="Voir la partition"
|
||||
aria-label="Voir la partition"
|
||||
>
|
||||
<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
|
||||
</svg>
|
||||
</a>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -51,15 +51,30 @@
|
||||
let combinedParts = $state<CombinedPart[]>([
|
||||
{ instrument: '', key: '', clef: '', part: '1' }
|
||||
]);
|
||||
|
||||
// Percussions (`per`): one or more instruments sharing the part
|
||||
type PercussionPart = { name: string; part: string };
|
||||
const PERCUSSIONS = [
|
||||
'batterie', 'glockenspiel', 'xylophone', 'vibraphone', 'timbales', 'grosse_caisse',
|
||||
'caisse_claire', 'cymbale', 'triangle', 'tambour', 'tam_tam', 'tom', 'gong',
|
||||
'bongos', 'maracas', 'tambourine', 'woodblock', 'claves', 'percussion'
|
||||
];
|
||||
let percussionParts = $state<PercussionPart[]>([{ name: '', part: '1' }]);
|
||||
|
||||
let uploadCombined = $derived(
|
||||
combinedParts
|
||||
.filter((p) => p.instrument)
|
||||
.map((p) =>
|
||||
[getInstrumentFile(p.instrument), p.key, p.clef, p.part]
|
||||
.filter((v) => v !== '')
|
||||
.join('-')
|
||||
)
|
||||
.join('+')
|
||||
uploadInstrument === 'per'
|
||||
? percussionParts
|
||||
.filter((p) => p.name)
|
||||
.map((p) => [p.name, p.part].filter((v) => v !== '').join('-'))
|
||||
.join('+')
|
||||
: combinedParts
|
||||
.filter((p) => p.instrument)
|
||||
.map((p) =>
|
||||
[getInstrumentFile(p.instrument), p.key, p.clef, p.part]
|
||||
.filter((v) => v !== '')
|
||||
.join('-')
|
||||
)
|
||||
.join('+')
|
||||
);
|
||||
let uploadWatermarkPosition = $state<'left' | 'right'>('left');
|
||||
|
||||
@@ -148,8 +163,8 @@
|
||||
|
||||
function getExpectedFilename(): string {
|
||||
if (!uploadInstrument) return '';
|
||||
// sup/par: the file is named after the combined instruments (see NAMING.md)
|
||||
if (uploadInstrument === 'sup' || uploadInstrument === 'par') {
|
||||
// sup/par/per: the file is named after the real instrument(s) (see NAMING.md)
|
||||
if (['sup', 'par', 'per'].includes(uploadInstrument)) {
|
||||
const combined = uploadCombined.trim().toLowerCase();
|
||||
return combined ? `${combined}.pdf` : '';
|
||||
}
|
||||
@@ -540,6 +555,54 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if uploadInstrument === 'per'}
|
||||
<div>
|
||||
<span class="label">Percussions</span>
|
||||
<div class="mt-1 space-y-2">
|
||||
{#each percussionParts as p, i}
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<select bind:value={p.name} class="input w-48" aria-label="Percussion {i + 1}">
|
||||
<option value="">Instrument…</option>
|
||||
{#each PERCUSSIONS as perc}
|
||||
<option value={perc}>{perc}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<input
|
||||
bind:value={p.part}
|
||||
class="input w-20"
|
||||
placeholder="Partie"
|
||||
aria-label="Partie percussion {i + 1}"
|
||||
/>
|
||||
{#if percussionParts.length > 1}
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => (percussionParts = percussionParts.filter((_, k) => k !== i))}
|
||||
class="rounded-full p-1.5 text-red-500 hover:bg-red-50 hover:text-red-700"
|
||||
title="Retirer"
|
||||
aria-label="Retirer la percussion {i + 1}"
|
||||
>
|
||||
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => (percussionParts = [...percussionParts, { name: '', part: '1' }])}
|
||||
class="btn btn-ghost mt-2 px-2 py-1"
|
||||
>
|
||||
+ Ajouter une percussion
|
||||
</button>
|
||||
<p class="mt-1 text-xs text-gray-400">
|
||||
Instruments de percussion reliés par « + » si plusieurs jouent la même partition
|
||||
(ex. <code>glockenspiel-1+xylophone-1</code>).
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user