mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-06 07:23:26 +00:00
Merge branch 'staging' into develop
Some checks failed
CI / build (push) Has been cancelled
CI / uitest (push) Has been cancelled
CI / uitest-pg (push) Has been cancelled
CI / uitest-qms (push) Has been cancelled
CI / uitest-workspaces (push) Has been cancelled
CI / svelte-check (push) Has been cancelled
CI / formatting (push) Has been cancelled
CI / test (push) Has been cancelled
CI / docker-build (push) Has been cancelled
CI / dist-build (push) Has been cancelled
Some checks failed
CI / build (push) Has been cancelled
CI / uitest (push) Has been cancelled
CI / uitest-pg (push) Has been cancelled
CI / uitest-qms (push) Has been cancelled
CI / uitest-workspaces (push) Has been cancelled
CI / svelte-check (push) Has been cancelled
CI / formatting (push) Has been cancelled
CI / test (push) Has been cancelled
CI / docker-build (push) Has been cancelled
CI / dist-build (push) Has been cancelled
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
commit
ce10156fe4
@ -19,7 +19,7 @@
|
|||||||
.underline {
|
.underline {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
|
||||||
input {
|
.antiEditBoxInput {
|
||||||
padding: 0.25rem 0.5rem;
|
padding: 0.25rem 0.5rem;
|
||||||
background-color: var(--theme-editbox-focus-color);
|
background-color: var(--theme-editbox-focus-color);
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
@ -43,7 +43,7 @@
|
|||||||
&:focus-within::after { content: ''; }
|
&:focus-within::after { content: ''; }
|
||||||
}
|
}
|
||||||
|
|
||||||
input {
|
.antiEditBoxInput {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
@ -86,7 +86,7 @@
|
|||||||
border-radius: .375rem;
|
border-radius: .375rem;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
|
|
||||||
input {
|
.antiEditBoxInput {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
|
||||||
&::placeholder { color: var(--theme-darker-color); }
|
&::placeholder { color: var(--theme-darker-color); }
|
||||||
@ -109,7 +109,7 @@
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
|
|
||||||
input {
|
.antiEditBoxInput {
|
||||||
font: inherit;
|
font: inherit;
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
@ -119,17 +119,17 @@
|
|||||||
&:hover input:not(:focus)::placeholder {
|
&:hover input:not(:focus)::placeholder {
|
||||||
color: var(--input-hover-PlaceholderColor);
|
color: var(--input-hover-PlaceholderColor);
|
||||||
}
|
}
|
||||||
input:focus::placeholder {
|
.antiEditBoxInput:focus::placeholder {
|
||||||
color: var(--input-focus-PlaceholderColor);
|
color: var(--input-focus-PlaceholderColor);
|
||||||
}
|
}
|
||||||
&.disabled {
|
&.disabled {
|
||||||
box-shadow: inset 0 0 0 1px var(--input-BorderColor);
|
box-shadow: inset 0 0 0 1px var(--input-BorderColor);
|
||||||
|
|
||||||
&,
|
&,
|
||||||
input {
|
.antiEditBoxInput {
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
input::placeholder {
|
.antiEditBoxInput::placeholder {
|
||||||
color: var(--input-PlaceholderColor);
|
color: var(--input-PlaceholderColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,4 +139,27 @@
|
|||||||
content: ' *';
|
content: ' *';
|
||||||
color: var(--theme-error-color);
|
color: var(--theme-error-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.antiEditBoxGridWrapper {
|
||||||
|
display: grid;
|
||||||
|
&::after {
|
||||||
|
content: attr(data-value) " ";
|
||||||
|
white-space: pre-wrap;
|
||||||
|
visibility: hidden;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
resize: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::after, textarea {
|
||||||
|
font: inherit;
|
||||||
|
outline: none;
|
||||||
|
background-color: transparent;
|
||||||
|
overflow: hidden;
|
||||||
|
grid-area: 1 / 1 / 2 / 2;
|
||||||
|
min-height: 1.25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
export let value: string | number | undefined = undefined
|
export let value: string | number | undefined = undefined
|
||||||
export let placeholder: IntlString = plugin.string.EditBoxPlaceholder
|
export let placeholder: IntlString = plugin.string.EditBoxPlaceholder
|
||||||
export let placeholderParam: any | undefined = undefined
|
export let placeholderParam: any | undefined = undefined
|
||||||
export let format: 'text' | 'password' | 'number' = 'text'
|
export let format: 'text' | 'password' | 'number' | 'text-multiline' = 'text'
|
||||||
export let maxDigitsAfterPoint: number | undefined = undefined
|
export let maxDigitsAfterPoint: number | undefined = undefined
|
||||||
export let kind: EditStyle = 'editbox'
|
export let kind: EditStyle = 'editbox'
|
||||||
export let autoFocus: boolean = false
|
export let autoFocus: boolean = false
|
||||||
@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
let input: HTMLInputElement
|
let input: HTMLInputElement | HTMLTextAreaElement
|
||||||
let phTranslate: string = ''
|
let phTranslate: string = ''
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
@ -135,8 +135,28 @@
|
|||||||
class:w-full={fullSize}
|
class:w-full={fullSize}
|
||||||
style:width={maxWidth}
|
style:width={maxWidth}
|
||||||
>
|
>
|
||||||
{#if format === 'password'}
|
{#if format === 'text-multiline'}
|
||||||
|
<div class="antiEditBoxGridWrapper" data-value={value}>
|
||||||
|
<textarea
|
||||||
|
rows="1"
|
||||||
|
class="antiEditBoxInput"
|
||||||
|
{disabled}
|
||||||
|
style:width={maxWidth}
|
||||||
|
bind:this={input}
|
||||||
|
bind:value
|
||||||
|
placeholder={phTranslate}
|
||||||
|
on:input={handleInput}
|
||||||
|
on:change
|
||||||
|
on:keydown
|
||||||
|
on:keypress
|
||||||
|
on:blur={() => {
|
||||||
|
dispatch('blur', value)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{:else if format === 'password'}
|
||||||
<input
|
<input
|
||||||
|
class="antiEditBoxInput"
|
||||||
{disabled}
|
{disabled}
|
||||||
style:width={maxWidth}
|
style:width={maxWidth}
|
||||||
id="userPassword"
|
id="userPassword"
|
||||||
@ -154,11 +174,11 @@
|
|||||||
/>
|
/>
|
||||||
{:else if format === 'number'}
|
{:else if format === 'number'}
|
||||||
<input
|
<input
|
||||||
|
class="antiEditBoxInput number"
|
||||||
{disabled}
|
{disabled}
|
||||||
style:width={maxWidth}
|
style:width={maxWidth}
|
||||||
bind:this={input}
|
bind:this={input}
|
||||||
type="number"
|
type="number"
|
||||||
class="number"
|
|
||||||
bind:value
|
bind:value
|
||||||
placeholder={phTranslate}
|
placeholder={phTranslate}
|
||||||
on:input={handleInput}
|
on:input={handleInput}
|
||||||
@ -171,6 +191,7 @@
|
|||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<input
|
<input
|
||||||
|
class="antiEditBoxInput"
|
||||||
{disabled}
|
{disabled}
|
||||||
style:width={maxWidth}
|
style:width={maxWidth}
|
||||||
bind:this={input}
|
bind:this={input}
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
"SurveySubmitConfirm": "You will not be able to change answers after that. Are you sure you want to submit now?",
|
"SurveySubmitConfirm": "You will not be able to change answers after that. Are you sure you want to submit now?",
|
||||||
"ValidateFail": "Some required questions are not answered",
|
"ValidateFail": "Some required questions are not answered",
|
||||||
"ValidateInfo": "This is how the form will look like for an user. Try to type answers and select options to test your survey. A green icon in the header above shows the form is filled properly",
|
"ValidateInfo": "This is how the form will look like for an user. Try to type answers and select options to test your survey. A green icon in the header above shows the form is filled properly",
|
||||||
"ValidateOk": "Form is filled correctly"
|
"ValidateOk": "Form is filled correctly",
|
||||||
|
"EditAnswers": "Edit answers"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
"SurveySubmitConfirm": "После этого вы больше не сможете изменять ответы. Вы уверены, что хотите завершить опрос сейчас?",
|
"SurveySubmitConfirm": "После этого вы больше не сможете изменять ответы. Вы уверены, что хотите завершить опрос сейчас?",
|
||||||
"ValidateFail": "Нет ответов на некоторые обязательные вопросы",
|
"ValidateFail": "Нет ответов на некоторые обязательные вопросы",
|
||||||
"ValidateInfo": "Так будет выглядеть форма для пользователя. Для проверки анкеты попробуйте вводить ответы и выбирать варианты. Зеленый значок в заголовке покажет, что форма заполнена правильно",
|
"ValidateInfo": "Так будет выглядеть форма для пользователя. Для проверки анкеты попробуйте вводить ответы и выбирать варианты. Зеленый значок в заголовке покажет, что форма заполнена правильно",
|
||||||
"ValidateOk": "Форма заполнена правильно"
|
"ValidateOk": "Форма заполнена правильно",
|
||||||
|
"EditAnswers": "Редактировать ответы"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="antiSection flex-gap-4">
|
<div class="antiSection flex-gap-4 poll mb-8">
|
||||||
{#if hasText(object.prompt)}
|
{#if hasText(object.prompt)}
|
||||||
<div class="antiSection-header">
|
<div class="antiSection-header">
|
||||||
<span class="antiSection-header__title">
|
<span class="antiSection-header__title">
|
||||||
@ -73,10 +73,16 @@
|
|||||||
<PollQuestion
|
<PollQuestion
|
||||||
bind:this={questionNodes[index]}
|
bind:this={questionNodes[index]}
|
||||||
bind:isAnswered={isAnswered[index]}
|
bind:isAnswered={isAnswered[index]}
|
||||||
readonly={readonly || object.isCompleted}
|
{readonly}
|
||||||
on:answered={saveAnswers}
|
on:answered={saveAnswers}
|
||||||
{question}
|
{question}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.poll {
|
||||||
|
user-select: text;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -35,6 +35,10 @@
|
|||||||
|
|
||||||
let object: Poll | undefined = undefined
|
let object: Poll | undefined = undefined
|
||||||
let canSubmit = false
|
let canSubmit = false
|
||||||
|
let requestUpdate = false
|
||||||
|
|
||||||
|
$: isCompleted = object?.isCompleted ?? false
|
||||||
|
$: editable = (!readonly && !isCompleted) || requestUpdate
|
||||||
|
|
||||||
$: updateObject(_id)
|
$: updateObject(_id)
|
||||||
|
|
||||||
@ -48,20 +52,22 @@
|
|||||||
if (object === undefined) {
|
if (object === undefined) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
showPopup(
|
requestUpdate = false
|
||||||
MessageBox,
|
// showPopup(
|
||||||
{
|
// MessageBox,
|
||||||
label: survey.string.SurveySubmit,
|
// {
|
||||||
message: survey.string.SurveySubmitConfirm
|
// label: survey.string.SurveySubmit,
|
||||||
},
|
// message: survey.string.SurveySubmitConfirm
|
||||||
undefined,
|
// },
|
||||||
async (result?: boolean) => {
|
// undefined,
|
||||||
if (result === true && object !== undefined) {
|
// async (result?: boolean) => {
|
||||||
|
// if (result === true && object !== undefined) {
|
||||||
|
// await getClient().updateDoc(object._class, object.space, object._id, { isCompleted: true })
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// )
|
||||||
await getClient().updateDoc(object._class, object.space, object._id, { isCompleted: true })
|
await getClient().updateDoc(object._class, object.space, object._id, { isCompleted: true })
|
||||||
}
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if object}
|
{#if object}
|
||||||
@ -85,8 +91,7 @@
|
|||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
|
|
||||||
<svelte:fragment slot="utils">
|
<svelte:fragment slot="utils">
|
||||||
{#if !readonly}
|
{#if editable}
|
||||||
{#if !(object.isCompleted ?? false)}
|
|
||||||
<Button
|
<Button
|
||||||
icon={survey.icon.Submit}
|
icon={survey.icon.Submit}
|
||||||
label={survey.string.SurveySubmit}
|
label={survey.string.SurveySubmit}
|
||||||
@ -95,6 +100,14 @@
|
|||||||
showTooltip={{ label: canSubmit ? undefined : survey.string.ValidateFail }}
|
showTooltip={{ label: canSubmit ? undefined : survey.string.ValidateFail }}
|
||||||
on:click={submit}
|
on:click={submit}
|
||||||
/>
|
/>
|
||||||
|
{:else}
|
||||||
|
<Button
|
||||||
|
icon={view.icon.Edit}
|
||||||
|
label={survey.string.EditAnswers}
|
||||||
|
on:click={() => {
|
||||||
|
requestUpdate = true
|
||||||
|
}}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<Button
|
<Button
|
||||||
icon={IconMoreH}
|
icon={IconMoreH}
|
||||||
@ -104,11 +117,10 @@
|
|||||||
showMenu(e, { object, excludedActions: [view.action.Open] })
|
showMenu(e, { object, excludedActions: [view.action.Open] })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
|
|
||||||
<div class="flex-col flex-grow flex-no-shrink">
|
<div class="flex-col flex-grow flex-no-shrink">
|
||||||
<EditPoll {object} {readonly} bind:canSubmit />
|
<EditPoll {object} readonly={!editable} bind:canSubmit />
|
||||||
</div>
|
</div>
|
||||||
</Panel>
|
</Panel>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -18,16 +18,16 @@
|
|||||||
import { MessageBox, getClient } from '@hcengineering/presentation'
|
import { MessageBox, getClient } from '@hcengineering/presentation'
|
||||||
import { Question, QuestionKind, Survey } from '@hcengineering/survey'
|
import { Question, QuestionKind, Survey } from '@hcengineering/survey'
|
||||||
import {
|
import {
|
||||||
|
ButtonIcon,
|
||||||
EditBox,
|
EditBox,
|
||||||
Icon,
|
Icon,
|
||||||
IconDelete,
|
IconDelete,
|
||||||
SelectPopup,
|
SelectPopup,
|
||||||
eventToHTMLElement,
|
eventToHTMLElement,
|
||||||
showPopup,
|
showPopup,
|
||||||
tooltip,
|
tooltip
|
||||||
ButtonIcon
|
|
||||||
} from '@hcengineering/ui'
|
} from '@hcengineering/ui'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher, onDestroy } from 'svelte'
|
||||||
import survey from '../plugin'
|
import survey from '../plugin'
|
||||||
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
@ -40,10 +40,17 @@
|
|||||||
let editQuestion: EditBox
|
let editQuestion: EditBox
|
||||||
let hovered: boolean = false
|
let hovered: boolean = false
|
||||||
|
|
||||||
$: question = parent?.questions?.[index] as Question
|
let defaultQuestion: Question = {
|
||||||
|
name: '',
|
||||||
|
kind: QuestionKind.STRING,
|
||||||
|
isMandatory: false,
|
||||||
|
hasCustomOption: false
|
||||||
|
}
|
||||||
|
|
||||||
|
$: question = (parent?.questions?.[index] as Question) ?? defaultQuestion
|
||||||
|
$: isNewQuestion = parent?.questions?.[index] === undefined
|
||||||
$: options = question?.options ?? []
|
$: options = question?.options ?? []
|
||||||
$: questionIcon =
|
$: questionIcon = isNewQuestion
|
||||||
question === undefined
|
|
||||||
? survey.icon.Question
|
? survey.icon.Question
|
||||||
: question.kind === QuestionKind.OPTIONS
|
: question.kind === QuestionKind.OPTIONS
|
||||||
? survey.icon.QuestionKindOptions
|
? survey.icon.QuestionKindOptions
|
||||||
@ -51,30 +58,48 @@
|
|||||||
? survey.icon.QuestionKindOption
|
? survey.icon.QuestionKindOption
|
||||||
: survey.icon.QuestionKindString
|
: survey.icon.QuestionKindString
|
||||||
|
|
||||||
|
let haveNameChanges = false
|
||||||
|
|
||||||
let newOption = ''
|
let newOption = ''
|
||||||
let newQuestion = ''
|
|
||||||
|
onDestroy(() => {
|
||||||
|
handleExit()
|
||||||
|
})
|
||||||
|
|
||||||
|
function handleExit (): void {
|
||||||
|
void handleNameChange()
|
||||||
|
}
|
||||||
|
|
||||||
async function updateParent (): Promise<void> {
|
async function updateParent (): Promise<void> {
|
||||||
await client.updateDoc(parent._class, parent.space, parent._id, { questions: parent.questions })
|
await client.updateDoc(parent._class, parent.space, parent._id, { questions: parent.questions })
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createQuestion (): Promise<void> {
|
$: if (isNewQuestion && question.name.trim() !== '') {
|
||||||
|
void createQuestion()
|
||||||
|
}
|
||||||
|
|
||||||
|
function createQuestion (): Promise<void> {
|
||||||
if (parent.questions === undefined) {
|
if (parent.questions === undefined) {
|
||||||
parent.questions = []
|
parent.questions = []
|
||||||
}
|
}
|
||||||
parent.questions.push({
|
parent.questions.push({ ...question })
|
||||||
name: newQuestion,
|
defaultQuestion = { ...defaultQuestion, name: '' }
|
||||||
kind: QuestionKind.STRING,
|
return updateParent()
|
||||||
isMandatory: false,
|
}
|
||||||
hasCustomOption: false
|
|
||||||
})
|
function handleNameChange (): Promise<void> | void {
|
||||||
await updateParent()
|
if (!haveNameChanges) return
|
||||||
newQuestion = ''
|
haveNameChanges = false
|
||||||
|
|
||||||
|
if (isNewQuestion) return createQuestion()
|
||||||
|
return changeName()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changeName (): Promise<void> {
|
async function changeName (): Promise<void> {
|
||||||
|
if (!isNewQuestion) {
|
||||||
await updateParent()
|
await updateParent()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function changeKind (kind: QuestionKind): Promise<void> {
|
async function changeKind (kind: QuestionKind): Promise<void> {
|
||||||
if (question.kind !== kind) {
|
if (question.kind !== kind) {
|
||||||
@ -348,6 +373,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:window on:beforeunload={handleExit} />
|
||||||
<div
|
<div
|
||||||
bind:this={rootElement}
|
bind:this={rootElement}
|
||||||
class="question-container flex-col flex-gap-2"
|
class="question-container flex-col flex-gap-2"
|
||||||
@ -357,27 +383,33 @@
|
|||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
<div class="flex-row-center flex-gap-3 text-base pr-2" on:click={focusQuestion}>
|
<div class="flex-row-center flex-gap-3 text-base pr-2" on:click={focusQuestion}>
|
||||||
{#if question === undefined}
|
{#if isNewQuestion}
|
||||||
<ButtonIcon size={'small'} disabled icon={survey.icon.Question} />
|
<div class="self-start">
|
||||||
<EditBox
|
<ButtonIcon size={'small'} disabled icon={questionIcon} />
|
||||||
bind:this={editQuestion}
|
</div>
|
||||||
kind={'editbox'}
|
|
||||||
placeholder={survey.string.QuestionPlaceholder}
|
|
||||||
bind:value={newQuestion}
|
|
||||||
on:change={createQuestion}
|
|
||||||
/>
|
|
||||||
{:else}
|
{:else}
|
||||||
<div role="presentation" draggable={!readonly} on:dragstart={rootDragStart} on:dragend={rootDragEnd}>
|
<div
|
||||||
|
class="self-start"
|
||||||
|
role="presentation"
|
||||||
|
draggable={!readonly}
|
||||||
|
on:dragstart={rootDragStart}
|
||||||
|
on:dragend={rootDragEnd}
|
||||||
|
>
|
||||||
<ButtonIcon size={'small'} disabled={readonly} icon={questionIcon} on:click={showQuestionParams} />
|
<ButtonIcon size={'small'} disabled={readonly} icon={questionIcon} on:click={showQuestionParams} />
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
<EditBox
|
<EditBox
|
||||||
bind:this={editQuestion}
|
bind:this={editQuestion}
|
||||||
kind={'editbox'}
|
format={'text-multiline'}
|
||||||
disabled={readonly}
|
disabled={readonly}
|
||||||
placeholder={survey.string.QuestionPlaceholderEmpty}
|
placeholder={survey.string.QuestionPlaceholderEmpty}
|
||||||
bind:value={question.name}
|
bind:value={question.name}
|
||||||
on:change={changeName}
|
on:input={() => {
|
||||||
|
haveNameChanges = true
|
||||||
|
}}
|
||||||
|
on:change={handleNameChange}
|
||||||
/>
|
/>
|
||||||
|
{#if !isNewQuestion}
|
||||||
{#if question.hasCustomOption && question.kind !== QuestionKind.STRING}
|
{#if question.hasCustomOption && question.kind !== QuestionKind.STRING}
|
||||||
<div class="flex-no-shrink" use:tooltip={{ label: survey.string.QuestionTooltipCustomOption }}>
|
<div class="flex-no-shrink" use:tooltip={{ label: survey.string.QuestionTooltipCustomOption }}>
|
||||||
<Icon icon={survey.icon.QuestionHasCustomOption} size={'small'} />
|
<Icon icon={survey.icon.QuestionHasCustomOption} size={'small'} />
|
||||||
@ -390,7 +422,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if question !== undefined && question.kind !== QuestionKind.STRING}
|
{#if !isNewQuestion && question.kind !== QuestionKind.STRING}
|
||||||
{#each options as option, index (index)}
|
{#each options as option, index (index)}
|
||||||
<div
|
<div
|
||||||
class="flex-row-center flex-gap-3 option"
|
class="flex-row-center flex-gap-3 option"
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
export let readonly: boolean = false
|
export let readonly: boolean = false
|
||||||
|
|
||||||
$: questions = object?.questions ?? []
|
$: questions = object?.questions ?? []
|
||||||
|
$: questionEditSlots = readonly ? questions : [...questions, {}]
|
||||||
|
|
||||||
async function nameChange (): Promise<void> {
|
async function nameChange (): Promise<void> {
|
||||||
await client.updateDoc(object._class, object.space, object._id, { name: object.name })
|
await client.updateDoc(object._class, object.space, object._id, { name: object.name })
|
||||||
@ -114,7 +115,7 @@
|
|||||||
<Label label={survey.string.Questions} />
|
<Label label={survey.string.Questions} />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{#each questions as question, index}
|
{#each questionEditSlots as question, index}
|
||||||
<div
|
<div
|
||||||
role="listitem"
|
role="listitem"
|
||||||
on:dragover={(ev) => {
|
on:dragover={(ev) => {
|
||||||
@ -129,6 +130,7 @@
|
|||||||
draggedOverIndex !== draggedIndex &&
|
draggedOverIndex !== draggedIndex &&
|
||||||
draggedOverIndex !== draggedIndex + 1}
|
draggedOverIndex !== draggedIndex + 1}
|
||||||
>
|
>
|
||||||
|
{#key index}
|
||||||
<EditQuestion
|
<EditQuestion
|
||||||
{index}
|
{index}
|
||||||
{readonly}
|
{readonly}
|
||||||
@ -141,23 +143,9 @@
|
|||||||
draggedOverIndex = undefined
|
draggedOverIndex = undefined
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{/key}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
{#if !readonly}
|
|
||||||
<div
|
|
||||||
role="listitem"
|
|
||||||
on:dragover={(ev) => {
|
|
||||||
dragOver(ev, questions.length)
|
|
||||||
}}
|
|
||||||
on:dragleave={(ev) => {
|
|
||||||
dragLeave(ev, questions.length)
|
|
||||||
}}
|
|
||||||
on:drop={dragDrop}
|
|
||||||
class:dragged-over={draggedOverIndex === questions.length && draggedIndex !== questions.length - 1}
|
|
||||||
>
|
|
||||||
<EditQuestion parent={object} index={-1} />
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@
|
|||||||
|
|
||||||
<div class="question-answer-container flex-col flex-gap-3">
|
<div class="question-answer-container flex-col flex-gap-3">
|
||||||
<div class="flex-row-center flex-gap-1 flex-no-shrink">
|
<div class="flex-row-center flex-gap-1 flex-no-shrink">
|
||||||
<span class="text-lg caption-color font-medium">{question.name}</span>
|
<strong class="text-base caption-color font-medium pre-wrap">{question.name}</strong>
|
||||||
{#if question.isMandatory && !readonly}
|
{#if question.isMandatory && !readonly}
|
||||||
<div
|
<div
|
||||||
class="flex-no-shrink"
|
class="flex-no-shrink"
|
||||||
@ -151,9 +151,9 @@
|
|||||||
{#if readonly}
|
{#if readonly}
|
||||||
{#each getReadonlyAnswers() as answer}
|
{#each getReadonlyAnswers() as answer}
|
||||||
{#if answer}
|
{#if answer}
|
||||||
<div class="pl-6">{answer}</div>
|
<div class="pre-wrap">{answer}</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="pl-6 content-halfcontent-color">
|
<div class="content-halfcontent-color">
|
||||||
<Label label={survey.string.NoAnswer} />
|
<Label label={survey.string.NoAnswer} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@ -180,7 +180,6 @@
|
|||||||
{#if selectedOption === customOption}
|
{#if selectedOption === customOption}
|
||||||
<div class="pl-6">
|
<div class="pl-6">
|
||||||
<EditBox
|
<EditBox
|
||||||
kind={'ghost-large'}
|
|
||||||
bind:value={answer}
|
bind:value={answer}
|
||||||
placeholder={survey.string.AnswerPlaceholder}
|
placeholder={survey.string.AnswerPlaceholder}
|
||||||
focusable
|
focusable
|
||||||
@ -206,7 +205,6 @@
|
|||||||
{#if selectedOptions[customOption]}
|
{#if selectedOptions[customOption]}
|
||||||
<div class="pl-6">
|
<div class="pl-6">
|
||||||
<EditBox
|
<EditBox
|
||||||
kind={'ghost-large'}
|
|
||||||
bind:value={answer}
|
bind:value={answer}
|
||||||
placeholder={survey.string.AnswerPlaceholder}
|
placeholder={survey.string.AnswerPlaceholder}
|
||||||
focusable
|
focusable
|
||||||
@ -218,13 +216,14 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
|
<div>
|
||||||
<EditBox
|
<EditBox
|
||||||
kind={'ghost-large'}
|
format={'text-multiline'}
|
||||||
bind:value={answer}
|
bind:value={answer}
|
||||||
placeholder={survey.string.AnswerPlaceholder}
|
placeholder={survey.string.AnswerPlaceholder}
|
||||||
focusable
|
|
||||||
on:change={answerChange}
|
on:change={answerChange}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -233,4 +232,7 @@
|
|||||||
padding-top: var(--spacing-2);
|
padding-top: var(--spacing-2);
|
||||||
border-top: 1px solid var(--theme-divider-color);
|
border-top: 1px solid var(--theme-divider-color);
|
||||||
}
|
}
|
||||||
|
.pre-wrap {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -95,7 +95,8 @@ const survey = plugin(surveyId, {
|
|||||||
SurveySubmitConfirm: '' as IntlString,
|
SurveySubmitConfirm: '' as IntlString,
|
||||||
ValidateFail: '' as IntlString,
|
ValidateFail: '' as IntlString,
|
||||||
ValidateInfo: '' as IntlString,
|
ValidateInfo: '' as IntlString,
|
||||||
ValidateOk: '' as IntlString
|
ValidateOk: '' as IntlString,
|
||||||
|
EditAnswers: '' as IntlString
|
||||||
},
|
},
|
||||||
component: {
|
component: {
|
||||||
CreateSurvey: '' as AnyComponent,
|
CreateSurvey: '' as AnyComponent,
|
||||||
|
Loading…
Reference in New Issue
Block a user