@kinetis/vector-ui 0.13.0 → 0.15.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.
Files changed (241) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/app/components/Vx/Cell/BooleanGroup.vue +20 -0
  3. package/app/components/Vx/Cell/Country.vue +13 -0
  4. package/app/components/Vx/Cell/Json.vue +2 -8
  5. package/app/components/Vx/Cell/Repeater.vue +64 -0
  6. package/app/components/Vx/Cell/Select.vue +26 -0
  7. package/app/components/Vx/Cell/Tag.vue +15 -0
  8. package/app/components/Vx/CommandPalette.vue +5 -2
  9. package/app/components/Vx/Import/Dialog.vue +2 -1
  10. package/app/components/Vx/Input/BooleanGroup.vue +39 -0
  11. package/app/components/Vx/Input/Country.vue +14 -0
  12. package/app/components/Vx/Input/Json.vue +63 -0
  13. package/app/components/Vx/Input/Repeater.vue +142 -35
  14. package/app/components/Vx/Input/Select.vue +31 -0
  15. package/app/components/Vx/Input/Tag.vue +47 -0
  16. package/app/components/Vx/Input/Textarea.vue +0 -1
  17. package/app/components/Vx/Layout.vue +1 -1
  18. package/app/components/Vx/List/BulkEdit.vue +2 -1
  19. package/app/components/Vx/List/FilterBar.vue +25 -5
  20. package/app/components/Vx/Resource/Audit.vue +2 -1
  21. package/app/components/Vx/Resource/Form.vue +13 -10
  22. package/app/components/VxAi/ApprovalCard.vue +2 -2
  23. package/app/components/VxAi/Assistant.vue +6 -7
  24. package/app/composables/useVectorAssistant.ts +64 -40
  25. package/app/composables/useVectorCountryNames.ts +38 -0
  26. package/app/composables/useVectorFields.ts +5 -1
  27. package/app/composables/useVectorForm.ts +27 -3
  28. package/app/composables/useVectorInputs.ts +7 -5
  29. package/app/i18n/ar/fields.ts +15 -0
  30. package/app/i18n/ar/list.ts +2 -0
  31. package/app/i18n/de/fields.ts +15 -0
  32. package/app/i18n/de/list.ts +2 -0
  33. package/app/i18n/en/fields.ts +15 -0
  34. package/app/i18n/en/list.ts +2 -0
  35. package/app/i18n/es/fields.ts +15 -0
  36. package/app/i18n/es/list.ts +2 -0
  37. package/app/i18n/fr/fields.ts +15 -0
  38. package/app/i18n/fr/list.ts +2 -0
  39. package/app/i18n/he/fields.ts +15 -0
  40. package/app/i18n/he/list.ts +2 -0
  41. package/app/i18n/it/fields.ts +15 -0
  42. package/app/i18n/it/list.ts +2 -0
  43. package/app/i18n/ja/fields.ts +15 -0
  44. package/app/i18n/ja/list.ts +2 -0
  45. package/app/i18n/ko/fields.ts +15 -0
  46. package/app/i18n/ko/list.ts +2 -0
  47. package/app/i18n/nl/fields.ts +15 -0
  48. package/app/i18n/nl/list.ts +2 -0
  49. package/app/i18n/pl/fields.ts +15 -0
  50. package/app/i18n/pl/list.ts +2 -0
  51. package/app/i18n/pt/fields.ts +15 -0
  52. package/app/i18n/pt/list.ts +2 -0
  53. package/app/i18n/pt-BR/fields.ts +15 -0
  54. package/app/i18n/pt-BR/list.ts +2 -0
  55. package/app/i18n/ru/fields.ts +15 -0
  56. package/app/i18n/ru/list.ts +2 -0
  57. package/app/i18n/tr/fields.ts +15 -0
  58. package/app/i18n/tr/list.ts +2 -0
  59. package/app/i18n/uk/fields.ts +15 -0
  60. package/app/i18n/uk/list.ts +2 -0
  61. package/app/i18n/zh-Hans/fields.ts +15 -0
  62. package/app/i18n/zh-Hans/list.ts +2 -0
  63. package/app/types/vector.ts +47 -8
  64. package/app/utils/countries/ar.ts +252 -0
  65. package/app/utils/countries/de.ts +252 -0
  66. package/app/utils/countries/en.ts +252 -0
  67. package/app/utils/countries/es.ts +252 -0
  68. package/app/utils/countries/fr.ts +252 -0
  69. package/app/utils/countries/he.ts +252 -0
  70. package/app/utils/countries/index.ts +44 -0
  71. package/app/utils/countries/it.ts +252 -0
  72. package/app/utils/countries/ja.ts +252 -0
  73. package/app/utils/countries/ko.ts +252 -0
  74. package/app/utils/countries/nl.ts +252 -0
  75. package/app/utils/countries/pl.ts +252 -0
  76. package/app/utils/countries/pt-BR.ts +252 -0
  77. package/app/utils/countries/pt.ts +252 -0
  78. package/app/utils/countries/ru.ts +252 -0
  79. package/app/utils/countries/tr.ts +252 -0
  80. package/app/utils/countries/uk.ts +252 -0
  81. package/app/utils/countries/zh-Hans.ts +252 -0
  82. package/app/utils/internal/repeater.ts +26 -0
  83. package/app/utils/recordLinks.ts +1 -1
  84. package/app/utils/rules.ts +7 -4
  85. package/dist/static/200.html +1 -1
  86. package/dist/static/404.html +1 -1
  87. package/dist/static/_nuxt/{CVGEoUmj.js → 1608Z87P.js} +1 -1
  88. package/dist/static/_nuxt/26EG815s.js +1 -0
  89. package/dist/static/_nuxt/{y5gvPoD3.js → 5DQbzGzQ.js} +1 -1
  90. package/dist/static/_nuxt/6LnFMZ9h.js +1 -0
  91. package/dist/static/_nuxt/{B65UlNtP.js → 81b_JWVP.js} +1 -1
  92. package/dist/static/_nuxt/951AFxTF.js +1 -0
  93. package/dist/static/_nuxt/{DDsQjoa8.js → B-3DkDEW.js} +1 -1
  94. package/dist/static/_nuxt/{BSj4WTjT.js → B-OK38pz.js} +1 -1
  95. package/dist/static/_nuxt/B4lOfJ_0.js +1 -0
  96. package/dist/static/_nuxt/{DwpSsR4l.js → B5Jt7Eqg.js} +1 -1
  97. package/dist/static/_nuxt/{CWfptrnU.js → B9JchbmS.js} +1 -1
  98. package/dist/static/_nuxt/{Dao3p0cp.js → BAH3b61H.js} +1 -1
  99. package/dist/static/_nuxt/BAkfhUIC.js +1 -0
  100. package/dist/static/_nuxt/BAz8wQLD.js +1 -0
  101. package/dist/static/_nuxt/BDoRuUKE.js +1 -0
  102. package/dist/static/_nuxt/{DOEj9Txc.js → BHK5j1Wx.js} +1 -1
  103. package/dist/static/_nuxt/{B-b861aP.js → BJ0_qGcm.js} +1 -1
  104. package/dist/static/_nuxt/BLF1JZGX.js +1 -0
  105. package/dist/static/_nuxt/BLZaIPT-.js +1 -0
  106. package/dist/static/_nuxt/BPF07eww.js +1 -0
  107. package/dist/static/_nuxt/{DGQrzV9s.js → BPXec4rF.js} +1 -1
  108. package/dist/static/_nuxt/BRKbRioI.js +1 -0
  109. package/dist/static/_nuxt/{B2rZ5lwu.js → BRRBOyND.js} +1 -1
  110. package/dist/static/_nuxt/{DHNZ4ANp.js → BTJZEoE6.js} +1 -1
  111. package/dist/static/_nuxt/{XnbMqODk.js → BU7J96HZ.js} +1 -1
  112. package/dist/static/_nuxt/{CE5HzlKJ.js → BUzE9uBK.js} +1 -1
  113. package/dist/static/_nuxt/BV8jrBHa.js +1 -0
  114. package/dist/static/_nuxt/BVtNJY11.js +1 -0
  115. package/dist/static/_nuxt/BW2cAI58.js +1 -0
  116. package/dist/static/_nuxt/{B9s6vEby.js → BXXQNvGc.js} +1 -1
  117. package/dist/static/_nuxt/{DdYMnBKs.js → B_CsPjDm.js} +1 -1
  118. package/dist/static/_nuxt/{CLJSzUt5.js → B_VpcKtj.js} +1 -1
  119. package/dist/static/_nuxt/BaztYiAl.js +1 -0
  120. package/dist/static/_nuxt/{DYPYEI74.js → BfkrLuli.js} +1 -1
  121. package/dist/static/_nuxt/{BQitPbA5.js → Bg7Wm7qC.js} +1 -1
  122. package/dist/static/_nuxt/{B8JL5gwX.js → Bk8atvdO.js} +1 -1
  123. package/dist/static/_nuxt/BklrzIIE.js +1 -0
  124. package/dist/static/_nuxt/Bl60DsIN.js +1 -0
  125. package/dist/static/_nuxt/{Clx69IQe.js → BoceWX8_.js} +1 -1
  126. package/dist/static/_nuxt/BooleanGroup.Ctn8QJv3.css +1 -0
  127. package/dist/static/_nuxt/BqdQqPGG.js +1 -0
  128. package/dist/static/_nuxt/{CFuvN8kq.js → BsHddetz.js} +1 -1
  129. package/dist/static/_nuxt/BtBn_mmM.js +1 -0
  130. package/dist/static/_nuxt/BtWvh8h-.js +1 -0
  131. package/dist/static/_nuxt/ByM6U2Qe.js +1 -0
  132. package/dist/static/_nuxt/C2ZWScju.js +1 -0
  133. package/dist/static/_nuxt/C6doA815.js +1 -0
  134. package/dist/static/_nuxt/CALBeSnc.js +1 -0
  135. package/dist/static/_nuxt/CB2gkR4K.js +1 -0
  136. package/dist/static/_nuxt/CCXHWF63.js +1 -0
  137. package/dist/static/_nuxt/CCnG_04Y.js +1 -0
  138. package/dist/static/_nuxt/CDzeC03e.js +1 -0
  139. package/dist/static/_nuxt/{BJxaGigr.js → CFgMeWCA.js} +1 -1
  140. package/dist/static/_nuxt/CG1HFqc_.js +1 -0
  141. package/dist/static/_nuxt/CGdWq8l5.js +1 -0
  142. package/dist/static/_nuxt/{CSgLLbCN.js → CJCWDpGq.js} +1 -1
  143. package/dist/static/_nuxt/{DcC5rHQt.js → CKfr82y9.js} +1 -1
  144. package/dist/static/_nuxt/CMc4sXE8.js +1 -0
  145. package/dist/static/_nuxt/CMqJrosi.js +1 -0
  146. package/dist/static/_nuxt/{CF_C4t63.js → CRKTuX5e.js} +1 -1
  147. package/dist/static/_nuxt/{tv5vSe5Y.js → CS--aGS9.js} +1 -1
  148. package/dist/static/_nuxt/{BJh6qVAK.js → CVQf7G1i.js} +1 -1
  149. package/dist/static/_nuxt/CVnTGJCS.js +1 -0
  150. package/dist/static/_nuxt/{DpWwaWd-.js → CXfD1O41.js} +12 -12
  151. package/dist/static/_nuxt/{DAXm0JlI.js → CZJzNdT8.js} +1 -1
  152. package/dist/static/_nuxt/Cdge5zAy.js +1 -0
  153. package/dist/static/_nuxt/CghQmIiQ.js +2 -0
  154. package/dist/static/_nuxt/{2u7wMpR1.js → Ci8knhX0.js} +1 -1
  155. package/dist/static/_nuxt/CjX9KrPv.js +1 -0
  156. package/dist/static/_nuxt/{Bw6FrC2B.js → CkYhLHis.js} +1 -1
  157. package/dist/static/_nuxt/{Dw7WalTb.js → CrHibPfx.js} +1 -1
  158. package/dist/static/_nuxt/CrVTXZp1.js +2 -0
  159. package/dist/static/_nuxt/CuOAA5sP.js +1 -0
  160. package/dist/static/_nuxt/{Bl4F_9Di.js → CuW09Pf9.js} +1 -1
  161. package/dist/static/_nuxt/D4MxxnmM.js +1 -0
  162. package/dist/static/_nuxt/D52PLnR1.js +1 -0
  163. package/dist/static/_nuxt/DFM4TY5F.js +1 -0
  164. package/dist/static/_nuxt/DG9iSq1o.js +1 -0
  165. package/dist/static/_nuxt/{CRAHgjs4.js → DK-FyJq0.js} +1 -1
  166. package/dist/static/_nuxt/{AbcTnLPe.js → DL-Y-SrR.js} +1 -1
  167. package/dist/static/_nuxt/DMsb54_5.js +2 -0
  168. package/dist/static/_nuxt/{CD5zJmlk.js → DPDKc2ix.js} +1 -1
  169. package/dist/static/_nuxt/DSzAMcFx.js +1 -0
  170. package/dist/static/_nuxt/DTacXreK.js +1 -0
  171. package/dist/static/_nuxt/DXCyzcMc.js +2 -0
  172. package/dist/static/_nuxt/DaThP9To.js +1 -0
  173. package/dist/static/_nuxt/{DryMzf1V.js → DoBDwz9i.js} +1 -1
  174. package/dist/static/_nuxt/{CIcNJyjb.js → Doofu92H.js} +1 -1
  175. package/dist/static/_nuxt/{SacKuioS.js → DvUd-qQE.js} +1 -1
  176. package/dist/static/_nuxt/ETG88Leh.js +1 -0
  177. package/dist/static/_nuxt/{WAarVmAq.js → IeIjl2of.js} +1 -1
  178. package/dist/static/_nuxt/MCKoiB3E.js +1 -0
  179. package/dist/static/_nuxt/{CjYmnU-l.js → NWmnUlHT.js} +1 -1
  180. package/dist/static/_nuxt/QPvezGDN.js +1 -0
  181. package/dist/static/_nuxt/QfM1ukFT.js +1 -0
  182. package/dist/static/_nuxt/RHss5Znh.js +1 -0
  183. package/dist/static/_nuxt/Repeater.Dt7fQjxv.css +1 -0
  184. package/dist/static/_nuxt/Rvt5jKoB.js +1 -0
  185. package/dist/static/_nuxt/{BowgCQje.js → UOMH3sKh.js} +1 -1
  186. package/dist/static/_nuxt/VCombobox.xsOJFBr8.css +1 -0
  187. package/dist/static/_nuxt/Yxj3clqu.js +1 -0
  188. package/dist/static/_nuxt/ZgjlRAd9.js +1 -0
  189. package/dist/static/_nuxt/{_resource_.Q2lVCG-n.css → _resource_.DiGLdv9u.css} +1 -1
  190. package/dist/static/_nuxt/builds/latest.json +1 -1
  191. package/dist/static/_nuxt/builds/meta/691bfc1d-4be7-4e21-9e24-735eb94ef678.json +1 -0
  192. package/dist/static/_nuxt/{entry.CANiyyNa.css → entry.B2UXd7Ey.css} +1 -1
  193. package/dist/static/_nuxt/{CHIGMs2v.js → jFK8N1q6.js} +1 -1
  194. package/dist/static/_nuxt/{DOq2YmIE.js → k4v9WOKm.js} +1 -1
  195. package/dist/static/_nuxt/{yIw8BzU6.js → lSAJcvgX.js} +1 -1
  196. package/dist/static/_nuxt/{B8wNbnS0.js → nJa3B-VU.js} +1 -1
  197. package/dist/static/_nuxt/{Cpel4vlt.js → sjOc3hy9.js} +1 -1
  198. package/dist/static/_nuxt/wFK8Gpv4.js +1 -0
  199. package/dist/static/_nuxt/{HdAGfEVj.js → xCL8Cexv.js} +1 -1
  200. package/dist/static/_nuxt/yks44VUO.js +1 -0
  201. package/dist/static/_nuxt/ypCgn3lo.js +1 -0
  202. package/dist/static/_nuxt/zY76lC6C.js +1 -0
  203. package/dist/static/index.html +1 -1
  204. package/dist/static/jobs/index.html +1 -1
  205. package/dist/static/login/index.html +1 -1
  206. package/dist/static/queues/index.html +1 -1
  207. package/dist/static/settings/index.html +1 -1
  208. package/dist/static/vector-bundle.json +125 -92
  209. package/package.json +1 -1
  210. package/app/components/Vx/Cell/Enum.vue +0 -14
  211. package/app/components/Vx/Input/Enum.vue +0 -21
  212. package/dist/static/_nuxt/-ksGenLl.js +0 -1
  213. package/dist/static/_nuxt/0Q9tQaGZ.js +0 -1
  214. package/dist/static/_nuxt/7hLwEPpo.js +0 -1
  215. package/dist/static/_nuxt/B4hfz7cN.js +0 -1
  216. package/dist/static/_nuxt/BE6e_jlD.js +0 -1
  217. package/dist/static/_nuxt/BFZfZyte.js +0 -1
  218. package/dist/static/_nuxt/BW9qBvMR.js +0 -1
  219. package/dist/static/_nuxt/BWscDCZb.js +0 -1
  220. package/dist/static/_nuxt/BXnWvqRw.js +0 -1
  221. package/dist/static/_nuxt/BcSEGymu.js +0 -2
  222. package/dist/static/_nuxt/Bj-QksVr.js +0 -2
  223. package/dist/static/_nuxt/BuTE4a2w.js +0 -1
  224. package/dist/static/_nuxt/C1y0neXX.js +0 -1
  225. package/dist/static/_nuxt/C52FYB-5.js +0 -1
  226. package/dist/static/_nuxt/CAXk9Oc1.js +0 -1
  227. package/dist/static/_nuxt/CQvUQgZO.js +0 -2
  228. package/dist/static/_nuxt/CXSf4TOH.js +0 -1
  229. package/dist/static/_nuxt/Cf2NM87n.js +0 -1
  230. package/dist/static/_nuxt/D3cIKCPa.js +0 -1
  231. package/dist/static/_nuxt/D3jC5ZAK.js +0 -1
  232. package/dist/static/_nuxt/D3xofh1k.js +0 -1
  233. package/dist/static/_nuxt/DOxWca9k.js +0 -1
  234. package/dist/static/_nuxt/DllQuWrz.js +0 -1
  235. package/dist/static/_nuxt/DvEvjhbF.js +0 -1
  236. package/dist/static/_nuxt/FfebEZGy.js +0 -1
  237. package/dist/static/_nuxt/PqTF-5Vs.js +0 -1
  238. package/dist/static/_nuxt/Repeater.CLIPcHKX.css +0 -1
  239. package/dist/static/_nuxt/bNqxxQg2.js +0 -1
  240. package/dist/static/_nuxt/builds/meta/f78103ad-2489-4aee-b300-160bb1a81e35.json +0 -1
  241. package/dist/static/_nuxt/rYfJ_RlJ.js +0 -1
