Skip to content

Commit

Permalink
fix: fix indexing for group entries, fix koishijs/koishi#1381
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Mar 23, 2024
1 parent e53aeff commit 3394a32
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Unit Test
run: yarn test:json
- name: Report Coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/coverage-final.json
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"serve": "^13.0.4",
"shx": "^0.3.4",
"typescript": "^5.3.2",
"vitepress": "1.0.0-rc.32",
"yakumo": "^1.0.0-alpha.9",
"yakumo-esbuild": "^1.0.0-alpha.2",
"yakumo-tsc": "^1.0.0-alpha.2"
"vitepress": "1.0.0-rc.40",
"yakumo": "^1.0.0-beta.11",
"yakumo-esbuild": "^1.0.0-beta.5",
"yakumo-tsc": "^1.0.0-beta.3"
}
}
2 changes: 1 addition & 1 deletion packages/form/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "schemastery-vue",
"description": "Type driven schema validator",
"version": "7.3.2",
"version": "7.3.3",
"main": "src/index.ts",
"files": [
"src"
Expand Down
11 changes: 11 additions & 0 deletions packages/form/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ export function useEntries() {
const isMax = computed(() => entries.value.length >= props.schema.meta.max)
const isMin = computed(() => entries.value.length >= props.schema.meta.max)

const reindex = () => {
if (props.schema.type !== 'array') return
for (let i = 0; i < entries.value.length; i++) {
entries.value[i][0] = '' + i
}
}

return {
entries,
isMax,
Expand All @@ -173,6 +180,7 @@ export function useEntries() {
entries.value[index][1] = entries.value[index - 1][1]
entries.value[index - 1][1] = temp
}
reindex()
},
down(index: number) {
if (props.schema.type === 'dict') {
Expand All @@ -182,12 +190,15 @@ export function useEntries() {
entries.value[index][1] = entries.value[index + 1][1]
entries.value[index + 1][1] = temp
}
reindex()
},
del(index: number) {
entries.value.splice(index, 1)
reindex()
},
insert(index: number) {
entries.value.splice(index, 0, ['', null])
reindex()
},
}
}
Expand Down

0 comments on commit 3394a32

Please sign in to comment.