userslist
This commit is contained in:
parent
ecf324453e
commit
bdecbf1e82
|
@ -1,7 +1,17 @@
|
|||
<script>
|
||||
import { onMount } from "svelte"
|
||||
import { store, backendUiStore } from "../../builderStore"
|
||||
import { tap, get, find, last, compose, flatten, map } from "lodash/fp"
|
||||
import {
|
||||
tap,
|
||||
get,
|
||||
find,
|
||||
last,
|
||||
compose,
|
||||
flatten,
|
||||
map,
|
||||
remove,
|
||||
keys
|
||||
} from "lodash/fp"
|
||||
import Select from "../../common/Select.svelte"
|
||||
import { getIndexSchema } from "../../common/core"
|
||||
import ActionButton from "../../common/ActionButton.svelte"
|
||||
|
@ -12,6 +22,14 @@
|
|||
export let selectRecord
|
||||
|
||||
const ITEMS_PER_PAGE = 10
|
||||
// Internal headers we want to hide from the user
|
||||
const INTERNAL_HEADERS = [
|
||||
"key",
|
||||
"sortKey",
|
||||
"type",
|
||||
"id",
|
||||
"isNew"
|
||||
]
|
||||
|
||||
let modalOpen = false
|
||||
let data = []
|
||||
|
@ -33,7 +51,7 @@
|
|||
$backendUiStore.selectedDatabase
|
||||
).then(records => {
|
||||
data = records || []
|
||||
headers = getSchema($backendUiStore.selectedView).map(get("name"))
|
||||
headers = hideInternalHeaders($backendUiStore.selectedView)
|
||||
})
|
||||
|
||||
$: paginatedData = data.slice(
|
||||
|
@ -41,13 +59,19 @@
|
|||
currentPage * ITEMS_PER_PAGE + ITEMS_PER_PAGE
|
||||
)
|
||||
|
||||
const getSchema = getIndexSchema($store.hierarchy)
|
||||
|
||||
const childViewsForRecord = compose(
|
||||
flatten,
|
||||
map("indexes"),
|
||||
get("children")
|
||||
)
|
||||
|
||||
const getSchema = getIndexSchema($store.hierarchy)
|
||||
const hideInternalHeaders = compose(
|
||||
remove(headerName => INTERNAL_HEADERS.includes(headerName)),
|
||||
map(get("name")),
|
||||
getSchema
|
||||
)
|
||||
|
||||
async function fetchRecordsForView(view, instance) {
|
||||
if (!view.name) return
|
||||
|
@ -66,10 +90,15 @@
|
|||
backendUiStore.update(state => {
|
||||
state.selectedRecord = record
|
||||
state.breadcrumbs = [state.selectedDatabase.name, record.id]
|
||||
state.selectedView = childViewsForRecord($store.hierarchy)[0]
|
||||
return state
|
||||
})
|
||||
}
|
||||
|
||||
$: {
|
||||
console.log($backendUiStore.selectedView)
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
if (views.length) {
|
||||
backendUiStore.actions.views.select(views[0])
|
||||
|
@ -140,8 +169,7 @@
|
|||
{data}
|
||||
bind:currentPage
|
||||
pageItemCount={data.length}
|
||||
{ITEMS_PER_PAGE}
|
||||
/>
|
||||
{ITEMS_PER_PAGE} />
|
||||
</section>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -24,6 +24,7 @@ export async function saveRecord(record, { appname, instanceId }) {
|
|||
let recordBase = { ...record }
|
||||
|
||||
// brand new record
|
||||
// car-model-id or name/specific-car-id/manus
|
||||
if (record.collectionName) {
|
||||
const collectionKey = `/${record.collectionName}`
|
||||
recordBase = getNewRecord(recordBase, collectionKey)
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
}
|
||||
|
||||
async function fetchUsers() {
|
||||
const DELETE_RECORDS_URL = `/_builder/instance/${currentAppInfo.appname}/${currentAppInfo.instanceId}/api/users`
|
||||
const response = await api.get(DELETE_RECORDS_URL);
|
||||
const FETCH_USERS_URL = `/_builder/instance/${currentAppInfo.appname}/${currentAppInfo.instanceId}/api/users`
|
||||
const response = await api.get(FETCH_USERS_URL);
|
||||
users = await response.json()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue