@conduction/nextcloud-vue 0.1.0-beta.1 → 0.1.0-beta.11
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/README.md +226 -0
- package/css/index.css +5 -0
- package/dist/nextcloud-vue.cjs.js +79416 -7715
- package/dist/nextcloud-vue.cjs.js.map +1 -1
- package/dist/nextcloud-vue.css +3583 -504
- package/dist/nextcloud-vue.esm.js +79343 -7692
- package/dist/nextcloud-vue.esm.js.map +1 -1
- package/l10n/en.json +164 -0
- package/l10n/nl.json +164 -0
- package/package.json +104 -63
- package/src/components/CnActionsBar/CnActionsBar.vue +254 -0
- package/src/components/CnActionsBar/index.js +1 -0
- package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +570 -0
- package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -0
- package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -0
- package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +422 -0
- package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -0
- package/src/components/CnAdvancedFormDialog/index.js +1 -0
- package/src/components/CnCard/CnCard.vue +415 -0
- package/src/components/CnCard/index.js +1 -0
- package/src/components/CnCardGrid/CnCardGrid.vue +156 -152
- package/src/components/CnCardGrid/index.js +1 -1
- package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
- package/src/components/CnCellRenderer/index.js +1 -1
- package/src/components/CnChartWidget/CnChartWidget.vue +346 -0
- package/src/components/CnChartWidget/index.js +1 -0
- package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
- package/src/components/CnConfigurationCard/index.js +1 -1
- package/src/components/CnContextMenu/CnContextMenu.vue +142 -0
- package/src/components/CnContextMenu/index.js +1 -0
- package/src/components/CnCopyDialog/CnCopyDialog.vue +266 -0
- package/src/components/CnCopyDialog/index.js +1 -0
- package/src/components/CnDashboardGrid/CnDashboardGrid.vue +229 -0
- package/src/components/CnDashboardGrid/index.js +1 -0
- package/src/components/CnDashboardPage/CnDashboardPage.vue +397 -0
- package/src/components/CnDashboardPage/index.js +1 -0
- package/src/components/CnDataTable/CnDataTable.vue +362 -354
- package/src/components/CnDataTable/index.js +1 -1
- package/src/components/CnDeleteDialog/CnDeleteDialog.vue +177 -0
- package/src/components/CnDeleteDialog/index.js +1 -0
- package/src/components/CnDetailCard/CnDetailCard.vue +225 -0
- package/src/components/CnDetailCard/index.js +1 -0
- package/src/components/CnDetailGrid/CnDetailGrid.vue +256 -0
- package/src/components/CnDetailGrid/index.js +1 -0
- package/src/components/CnDetailPage/CnDetailPage.vue +432 -0
- package/src/components/CnDetailPage/index.js +1 -0
- package/src/components/CnFacetSidebar/CnFacetSidebar.vue +234 -223
- package/src/components/CnFacetSidebar/index.js +1 -1
- package/src/components/CnFilterBar/CnFilterBar.vue +153 -152
- package/src/components/CnFilterBar/index.js +1 -1
- package/src/components/CnFormDialog/CnFormDialog.vue +1047 -0
- package/src/components/CnFormDialog/index.js +1 -0
- package/src/components/CnIcon/CnIcon.vue +89 -0
- package/src/components/CnIcon/index.js +1 -0
- package/src/components/CnIndexPage/CnIndexPage.vue +980 -682
- package/src/components/CnIndexPage/index.js +1 -1
- package/src/components/CnIndexSidebar/CnIndexSidebar.vue +536 -0
- package/src/components/CnIndexSidebar/index.js +1 -0
- package/src/components/CnInfoWidget/CnInfoWidget.vue +219 -0
- package/src/components/CnInfoWidget/index.js +1 -0
- package/src/components/CnItemCard/CnItemCard.vue +134 -0
- package/src/components/CnItemCard/index.js +1 -0
- package/src/components/CnJsonViewer/CnJsonViewer.vue +312 -0
- package/src/components/CnJsonViewer/index.js +1 -0
- package/src/components/CnKpiGrid/CnKpiGrid.vue +93 -89
- package/src/components/CnKpiGrid/index.js +1 -1
- package/src/components/CnMassActionBar/CnMassActionBar.vue +161 -160
- package/src/components/CnMassActionBar/index.js +1 -1
- package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +327 -320
- package/src/components/CnMassCopyDialog/index.js +1 -1
- package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +245 -238
- package/src/components/CnMassDeleteDialog/index.js +1 -1
- package/src/components/CnMassExportDialog/CnMassExportDialog.vue +191 -190
- package/src/components/CnMassExportDialog/index.js +1 -1
- package/src/components/CnMassImportDialog/CnMassImportDialog.vue +494 -491
- package/src/components/CnMassImportDialog/index.js +1 -1
- package/src/components/CnNoteCard/CnNoteCard.vue +149 -0
- package/src/components/CnNoteCard/index.js +1 -0
- package/src/components/CnNotesCard/CnNotesCard.vue +416 -0
- package/src/components/CnNotesCard/index.js +1 -0
- package/src/components/CnObjectCard/CnObjectCard.vue +294 -292
- package/src/components/CnObjectCard/index.js +1 -1
- package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +854 -0
- package/src/components/CnObjectDataWidget/index.js +1 -0
- package/src/components/CnObjectMetadataWidget/CnObjectMetadataWidget.vue +289 -0
- package/src/components/CnObjectMetadataWidget/index.js +1 -0
- package/src/components/CnObjectSidebar/CnAuditTrailTab.vue +369 -0
- package/src/components/CnObjectSidebar/CnFilesTab.vue +287 -0
- package/src/components/CnObjectSidebar/CnNotesTab.vue +250 -0
- package/src/components/CnObjectSidebar/CnObjectSidebar.vue +255 -0
- package/src/components/CnObjectSidebar/CnTagsTab.vue +259 -0
- package/src/components/CnObjectSidebar/CnTasksTab.vue +483 -0
- package/src/components/CnObjectSidebar/index.js +6 -0
- package/src/components/CnPageHeader/CnPageHeader.vue +61 -0
- package/src/components/CnPageHeader/index.js +1 -0
- package/src/components/CnPagination/CnPagination.vue +253 -252
- package/src/components/CnPagination/index.js +1 -1
- package/src/components/CnProgressBar/CnProgressBar.vue +262 -0
- package/src/components/CnProgressBar/index.js +1 -0
- package/src/components/CnRegisterMapping/CnRegisterMapping.vue +793 -0
- package/src/components/CnRegisterMapping/index.js +1 -0
- package/src/components/CnRowActions/CnRowActions.vue +95 -73
- package/src/components/CnRowActions/index.js +1 -1
- package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -0
- package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +788 -0
- package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -0
- package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -0
- package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -0
- package/src/components/CnSchemaFormDialog/index.js +1 -0
- package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
- package/src/components/CnSettingsCard/index.js +1 -1
- package/src/components/CnSettingsSection/CnSettingsSection.vue +267 -266
- package/src/components/CnSettingsSection/index.js +1 -1
- package/src/components/CnStatsBlock/CnStatsBlock.vue +437 -366
- package/src/components/CnStatsBlock/index.js +1 -1
- package/src/components/CnStatsPanel/CnStatsPanel.vue +321 -0
- package/src/components/CnStatsPanel/index.js +1 -0
- package/src/components/CnStatusBadge/CnStatusBadge.vue +90 -77
- package/src/components/CnStatusBadge/index.js +1 -1
- package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +545 -0
- package/src/components/CnTabbedFormDialog/index.js +1 -0
- package/src/components/CnTableWidget/CnTableWidget.vue +333 -0
- package/src/components/CnTableWidget/index.js +1 -0
- package/src/components/CnTasksCard/CnTasksCard.vue +374 -0
- package/src/components/CnTasksCard/index.js +1 -0
- package/src/components/CnTileWidget/CnTileWidget.vue +159 -0
- package/src/components/CnTileWidget/index.js +1 -0
- package/src/components/CnTimelineStages/CnTimelineStages.vue +294 -0
- package/src/components/CnTimelineStages/index.js +1 -0
- package/src/components/CnUserActionMenu/CnUserActionMenu.vue +436 -0
- package/src/components/CnUserActionMenu/index.js +1 -0
- package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +313 -312
- package/src/components/CnVersionInfoCard/index.js +1 -1
- package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -0
- package/src/components/CnWidgetRenderer/index.js +1 -0
- package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +248 -0
- package/src/components/CnWidgetWrapper/index.js +1 -0
- package/src/components/index.js +57 -25
- package/src/composables/index.js +5 -3
- package/src/composables/useContextMenu.js +126 -0
- package/src/composables/useDashboardView.js +286 -0
- package/src/composables/useDetailView.js +290 -132
- package/src/composables/useListView.js +364 -153
- package/src/composables/useSubResource.js +142 -142
- package/src/constants/metadata.js +30 -0
- package/src/css/CnSchemaFormDialog.css +546 -0
- package/src/css/__sample_nextcloud_tokens.css +110 -0
- package/src/css/actions-bar.css +54 -0
- package/src/css/badge.css +83 -51
- package/src/css/card.css +129 -128
- package/src/css/context-menu.css +20 -0
- package/src/css/dashboard.css +70 -0
- package/src/css/detail-page.css +235 -0
- package/src/css/detail.css +68 -68
- package/src/css/index-page.css +44 -0
- package/src/css/index-sidebar.css +193 -0
- package/src/css/index.css +17 -8
- package/src/css/layout.css +90 -90
- package/src/css/page-header.css +35 -0
- package/src/css/pagination.css +72 -72
- package/src/css/table.css +142 -143
- package/src/css/timeline-stages.css +220 -0
- package/src/css/utilities.css +46 -46
- package/src/index.js +95 -50
- package/src/l10n/index.js +12 -0
- package/src/mixins/gridLayout.js +118 -0
- package/src/store/createCrudStore.d.ts +350 -0
- package/src/store/createCrudStore.js +413 -0
- package/src/store/createSubResourcePlugin.js +125 -135
- package/src/store/index.js +4 -3
- package/src/store/pluginMerge.js +55 -0
- package/src/store/plugins/auditTrails.js +357 -17
- package/src/store/plugins/files.js +250 -186
- package/src/store/plugins/index.js +8 -4
- package/src/store/plugins/lifecycle.js +180 -180
- package/src/store/plugins/logs.d.ts +22 -0
- package/src/store/plugins/logs.js +172 -0
- package/src/store/plugins/registerMapping.js +195 -0
- package/src/store/plugins/relations.js +68 -68
- package/src/store/plugins/search.js +385 -0
- package/src/store/plugins/selection.js +104 -0
- package/src/store/useObjectStore.js +793 -625
- package/src/types/auditTrail.d.ts +32 -32
- package/src/types/file.d.ts +23 -23
- package/src/types/index.d.ts +67 -35
- package/src/types/notification.d.ts +36 -36
- package/src/types/object.d.ts +40 -40
- package/src/types/organisation.d.ts +41 -41
- package/src/types/register.d.ts +25 -25
- package/src/types/schema.d.ts +39 -39
- package/src/types/shared.d.ts +79 -79
- package/src/types/source.d.ts +14 -14
- package/src/types/task.d.ts +31 -31
- package/src/utils/errors.js +96 -96
- package/src/utils/getTheme.js +9 -0
- package/src/utils/headers.js +80 -44
- package/src/utils/id.js +13 -0
- package/src/utils/index.js +4 -3
- package/src/utils/schema.js +423 -287
- package/src/utils/widgetVisibility.js +162 -0
- package/src/components/CnDetailViewLayout/CnDetailViewLayout.vue +0 -88
- package/src/components/CnDetailViewLayout/index.js +0 -1
- package/src/components/CnEmptyState/CnEmptyState.vue +0 -78
- package/src/components/CnEmptyState/index.js +0 -1
- package/src/components/CnListViewLayout/CnListViewLayout.vue +0 -80
- package/src/components/CnListViewLayout/index.js +0 -1
- package/src/components/CnViewModeToggle/CnViewModeToggle.vue +0 -77
- package/src/components/CnViewModeToggle/index.js +0 -1
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Fragment>
|
|
3
|
+
<div class="cn-schema-form__scrollable">
|
|
4
|
+
<CnDataTable
|
|
5
|
+
:columns="tableColumns"
|
|
6
|
+
:rows="propertyRows"
|
|
7
|
+
row-key="_id"
|
|
8
|
+
:selectable="false"
|
|
9
|
+
:row-class="getRowClass"
|
|
10
|
+
:empty-text="'No properties found. Click "Add property" to create one.'"
|
|
11
|
+
@row-click="onRowClick">
|
|
12
|
+
<template #actions-header>
|
|
13
|
+
<NcButton
|
|
14
|
+
type="primary"
|
|
15
|
+
:disabled="loading"
|
|
16
|
+
@click="$emit('add-property')">
|
|
17
|
+
<template #icon>
|
|
18
|
+
<Plus :size="20" />
|
|
19
|
+
</template>
|
|
20
|
+
Add property
|
|
21
|
+
</NcButton>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<template #column-_key="{ row }">
|
|
25
|
+
<div v-if="selectedProperty === row._key" class="cn-schema-form__name-input-container" @click.stop>
|
|
26
|
+
<AlertOutline v-if="isPropertyModified(row._key)"
|
|
27
|
+
:size="16"
|
|
28
|
+
class="cn-schema-form__warning-icon"
|
|
29
|
+
:title="'Property has been modified. Changes will only take effect after the schema is saved.'" />
|
|
30
|
+
<NcTextField
|
|
31
|
+
ref="propertyNameInput"
|
|
32
|
+
:value="row._key"
|
|
33
|
+
label="(technical) Property Name"
|
|
34
|
+
@update:value="onPropertyKeyUpdate(row._key, $event)"
|
|
35
|
+
@click.stop />
|
|
36
|
+
</div>
|
|
37
|
+
<div v-else class="cn-schema-form__name-display-container">
|
|
38
|
+
<AlertOutline v-if="isPropertyModified(row._key)"
|
|
39
|
+
:size="16"
|
|
40
|
+
class="cn-schema-form__warning-icon"
|
|
41
|
+
:title="'Property has been modified. Changes will only take effect after the schema is saved.'" />
|
|
42
|
+
<div class="cn-schema-form__name-with-chips">
|
|
43
|
+
<span class="cn-schema-form__property-name">{{ row._key }}</span>
|
|
44
|
+
<div class="cn-schema-form__inline-chips">
|
|
45
|
+
<span v-if="isPropertyRequired(schema, row._key)"
|
|
46
|
+
class="cn-schema-form__property-chip cn-schema-form__chip-primary">Required</span>
|
|
47
|
+
<span v-if="row.immutable"
|
|
48
|
+
class="cn-schema-form__property-chip cn-schema-form__chip-secondary">Immutable</span>
|
|
49
|
+
<span v-if="row.deprecated"
|
|
50
|
+
class="cn-schema-form__property-chip cn-schema-form__chip-warning">Deprecated</span>
|
|
51
|
+
<span v-if="row.visible === false"
|
|
52
|
+
class="cn-schema-form__property-chip cn-schema-form__chip-secondary">Hidden in view</span>
|
|
53
|
+
<span v-if="row.hideOnCollection"
|
|
54
|
+
class="cn-schema-form__property-chip cn-schema-form__chip-secondary">Hidden in Collection</span>
|
|
55
|
+
<span v-if="row.hideOnForm"
|
|
56
|
+
class="cn-schema-form__property-chip cn-schema-form__chip-secondary">Hidden in Form</span>
|
|
57
|
+
<span v-if="row.const !== undefined"
|
|
58
|
+
class="cn-schema-form__property-chip cn-schema-form__chip-success">Constant</span>
|
|
59
|
+
<span v-if="row.enum && row.enum.length > 0"
|
|
60
|
+
class="cn-schema-form__property-chip cn-schema-form__chip-success">Enumeration ({{ row.enum.length }})</span>
|
|
61
|
+
<span v-if="row.facetable === true || (typeof row.facetable === 'object' && row.facetable !== null)"
|
|
62
|
+
class="cn-schema-form__property-chip cn-schema-form__chip-info">Facetable</span>
|
|
63
|
+
<span v-if="hasCustomTableSettings(row._key)"
|
|
64
|
+
class="cn-schema-form__property-chip cn-schema-form__chip-table">Table</span>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</template>
|
|
69
|
+
|
|
70
|
+
<template #column-type="{ row }">
|
|
71
|
+
<NcSelect
|
|
72
|
+
v-if="selectedProperty === row._key"
|
|
73
|
+
v-model="schema.properties[row._key].type"
|
|
74
|
+
:options="typeOptionsForSelect"
|
|
75
|
+
input-label="Property Type"
|
|
76
|
+
@click.stop />
|
|
77
|
+
<span v-else>{{ row.type }}</span>
|
|
78
|
+
</template>
|
|
79
|
+
|
|
80
|
+
<template #row-actions="{ row }">
|
|
81
|
+
<CnSchemaPropertyActions
|
|
82
|
+
:property-key="row._key"
|
|
83
|
+
:property="schema.properties[row._key]"
|
|
84
|
+
:schema-item="schema"
|
|
85
|
+
:original-properties="originalProperties"
|
|
86
|
+
:available-schemas="availableSchemas"
|
|
87
|
+
:available-registers="availableRegisters"
|
|
88
|
+
:available-tags-options="availableTagsOptions"
|
|
89
|
+
:user-groups="userGroups"
|
|
90
|
+
:sorted-user-groups="sortedUserGroups"
|
|
91
|
+
:loading-groups="loadingGroups"
|
|
92
|
+
@copy-property="$emit('copy-property', $event)"
|
|
93
|
+
@delete-property="$emit('delete-property', $event)" />
|
|
94
|
+
</template>
|
|
95
|
+
</CnDataTable>
|
|
96
|
+
</div>
|
|
97
|
+
<CnNoteCard v-if="propertiesModified && !loading" type="warning" class="cn-schema-form__properties-warning">
|
|
98
|
+
<p>Properties have been modified. Changes will only take effect after the schema is saved.</p>
|
|
99
|
+
</CnNoteCard>
|
|
100
|
+
</Fragment>
|
|
101
|
+
</template>
|
|
102
|
+
|
|
103
|
+
<!-- eslint-disable jsdoc/valid-types -->
|
|
104
|
+
<script>
|
|
105
|
+
import { NcButton, NcTextField, NcSelect } from '@nextcloud/vue'
|
|
106
|
+
import { CnDataTable } from '../CnDataTable/index.js'
|
|
107
|
+
import { CnNoteCard } from '../CnNoteCard/index.js'
|
|
108
|
+
import CnSchemaPropertyActions from './CnSchemaPropertyActions.vue'
|
|
109
|
+
|
|
110
|
+
import Plus from 'vue-material-design-icons/Plus.vue'
|
|
111
|
+
import AlertOutline from 'vue-material-design-icons/AlertOutline.vue'
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* CnSchemaPropertiesTab — Properties table tab for CnSchemaFormDialog.
|
|
115
|
+
*
|
|
116
|
+
* Renders the properties of a JSON Schema in a CnDataTable with inline editing
|
|
117
|
+
* for property name and type, plus an actions dropdown per row.
|
|
118
|
+
*
|
|
119
|
+
* @event add-property Emitted when "Add property" button is clicked.
|
|
120
|
+
* @event update:selected-property Emitted when row selection changes. Payload: key or null.
|
|
121
|
+
* @event update:property-key Emitted when property is renamed. Payload: { oldKey, newKey }.
|
|
122
|
+
* @event copy-property Emitted when copy action is triggered. Payload: key.
|
|
123
|
+
* @event delete-property Emitted when delete action is triggered. Payload: key.
|
|
124
|
+
*/
|
|
125
|
+
export default {
|
|
126
|
+
name: 'CnSchemaPropertiesTab',
|
|
127
|
+
components: {
|
|
128
|
+
NcButton,
|
|
129
|
+
NcTextField,
|
|
130
|
+
NcSelect,
|
|
131
|
+
CnDataTable,
|
|
132
|
+
CnNoteCard,
|
|
133
|
+
CnSchemaPropertyActions,
|
|
134
|
+
Plus,
|
|
135
|
+
AlertOutline,
|
|
136
|
+
},
|
|
137
|
+
props: {
|
|
138
|
+
/** The full schema item (needs .properties, .required) */
|
|
139
|
+
schemaItem: { type: Object, required: true },
|
|
140
|
+
/** Disable state */
|
|
141
|
+
loading: { type: Boolean, default: false },
|
|
142
|
+
/** Currently selected property key */
|
|
143
|
+
selectedProperty: { type: String, default: null },
|
|
144
|
+
/** Whether any properties have been modified */
|
|
145
|
+
propertiesModified: { type: Boolean, default: false },
|
|
146
|
+
/** Original properties snapshot for modification detection */
|
|
147
|
+
originalProperties: { type: Object, default: () => ({}) },
|
|
148
|
+
/** Type options for the inline NcSelect */
|
|
149
|
+
typeOptionsForSelect: { type: Array, default: () => [] },
|
|
150
|
+
/** Available schemas for references */
|
|
151
|
+
availableSchemas: { type: Array, default: () => [] },
|
|
152
|
+
/** Available registers */
|
|
153
|
+
availableRegisters: { type: Array, default: () => [] },
|
|
154
|
+
/** Available tags for file property config */
|
|
155
|
+
availableTagsOptions: { type: Array, default: () => [] },
|
|
156
|
+
/** User groups for RBAC */
|
|
157
|
+
userGroups: { type: Array, default: () => [] },
|
|
158
|
+
/** Filtered/sorted user groups */
|
|
159
|
+
sortedUserGroups: { type: Array, default: () => [] },
|
|
160
|
+
/** Whether groups are loading */
|
|
161
|
+
loadingGroups: { type: Boolean, default: false },
|
|
162
|
+
},
|
|
163
|
+
data() {
|
|
164
|
+
return {
|
|
165
|
+
propertyStableIds: {},
|
|
166
|
+
nextPropertyId: 1,
|
|
167
|
+
isRenaming: false,
|
|
168
|
+
tableColumns: [
|
|
169
|
+
{ key: '_key', label: 'Name', sortable: false },
|
|
170
|
+
{ key: 'type', label: 'Type', sortable: false },
|
|
171
|
+
],
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
computed: {
|
|
175
|
+
/** Local alias to avoid vue/no-mutating-props on template bindings */
|
|
176
|
+
schema() {
|
|
177
|
+
return this.schemaItem
|
|
178
|
+
},
|
|
179
|
+
sortedProperties() {
|
|
180
|
+
const properties = this.schema.properties || {}
|
|
181
|
+
return Object.entries(properties)
|
|
182
|
+
.sort(([, propA], [, propB]) => {
|
|
183
|
+
const orderA = propA.order || 0
|
|
184
|
+
const orderB = propB.order || 0
|
|
185
|
+
if (orderA > 0 && orderB > 0) {
|
|
186
|
+
return orderA - orderB
|
|
187
|
+
}
|
|
188
|
+
if (orderA > 0) return -1
|
|
189
|
+
if (orderB > 0) return 1
|
|
190
|
+
const createdA = propA.created || ''
|
|
191
|
+
const createdB = propB.created || ''
|
|
192
|
+
return createdA.localeCompare(createdB)
|
|
193
|
+
})
|
|
194
|
+
},
|
|
195
|
+
propertyRows() {
|
|
196
|
+
return this.sortedProperties.map(([key, prop]) => ({
|
|
197
|
+
_id: this.getStablePropertyId(key),
|
|
198
|
+
_key: key,
|
|
199
|
+
...prop,
|
|
200
|
+
}))
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
watch: {
|
|
204
|
+
selectedProperty(newKey) {
|
|
205
|
+
if (newKey) {
|
|
206
|
+
// Skip focus+select when the change comes from a rename —
|
|
207
|
+
// onPropertyKeyUpdate handles its own cursor positioning.
|
|
208
|
+
if (this.isRenaming) {
|
|
209
|
+
this.isRenaming = false
|
|
210
|
+
return
|
|
211
|
+
}
|
|
212
|
+
this.$nextTick(() => {
|
|
213
|
+
if (this.$refs.propertyNameInput) {
|
|
214
|
+
const inputs = Array.isArray(this.$refs.propertyNameInput)
|
|
215
|
+
? this.$refs.propertyNameInput
|
|
216
|
+
: [this.$refs.propertyNameInput]
|
|
217
|
+
if (inputs[0]) {
|
|
218
|
+
const input = inputs[0].$el.querySelector('input')
|
|
219
|
+
if (input) {
|
|
220
|
+
input.focus()
|
|
221
|
+
input.select()
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
methods: {
|
|
230
|
+
getStablePropertyId(propertyName) {
|
|
231
|
+
if (!this.propertyStableIds[propertyName]) {
|
|
232
|
+
this.propertyStableIds[propertyName] = this.nextPropertyId++
|
|
233
|
+
}
|
|
234
|
+
return this.propertyStableIds[propertyName]
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
isPropertyRequired(schema, key) {
|
|
238
|
+
const isInSchemaRequired = schema.required && schema.required.includes(key)
|
|
239
|
+
const hasPropertyRequired = schema.properties && schema.properties[key] && schema.properties[key].required === true
|
|
240
|
+
return isInSchemaRequired || hasPropertyRequired
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
isPropertyModified(key) {
|
|
244
|
+
if (!this.originalProperties) return false
|
|
245
|
+
const currentProperty = JSON.stringify(this.schema.properties[key] || {})
|
|
246
|
+
const originalProperty = JSON.stringify(this.originalProperties[key] || {})
|
|
247
|
+
return currentProperty !== originalProperty
|
|
248
|
+
},
|
|
249
|
+
|
|
250
|
+
hasCustomTableSettings(key) {
|
|
251
|
+
const table = this.schema.properties[key]?.table
|
|
252
|
+
if (!table) return false
|
|
253
|
+
const defaults = { default: false }
|
|
254
|
+
return !Object.keys(table).every(setting => table[setting] === defaults[setting])
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
getRowClass(row) {
|
|
258
|
+
const classes = []
|
|
259
|
+
if (this.selectedProperty === row._key) {
|
|
260
|
+
classes.push('cn-schema-form__selected-row')
|
|
261
|
+
}
|
|
262
|
+
if (this.isPropertyModified(row._key)) {
|
|
263
|
+
classes.push('cn-schema-form__modified-row')
|
|
264
|
+
}
|
|
265
|
+
return classes.join(' ')
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
onRowClick(row) {
|
|
269
|
+
if (this.selectedProperty === row._key) return
|
|
270
|
+
this.$emit('update:selected-property', row._key)
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
onPropertyKeyUpdate(oldKey, newKey) {
|
|
274
|
+
if (!newKey || newKey === oldKey) return
|
|
275
|
+
if (this.schema.properties[newKey] && newKey !== oldKey) return
|
|
276
|
+
|
|
277
|
+
this.isRenaming = true
|
|
278
|
+
|
|
279
|
+
// Transfer stable ID
|
|
280
|
+
if (this.propertyStableIds[oldKey]) {
|
|
281
|
+
this.propertyStableIds[newKey] = this.propertyStableIds[oldKey]
|
|
282
|
+
delete this.propertyStableIds[oldKey]
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
this.$emit('update:property-key', { oldKey, newKey })
|
|
286
|
+
|
|
287
|
+
// Refocus after rename
|
|
288
|
+
this.$nextTick(() => {
|
|
289
|
+
if (this.$refs.propertyNameInput) {
|
|
290
|
+
const inputs = Array.isArray(this.$refs.propertyNameInput)
|
|
291
|
+
? this.$refs.propertyNameInput
|
|
292
|
+
: [this.$refs.propertyNameInput]
|
|
293
|
+
if (inputs[0]) {
|
|
294
|
+
const input = inputs[0].$el.querySelector('input')
|
|
295
|
+
if (input) {
|
|
296
|
+
input.focus()
|
|
297
|
+
input.setSelectionRange(input.value.length, input.value.length)
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
})
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
}
|
|
305
|
+
</script>
|