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