fix(web): a poll asks its own question instead of a stock one

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 21:45:07 +02:00
parent f36c31e66d
commit 41f81cd2b0
2 changed files with 41 additions and 27 deletions

View File

@@ -1365,9 +1365,16 @@ const MAX_FILE_BYTES = 25 * 1024 * 1024;
<fieldset class="ts-poll-editor">
<legend>Encuesta · de 2 a 6 opciones</legend>
<p class="ts-poll-editor__hint">
La pregunta va en el texto de arriba. Se publica con el
comentario, al pulsar «Publicar encuesta».
Se publica con el comentario, al pulsar «Publicar
encuesta». El texto de arriba es opcional.
</p>
<pi-text-field
placeholder="¿Stripe o Redsys para los pagos?"
[value]="pollQuestion()"
(valueChange)="pollQuestion.set($event.slice(0, 200))"
>
<pi-label [isRequired]="true">Pregunta</pi-label>
</pi-text-field>
@for (option of pollOptions(); track $index) {
<div class="ts-poll-editor__row">
<pi-text-field
@@ -1446,7 +1453,7 @@ const MAX_FILE_BYTES = 25 * 1024 * 1024;
[text]="pollOn() ? 'Publicar encuesta' : 'Comentar'"
[disabled]="
pollOn()
? pollReady() < 2
? !pollQuestion().trim() || pollReady() < 2
: !commentBody().trim() && !commentFiles().length
"
(execute)="addComment()"
@@ -2583,11 +2590,12 @@ export class IssuePage {
protected addComment(): void {
const files = this.commentFiles();
// Only files (a recording, say) need no words: their names say it.
const text = this.commentBody().trim();
const question = this.pollOn() ? this.pollQuestion().trim() : '';
// A poll's question heads the comment; the text, if any, follows.
const body =
this.commentBody().trim() ||
// A poll alone asks its own question.
(this.pollOn() ? '📊 ¿Qué opción preferís?' : '') ||
(question ? `**${question}**${text ? `\n\n${text}` : ''}` : text) ||
// Only files (a recording, say) need no words: their names say it.
(files.length === 1
? `📎 ${files[0].name}`
: files.length
@@ -2597,6 +2605,10 @@ export class IssuePage {
const options = this.pollOptions()
.map((o) => o.trim())
.filter(Boolean);
if (this.pollOn() && !question) {
this.toast.error('Escribe la pregunta de la encuesta');
return;
}
if (this.pollOn() && options.length < 2) {
this.toast.error('Una encuesta necesita al menos dos opciones');
return;
@@ -2609,6 +2621,7 @@ export class IssuePage {
/** A quick poll in the new comment: its options while it is written. */
protected readonly pollOn = signal(false);
protected readonly pollQuestion = signal('');
protected readonly pollOptions = signal<string[]>(['', '']);
/** Options written so far: two make a poll ready to publish. */
protected readonly pollReady = computed(
@@ -2616,6 +2629,7 @@ export class IssuePage {
);
protected startPoll(): void {
this.pollQuestion.set('');
this.pollOptions.set(['', '']);
this.pollOn.set(true);
}