mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 11:31:57 +03:00
Tracker: improve CheckBox (#1356)
Signed-off-by: Artyom Grigorovich <grigorovichartyom@gmail.com>
This commit is contained in:
parent
fd92ec7d8c
commit
b3d6a11161
@ -13,14 +13,26 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { createEventDispatcher } from 'svelte'
|
||||||
|
|
||||||
export let checked: boolean = false
|
export let checked: boolean = false
|
||||||
export let symbol: 'check' | 'minus' = 'check'
|
export let symbol: 'check' | 'minus' = 'check'
|
||||||
export let circle: boolean = false
|
export let circle: boolean = false
|
||||||
export let primary: boolean = false
|
export let primary: boolean = false
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
const handleValueChanged = (event: Event) => {
|
||||||
|
const eventTarget = event.target as HTMLInputElement
|
||||||
|
const isChecked = eventTarget.checked
|
||||||
|
|
||||||
|
dispatch('value', isChecked)
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<label class="checkbox" class:circle class:primary class:checked>
|
<label class="checkbox" class:circle class:primary class:checked>
|
||||||
<input class="chBox" type="checkbox" bind:checked on:change />
|
<input class="chBox" type="checkbox" bind:checked on:change={handleValueChanged} />
|
||||||
<svg class="checkSVG" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
<svg class="checkSVG" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||||
{#if !circle}
|
{#if !circle}
|
||||||
<path
|
<path
|
||||||
|
@ -75,11 +75,8 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleIssueSelected = (id: Ref<Doc>, event: Event) => {
|
const handleIssueSelected = (id: Ref<Doc>, event: CustomEvent<boolean>) => {
|
||||||
const eventTarget = event.target as HTMLInputElement
|
if (event.detail) {
|
||||||
const isChecked = eventTarget.checked
|
|
||||||
|
|
||||||
if (isChecked) {
|
|
||||||
selectedIssueIds.add(id)
|
selectedIssueIds.add(id)
|
||||||
} else {
|
} else {
|
||||||
selectedIssueIds.delete(id)
|
selectedIssueIds.delete(id)
|
||||||
@ -116,7 +113,7 @@
|
|||||||
<div class="eListGridCheckBox ml-2">
|
<div class="eListGridCheckBox ml-2">
|
||||||
<CheckBox
|
<CheckBox
|
||||||
checked={selectedIssueIds.has(docObject._id)}
|
checked={selectedIssueIds.has(docObject._id)}
|
||||||
on:change={(event) => {
|
on:value={(event) => {
|
||||||
handleIssueSelected(docObject._id, event)
|
handleIssueSelected(docObject._id, event)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -48,7 +48,8 @@
|
|||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
$: sortingFunction = (config.find(it => (typeof it !== 'string') && it.sortingKey === sortKey) as BuildModelKey)?.sortingFunction
|
$: sortingFunction = (config.find((it) => typeof it !== 'string' && it.sortingKey === sortKey) as BuildModelKey)
|
||||||
|
?.sortingFunction
|
||||||
|
|
||||||
let qindex = 0
|
let qindex = 0
|
||||||
async function update (
|
async function update (
|
||||||
@ -103,11 +104,9 @@
|
|||||||
|
|
||||||
let checked: Set<Ref<Doc>> = new Set<Ref<Doc>>()
|
let checked: Set<Ref<Doc>> = new Set<Ref<Doc>>()
|
||||||
|
|
||||||
function check (id: Ref<Doc>, e: Event) {
|
function check (id: Ref<Doc>, event: CustomEvent<boolean>) {
|
||||||
if (!enableChecking) return
|
if (!enableChecking) return
|
||||||
const target = e.target as HTMLInputElement
|
if (event.detail) {
|
||||||
const value = target.checked
|
|
||||||
if (value) {
|
|
||||||
checked.add(id)
|
checked.add(id)
|
||||||
} else {
|
} else {
|
||||||
checked.delete(id)
|
checked.delete(id)
|
||||||
@ -138,8 +137,8 @@
|
|||||||
<CheckBox
|
<CheckBox
|
||||||
symbol={'minus'}
|
symbol={'minus'}
|
||||||
checked={objects?.length === checked.size && objects?.length > 0}
|
checked={objects?.length === checked.size && objects?.length > 0}
|
||||||
on:change={(e) => {
|
on:value={(event) => {
|
||||||
objects.map((o) => check(o._id, e))
|
objects.map((object) => check(object._id, event))
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -182,20 +181,23 @@
|
|||||||
<div class="antiTable-cells__checkCell">
|
<div class="antiTable-cells__checkCell">
|
||||||
<CheckBox
|
<CheckBox
|
||||||
checked={checked.has(object._id)}
|
checked={checked.has(object._id)}
|
||||||
on:change={(e) => {
|
on:value={(event) => {
|
||||||
check(object._id, e)
|
check(object._id, event)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<Component is={notification.component.NotificationPresenter} props={{ value: object, kind: enableChecking ? 'table' : 'block' }} />
|
<Component
|
||||||
|
is={notification.component.NotificationPresenter}
|
||||||
|
props={{ value: object, kind: enableChecking ? 'table' : 'block' }}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="antiTable-cells__checkCell">
|
<div class="antiTable-cells__checkCell">
|
||||||
<CheckBox
|
<CheckBox
|
||||||
checked={checked.has(object._id)}
|
checked={checked.has(object._id)}
|
||||||
on:change={(e) => {
|
on:value={(event) => {
|
||||||
check(object._id, e)
|
check(object._id, event)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -209,7 +211,11 @@
|
|||||||
value={getObjectValue(attribute.key, object) ?? ''}
|
value={getObjectValue(attribute.key, object) ?? ''}
|
||||||
{...attribute.props}
|
{...attribute.props}
|
||||||
/>
|
/>
|
||||||
<div id='context-menu' class="antiTable-cells__firstCell-menuRow" on:click={(ev) => showMenu(ev, object, row)}>
|
<div
|
||||||
|
id="context-menu"
|
||||||
|
class="antiTable-cells__firstCell-menuRow"
|
||||||
|
on:click={(ev) => showMenu(ev, object, row)}
|
||||||
|
>
|
||||||
<MoreV size={'small'} />
|
<MoreV size={'small'} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -236,9 +242,7 @@
|
|||||||
{#if enableChecking}
|
{#if enableChecking}
|
||||||
<td>
|
<td>
|
||||||
<div class="antiTable-cells__checkCell">
|
<div class="antiTable-cells__checkCell">
|
||||||
<CheckBox
|
<CheckBox checked={false} />
|
||||||
checked={false}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
{/if}
|
{/if}
|
||||||
|
Loading…
Reference in New Issue
Block a user