mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
popup's onClose callback
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
aa48e78d29
commit
120dab0f04
@ -31,6 +31,6 @@
|
||||
<svelte:window on:keydown={handleKeydown} />
|
||||
|
||||
{#each $modal as popup, i}
|
||||
<PopupInstance is={popup.is} props={popup.props} element={popup.element} zIndex={(i+1) * 500}/>
|
||||
<PopupInstance is={popup.is} props={popup.props} element={popup.element} onClose={popup.onClose} zIndex={(i+1) * 500}/>
|
||||
{/each}
|
||||
|
||||
|
@ -22,12 +22,15 @@ import { closePopup } from '..'
|
||||
export let is: AnyComponent | AnySvelteComponent
|
||||
export let props: object
|
||||
export let element: HTMLElement | undefined
|
||||
export let onClose: (result: any) => void | undefined
|
||||
export let zIndex: number
|
||||
|
||||
let modalHTML: HTMLElement
|
||||
let modalOHTML: HTMLElement
|
||||
|
||||
function close() {
|
||||
function close(ev: CustomEvent) {
|
||||
console.log('got close, data', ev.detail)
|
||||
if (onClose !== undefined) onClose(ev.detail)
|
||||
closePopup()
|
||||
}
|
||||
|
||||
|
@ -71,13 +71,13 @@ export function createApp (target: HTMLElement): SvelteComponent {
|
||||
interface CompAndProps {
|
||||
is: AnySvelteComponent | AnyComponent | undefined
|
||||
props: any
|
||||
element: HTMLElement | undefined
|
||||
element?: HTMLElement
|
||||
onClose?: (result: any) => void
|
||||
}
|
||||
|
||||
export const store = writable<CompAndProps>({
|
||||
is: undefined,
|
||||
props: {},
|
||||
element: undefined
|
||||
})
|
||||
|
||||
export function showModal (component: AnySvelteComponent | AnyComponent, props: any, element?: HTMLElement): void {
|
||||
@ -90,9 +90,9 @@ export function closeModal (): void {
|
||||
|
||||
export const popupstore = writable<CompAndProps[]>([])
|
||||
|
||||
export function showPopup (component: AnySvelteComponent | AnyComponent, props: any, element?: HTMLElement): void {
|
||||
export function showPopup (component: AnySvelteComponent | AnyComponent, props: any, element?: HTMLElement, onClose?: (result: any) => void): void {
|
||||
popupstore.update(popups => {
|
||||
popups.push({ is: component, props, element: element })
|
||||
popups.push({ is: component, props, element, onClose })
|
||||
return popups
|
||||
})
|
||||
}
|
||||
|
@ -15,11 +15,14 @@
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import { EditBox } from '@anticrm/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { EditBox, Button } from '@anticrm/ui'
|
||||
import { getClient } from '@anticrm/presentation'
|
||||
|
||||
import contact, { ChannelProvider } from '@anticrm/contact'
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
let providers: ChannelProvider[] = []
|
||||
let values: string[]
|
||||
|
||||
@ -40,6 +43,7 @@
|
||||
<EditBox label={'Twitter'} placeholder={'@rosychen'} />
|
||||
<EditBox label={'Facebook'} placeholder={'facebook/rosamundch'} />
|
||||
</div> -->
|
||||
<Button label="Apply" on:click={() => { dispatch('close', 42) }}/>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
|
Loading…
Reference in New Issue
Block a user