Browse Source

feat: secret questions in the AI chat take a hidden input and show the answer masked; review labels for SMS delivery settings

pull/16833/head
Igor Kulikov 3 weeks ago
parent
commit
58cf399e47
  1. 3
      ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts
  2. 16
      ui-ngx/src/app/modules/home/components/ai/ai-question.component.html
  3. 12
      ui-ngx/src/app/modules/home/components/ai/ai-question.component.ts
  4. 1
      ui-ngx/src/app/shared/models/solution-creator.models.ts
  5. 4
      ui-ngx/src/assets/locale/locale.constant-en_US.json

3
ui-ngx/src/app/modules/home/components/ai/ai-action.models.ts

@ -241,7 +241,8 @@ export function aiQuestionsOf(args: unknown): AiQuestion[] {
.slice(0, 6)
.map(option => ({label: option.label.trim(), hint: typeof option.hint === 'string' ? option.hint : undefined})),
recommended: Array.isArray(question.recommended) ? question.recommended.filter(label => typeof label === 'string') : undefined,
multiple: question.multiple === true
multiple: question.multiple === true,
secret: question.secret === true && !(Array.isArray(question.options) && question.options.length)
}));
}

16
ui-ngx/src/app/modules/home/components/ai/ai-question.component.html

@ -15,7 +15,7 @@
@for (item of answers; track item.question.id) {
<div class="k-q">
<span class="k-qt">{{ item.question.question }}</span>
<span class="k-opts"><button type="button" class="ob-chip" aria-pressed="true" disabled>{{ item.answer }}</button></span>
<span class="k-opts"><button type="button" class="ob-chip" aria-pressed="true" disabled>{{ shown(item) }}</button></span>
</div>
}
</div>
@ -78,12 +78,18 @@
<div class="k-ask-a">
@if (isFree(step)) {
<div class="k-optcards list">
<div class="k-optcard other free" (click)="freeArea.focus()">
<div class="k-optcard other free" (click)="$any($event.currentTarget).querySelector('.k-opt-input')?.focus()">
<span class="k-optbody">
<b>{{ 'ai-assistant.question.your-answer' | translate }}</b>
<textarea #freeArea class="k-opt-input" rows="1" spellcheck="false" [disabled]="disabled()"
[value]="otherText(step)" [placeholder]="'ai-assistant.question.type-answer' | translate"
[attr.aria-label]="step.question" (input)="type(step, freeArea)" (keydown.enter)="onEnter($event)"></textarea>
@if (step.secret) {
<input #secretInput class="k-opt-input" type="password" autocomplete="new-password" spellcheck="false" [disabled]="disabled()"
[value]="otherText(step)" [placeholder]="'ai-assistant.question.type-secret' | translate"
[attr.aria-label]="step.question" (input)="type(step, secretInput)" (keydown.enter)="onEnter($event)">
} @else {
<textarea #freeArea class="k-opt-input" rows="1" spellcheck="false" [disabled]="disabled()"
[value]="otherText(step)" [placeholder]="'ai-assistant.question.type-answer' | translate"
[attr.aria-label]="step.question" (input)="type(step, freeArea)" (keydown.enter)="onEnter($event)"></textarea>
}
</span>
</div>
</div>

12
ui-ngx/src/app/modules/home/components/ai/ai-question.component.ts

@ -133,11 +133,17 @@ export class AiQuestionComponent {
}
}
type(question: AiQuestion, area: HTMLTextAreaElement): void {
type(question: AiQuestion, area: HTMLTextAreaElement | HTMLInputElement): void {
this.pickOther(question);
this.typed.update(values => ({...values, [question.id]: area.value}));
area.style.height = 'auto';
area.style.height = area.scrollHeight + 'px';
if (area instanceof HTMLTextAreaElement) {
area.style.height = 'auto';
area.style.height = area.scrollHeight + 'px';
}
}
shown(item: {question: AiQuestion; answer: string}): string {
return item.question.secret && item.answer ? '••••••••' : item.answer;
}
next(): void {

1
ui-ngx/src/app/shared/models/solution-creator.models.ts

@ -74,6 +74,7 @@ export interface AiQuestion {
options: AiQuestionOption[];
recommended?: string | string[];
multiple?: boolean;
secret?: boolean;
}
export interface AiQuestionAnswer {

4
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -705,7 +705,8 @@
"none": "None",
"no-answer": "No answer",
"your-answer": "Your answer",
"type-answer": "Type the answer"
"type-answer": "Type the answer",
"type-secret": "Paste it here; it stays hidden"
},
"ai-assistant": "AI Assistant",
"configure-with-ai": "Configure with AI",
@ -1459,6 +1460,7 @@
"when": "Sends at",
"slack": "Slack",
"mobileApp": "Mobile app",
"sms": "SMS",
"body": "Message",
"keys": "Keys",
"scope": "Scope"

Loading…
Cancel
Save