@stonecrop/desktop 0.11.10 → 0.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/desktop",
3
- "version": "0.11.10",
3
+ "version": "0.12.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": {
@@ -32,10 +32,11 @@
32
32
  "**/*.css"
33
33
  ],
34
34
  "dependencies": {
35
- "@stonecrop/aform": "0.11.10",
36
- "@stonecrop/stonecrop": "0.11.10",
37
- "@stonecrop/themes": "0.11.10",
38
- "@stonecrop/atable": "0.11.10"
35
+ "@stonecrop/aform": "0.12.0",
36
+ "@stonecrop/atable": "0.12.0",
37
+ "@stonecrop/schema": "0.12.0",
38
+ "@stonecrop/themes": "0.12.0",
39
+ "@stonecrop/stonecrop": "0.12.0"
39
40
  },
40
41
  "peerDependencies": {
41
42
  "vue": "^3.5.33"
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div :class="{ collapsed: !isOpen }" class="action-set">
3
3
  <div class="action-menu-icon">
4
- <div id="cross" @click="onClick" :class="{ rotated: isOpen }">×</div>
4
+ <div id="cross" :class="{ rotated: isOpen }" @click="onClick">×</div>
5
5
  </div>
6
6
  <div style="margin-right: 30px"></div>
7
7
  <div v-for="(el, index) in elements" :key="el.label" class="action-element">
@@ -16,7 +16,7 @@
16
16
  </div>
17
17
  <div v-if="el.type == 'dropdown'">
18
18
  <div class="dropdown-header">
19
- <div @click="toggleDropdown(index)" class="cross" :class="{ rotated: dropdownOpen[index] }">×</div>
19
+ <div class="cross" :class="{ rotated: dropdownOpen[index] }" @click="toggleDropdown(index)">×</div>
20
20
  <button class="button-default dropdown-title" @click="toggleDropdown(index)">
21
21
  {{ el.label }}
22
22
  </button>
@@ -32,7 +32,8 @@
32
32
 
33
33
  <script setup lang="ts">
34
34
  import { useStonecrop } from '@stonecrop/stonecrop'
35
- import { AForm, type SchemaTypes, type TableColumn, type TableConfig } from '@stonecrop/aform'
35
+ import { AForm, type SchemaTypes } from '@stonecrop/aform'
36
+ import type { ColumnSchema } from '@stonecrop/schema'
36
37
  import { computed, onMounted, provide, ref, unref, watch } from 'vue'
37
38
 
38
39
  import ActionSet from './ActionSet.vue'
@@ -161,7 +162,7 @@ const currentDoctype = computed(() => {
161
162
 
162
163
  // For named routes, use params.doctype
163
164
  if (route.value.params.doctype) {
164
- return route.value.params.doctype as string
165
+ return route.value.params.doctype.toString()
165
166
  }
166
167
 
167
168
  // For catch-all routes that haven't been registered yet, extract from path
@@ -185,7 +186,7 @@ const routeDoctype = computed(() => {
185
186
 
186
187
  // For named routes, use params.doctype
187
188
  if (route.value.params.doctype) {
188
- return route.value.params.doctype as string
189
+ return route.value.params.doctype.toString()
189
190
  }
190
191
 
191
192
  // For catch-all routes, extract from path
@@ -203,7 +204,7 @@ const currentRecordId = computed(() => {
203
204
 
204
205
  // For named routes, use params.recordId
205
206
  if (route.value.params.recordId) {
206
- return route.value.params.recordId as string
207
+ return route.value.params.recordId.toString()
207
208
  }
208
209
 
209
210
  // For catch-all routes that haven't been registered yet, extract from path
@@ -495,11 +496,11 @@ const getDoctypesSchema = (): SchemaTypes[] => {
495
496
  edit: false,
496
497
  width: '20ch',
497
498
  },
498
- ] as TableColumn[],
499
+ ],
499
500
  config: {
500
501
  view: 'list',
501
502
  fullWidth: true,
502
- } as TableConfig,
503
+ },
503
504
  rows,
504
505
  },
505
506
  ]
@@ -509,23 +510,21 @@ const getRecordsSchema = (): SchemaTypes[] => {
509
510
  if (!currentDoctype.value) return []
510
511
  if (!stonecrop.value) return []
511
512
 
512
- const records = getRecords()
513
- const columns = getColumns()
514
- const idField = props.recordIdField || 'id'
513
+ const registry = stonecrop.value.registry
514
+ const doctype = registry.registry[currentDoctype.value]
515
515
 
516
- // If no columns are available, let the template fallback handle the loading state
517
- if (columns.length === 0) {
518
- return []
519
- }
516
+ if (!doctype) return []
517
+
518
+ const schema = registry.resolveSchema(doctype)
520
519
 
521
- // Ensure the ID column is first so click handler can reliably find it
522
- const idColumn = columns.find(c => c.fieldname === idField)
523
- const otherColumns = columns.filter(c => c.fieldname !== idField)
524
- const orderedColumns = idColumn ? [idColumn, ...otherColumns] : columns
520
+ // If no schema is available, let the template fallback handle the loading state
521
+ if (schema.length === 0) return []
522
+
523
+ const records = getRecords()
524
+ const idField = props.recordIdField || 'id'
525
525
 
526
- const rows = records.map((record: any) => ({
526
+ const rows = records.map(record => ({
527
527
  ...record,
528
- // Use the canonical ID field for navigation
529
528
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
530
529
  id: record[idField] || record.id || '',
531
530
  actions: 'Edit | Delete',
@@ -535,28 +534,12 @@ const getRecordsSchema = (): SchemaTypes[] => {
535
534
  {
536
535
  fieldname: 'records_table',
537
536
  component: 'ATable',
538
- columns: [
539
- ...orderedColumns.map(col => ({
540
- label: col.label,
541
- name: col.fieldname,
542
- fieldtype: col.fieldtype,
543
- align: 'left',
544
- edit: false,
545
- width: '20ch',
546
- })),
547
- {
548
- label: 'Actions',
549
- name: 'actions',
550
- fieldtype: 'Data',
551
- align: 'center',
552
- edit: false,
553
- width: '20ch',
554
- },
555
- ] as TableColumn[],
537
+ kind: 'table',
538
+ schema: [...(schema as ColumnSchema[]), { fieldname: 'actions', label: 'Actions', fieldtype: 'Data' }],
556
539
  config: {
557
540
  view: 'list',
558
541
  fullWidth: true,
559
- } as TableConfig,
542
+ },
560
543
  rows,
561
544
  },
562
545
  ]
@@ -597,28 +580,6 @@ const getRecords = () => {
597
580
  return []
598
581
  }
599
582
 
600
- const getColumns = () => {
601
- if (!stonecrop.value || !currentDoctype.value) return []
602
-
603
- try {
604
- const registry = stonecrop.value.registry
605
- const doctype = registry.registry[currentDoctype.value]
606
-
607
- if (doctype?.schema) {
608
- const schemaArray = 'toArray' in doctype.schema ? doctype.schema.toArray() : doctype.schema
609
- return schemaArray.map(field => ({
610
- fieldname: field.fieldname,
611
- label: ('label' in field && field.label) || field.fieldname,
612
- fieldtype: ('fieldtype' in field && field.fieldtype) || 'Data',
613
- }))
614
- }
615
- } catch {
616
- // Error getting schema - return empty array
617
- }
618
-
619
- return []
620
- }
621
-
622
583
  // Schema for different views - defined here after all helper functions are available
623
584
  const currentViewSchema = computed(() => {
624
585
  switch (currentView.value) {