2020-07-21 16:01:32 +02:00
|
|
|
<script>
|
|
|
|
import { MoreIcon } from "components/common/Icons"
|
|
|
|
import { store } from "builderStore"
|
|
|
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
|
|
|
import UIkit from "uikit"
|
|
|
|
import api from "builderStore/api"
|
2020-07-21 21:49:52 +02:00
|
|
|
import Portal from "svelte-portal"
|
|
|
|
import { DropdownMenu } from "@budibase/bbui"
|
2020-07-21 16:01:32 +02:00
|
|
|
|
|
|
|
export let screen
|
|
|
|
|
|
|
|
let confirmDeleteDialog
|
2020-07-21 21:49:52 +02:00
|
|
|
let dropdown
|
|
|
|
let buttonForDropdown
|
2020-07-21 16:01:32 +02:00
|
|
|
|
|
|
|
const hideDropdown = () => {
|
|
|
|
dropdown.hide()
|
|
|
|
}
|
|
|
|
|
|
|
|
const deleteScreen = () => {
|
|
|
|
store.update(s => {
|
|
|
|
const screens = s.screens.filter(c => c.name !== screen.name)
|
|
|
|
s.screens = screens
|
|
|
|
if (s.currentPreviewItem.name === screen.name) {
|
|
|
|
s.currentPreviewItem = s.pages[s.currentPageName]
|
|
|
|
s.currentFrontEndType = "page"
|
|
|
|
}
|
|
|
|
|
|
|
|
api.delete(
|
|
|
|
`/_builder/api/pages/${s.currentPageName}/screens/${screen.name}`
|
|
|
|
)
|
|
|
|
|
|
|
|
return s
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="root boundary" on:click|stopPropagation={() => {}}>
|
2020-07-21 21:49:52 +02:00
|
|
|
<button on:click={() => dropdown.show()} bind:this={buttonForDropdown}>
|
2020-07-21 16:01:32 +02:00
|
|
|
<MoreIcon />
|
|
|
|
</button>
|
2020-07-21 21:49:52 +02:00
|
|
|
<DropdownMenu bind:this={dropdown} anchor={buttonForDropdown}>
|
|
|
|
<ul class="menu" on:click={hideDropdown}>
|
|
|
|
<li class="item" on:click={() => confirmDeleteDialog.show()}>
|
|
|
|
<i class="icon ri-delete-bin-2-line" />
|
|
|
|
Delete
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</DropdownMenu>
|
2020-07-21 16:01:32 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<ConfirmDialog
|
|
|
|
bind:this={confirmDeleteDialog}
|
|
|
|
title="Confirm Delete"
|
|
|
|
body={`Are you sure you wish to delete the screen '${screen.props._instanceName}' ?`}
|
|
|
|
okText="Delete Screen"
|
|
|
|
onOk={deleteScreen} />
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.root {
|
|
|
|
overflow: hidden;
|
|
|
|
z-index: 9;
|
|
|
|
}
|
|
|
|
|
|
|
|
.root button {
|
|
|
|
border-style: none;
|
|
|
|
border-radius: 2px;
|
|
|
|
padding: 5px;
|
|
|
|
background: transparent;
|
|
|
|
cursor: pointer;
|
|
|
|
color: var(--ink);
|
|
|
|
outline: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu {
|
|
|
|
z-index: 100000;
|
|
|
|
overflow: visible;
|
|
|
|
padding: 12px 0px;
|
|
|
|
border-radius: 5px;
|
2020-07-21 21:49:52 +02:00
|
|
|
margin: 0;
|
2020-07-21 16:01:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.menu li {
|
|
|
|
border-style: none;
|
|
|
|
background-color: transparent;
|
|
|
|
list-style-type: none;
|
|
|
|
padding: 4px 16px;
|
|
|
|
margin: 0;
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
|
|
|
|
.item {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu li:not(.disabled) {
|
|
|
|
cursor: pointer;
|
|
|
|
color: var(--grey-7);
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu li:not(.disabled):hover {
|
|
|
|
color: var(--ink);
|
|
|
|
background-color: var(--grey-1);
|
|
|
|
}
|
|
|
|
</style>
|