mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-20 23:32:14 +00:00
UBER-462: prevent creating existing enum value and disable the button in that case (#3465)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
db53abf7c0
commit
f450e03bb7
@ -28,6 +28,7 @@
|
|||||||
export let size: 'x-small' | 'small' | 'medium' | 'large'
|
export let size: 'x-small' | 'small' | 'medium' | 'large'
|
||||||
export let action: (ev: MouseEvent) => Promise<void> | void = async () => {}
|
export let action: (ev: MouseEvent) => Promise<void> | void = async () => {}
|
||||||
export let invisible: boolean = false
|
export let invisible: boolean = false
|
||||||
|
export let disabled: boolean = false
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
@ -35,6 +36,7 @@
|
|||||||
use:tooltip={{ label, direction, props: labelProps }}
|
use:tooltip={{ label, direction, props: labelProps }}
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
on:click|stopPropagation|preventDefault={action}
|
on:click|stopPropagation|preventDefault={action}
|
||||||
|
{disabled}
|
||||||
>
|
>
|
||||||
<div class="icon {size}" class:invisible>
|
<div class="icon {size}" class:invisible>
|
||||||
<Icon {icon} {size} {iconProps} />
|
<Icon {icon} {size} {iconProps} />
|
||||||
@ -53,7 +55,7 @@
|
|||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&:hover .icon {
|
&:not(:disabled):hover .icon {
|
||||||
color: var(--theme-caption-color);
|
color: var(--theme-caption-color);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
@ -64,6 +66,9 @@
|
|||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&:disabled {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.small {
|
.small {
|
||||||
width: 1rem;
|
width: 1rem;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
async function add () {
|
async function add () {
|
||||||
if (newValue.trim().length === 0) return
|
if (newValue.trim().length === 0) return
|
||||||
|
if (value.enumValues.includes(newValue.trim())) return
|
||||||
await client.update(value, {
|
await client.update(value, {
|
||||||
$push: { enumValues: newValue }
|
$push: { enumValues: newValue }
|
||||||
})
|
})
|
||||||
@ -123,7 +124,13 @@
|
|||||||
bind:value={newValue}
|
bind:value={newValue}
|
||||||
/>
|
/>
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<ActionIcon icon={IconAdd} label={setting.string.Add} action={add} size={'small'} />
|
<ActionIcon
|
||||||
|
icon={IconAdd}
|
||||||
|
label={setting.string.Add}
|
||||||
|
action={add}
|
||||||
|
size={'small'}
|
||||||
|
disabled={value.enumValues.includes(newValue.trim())}
|
||||||
|
/>
|
||||||
|
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
icon={IconAttachment}
|
icon={IconAttachment}
|
||||||
|
Loading…
Reference in New Issue
Block a user