Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSK-1311: add editors for String and Number #3056

Merged
merged 4 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions plugins/view-resources/src/components/BooleanPresenter.svelte
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
<!--
// Copyright © 2020, 2021 Anticrm Platform Contributors.
// Copyright © 2021 Hardcore Engineering Inc.
//
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { BooleanIcon, Label } from '@hcengineering/ui'
import { getBooleanLabel } from '../utils'
import BooleanEditor from './BooleanEditor.svelte'

export let value: any
export let inline: boolean = false
export let onChange: ((value: any) => void) | undefined = undefined
</script>

<div class="{inline ? 'inline-presenter' : 'flex-presenter'} yesno-container">
<div class="icon small-gap"><BooleanIcon {value} /></div>
<span><Label label={getBooleanLabel(value)} /></span>
{#if onChange !== undefined}
<BooleanEditor {onChange} {value} />
{:else}
<div class="icon small-gap"><BooleanIcon {value} /></div>
<span><Label label={getBooleanLabel(value)} /></span>
{/if}
</div>

<style lang="scss">
Expand Down
2 changes: 1 addition & 1 deletion plugins/view-resources/src/components/NumberEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// export let label: IntlString
export let placeholder: IntlString
export let value: number | undefined
export let focus: boolean
export let focus: boolean = false
// export let maxWidth: string = '10rem'
export let onChange: (value: number | undefined) => void
export let kind: 'no-border' | 'link' | 'button' = 'no-border'
Expand Down
18 changes: 14 additions & 4 deletions plugins/view-resources/src/components/NumberPresenter.svelte
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
<!--
// Copyright © 2020, 2021 Anticrm Platform Contributors.
// Copyright © 2021 Hardcore Engineering Inc.
//
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import NumberEditor from './NumberEditor.svelte'
import { getEmbeddedLabel, IntlString } from '@hcengineering/platform'

export let value: number | undefined
export let onChange: ((value: number | undefined) => void) | undefined = undefined
export let placeholder: IntlString = getEmbeddedLabel(' ')
export let kind: 'no-border' | 'link' | 'button' = 'link'
</script>

<span>{value || ''}</span>
{#if onChange !== undefined}
<NumberEditor {onChange} {value} {placeholder} {kind} />
{:else}
<span>{value || ''}</span>
{/if}
15 changes: 10 additions & 5 deletions plugins/view-resources/src/components/StringPresenter.svelte
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
<!--
// Copyright © 2020, 2021 Anticrm Platform Contributors.
// Copyright © 2021 Hardcore Engineering Inc.
//
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { getEmbeddedLabel } from '@hcengineering/platform'
import { getEmbeddedLabel, IntlString } from '@hcengineering/platform'
import { LabelAndProps, tooltip } from '@hcengineering/ui'
import StringEditor from './StringEditor.svelte'

export let value: string | string[] | undefined
export let onChange: ((value: string) => void) | undefined = undefined
export let placeholder: IntlString = getEmbeddedLabel('')

$: tooltipParams = getTooltip(value)

Expand All @@ -40,7 +43,9 @@
{#each value as str, i}
<span class:ml-1={i !== 0}>{str}</span>
{/each}
{:else}
{:else if onChange === undefined}
{value ?? ''}
{:else}
<StringEditor {onChange} value={value ?? ''} {placeholder} />
{/if}
</span>
9 changes: 5 additions & 4 deletions tests/sanity/tests/recruit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ test.describe('recruit tests', () => {

await page.click(`text="${last} ${first}"`)

await expect(page.locator(`text=${first}`).first()).toBeVisible()
await expect(page.locator(`text=${last}`).first()).toBeVisible()
await expect(page.locator(`text=${loc}`).first()).toBeVisible()

const panel = page.locator('.popupPanel')

expect(await panel.locator('[placeholder="First name"]').inputValue()).toEqual(first)
expect(await panel.locator('[placeholder="Last name"]').inputValue()).toEqual(last)
expect(await panel.locator('[placeholder="Location"]').inputValue()).toEqual(loc)

await panel.locator('[id="gmail\\:string\\:Email"]').scrollIntoViewIfNeeded()
await panel.locator('[id="gmail\\:string\\:Email"]').click()
expect(await page.locator('.cover-channel >> input').inputValue()).toEqual(email)
Expand Down