inicontent 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/pull_request.yml +18 -0
- package/CONTRIBUTING.md +67 -0
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/app/app.vue +106 -0
- package/app/assets/main.css +974 -0
- package/app/components/Api/EndpointCard.vue +169 -0
- package/app/components/Api/SchemaDocsTable.vue +208 -0
- package/app/components/Asset/Card.vue +1363 -0
- package/app/components/Asset/Grid.vue +295 -0
- package/app/components/Asset/Icon.vue +38 -0
- package/app/components/Asset/Preview.vue +486 -0
- package/app/components/Asset/Scanner.vue +700 -0
- package/app/components/Asset/Thumb.vue +708 -0
- package/app/components/Auth/Reset.vue +99 -0
- package/app/components/Auth/index.vue +346 -0
- package/app/components/ChatInterface.vue +2326 -0
- package/app/components/ChatPagePreview.vue +34 -0
- package/app/components/Column/Array.vue +29 -0
- package/app/components/Column/Asset.vue +21 -0
- package/app/components/Column/Boolean.vue +12 -0
- package/app/components/Column/Color.vue +9 -0
- package/app/components/Column/Date.vue +57 -0
- package/app/components/Column/Edit.vue +215 -0
- package/app/components/Column/Email.vue +9 -0
- package/app/components/Column/Html.vue +27 -0
- package/app/components/Column/Id.vue +20 -0
- package/app/components/Column/Locale.vue +32 -0
- package/app/components/Column/Object.vue +18 -0
- package/app/components/Column/Password.vue +7 -0
- package/app/components/Column/Role.vue +15 -0
- package/app/components/Column/S.vue +14 -0
- package/app/components/Column/Table/Single.vue +49 -0
- package/app/components/Column/Table/index.vue +42 -0
- package/app/components/Column/Tags.vue +31 -0
- package/app/components/Column/Text.vue +9 -0
- package/app/components/Column/Url.vue +9 -0
- package/app/components/Column/index.vue +41 -0
- package/app/components/Dashboard/Editor.vue +221 -0
- package/app/components/Dashboard/Grid.vue +270 -0
- package/app/components/Dashboard/View.vue +131 -0
- package/app/components/Dashboard/Widget/BarChart.vue +73 -0
- package/app/components/Dashboard/Widget/Counter.vue +51 -0
- package/app/components/Dashboard/Widget/LineChart.vue +76 -0
- package/app/components/Dashboard/Widget/PieChart.vue +75 -0
- package/app/components/Dashboard/Widget/Table.vue +94 -0
- package/app/components/Dashboard/WidgetEditor.vue +274 -0
- package/app/components/Data/Array.vue +102 -0
- package/app/components/Data/Html.vue +9 -0
- package/app/components/Data/Icon.vue +9 -0
- package/app/components/Data/Object.vue +10 -0
- package/app/components/Data/S.vue +16 -0
- package/app/components/Data/Table.vue +53 -0
- package/app/components/Data/Value.vue +34 -0
- package/app/components/Data/index.vue +14 -0
- package/app/components/Field/Array.vue +324 -0
- package/app/components/Field/Asset/Actions.vue +97 -0
- package/app/components/Field/Asset/index.vue +639 -0
- package/app/components/Field/Boolean.vue +26 -0
- package/app/components/Field/Checkbox.vue +48 -0
- package/app/components/Field/Color.vue +27 -0
- package/app/components/Field/Date.vue +30 -0
- package/app/components/Field/Email.vue +51 -0
- package/app/components/Field/EmailTemplate.vue +420 -0
- package/app/components/Field/Html/ColorPicker.vue +127 -0
- package/app/components/Field/Html/Editor.vue +544 -0
- package/app/components/Field/Html/index.vue +25 -0
- package/app/components/Field/Icon.vue +114 -0
- package/app/components/Field/JSON.vue +113 -0
- package/app/components/Field/Mention.vue +36 -0
- package/app/components/Field/Number.vue +27 -0
- package/app/components/Field/Object.vue +92 -0
- package/app/components/Field/Password.vue +55 -0
- package/app/components/Field/Radio.vue +47 -0
- package/app/components/Field/S.vue +44 -0
- package/app/components/Field/Select.vue +49 -0
- package/app/components/Field/Table.vue +348 -0
- package/app/components/Field/Tags.vue +113 -0
- package/app/components/Field/Text.vue +31 -0
- package/app/components/Field/Textarea.vue +33 -0
- package/app/components/Field/Url.vue +40 -0
- package/app/components/Field/Wrapper.vue +128 -0
- package/app/components/Field/index.vue +68 -0
- package/app/components/FloatingChatbot.vue +73 -0
- package/app/components/Form/Card.vue +151 -0
- package/app/components/Form/Drawer.vue +195 -0
- package/app/components/Form/index.vue +621 -0
- package/app/components/Header.vue +328 -0
- package/app/components/Offline/ConflictModal.vue +200 -0
- package/app/components/Offline/SyncStatus.vue +249 -0
- package/app/components/PlatformFeatureLanding.vue +65 -0
- package/app/components/Table/Backups.vue +638 -0
- package/app/components/Table/Flows.vue +814 -0
- package/app/components/Table/Grid.vue +296 -0
- package/app/components/Table/Icon.vue +36 -0
- package/app/components/Table/Logs.vue +181 -0
- package/app/components/Table/Schedules.vue +722 -0
- package/app/components/Table/Search/Button.vue +256 -0
- package/app/components/Table/Search/Items.vue +286 -0
- package/app/components/Table/Search/index.vue +87 -0
- package/app/components/Table/Settings/Schema.vue +801 -0
- package/app/components/Table/Settings/index.vue +631 -0
- package/app/components/Table/TranslateDrawer.vue +526 -0
- package/app/components/Table/Views/Kanban.vue +289 -0
- package/app/components/Table/Views/Table.vue +1273 -0
- package/app/components/Table/index.vue +890 -0
- package/app/composables/Translation/define.ts +41 -0
- package/app/composables/Translation/fetch.ts +107 -0
- package/app/composables/Translation/languages.ts +1 -0
- package/app/composables/Translation/loadCoreTranslations.ts +38 -0
- package/app/composables/Translation/translate.ts +250 -0
- package/app/composables/databaseCookies.ts +79 -0
- package/app/composables/fieldValidator.ts +72 -0
- package/app/composables/fieldsList.ts +301 -0
- package/app/composables/formatDatabase.ts +101 -0
- package/app/composables/index.ts +444 -0
- package/app/composables/openDrawer.ts +118 -0
- package/app/composables/optimizeFile.ts +287 -0
- package/app/composables/renderLabel.ts +88 -0
- package/app/composables/schemaClipboard.ts +95 -0
- package/app/composables/search.ts +353 -0
- package/app/composables/setThemeConfig.ts +48 -0
- package/app/composables/translationValue.ts +169 -0
- package/app/composables/useAssetPreview.ts +84 -0
- package/app/composables/useAssetUploader.ts +56 -0
- package/app/composables/useDashboardData.ts +310 -0
- package/app/composables/useDocumentThumbnail.ts +351 -0
- package/app/composables/useEcharts.ts +33 -0
- package/app/composables/useLocalDatabaseConfig.ts +51 -0
- package/app/composables/useOcr.ts +300 -0
- package/app/composables/useOfflineFetch.ts +194 -0
- package/app/composables/useOfflineItem.ts +107 -0
- package/app/composables/useOfflineQueue.ts +302 -0
- package/app/composables/useOfflineSync.ts +235 -0
- package/app/composables/usePasskeyAuth.ts +156 -0
- package/app/composables/usePdfCompressor.ts +180 -0
- package/app/composables/usePlatformRedirect.ts +72 -0
- package/app/composables/useRealtimeSync.ts +233 -0
- package/app/composables/useReferencedItems.ts +180 -0
- package/app/composables/useScanner.ts +664 -0
- package/app/composables/useSubscription.ts +650 -0
- package/app/composables/useThumbnailCache.ts +136 -0
- package/app/composables/useVideoCompressor.ts +194 -0
- package/app/error.vue +112 -0
- package/app/layouts/api.vue +188 -0
- package/app/layouts/dashboard.vue +91 -0
- package/app/layouts/default.vue +228 -0
- package/app/layouts/table.vue +471 -0
- package/app/locales/ar.ts +996 -0
- package/app/locales/en.ts +655 -0
- package/app/locales/es.ts +996 -0
- package/app/locales/fr.ts +997 -0
- package/app/middleware/dashboard.ts +33 -0
- package/app/middleware/database.ts +83 -0
- package/app/middleware/global.ts +1 -0
- package/app/middleware/sid-ingest.global.ts +29 -0
- package/app/middleware/table.ts +54 -0
- package/app/middleware/user.ts +26 -0
- package/app/pages/[[database]]/admin/api/auth/index.vue +306 -0
- package/app/pages/[[database]]/admin/api/index.vue +18 -0
- package/app/pages/[[database]]/admin/api/tables/[table]/index.vue +497 -0
- package/app/pages/[[database]]/admin/api/tables/index.vue +87 -0
- package/app/pages/[[database]]/admin/billing/index.vue +16 -0
- package/app/pages/[[database]]/admin/dashboards/[id]/edit.vue +66 -0
- package/app/pages/[[database]]/admin/dashboards/[id]/index.vue +117 -0
- package/app/pages/[[database]]/admin/dashboards/index.vue +20 -0
- package/app/pages/[[database]]/admin/index.vue +28 -0
- package/app/pages/[[database]]/admin/settings.vue +526 -0
- package/app/pages/[[database]]/admin/tables/[table]/[id]/edit.vue +143 -0
- package/app/pages/[[database]]/admin/tables/[table]/[id]/index.vue +146 -0
- package/app/pages/[[database]]/admin/tables/[table]/flows.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/index.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/new.vue +12 -0
- package/app/pages/[[database]]/admin/tables/[table]/schedules.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/settings.vue +30 -0
- package/app/pages/[[database]]/admin/tables/assets/[...path].vue +24 -0
- package/app/pages/[[database]]/admin/tables/assets/flows.vue +10 -0
- package/app/pages/[[database]]/admin/tables/backups/index.vue +10 -0
- package/app/pages/[[database]]/admin/tables/blocks/index.vue +16 -0
- package/app/pages/[[database]]/admin/tables/index.vue +20 -0
- package/app/pages/[[database]]/admin/tables/pages/index.vue +16 -0
- package/app/pages/[[database]]/admin/tables/templates/index.vue +16 -0
- package/app/pages/[[database]]/api/index.vue +120 -0
- package/app/pages/[[database]]/auth/index.vue +12 -0
- package/app/pages/[[database]]/auth/reset.vue +10 -0
- package/app/pages/[[database]]/index.vue +10 -0
- package/app/plugins/offline-warmup.client.ts +53 -0
- package/app/plugins/template-globals.ts +9 -0
- package/app/spa-loading-template.html +93 -0
- package/biome.json +53 -0
- package/index.d.ts +380 -0
- package/modules/naiveui.ts +41 -0
- package/nuxt.config.ts +269 -0
- package/package.json +56 -0
- package/pnpm-workspace.yaml +5 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/pwa-192x192.png +0 -0
- package/public/pwa-512x512.png +0 -0
- package/public/pwa-maskable-192x192.png +0 -0
- package/public/pwa-maskable-512x512.png +0 -0
- package/public/vendor/opencv.js +48 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<LazyDataTable v-if="field.table && field.table !== 'assets'" :field :value />
|
|
3
|
+
<LazyColumn v-else-if="field.subType" :field="{ ...field, type: field.subType }" :value="value" />
|
|
4
|
+
<LazyColumn v-else-if="!isArrayOfObjects(field.children)"
|
|
5
|
+
:field="{ ...field, type: field.children === 'table' ? 'table' : 'tags' }" :value="value" />
|
|
6
|
+
<NListItem v-else-if="shouldRenderAsTable">
|
|
7
|
+
<div class="array-table-wrapper">
|
|
8
|
+
<table class="array-table">
|
|
9
|
+
<thead>
|
|
10
|
+
<tr>
|
|
11
|
+
<th class="index-col">#</th>
|
|
12
|
+
<th v-for="column in field.children" :key="column.key">
|
|
13
|
+
{{ column.label || column.key }}
|
|
14
|
+
</th>
|
|
15
|
+
</tr>
|
|
16
|
+
</thead>
|
|
17
|
+
<tbody>
|
|
18
|
+
<tr v-for="(row, rowIndex) in rows" :key="rowIndex">
|
|
19
|
+
<td class="index-col">{{ rowIndex + 1 }}</td>
|
|
20
|
+
<td v-for="column in field.children" :key="column.key">
|
|
21
|
+
<DataValue :field="column" :value="row[column.key]" />
|
|
22
|
+
</td>
|
|
23
|
+
</tr>
|
|
24
|
+
</tbody>
|
|
25
|
+
</table>
|
|
26
|
+
</div>
|
|
27
|
+
</NListItem>
|
|
28
|
+
<NListItem v-else v-for="(,index) in rows">
|
|
29
|
+
<template #prefix>
|
|
30
|
+
<NText strong>
|
|
31
|
+
{{ index + 1 }}
|
|
32
|
+
</NText>
|
|
33
|
+
</template>
|
|
34
|
+
<Data
|
|
35
|
+
v-for="child in childrenSchema.filter(child => typeof rows[index][child.key] !== 'undefined')"
|
|
36
|
+
:field="child" :value="rows[index][child.key]" />
|
|
37
|
+
</NListItem>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script lang="ts" setup>
|
|
41
|
+
import { isArrayOfObjects } from "inibase/utils"
|
|
42
|
+
|
|
43
|
+
type Row = Record<string, unknown>
|
|
44
|
+
|
|
45
|
+
const { field, value } = defineProps<{ field: Field; value: unknown }>()
|
|
46
|
+
|
|
47
|
+
const rows = computed<Row[]>(() => {
|
|
48
|
+
return Array.isArray(value) ? (value as Row[]) : []
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const childrenSchema = computed<Schema>(() => {
|
|
52
|
+
return Array.isArray(field.children) ? (field.children as Schema) : []
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const hasNestedArrayObjectChild = computed(() => {
|
|
56
|
+
return childrenSchema.value.some(child => {
|
|
57
|
+
const type = child.type
|
|
58
|
+
if (Array.isArray(type)) {
|
|
59
|
+
const normalized = type.map(entry => String(entry).toLowerCase())
|
|
60
|
+
return normalized.includes('array') && normalized.includes('object')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const normalized = String(type || '').toLowerCase()
|
|
64
|
+
if (normalized.includes('array') && normalized.includes('object')) {
|
|
65
|
+
return true
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return normalized === 'array' && Array.isArray(child.children) && child.children.length > 0
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const shouldRenderAsTable = computed(() => {
|
|
73
|
+
return isArrayOfObjects(field.children) && rows.value.length > 0 && !hasNestedArrayObjectChild.value
|
|
74
|
+
})
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<style scoped>
|
|
78
|
+
.array-table-wrapper {
|
|
79
|
+
overflow-x: auto;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.array-table {
|
|
83
|
+
width: 100%;
|
|
84
|
+
border-collapse: collapse;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.array-table th,
|
|
88
|
+
.array-table td {
|
|
89
|
+
padding: 8px;
|
|
90
|
+
border-bottom: 1px solid var(--n-border-color);
|
|
91
|
+
white-space: nowrap;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.array-table th {
|
|
95
|
+
font-weight: 600;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.index-col {
|
|
99
|
+
width: 56px;
|
|
100
|
+
min-width: 56px;
|
|
101
|
+
}
|
|
102
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="typeof value === 'string'"
|
|
3
|
+
v-html="value?.replaceAll('<img ', '<img style=\'width:100%\'').replaceAll('\n', '<br />') || ''"></div>
|
|
4
|
+
<div v-else>{{ value }}</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
const { value } = defineProps<{ value?: string | number }>()
|
|
9
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NFlex vertical :size="0">
|
|
3
|
+
<Data v-for="child in (field.children as Schema).filter(child => typeof value[child.key] !== 'undefined')"
|
|
4
|
+
:field="child" :value="value[child.key]" />
|
|
5
|
+
</NFlex>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script lang="ts" setup>
|
|
9
|
+
const { field, value } = defineProps<{ field: Field; value: any }>()
|
|
10
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NScrollbar v-if="!disableScroll" x-scrollable>
|
|
3
|
+
<NList class="printable" hoverable :bordered="false">
|
|
4
|
+
<Data v-for="field in schema.filter(field => typeof value[field.key] !== 'undefined')" :field
|
|
5
|
+
:value="value[field.key]"></Data>
|
|
6
|
+
</NList>
|
|
7
|
+
</NScrollbar>
|
|
8
|
+
<NList v-else hoverable :bordered="false">
|
|
9
|
+
<Data v-for="field in schema.filter(field => typeof value[field.key] !== 'undefined')" :field
|
|
10
|
+
:value="value[field.key]"></Data>
|
|
11
|
+
</NList>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts" setup>
|
|
15
|
+
const { schema, value, disableScroll } = defineProps<{ schema: Schema; value: Item; disableScroll?: boolean }>()
|
|
16
|
+
</script>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NFlex :wrap="false" class="tableCellLinks">
|
|
3
|
+
<NButton v-for="value in values" class="tableCellLinkButton" tag="a"
|
|
4
|
+
:href="`${$route.params.database ? `/${$route.params.database}` : ''}/admin/tables/${field.table}/${idOf(value)}`"
|
|
5
|
+
@click.prevent.stop="handleClick(value)" :loading="Loading[`Drawer_${field.table}_${idOf(value)}`]" size="small"
|
|
6
|
+
round>
|
|
7
|
+
<template v-if="table" #icon>
|
|
8
|
+
<LazyTableIcon :table="table" />
|
|
9
|
+
</template>
|
|
10
|
+
{{ renderLabel(table, resolvedItem(value) ?? ({ id: idOf(value) } as Item)) }}
|
|
11
|
+
</NButton>
|
|
12
|
+
</NFlex>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
import { isObject } from "inibase/utils";
|
|
17
|
+
|
|
18
|
+
const props = defineProps<{
|
|
19
|
+
field: Field;
|
|
20
|
+
value?: Item | Item[] | string | number | (string | number)[];
|
|
21
|
+
}>();
|
|
22
|
+
|
|
23
|
+
const database = useState<Database>("database");
|
|
24
|
+
const table = database.value.tables?.find(({ slug }) => slug === props.field.table);
|
|
25
|
+
|
|
26
|
+
const values = computed(() => ([] as unknown[]).concat(props.value ?? []));
|
|
27
|
+
|
|
28
|
+
const Loading = useState<Record<string, boolean>>("Loading", () => ({}));
|
|
29
|
+
|
|
30
|
+
// Table references can be raw ids (translated / stored values). Resolve them
|
|
31
|
+
// through the shared cache which batches all ids of the current page into a
|
|
32
|
+
// single request per referenced table. Object values are used as-is and never
|
|
33
|
+
// trigger a fetch.
|
|
34
|
+
const referenced = useReferencedItems(props.field.table);
|
|
35
|
+
|
|
36
|
+
watch(values, (list) => referenced.register(list), { immediate: true });
|
|
37
|
+
|
|
38
|
+
function idOf(value: unknown): string {
|
|
39
|
+
return isObject(value) ? String((value as Item).id ?? "") : String(value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function resolvedItem(value: unknown): Item | undefined {
|
|
43
|
+
if (isObject(value)) return value as Item;
|
|
44
|
+
return referenced.items.value[idOf(value)];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function handleClick(value: unknown) {
|
|
48
|
+
const id = idOf(value);
|
|
49
|
+
if (id && props.field.table) {
|
|
50
|
+
openDrawer(props.field.table, id, {}, "view");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<template v-if="value === null || value === undefined || (Array.isArray(value) && value.length === 0)">
|
|
3
|
+
<LazyColumnBoolean v-if="detectedFieldType === 'boolean'" />
|
|
4
|
+
<NText :depth="3" v-else>--</NText>
|
|
5
|
+
</template>
|
|
6
|
+
<LazyColumnRole v-else-if="detectedFieldType === 'role'" :value />
|
|
7
|
+
<NScrollbar v-else-if="['table', 'tags', 'select', 'checkbox'].includes(detectedFieldType)" x-scrollable>
|
|
8
|
+
<LazyColumnAsset v-if="detectedFieldType === 'table' && field.table === 'assets'" :value />
|
|
9
|
+
<LazyDataTable v-else-if="detectedFieldType === 'table'" :value :field />
|
|
10
|
+
<LazyColumnTags v-else-if="['tags', 'select', 'checkbox'].includes(detectedFieldType)" :field :value />
|
|
11
|
+
</NScrollbar>
|
|
12
|
+
<LazyColumnColor v-else-if="detectedFieldType === 'color'" :value />
|
|
13
|
+
<LazyColumnUrl v-else-if="detectedFieldType === 'url'" :value />
|
|
14
|
+
<LazyColumnEmail v-else-if="detectedFieldType === 'email'" :value />
|
|
15
|
+
<LazyDataHtml v-else-if="['html', 'textarea', 'json'].includes(detectedFieldType)" :value />
|
|
16
|
+
<LazyColumnPassword v-else-if="detectedFieldType === 'password'" :value />
|
|
17
|
+
<LazyColumnBoolean v-else-if="detectedFieldType === 'boolean'" :value />
|
|
18
|
+
<LazyColumnDate v-else-if="detectedFieldType === 'date'" :value :field />
|
|
19
|
+
<LazyDataObject v-else-if="detectedFieldType === 'object'" :value :field />
|
|
20
|
+
<LazyDataArray v-else-if="detectedFieldType === 'array'" :value :field />
|
|
21
|
+
<LazyColumnText
|
|
22
|
+
v-else-if="['string', 'text', 'number', 'radio', 'id', 'multiple', 'json'].includes(detectedFieldType)"
|
|
23
|
+
:value />
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
<script lang="ts" setup>
|
|
28
|
+
const { field, value } = defineProps<{ field: Field; value: any }>()
|
|
29
|
+
|
|
30
|
+
let detectedFieldType = (field.subType ?? field.type) as
|
|
31
|
+
| DB_FieldType
|
|
32
|
+
| CMS_FieldType
|
|
33
|
+
if (Array.isArray(detectedFieldType)) detectedFieldType = getField(field).key
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NListItem>
|
|
3
|
+
<template #prefix>
|
|
4
|
+
<NButton text>
|
|
5
|
+
<strong>{{ t(field.key) }}:</strong>
|
|
6
|
+
</NButton>
|
|
7
|
+
</template>
|
|
8
|
+
<DataValue :field :value />
|
|
9
|
+
</NListItem>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script lang="ts" setup>
|
|
13
|
+
const { field, value } = defineProps<{ field: Field; value: any }>()
|
|
14
|
+
</script>
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<LazyField v-if="field.subType" :field="{
|
|
3
|
+
...field,
|
|
4
|
+
isArray: true,
|
|
5
|
+
}" v-model="modelValue" />
|
|
6
|
+
<LazyField v-else-if="!isArrayOfObjects(field.children)" :field="{
|
|
7
|
+
...field,
|
|
8
|
+
subType: field.children === 'table' ? 'array-table' : (field.options?.length ? 'select' : 'tags'),
|
|
9
|
+
isArray: true,
|
|
10
|
+
}" v-model="modelValue" />
|
|
11
|
+
<NCollapse v-else-if="field.isTable === false || field.children.filter(
|
|
12
|
+
(f: any) => (f.type === 'array' && isArrayOfObjects(f.children)) || (f.width && f.width > 1),
|
|
13
|
+
).length" display-directive="if" arrow-placement="right" :trigger-areas="['main', 'arrow']"
|
|
14
|
+
:default-expanded-names="field.expand ? String(field.id) : undefined" v-model:expanded-names="parentExpanded"
|
|
15
|
+
accordion>
|
|
16
|
+
<template #arrow>
|
|
17
|
+
<NIcon>
|
|
18
|
+
<Icon name="tabler:chevron-left" v-if="!!modelValue?.length" />
|
|
19
|
+
</NIcon>
|
|
20
|
+
</template>
|
|
21
|
+
<NCollapseItem style="margin: 0 0 20px;" display-directive="if" :name="String(field.id)"
|
|
22
|
+
:disabled="!modelValue?.length">
|
|
23
|
+
<template #header>
|
|
24
|
+
<NDropdown size="small" :placement="Language === 'ar' ? 'left' : 'right'" show-arrow trigger="hover"
|
|
25
|
+
:delay="1500" :options="dropdownOptions" @select="handleSelect">
|
|
26
|
+
{{ t(field.key) }}
|
|
27
|
+
</NDropdown>
|
|
28
|
+
</template>
|
|
29
|
+
<template #header-extra>
|
|
30
|
+
<NFlex>
|
|
31
|
+
<component v-if="field.extraActions" :is="field.extraActions"></component>
|
|
32
|
+
<NButtonGroup>
|
|
33
|
+
<NButton v-if="!field.disableActions" size="small" round @click="handleAddNewItem">
|
|
34
|
+
<template #icon>
|
|
35
|
+
<NIcon>
|
|
36
|
+
<Icon name="tabler:plus" />
|
|
37
|
+
</NIcon>
|
|
38
|
+
</template>
|
|
39
|
+
</NButton>
|
|
40
|
+
<component v-if="field.extraButtons" :is="field.extraButtons"></component>
|
|
41
|
+
</NButtonGroup>
|
|
42
|
+
</NFlex>
|
|
43
|
+
</template>
|
|
44
|
+
<NCollapse display-directive="if" accordion v-model:expanded-names="expandedNames"
|
|
45
|
+
:trigger-areas="['main', 'arrow']">
|
|
46
|
+
<NCollapseItem v-if="modelValue" v-for="(_item, index) of modelValue" display-directive="if"
|
|
47
|
+
:name="`${field.id}.${index}`">
|
|
48
|
+
<template #header>
|
|
49
|
+
{{ getCollapseItemTitle(field, (_item as Item), index) }}
|
|
50
|
+
</template>
|
|
51
|
+
<template #header-extra>
|
|
52
|
+
<NFlex>
|
|
53
|
+
<component v-if="field.itemExtraActions" :is="field.itemExtraActions(index)"></component>
|
|
54
|
+
<NButtonGroup>
|
|
55
|
+
<NButton size="small" round type="error" quaternary
|
|
56
|
+
:disabled="typeof field.inputProps === 'function' ? field.inputProps(index)?.disabled : field.inputProps?.disabled"
|
|
57
|
+
@click="handleDeleteItem(index)">
|
|
58
|
+
<template #icon>
|
|
59
|
+
<NIcon>
|
|
60
|
+
<Icon name="tabler:trash" />
|
|
61
|
+
</NIcon>
|
|
62
|
+
</template>
|
|
63
|
+
</NButton>
|
|
64
|
+
<component v-if="field.itemExtraButtons && !Array.isArray(field.itemExtraButtons)"
|
|
65
|
+
:is="field.itemExtraButtons(index)">
|
|
66
|
+
</component>
|
|
67
|
+
<component v-else-if="field.itemExtraButtons && Array.isArray(field.itemExtraButtons)"
|
|
68
|
+
v-for="component in field.itemExtraButtons(index)" :is="component">
|
|
69
|
+
</component>
|
|
70
|
+
</NButtonGroup>
|
|
71
|
+
</NFlex>
|
|
72
|
+
</template>
|
|
73
|
+
<div class="collapseContentPadding">
|
|
74
|
+
<LazyFieldS v-model="(modelValue[index] as Item)" :schema="(field.children as Schema).map((child) => ({
|
|
75
|
+
...child,
|
|
76
|
+
...(typeof child.inputProps === 'function' ? { inputProps: child.inputProps(index) } : {}),
|
|
77
|
+
...(typeof child.labelProps === 'function' ? { labelProps: child.labelProps(index) } : {}),
|
|
78
|
+
...(typeof child.render === 'function' ? { render: child.render(index) } : {})
|
|
79
|
+
}))" />
|
|
80
|
+
</div>
|
|
81
|
+
</NCollapseItem>
|
|
82
|
+
</NCollapse>
|
|
83
|
+
</NCollapseItem>
|
|
84
|
+
</NCollapse>
|
|
85
|
+
<NCard v-else :bordered="false" content-style="padding-left: 0; padding-right: 0;"
|
|
86
|
+
header-style="padding-top: 0; padding-left: 0; padding-right: 0;">
|
|
87
|
+
<template #header>
|
|
88
|
+
<NDropdown size="small" :placement="Language === 'ar' ? 'left' : 'right'" show-arrow trigger="hover"
|
|
89
|
+
:delay="1500" :options="dropdownOptions" @select="handleSelect">
|
|
90
|
+
{{ t(field.key) }}
|
|
91
|
+
</NDropdown>
|
|
92
|
+
</template>
|
|
93
|
+
<template #header-extra>
|
|
94
|
+
<NFlex>
|
|
95
|
+
<component v-if="field.extraActions" :is="field.extraActions"></component>
|
|
96
|
+
<NButtonGroup>
|
|
97
|
+
<NButton v-if="!field.disableActions" size="small" round @click="handleAddNewItem">
|
|
98
|
+
<template #icon>
|
|
99
|
+
<NIcon>
|
|
100
|
+
<Icon name="tabler:plus" />
|
|
101
|
+
</NIcon>
|
|
102
|
+
</template>
|
|
103
|
+
</NButton>
|
|
104
|
+
<template v-if="field.extraButtons">
|
|
105
|
+
<component v-if="Array.isArray(field.extraButtons)"
|
|
106
|
+
v-for="(component, index) in field.extraButtons" :is="component" :key="index"></component>
|
|
107
|
+
<component v-else :is="field.extraButtons"></component>
|
|
108
|
+
</template>
|
|
109
|
+
</NButtonGroup>
|
|
110
|
+
</NFlex>
|
|
111
|
+
</template>
|
|
112
|
+
<NDataTable v-if="field.children" :columns :data="(modelValue as Item[])" :scroll-x="tableWidth" />
|
|
113
|
+
</NCard>
|
|
114
|
+
</template>
|
|
115
|
+
|
|
116
|
+
<script setup lang="ts">
|
|
117
|
+
import { isArrayOfObjects, isStringified } from "inibase/utils";
|
|
118
|
+
import Inison from "inison";
|
|
119
|
+
import type { DataTableColumns, DropdownOption } from "naive-ui";
|
|
120
|
+
import {
|
|
121
|
+
Icon,
|
|
122
|
+
LazyField,
|
|
123
|
+
NButton,
|
|
124
|
+
NFlex,
|
|
125
|
+
NIcon,
|
|
126
|
+
NPerformantEllipsis,
|
|
127
|
+
NText,
|
|
128
|
+
NButtonGroup
|
|
129
|
+
} from "#components";
|
|
130
|
+
|
|
131
|
+
const database = useState<Database>("database");
|
|
132
|
+
|
|
133
|
+
const Language = useScopedCookie<LanguagesType>("language", database.value?.slug);
|
|
134
|
+
|
|
135
|
+
const { field } = defineProps<{ field: Field }>();
|
|
136
|
+
|
|
137
|
+
const modelValue = defineModel<(string | number | Item)[]>();
|
|
138
|
+
const parentExpanded = ref<string[]>();
|
|
139
|
+
|
|
140
|
+
const expandedNames = ref<string[]>();
|
|
141
|
+
watch(expandedNames, (v) => {
|
|
142
|
+
if (v) parentExpanded.value = [String(field.id)];
|
|
143
|
+
});
|
|
144
|
+
function handleAddNewItem() {
|
|
145
|
+
let newElementIndex: number;
|
|
146
|
+
if (!modelValue.value) {
|
|
147
|
+
newElementIndex = 0;
|
|
148
|
+
modelValue.value = [
|
|
149
|
+
field.onCreate
|
|
150
|
+
? field.onCreate instanceof Function
|
|
151
|
+
? field.onCreate(newElementIndex) || {}
|
|
152
|
+
: field.onCreate
|
|
153
|
+
: {},
|
|
154
|
+
];
|
|
155
|
+
} else {
|
|
156
|
+
newElementIndex = toRaw(modelValue.value).length;
|
|
157
|
+
modelValue.value.push(
|
|
158
|
+
field.onCreate
|
|
159
|
+
? field.onCreate instanceof Function
|
|
160
|
+
? field.onCreate(newElementIndex) || {}
|
|
161
|
+
: field.onCreate
|
|
162
|
+
: {},
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
expandedNames.value = [`${field.id}.${newElementIndex}`];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function handleDeleteItem(index: number) {
|
|
169
|
+
if (field.onDelete) field.onDelete(index);
|
|
170
|
+
modelValue.value?.splice(index, 1);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async function handleSelect(value: string) {
|
|
174
|
+
switch (value) {
|
|
175
|
+
case "copy": {
|
|
176
|
+
if (!modelValue.value) return;
|
|
177
|
+
await copyToClipboard(Inison.stringify(modelValue.value));
|
|
178
|
+
window.$message.success(t("copiedSuccessfully"));
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
case "paste": {
|
|
182
|
+
try {
|
|
183
|
+
const itemFromClipboard = await navigator.clipboard.readText();
|
|
184
|
+
|
|
185
|
+
if (!itemFromClipboard) {
|
|
186
|
+
window.$message.error(t("clipboardEmpty"));
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (!isStringified(itemFromClipboard)) {
|
|
190
|
+
window.$message.error(t("clipboardItemIsNotCorrect"));
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const unstringifiedItem = Inison.unstringify<Item[]>(itemFromClipboard);
|
|
195
|
+
if (!unstringifiedItem && !Array.isArray(unstringifiedItem)) {
|
|
196
|
+
window.$message.error(t("clipboardItemIsNotCorrect"));
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
modelValue.value = unstringifiedItem;
|
|
201
|
+
} catch {
|
|
202
|
+
window.$message.error(t("clipboardItemIsNotCorrect"));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const dropdownOptions = computed<DropdownOption[]>(() => [
|
|
208
|
+
{
|
|
209
|
+
label: t("copyItem"),
|
|
210
|
+
key: "copy",
|
|
211
|
+
show:
|
|
212
|
+
!!modelValue.value &&
|
|
213
|
+
Array.isArray(modelValue.value) &&
|
|
214
|
+
modelValue.value.length > 0,
|
|
215
|
+
icon: () => h(NIcon, () => h(Icon, { name: "tabler:copy" })),
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
label: t("pasteItem"),
|
|
219
|
+
key: "paste",
|
|
220
|
+
icon: () => h(NIcon, () => h(Icon, { name: "tabler:clipboard" })),
|
|
221
|
+
},
|
|
222
|
+
]);
|
|
223
|
+
|
|
224
|
+
const columns = ref<DataTableColumns<any>>();
|
|
225
|
+
const tableWidth = ref<number>(0);
|
|
226
|
+
|
|
227
|
+
function setColumns() {
|
|
228
|
+
columns.value = [
|
|
229
|
+
...(field.children as Schema).map((child) => ({
|
|
230
|
+
width: t(child.key).length > 10 ? t(child.key).length * 14 : 150,
|
|
231
|
+
title: () =>
|
|
232
|
+
h(NFlex, { wrap: false, align: "center", justify: "start" }, () => [
|
|
233
|
+
getField(child).icon(),
|
|
234
|
+
h(NPerformantEllipsis, () => t(child.key)),
|
|
235
|
+
child.required
|
|
236
|
+
? h(
|
|
237
|
+
NText,
|
|
238
|
+
{
|
|
239
|
+
type: "error",
|
|
240
|
+
},
|
|
241
|
+
() => " *",
|
|
242
|
+
)
|
|
243
|
+
: undefined,
|
|
244
|
+
]),
|
|
245
|
+
key: child.id,
|
|
246
|
+
render: (_item: any, index: number) =>
|
|
247
|
+
h(LazyField, {
|
|
248
|
+
field: {
|
|
249
|
+
...child,
|
|
250
|
+
labelProps: {
|
|
251
|
+
style: {
|
|
252
|
+
marginTop: "24px",
|
|
253
|
+
},
|
|
254
|
+
showLabel: false,
|
|
255
|
+
},
|
|
256
|
+
isTable: true,
|
|
257
|
+
...(typeof child.inputProps === "function"
|
|
258
|
+
? { inputProps: child.inputProps(index) }
|
|
259
|
+
: {}),
|
|
260
|
+
...(typeof child.labelProps === "function"
|
|
261
|
+
? { labelProps: child.labelProps(index) }
|
|
262
|
+
: {}),
|
|
263
|
+
...(typeof child.render === "function"
|
|
264
|
+
? { render: child.render(index) }
|
|
265
|
+
: {}),
|
|
266
|
+
},
|
|
267
|
+
"onUpdate:modelValue": (newValue) => {
|
|
268
|
+
// @ts-ignore
|
|
269
|
+
(modelValue.value as Item[])[index][child.key] = newValue;
|
|
270
|
+
},
|
|
271
|
+
// @ts-ignore
|
|
272
|
+
modelValue: (modelValue.value as Item[])[index][child.key],
|
|
273
|
+
}),
|
|
274
|
+
})),
|
|
275
|
+
field.disableItemActions === true
|
|
276
|
+
? {}
|
|
277
|
+
: {
|
|
278
|
+
title: t("actions"),
|
|
279
|
+
fixed: "right",
|
|
280
|
+
align: "center",
|
|
281
|
+
width: 100,
|
|
282
|
+
key: "actions",
|
|
283
|
+
render: (_row: any, index: number) =>
|
|
284
|
+
h(NButtonGroup, () =>
|
|
285
|
+
[
|
|
286
|
+
field.itemExtraButtons ? field.itemExtraButtons(index) : null,
|
|
287
|
+
h(
|
|
288
|
+
NButton,
|
|
289
|
+
{
|
|
290
|
+
disabled:
|
|
291
|
+
typeof field.inputProps === "function"
|
|
292
|
+
? field.inputProps(index)?.disabled
|
|
293
|
+
: field.inputProps?.disabled,
|
|
294
|
+
|
|
295
|
+
secondary: true,
|
|
296
|
+
circle: true,
|
|
297
|
+
size: "small",
|
|
298
|
+
type: "error",
|
|
299
|
+
onClick: () => handleDeleteItem(index),
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
icon: () =>
|
|
303
|
+
h(NIcon, () => h(Icon, { name: "tabler:trash" })),
|
|
304
|
+
},
|
|
305
|
+
),
|
|
306
|
+
]
|
|
307
|
+
.filter((i) => i !== null)
|
|
308
|
+
.flat(Infinity),
|
|
309
|
+
),
|
|
310
|
+
},
|
|
311
|
+
] as DataTableColumns<any>;
|
|
312
|
+
|
|
313
|
+
tableWidth.value = columns.value.reduce(
|
|
314
|
+
(accumulator: number, { width }) =>
|
|
315
|
+
accumulator + ((width as number | undefined) ?? 0),
|
|
316
|
+
40,
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
watch(Language, setColumns);
|
|
321
|
+
onMounted(() => {
|
|
322
|
+
if (isArrayOfObjects(field.children)) setColumns();
|
|
323
|
+
});
|
|
324
|
+
</script>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NTooltip :delay="1500">
|
|
3
|
+
<template #trigger>
|
|
4
|
+
<NButton circle secondary size="tiny" @click.prevent.stop="showAssetsModal = true">
|
|
5
|
+
<template #icon>
|
|
6
|
+
<NIcon>
|
|
7
|
+
<Icon name="tabler:books" />
|
|
8
|
+
</NIcon>
|
|
9
|
+
</template>
|
|
10
|
+
</NButton>
|
|
11
|
+
</template>
|
|
12
|
+
{{ t('gallery') }}
|
|
13
|
+
</NTooltip>
|
|
14
|
+
<NPopover trigger="click">
|
|
15
|
+
<template #trigger>
|
|
16
|
+
<NTooltip :delay="1500" placement="bottom">
|
|
17
|
+
<template #trigger>
|
|
18
|
+
<NButton circle secondary size="tiny" @click.prevent.stop="importInputRef?.focus()">
|
|
19
|
+
<template #icon>
|
|
20
|
+
<NIcon>
|
|
21
|
+
<Icon name="tabler:link" />
|
|
22
|
+
</NIcon>
|
|
23
|
+
</template>
|
|
24
|
+
</NButton>
|
|
25
|
+
</template>
|
|
26
|
+
{{ t('import') }}
|
|
27
|
+
</NTooltip>
|
|
28
|
+
</template>
|
|
29
|
+
<NInputGroup>
|
|
30
|
+
<NInput size="small" :input-props="{ type: 'url' }" ref="importInputRef" v-model:value="assetURLs"
|
|
31
|
+
:placeholder="t('assetLink')" clearable @keydown.enter.prevent="importAsset">
|
|
32
|
+
<template #suffix>
|
|
33
|
+
<NIcon>
|
|
34
|
+
<Icon name="tabler:link" />
|
|
35
|
+
</NIcon>
|
|
36
|
+
</template>
|
|
37
|
+
</NInput>
|
|
38
|
+
<NTooltip :delay="1500">
|
|
39
|
+
<template #trigger>
|
|
40
|
+
<NButton size="small" :loading="Loading.import" :disabled="!assetURLs" tag="a" @click.prevent.stop="importAsset">
|
|
41
|
+
<template #icon>
|
|
42
|
+
<NIcon>
|
|
43
|
+
<Icon name="tabler:arrow-right" />
|
|
44
|
+
</NIcon>
|
|
45
|
+
</template>
|
|
46
|
+
</NButton>
|
|
47
|
+
</template>
|
|
48
|
+
{{ t('import') }}
|
|
49
|
+
</NTooltip>
|
|
50
|
+
</NInputGroup>
|
|
51
|
+
</NPopover>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script lang="ts" setup>
|
|
55
|
+
import type { NInput } from "naive-ui"
|
|
56
|
+
|
|
57
|
+
const { field, callback } = defineProps<{
|
|
58
|
+
field: Field
|
|
59
|
+
callback: CallableFunction
|
|
60
|
+
}>()
|
|
61
|
+
|
|
62
|
+
const showAssetsModal = defineModel<boolean>("showAssetsModal")
|
|
63
|
+
|
|
64
|
+
const importInputRef = ref<InstanceType<typeof NInput>>()
|
|
65
|
+
|
|
66
|
+
const config = useRuntimeConfig()
|
|
67
|
+
const assetURLs = ref()
|
|
68
|
+
const database = useState<Database>("database")
|
|
69
|
+
const Loading = useState<Record<string, boolean>>("Loading", () => ({}))
|
|
70
|
+
|
|
71
|
+
const Language = useScopedCookie<LanguagesType>("language", database.value?.slug)
|
|
72
|
+
const sessionID = useScopedCookie<string>("sid", database.value?.slug)
|
|
73
|
+
|
|
74
|
+
async function importAsset() {
|
|
75
|
+
Loading.value.import = true
|
|
76
|
+
const data = await $fetch<apiResponse<Asset | Asset[]>>(
|
|
77
|
+
`${config.public.apiBase}${database.value.slug ?? "inicontent"}/assets/import${field.suffix || ""}${field.suffix?.includes("?") ? "&" : "?"}${database.value.slug}_sid=${sessionID.value}`,
|
|
78
|
+
{
|
|
79
|
+
method: "POST",
|
|
80
|
+
headers: {
|
|
81
|
+
"Content-Type": "text/plain; charset=utf-8",
|
|
82
|
+
},
|
|
83
|
+
body: assetURLs.value,
|
|
84
|
+
params: {
|
|
85
|
+
locale: Language.value,
|
|
86
|
+
},
|
|
87
|
+
credentials: "include",
|
|
88
|
+
},
|
|
89
|
+
)
|
|
90
|
+
if (data.result) {
|
|
91
|
+
assetURLs.value = undefined
|
|
92
|
+
callback(data.result)
|
|
93
|
+
importInputRef.value?.clear()
|
|
94
|
+
} else window.$message.error(data.message)
|
|
95
|
+
Loading.value.import = false
|
|
96
|
+
}
|
|
97
|
+
</script>
|