@@ -1,10 +1,13 @@
1
1
  <script setup lang="ts">
2
2
  import type { VectorField } from '#vector/app/types/vector'
3
3
 
4
- // An owned relation's rows edited inside the parent's form: one line of
5
- // the child's inputs per row, added and removed within the repeater's
6
- // bounds. The form sends the whole list; a row keeps its `id`, so the
7
- // server updates that child, and a row without one is created.
4
+ // Rows edited inside the record's form: one line of inputs per row, added
5
+ // and removed within the repeater's bounds, and dragged by their handle
6
+ // (or moved with the arrow keys on it) when the repeater is sortable. A
7
+ // JSON repeater's rows are objects of its own row fields; a relationship
8
+ // repeater's are child records, each keeping its `id`, so the server
9
+ // updates that child, and a row without one is created. The form sends
10
+ // the whole list, in its order.
8
11
  const props = defineProps<{
9
12
  field: VectorField
10
13
  /** the form's rules for the field itself; a row's inputs carry their own */
@@ -22,17 +25,32 @@ const { t, noun } = useVectorT()
22
25
  const { resource: resourceOf } = useVectorSchema()
23
26
  const { inputFor } = useVectorInputs()
24
27
 
25
- const child = computed(() => props.field.relation ? resourceOf(props.field.relation.resource) : undefined)
26
- const columns = computed<VectorField[]>(() => (props.field.repeater?.fields ?? [])
27
- .map(name => child.value?.fields.find(f => f.name === name))
28
- .filter((f): f is VectorField => f !== undefined))
28
+ const json = computed(() => props.field.repeater?.mode !== 'relationship')
29
+ const child = computed(() => !json.value && props.field.relation ? resourceOf(props.field.relation.resource) : undefined)
30
+ const available = computed(() => json.value || child.value !== undefined)
31
+ const columns = computed<VectorField[]>(() => json.value
32
+ ? props.field.repeater?.rowFields ?? []
33
+ : (props.field.repeater?.fields ?? [])
34
+ .map(name => child.value?.fields.find(f => f.name === name))
35
+ .filter((f): f is VectorField => f !== undefined))
29
36
  const min = computed(() => props.field.repeater?.min ?? 0)
30
37
  const max = computed(() => props.field.repeater?.max ?? 100)
38
+ const sortable = computed(() => props.field.repeater?.sortable === true && !props.disabled)
31
39
  const rows = computed(() => (Array.isArray(model.value) ? model.value : []))
32
40
  const width = computed(() => Math.max(3, Math.floor(12 / Math.max(1, Math.min(columns.value.length, 4)))))
41
+ // a row's inputs ask for options and uploads as the resource they belong to
42
+ const rowResource = computed(() => child.value?.slug ?? props.resource)
33
43
 
34
- // Stable keys, so removing a row keeps every other row's inputs (and a
35
- // relation input's loaded label) with the row it belongs to.
44
+ const rowLabel = (index: number) => child.value
45
+ ? t('fields.repeater.row', { label: child.value.labelSingular, n: index + 1 })
46
+ : t('fields.rows.row', { n: index + 1 })
47
+ const removeLabel = (index: number) => child.value
48
+ ? t('fields.repeater.remove', { label: noun(child.value.labelSingular), n: index + 1 })
49
+ : t('fields.rows.remove', { n: index + 1 })
50
+ const addLabel = computed(() => child.value ? t('fields.repeater.add', { label: noun(child.value.labelSingular) }) : t('fields.rows.add'))
51
+
52
+ // Stable keys, so removing or moving a row keeps every other row's inputs
53
+ // (and a relation input's loaded label) with the row it belongs to.
36
54
  let next = 0
37
55
  const keys = ref<number[]>([])
38
56
  watch(() => rows.value.length, (length) => {
@@ -42,6 +60,7 @@ watch(() => rows.value.length, (length) => {
42
60
  /** A new row's value for a column: its default, else unchecked for a checkbox, else empty. */
43
61
  function blankValue(f: VectorField): unknown {
44
62
  if (f.hasDefault) return f.default
63
+ if (f.type === 'tag') return []
45
64
  return f.type === 'boolean' ? false : null
46
65
  }
47
66
 
@@ -67,23 +86,88 @@ function set(index: number, name: string, value: unknown) {
67
86
  if (props.serverErrors) delete props.serverErrors[`${props.field.name}.${index}.${name}`]
68
87
  }
69
88
 
70
- /** Row errors are keyed by position, which a removal shifts: they go with it. */
89
+ /** Row errors are keyed by position, which a removal or a move shifts: they go with it. */
71
90
  function clearRowErrors() {
72
91
  for (const key of Object.keys(props.serverErrors ?? {})) {
73
92
  if (key.startsWith(`${props.field.name}.`)) delete props.serverErrors![key]
74
93
  }
75
94
  }
76
95
 
77
- // A row's inputs read the record they belong to through the relation back
78
- // to it: a line priced in `order.currency` sees the order being edited.
96
+ // --- reordering ----------------------------------------------------------
97
+
98
+ /** What a screen reader hears after a move. */
99
+ const announcement = ref('')
100
+ const handles = ref<HTMLElement[]>([])
101
+
102
+ /** Moves the row at `from` to `to`, its key and inputs with it. */
103
+ function move(from: number, to: number) {
104
+ if (from === to || to < 0 || to >= rows.value.length) return
105
+
106
+ const reorder = <T,>(list: T[]) => {
107
+ const copy = [...list]
108
+ const [moved] = copy.splice(from, 1)
109
+ copy.splice(to, 0, moved as T)
110
+ return copy
111
+ }
112
+
113
+ keys.value = reorder(keys.value)
114
+ model.value = reorder(rows.value)
115
+ clearRowErrors()
116
+ announcement.value = t('fields.rows.moved', { from: from + 1, to: to + 1 })
117
+ }
118
+
119
+ /** The arrow keys on a row's handle move the row, the handle keeping focus. */
120
+ async function onHandleKey(event: KeyboardEvent, index: number) {
121
+ const to = event.key === 'ArrowUp' ? index - 1 : event.key === 'ArrowDown' ? index + 1 : null
122
+ if (to === null || to < 0 || to >= rows.value.length) return
123
+
124
+ event.preventDefault()
125
+ move(index, to)
126
+ await nextTick()
127
+ handles.value[to]?.focus()
128
+ }
129
+
130
+ const dragging = ref<number | null>(null)
131
+ const over = ref<number | null>(null)
132
+
133
+ function onDragStart(event: DragEvent, index: number) {
134
+ dragging.value = index
135
+ event.dataTransfer?.setData('text/plain', String(index))
136
+ if (event.dataTransfer) event.dataTransfer.effectAllowed = 'move'
137
+ }
138
+
139
+ function onDrop(index: number) {
140
+ if (dragging.value !== null) move(dragging.value, index)
141
+ dragging.value = null
142
+ over.value = null
143
+ }
144
+
145
+ // A relationship row's inputs read the record they belong to through the
146
+ // relation back to it: a line priced in `order.currency` sees the order
147
+ // being edited. A JSON row's inputs read the row.
79
148
  const inverse = computed(() => props.field.relation?.inverse)
80
149
  const rowRecord = (row: Record<string, unknown>) => (inverse.value ? { ...row, [inverse.value]: props.record ?? {} } : row)
81
150
 
82
151
  const rowErrors = (index: number, name: string) => props.serverErrors?.[`${props.field.name}.${index}.${name}`] ?? []
152
+ /**
153
+ * A row's errors no input of it shows: the row's own (`specs.2`, a row
154
+ * that is not an object) and a key the row may not hold (`specs.2.colour`).
155
+ */
156
+ function rowOwnErrors(index: number): string[] {
157
+ const prefix = `${props.field.name}.${index}`
158
+
159
+ return Object.entries(props.serverErrors ?? {}).flatMap(([key, messages]) => {
160
+ if (key === prefix) return messages
161
+ if (!key.startsWith(`${prefix}.`)) return []
162
+
163
+ const column = key.slice(prefix.length + 1)
164
+ return columns.value.some(c => c.name === column) ? [] : messages.map(message => `${column}: ${message}`)
165
+ })
166
+ }
83
167
 
84
168
  // A new record starts with the rows it must hold.
85
169
  onMounted(() => {
86
- if (child.value && rows.value.length < min.value && !props.record?.id) {
170
+ if (available.value && rows.value.length < min.value && !props.record?.id) {
87
171
  model.value = [...rows.value, ...Array.from({ length: min.value - rows.value.length }, blank)]
88
172
  }
89
173
  })
@@ -97,43 +181,64 @@ onMounted(() => {
97
181
  <span class="text-caption text-medium-emphasis">{{ t('fields.repeater.count', { count: rows.length, max }) }}</span>
98
182
  </div>
99
183
  <v-alert v-for="message in errorMessages" :key="message" type="error" variant="tonal" density="compact" class="mb-2" :text="message" />
100
- <p v-if="!child" class="text-medium-emphasis text-body-2">{{ t('fields.repeater.unavailable') }}</p>
184
+ <p v-if="!available" class="text-medium-emphasis text-body-2">{{ t('fields.repeater.unavailable') }}</p>
101
185
  <template v-else>
102
186
  <fieldset
103
187
  v-for="(row, index) in rows"
104
188
  :key="keys[index]"
105
- class="vx-fieldset d-flex ga-2 align-start mb-1"
106
- :aria-label="t('fields.repeater.row', { label: child.labelSingular, n: index + 1 })"
189
+ class="vx-fieldset vx-repeater-row d-flex ga-2 align-start mb-1"
190
+ :class="{ 'vx-repeater-row--over': over === index && dragging !== index }"
191
+ :aria-label="rowLabel(index)"
192
+ @dragover.prevent="over = index"
193
+ @dragleave="over = over === index ? null : over"
194
+ @drop.prevent="onDrop(index)"
107
195
  >
108
- <v-row density="compact" class="flex-grow-1">
109
- <v-col v-for="column in columns" :key="column.name" cols="12" :md="width">
110
- <component
111
- :is="inputFor(column)"
112
- :model-value="row[column.name]"
113
- :field="column"
114
- :rules="rulesFor(column, row.id ? 'update' : 'create')"
115
- :error-messages="rowErrors(index, column.name)"
116
- :record="rowRecord(row)"
117
- :resource="child.slug"
118
- :disabled="disabled"
119
- density="compact"
120
- @update:model-value="(value: unknown) => set(index, column.name, value)"
121
- />
122
- </v-col>
123
- </v-row>
196
+ <v-btn
197
+ v-if="sortable"
198
+ :ref="(el: unknown) => { const node = (el as { $el?: HTMLElement } | null)?.$el; if (node) handles[index] = node }"
199
+ icon="mdi-drag-vertical"
200
+ variant="text"
201
+ size="small"
202
+ class="mt-2 vx-repeater-handle"
203
+ draggable="true"
204
+ :aria-label="t('fields.rows.drag', { n: index + 1 })"
205
+ @dragstart="onDragStart($event, index)"
206
+ @dragend="dragging = null; over = null"
207
+ @keydown="onHandleKey($event, index)"
208
+ />
209
+ <div class="flex-grow-1">
210
+ <v-alert v-for="message in rowOwnErrors(index)" :key="message" type="error" variant="tonal" density="compact" class="mb-1" :text="message" />
211
+ <v-row density="compact">
212
+ <v-col v-for="column in columns" :key="column.name" cols="12" :md="width">
213
+ <component
214
+ :is="inputFor(column)"
215
+ :model-value="row[column.name]"
216
+ :field="column"
217
+ :rules="rulesFor(column, row.id ? 'update' : 'create')"
218
+ :error-messages="rowErrors(index, column.name)"
219
+ :record="rowRecord(row)"
220
+ :resource="rowResource"
221
+ :disabled="disabled"
222
+ density="compact"
223
+ @update:model-value="(value: unknown) => set(index, column.name, value)"
224
+ />
225
+ </v-col>
226
+ </v-row>
227
+ </div>
124
228
  <v-btn
125
229
  icon="mdi-close"
126
230
  variant="text"
127
231
  size="small"
128
232
  class="mt-2"
129
233
  :disabled="disabled || rows.length <= min"
130
- :aria-label="t('fields.repeater.remove', { label: noun(child.labelSingular), n: index + 1 })"
234
+ :aria-label="removeLabel(index)"
131
235
  @click="remove(index)"
132
236
  />
133
237
  </fieldset>
134
238
  <v-btn variant="tonal" size="small" prepend-icon="mdi-plus" :disabled="disabled || rows.length >= max" @click="add">
135
- {{ t('fields.repeater.add', { label: noun(child.labelSingular) }) }}
239
+ {{ addLabel }}
136
240
  </v-btn>
241
+ <span class="d-sr-only" aria-live="polite">{{ announcement }}</span>
137
242
  </template>
138
243
  </v-card>
139
244
  </template>
@@ -141,4 +246,6 @@ onMounted(() => {
141
246
  <style scoped>
142
247
  /* a fieldset that groups without a fieldset's own border, padding and margin */
143
248
  .vx-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
249
+ .vx-repeater-handle { cursor: grab; }
250
+ .vx-repeater-row--over { outline: 2px dashed rgb(var(--v-theme-primary)); outline-offset: 2px; border-radius: 4px; }
144
251
  </style>
@@ -0,0 +1,31 @@
1
+ <script setup lang="ts">
2
+ import type { VectorField } from '#vector/app/types/vector'
3
+
4
+ // One option, or several for a multiple select (shown as chips). A
5
+ // searchable select types to narrow a long list.
6
+ // `disabled` stays undefined when not given, so a disabled v-form still disables the field
7
+ const props = withDefaults(defineProps<{ field: VectorField, rules: ((v: unknown) => true | string)[], errorMessages: string[], record?: Record<string, unknown>, resource?: string, disabled?: boolean }>(), { record: undefined, resource: undefined, disabled: undefined })
8
+ const model = defineModel<string | number | (string | number)[] | null>()
9
+ const multiple = computed(() => props.field.multiple === true)
10
+ // what both inputs share; each is named in the template so Vuetify imports it
11
+ const shared = computed(() => ({
12
+ label: props.field.label,
13
+ items: props.field.options ?? [],
14
+ itemTitle: 'label',
15
+ itemValue: 'value',
16
+ multiple: multiple.value,
17
+ chips: multiple.value,
18
+ closableChips: multiple.value,
19
+ rules: props.rules,
20
+ errorMessages: props.errorMessages,
21
+ clearable: props.field.nullable === true,
22
+ hint: props.field.help ?? undefined,
23
+ persistentHint: !!props.field.help,
24
+ disabled: props.disabled,
25
+ }))
26
+ </script>
27
+
28
+ <template>
29
+ <v-autocomplete v-if="field.autocomplete" v-model="model" v-bind="shared" auto-select-first />
30
+ <v-select v-else v-model="model" v-bind="shared" />
31
+ </template>
@@ -0,0 +1,47 @@
1
+ <script setup lang="ts">
2
+ import type { VectorField } from '#vector/app/types/vector'
3
+ import { normalizeTags } from '#vector/app/utils/internal/repeater'
4
+
5
+ // Free-text tags as chips: typed and confirmed with Enter (or a comma),
6
+ // picked from the field's suggestions, or pasted. The list is kept as the
7
+ // server stores it: trimmed, without empty tags, each at most once
8
+ // ignoring case. A suggestion never restricts what a tag may be.
9
+ const props = defineProps<{ field: VectorField, rules: ((v: unknown) => true | string)[], errorMessages: string[], record?: Record<string, unknown>, resource?: string, disabled?: boolean }>()
10
+ const model = defineModel<string[] | null>()
11
+
12
+ const { t } = useVectorT()
13
+ const maxLength = computed(() => props.field.tags?.maxLength ?? 50)
14
+ const maxTags = computed(() => props.field.tags?.maxTags ?? 20)
15
+ const tags = computed(() => (Array.isArray(model.value) ? model.value : []))
16
+
17
+ const limits = (value: unknown) => {
18
+ const list = Array.isArray(value) ? value : []
19
+ if (list.some(tag => typeof tag === 'string' && tag.trim().length > maxLength.value)) return t('fields.rules.maxLength', { max: maxLength.value })
20
+ if (list.length > maxTags.value) return t('fields.tags.tooMany', { max: maxTags.value })
21
+ return true
22
+ }
23
+
24
+ function update(value: unknown) {
25
+ const list = normalizeTags(Array.isArray(value) ? value : [])
26
+ model.value = list.length === 0 && props.field.nullable === true ? null : list
27
+ }
28
+ </script>
29
+
30
+ <template>
31
+ <v-combobox
32
+ :model-value="tags"
33
+ :label="field.label"
34
+ :items="field.tags?.suggestions ?? []"
35
+ :rules="[...rules, limits]"
36
+ :error-messages="errorMessages"
37
+ :disabled="disabled"
38
+ :hint="field.help ?? t('fields.tags.hint')"
39
+ :delimiters="[',']"
40
+ multiple
41
+ chips
42
+ closable-chips
43
+ hide-no-data
44
+ persistent-hint
45
+ @update:model-value="update"
46
+ />
47
+ </template>
@@ -17,7 +17,6 @@ const innerAddons = useVectorInputAddons(() => props.field.type, () => 'inner')
17
17
  :hint="field.help ?? undefined"
18
18
  :persistent-hint="!!field.help"
19
19
  :disabled="props.disabled"
20
- :class="{ 'font-monospace': props.field.type === 'json' }"
21
20
  auto-grow
22
21
  rows="3"
23
22
  >
@@ -64,7 +64,7 @@ watch(() => props.errors, () => {
64
64
  </v-col>
65
65
 
66
66
  <v-col v-else-if="node.kind === 'section'" cols="12" class="vx-layout-section" :data-layout-section="node.label">
67
- <v-expansion-panels v-if="node.collapsible" :model-value="open[key] ? [0] : []" variant="accordion" @update:model-value="(v: unknown) => open[key] = Array.isArray(v) && v.length > 0">
67
+ <v-expansion-panels v-if="node.collapsible" :model-value="open[key] ? [0] : []" multiple variant="accordion" @update:model-value="(v: unknown) => open[key] = Array.isArray(v) && v.length > 0">
68
68
  <v-expansion-panel :value="0">
69
69
  <v-expansion-panel-title>
70
70
  <span class="font-weight-medium">{{ node.label }}</span>
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { childRepeater } from '#vector/app/utils/internal/repeater'
2
3
  import type { SubmitEventPromise } from 'vuetify'
3
4
  import type { VectorResource, VectorSelection } from '#vector/app/types/vector'
4
5
 
@@ -19,7 +20,7 @@ const notifications = useVectorNotifications()
19
20
  const client = useVectorResource(() => props.resource.slug)
20
21
  const { editable } = useVectorInputs()
21
22
 
22
- const editableFields = computed(() => props.resource.fields.filter(f => editable(f, 'update') && f.type !== 'password' && f.type !== 'hasMany'))
23
+ const editableFields = computed(() => props.resource.fields.filter(f => editable(f, 'update') && f.type !== 'password' && !childRepeater(f)))
23
24
  const chosen = ref<string[]>([])
24
25
  const fields = computed(() => editableFields.value.filter(f => chosen.value.includes(f.name)))
25
26
  const values = reactive<Record<string, unknown>>({})
@@ -24,8 +24,18 @@ function openAdd(where: Target, event: Event) {
24
24
  }
25
25
 
26
26
  const { t, locale } = useVectorT()
27
+ const countryNames = useVectorCountryNames()
27
28
 
28
- const OPERATORS: readonly VectorOperator[] = ['eq', 'ne', 'lt', 'lte', 'gt', 'gte', 'in', 'nin', 'like', 'nlike', 'between', 'null', 'nnull']
29
+ /** The values a choice field offers, each named as the UI shows it: a currency by its name, a country in the UI's language, a flag by its label. */
30
+ function choicesOf(f: VectorField): { value: string | number, label: string }[] {
31
+ if (f.type === 'currency') return (f.options ?? []).map(o => ({ value: o.value, label: currencyLabel(String(o.value), locale.value) }))
32
+ if (f.type === 'country') return withCountryNames(f, countryNames.value).options ?? []
33
+ return f.options ?? []
34
+ }
35
+
36
+ const CHOICE_TYPES = new Set(['select', 'country', 'booleanGroup', 'currency'])
37
+
38
+ const OPERATORS: readonly VectorOperator[] = ['eq', 'ne', 'lt', 'lte', 'gt', 'gte', 'in', 'nin', 'like', 'nlike', 'between', 'any', 'all', 'null', 'nnull']
29
39
 
30
40
  const operatorLabel = (op: string): string => (OPERATORS as readonly string[]).includes(op) ? t(`list.filter.operators.${op}`) : op
31
41
 
@@ -52,7 +62,16 @@ watch(field, (f) => {
52
62
  })
53
63
 
54
64
  const needsValue = computed(() => operator.value !== null && !['null', 'nnull'].includes(operator.value))
55
- const list = computed(() => operator.value === 'in' || operator.value === 'nin')
65
+ // a list of values: in/nin of a column, any/all of a multiple select's options or of tags
66
+ const list = computed(() => ['in', 'nin', 'any', 'all'].includes(operator.value ?? ''))
67
+
68
+ /** What a choice input shows as picked: the comma-separated `value` as the options' own values, a list for a list operator. */
69
+ const picked = computed(() => {
70
+ const own = new Map(field.value ? choicesOf(field.value).map(o => [String(o.value), o.value] as const) : [])
71
+ const parts = value.value === '' ? [] : value.value.split(',').map(text => own.get(text) ?? text)
72
+
73
+ return list.value ? parts : (parts[0] ?? null)
74
+ })
56
75
 
57
76
  const searchRelation = useDebounceFn(async (q: string) => {
58
77
  if (!field.value) return
@@ -157,8 +176,7 @@ function chipText(name: string, op: string, v: string): string {
157
176
 
158
177
  let shown = v
159
178
 
160
- if (f.type === 'enum') shown = v.split(',').map(x => f.options?.find(o => String(o.value) === x)?.label ?? x).join(', ')
161
- if (f.type === 'currency') shown = v.split(',').map(x => currencyLabel(x, locale.value)).join(', ')
179
+ if (CHOICE_TYPES.has(f.type)) shown = v.split(',').map(x => choicesOf(f).find(o => String(o.value) === x)?.label ?? x).join(', ')
162
180
  if (f.type === 'boolean') shown = v === 'true' || v === '1' ? t('list.filter.yes') : t('list.filter.no')
163
181
  if (f.type === 'money' && !['in', 'nin', 'between'].includes(op)) shown = (Number(v) / 10 ** moneyDigits(f)).toFixed(moneyDigits(f))
164
182
  if (op === 'between') shown = v.replace(',', ` ${t('list.filter.and')} `)
@@ -204,7 +222,9 @@ const anything = computed(() => active.value.length > 0 || groups.value.length >
204
222
  <v-select v-model="fieldName" :label="t('list.field')" :items="filterable" item-title="label" item-value="name" density="compact" hide-details class="mb-3" />
205
223
  <v-select v-if="field" v-model="operator" :label="t('list.filter.condition')" :items="field.operators.map(op => ({ title: operatorLabel(op), value: op }))" density="compact" hide-details class="mb-3" />
206
224
  <template v-if="field && needsValue">
207
- <v-select v-if="field.type === 'enum' || field.type === 'currency'" v-model="value" :label="t('list.filter.value')" :items="field.type === 'currency' ? (field.options ?? []).map(o => ({ value: o.value, label: currencyLabel(String(o.value), locale) })) : (field.options ?? [])" item-title="label" item-value="value" density="compact" hide-details class="mb-3" :multiple="list" @update:model-value="(v: unknown) => value = Array.isArray(v) ? v.join(',') : String(v ?? '')" />
225
+ <v-autocomplete v-if="CHOICE_TYPES.has(field.type) && field.autocomplete" :model-value="picked" :label="t('list.filter.value')" :items="choicesOf(field)" item-title="label" item-value="value" density="compact" hide-details class="mb-3" :multiple="list" @update:model-value="(v: unknown) => value = Array.isArray(v) ? v.join(',') : String(v ?? '')" />
226
+ <v-select v-else-if="CHOICE_TYPES.has(field.type)" :model-value="picked" :label="t('list.filter.value')" :items="choicesOf(field)" item-title="label" item-value="value" density="compact" hide-details class="mb-3" :multiple="list" @update:model-value="(v: unknown) => value = Array.isArray(v) ? v.join(',') : String(v ?? '')" />
227
+ <v-combobox v-else-if="field.type === 'tag'" :model-value="value === '' ? [] : value.split(',')" :label="t('list.filter.value')" :items="field.tags?.suggestions ?? []" :hint="t('fields.tags.hint')" :delimiters="[',']" density="compact" class="mb-3" multiple chips closable-chips hide-no-data persistent-hint @update:model-value="(v: unknown) => value = Array.isArray(v) ? v.map(x => String(x).trim()).filter(x => x !== '').join(',') : String(v ?? '')" />
208
228
  <v-select v-else-if="field.type === 'boolean'" v-model="value" :label="t('list.filter.value')" :items="[{ title: t('common.yes'), value: 'true' }, { title: t('common.no'), value: 'false' }]" density="compact" hide-details class="mb-3" />
209
229
  <v-autocomplete v-else-if="field.type === 'belongsTo'" v-model:search="relationSearch" :label="t('list.filter.value')" :items="relationOptions" item-title="label" item-value="id" density="compact" hide-details class="mb-3" :multiple="list" no-filter @update:model-value="(v: unknown) => value = Array.isArray(v) ? v.join(',') : String(v ?? '')" />
210
230
  <template v-else>
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { childRepeater } from '#vector/app/utils/internal/repeater'
2
3
  import type { VectorAuditEntry, VectorResource } from '#vector/app/types/vector'
3
4
 
4
5
  // The audit trail of one record: who changed what, when, as whom. An
@@ -27,7 +28,7 @@ function revertableFields(entry: VectorAuditEntry): string[] {
27
28
  if (!props.canUpdate || !['update', 'revert'].includes(entry.event)) return []
28
29
  return Object.keys(entry.changes).filter((name) => {
29
30
  const field = props.resource.fields.find(f => f.name === name)
30
- return field !== undefined && !field.readonly && field.views.includes('update') && !['id', 'hasOne', 'hasMany', 'manyToMany', 'password'].includes(field.type)
31
+ return field !== undefined && !field.readonly && field.views.includes('update') && !['id', 'hasOne', 'hasMany', 'manyToMany', 'password'].includes(field.type) && !childRepeater(field)
31
32
  })
32
33
  }
33
34
 
@@ -2,6 +2,7 @@
2
2
  import type { SubmitEventPromise } from 'vuetify'
3
3
  import type { VectorField, VectorFieldState, VectorLayoutNode, VectorRecord, VectorResource } from '#vector/app/types/vector'
4
4
  import { type Violation, violationsOf } from '#vector/app/utils/internal/violations'
5
+ import { childRepeater } from '#vector/app/utils/internal/repeater'
5
6
 
6
7
  // A create or edit form generated from the descriptor: one input per
7
8
  // editable field, client rules mirroring the server's, and the server's
@@ -52,10 +53,12 @@ const clone = (value: unknown) => value === undefined ? undefined : JSON.parse(J
52
53
  * (a stored key belongs to its record). Collections load below.
53
54
  */
54
55
  const copies = (field: VectorField) => props.operation === 'create' && props.copyOf !== undefined
55
- && field.unique !== true && !['file', 'image', 'manyToMany', 'hasMany'].includes(field.type)
56
+ && field.unique !== true && !['file', 'image', 'manyToMany'].includes(field.type) && !childRepeater(field)
56
57
 
57
58
  /** What a field starts with when nothing gives it a value: on create its declared default, else its type's empty one. */
58
59
  function initialValue(field: VectorField): unknown {
60
+ // a flag group starts with every flag, off unless its default turns it on
61
+ if (field.type === 'booleanGroup') return flagsStart(field, props.operation === 'create')
59
62
  return props.operation === 'create' && field.hasDefault ? JSON.parse(JSON.stringify(field.default ?? null)) : defaultFor(field)
60
63
  }
61
64
 
@@ -70,8 +73,8 @@ function start() {
70
73
  value = (current as { id: unknown }).id
71
74
  }
72
75
 
73
- if (field.type === 'manyToMany' || field.type === 'hasMany') {
74
- value = [] // the ids, or a repeater's rows, load from their endpoint below
76
+ if (field.type === 'manyToMany' || childRepeater(field)) {
77
+ value = [] // the ids, or a relationship repeater's rows, load from their endpoint below
75
78
  }
76
79
 
77
80
  values[field.name] = value
@@ -82,7 +85,7 @@ start()
82
85
 
83
86
  function defaultFor(field: VectorField): unknown {
84
87
  if (field.type === 'boolean') return false
85
- if (field.type === 'manyToMany' || field.type === 'hasMany') return []
88
+ if (['manyToMany', 'repeater', 'tag'].includes(field.type)) return []
86
89
  return null
87
90
  }
88
91
 
@@ -103,8 +106,8 @@ if (loadFrom) {
103
106
  })
104
107
  }
105
108
 
106
- // A repeater's rows: each child as a row of the fields it writes, its relations as ids.
107
- for (const field of fields.value.filter(f => f.repeater)) {
109
+ // A relationship repeater's rows: each child as a row of the fields it writes, its relations as ids.
110
+ for (const field of fields.value.filter(childRepeater)) {
108
111
  client.rows(loadFrom.id, field.name).catch((error) => {
109
112
  unloaded.add(field.name)
110
113
  formError.value = vectorErrorMessage(error)
@@ -140,7 +143,7 @@ async function allRelatedIds(id: string | number, field: VectorField): Promise<u
140
143
  }
141
144
  }
142
145
 
143
- const wide = (field: VectorField) => ['markdown', 'richtext', 'text', 'json', 'keyValue'].includes(field.type) || !!field.repeater
146
+ const wide = (field: VectorField) => ['markdown', 'richtext', 'text', 'json', 'keyValue', 'repeater'].includes(field.type)
144
147
 
145
148
  /** Fields the browser's own rules refused on the last submit, by the input id each carries. */
146
149
  const clientErrors = ref<string[]>([])
@@ -245,8 +248,8 @@ function showFailure(error: unknown) {
245
248
 
246
249
  /** One violation under the field it names, or above the form when it names none the form holds. */
247
250
  function showViolation(violation: Violation) {
248
- // a repeater row's own violation stays with its row: `lines.2.quantity`
249
- const repeated = violation.path.length >= 3 && fields.value.some(f => f.name === violation.path[0] && f.repeater)
251
+ // a repeater row's own violation stays with its row: `lines.2.quantity`, or `specs.2` for the row itself
252
+ const repeated = violation.path.length >= 2 && fields.value.some(f => f.name === violation.path[0] && f.type === 'repeater')
250
253
  const key = repeated ? violation.path.slice(0, 3).join('.') : String(violation.path[0] ?? '')
251
254
 
252
255
  if (key && (key in values || repeated)) {
@@ -350,7 +353,7 @@ const hiddenErrors = computed(() => Object.entries(serverErrors)
350
353
  :error-messages="serverErrors[name] ?? []"
351
354
  :record="inputRecord"
352
355
  :resource="resource.slug"
353
- v-bind="fieldsByName.get(name)!.repeater ? { serverErrors } : {}"
356
+ v-bind="fieldsByName.get(name)!.type === 'repeater' ? { serverErrors } : {}"
354
357
  @update:model-value="clearServerError(name)"
355
358
  />
356
359
  <VxInputAddons
@@ -15,7 +15,7 @@ const host = useVectorHost()
15
15
  const { t } = useVectorT()
16
16
 
17
17
  /** Arguments shown in their own rows rather than as the change's fields. */
18
- const NAMED = ['resource', 'id', 'values']
18
+ const NAMED = new Set(['resource', 'id', 'values'])
19
19
 
20
20
  const frame = computed(() => props.approval.frame)
21
21
  const resource = computed(() => frame.value.resource === null ? undefined : host.schema.value?.resources?.[frame.value.resource])
@@ -54,7 +54,7 @@ const changes = computed<Row[]>(() => {
54
54
 
55
55
  /** The call's other arguments (an action's name and ids, a delete's force, a version), as they are. */
56
56
  const others = computed(() => Object.entries(frame.value.arguments)
57
- .filter(([name]) => !NAMED.includes(name))
57
+ .filter(([name]) => !NAMED.has(name))
58
58
  .map(([name, value]) => ({ name, value: show(value) })))
59
59
 
60
60
  const expires = computed(() => formatDateTime(frame.value.expiresAt))
@@ -23,14 +23,13 @@ import ApprovalCard from './ApprovalCard.vue'
23
23
  // heard, only when capabilities.ai.assistant is on.
24
24
 
25
25
  /** The tools that only propose a change. */
26
- const PROPOSING = ['vector_create', 'vector_update', 'vector_delete', 'vector_run_action']
26
+ const PROPOSING = new Set(['vector_create', 'vector_update', 'vector_delete', 'vector_run_action'])
27
27
 
28
28
  // the layout's own attributes (data-shell-action) go on the button: the drawer is elsewhere
29
29
  defineOptions({ inheritAttrs: false })
30
30
 
31
31
  const host = useVectorHost()
32
32
  const appConfig = useAppConfig()
33
- const route = useRoute()
34
33
  const router = useRouter()
35
34
  const { t } = useVectorT()
36
35
  const { open, draft, turns, busy, refused, send, retry, reset, decide } = useVectorAssistant()
@@ -43,7 +42,7 @@ const slugs = computed(() => new Set(Object.keys(host.schema.value?.resources ??
43
42
 
44
43
  /** Which page the questions are about, in words. */
45
44
  const contextLine = computed(() => {
46
- void route.fullPath // follows navigation
45
+ // follows navigation: host.context() reads the router's current route
47
46
  const ctx = host.context()
48
47
  const resource = ctx.resource === undefined ? undefined : host.schema.value?.resources?.[ctx.resource]
49
48
  if (resource === undefined) return ctx.path === '/' ? t('shell.home.title') : t('ai.assistant.context.page', { path: ctx.path })
@@ -61,10 +60,10 @@ function html(content: string): string {
61
60
 
62
61
  /** A record link in an answer navigates inside the admin, rather than reloading it. */
63
62
  function follow(event: MouseEvent) {
64
- const link = (event.target as Element | null)?.closest('a[data-record-link]')
63
+ const link = (event.target as Element | null)?.closest<HTMLElement>('a[data-record-link]')
65
64
  if (!link || event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0) return
66
65
  event.preventDefault()
67
- const [slug = '', id = ''] = (link.getAttribute('data-record-link') ?? '').split('#')
66
+ const [slug = '', id = ''] = (link.dataset.recordLink ?? '').split('#')
68
67
  void navigateTo(`${appConfig.vector.basePath}/r/${encodeURIComponent(slug)}/${encodeURIComponent(id)}`)
69
68
  }
70
69
 
@@ -77,7 +76,7 @@ function onKeydown(event: KeyboardEvent) {
77
76
 
78
77
  /** The chip of a tool, with how many times when more than once. */
79
78
  function chipLabel(name: string, count: number): string {
80
- const proposing = PROPOSING.includes(name)
79
+ const proposing = PROPOSING.has(name)
81
80
  if (count === 1) return t(proposing ? 'ai.assistant.proposingTool' : 'ai.assistant.tool', { name })
82
81
  return t(proposing ? 'ai.assistant.proposingToolTimes' : 'ai.assistant.toolTimes', { name, count })
83
82
  }
@@ -132,7 +131,7 @@ onBeforeUnmount(() => {
132
131
  <v-sheet v-if="turn.role === 'user'" color="primary" variant="tonal" rounded class="pa-2 ms-8 text-body-2 vx-ai-assistant__user">{{ turn.content }}</v-sheet>
133
132
  <div v-else class="me-4">
134
133
  <div v-if="toolChips(turn.tools).length" class="d-flex flex-wrap ga-1 mb-1" data-ai-assistant-tools>
135
- <v-chip v-for="chip in toolChips(turn.tools)" :key="chip.name" size="x-small" variant="outlined" :prepend-icon="PROPOSING.includes(chip.name) ? 'mdi-pencil-outline' : 'mdi-database-search-outline'" data-ai-assistant-tool>{{ chipLabel(chip.name, chip.count) }}</v-chip>
134
+ <v-chip v-for="chip in toolChips(turn.tools)" :key="chip.name" size="x-small" variant="outlined" :prepend-icon="PROPOSING.has(chip.name) ? 'mdi-pencil-outline' : 'mdi-database-search-outline'" data-ai-assistant-tool>{{ chipLabel(chip.name, chip.count) }}</v-chip>
136
135
  </div>
137
136
  <!-- eslint-disable-next-line vue/no-v-html -- Markdown sanitized by the admin's own renderer; the record links are built, not parsed -->
138
137
  <div v-if="turn.content" class="text-body-2 vx-ai-assistant__answer" data-ai-assistant-answer @click="follow" v-html="html(turn.content)" />