Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
volar committed Nov 7, 2023
1 parent 22cd378 commit 52c87ac
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 133 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
## [1.35.0](https://github.com/anzusystems/common-admin/compare/1.35.0...1.36.0) (2023-11-02)
## [1.37.0](https://github.com/anzusystems/common-admin/compare/1.36.0...1.37.0) (2023-11-07)

### Bug Fixes
* **ASortable:** force rerender after move

### Features
* **chore:** updated dependencies
* **SortableItemDataAware** interface: id is now optional

### BREAKING CHANGES
* **dependencies:** new vue required version `[email protected]`

## [1.36.0](https://github.com/anzusystems/common-admin/compare/1.35.0...1.36.0) (2023-11-06)

### Features
* **chore:** updated dependencies
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"./styles": "./dist/style.css",
"./*": "./*"
},
"version": "1.36.0",
"version": "1.37.0",
"type": "module",
"license": "Apache-2.0",
"scripts": {
Expand Down Expand Up @@ -43,7 +43,7 @@
"@types/node": "^20.8.10",
"@types/sortablejs": "^1.15.4",
"@types/webfontloader": "^1.6.36",
"@typescript-eslint/parser": "^6.9.1",
"@typescript-eslint/parser": "^6.10.0",
"@vitejs/plugin-vue": "^4.4.0",
"@vue/eslint-config-prettier": "^8.0.0",
"@vue/eslint-config-typescript": "^12.0.0",
Expand Down Expand Up @@ -76,7 +76,7 @@
"vite-plugin-dts": "^3.6.3",
"vite-plugin-vuetify": "^1.0.2",
"vitepress": "1.0.0-rc.25",
"vue": "3.3.7",
"vue": "3.3.8",
"vue-flatpickr-component": "^11.0.3",
"vue-i18n": "9.6.5",
"vue-router": "4.2.5",
Expand All @@ -93,7 +93,7 @@
"dayjs": "1.11.10",
"flatpickr": "4.6.13",
"pinia": "2.1.7",
"vue": "3.3.7",
"vue": "3.3.8",
"vue-i18n": "9.6.5",
"vue-router": "4.2.5",
"vuetify": "3.3.23"
Expand Down
2 changes: 2 additions & 0 deletions src/components/sortable/ASortable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ const initSortable = () => {
dragClass: DRAG_CLASS,
chosenClass: CHOSEN_CLASS,
onEnd: async (event: SortableEvent) => {
console.log(event.oldIndex)
console.log(event.newIndex)
if (props.disableDefaultSort || isUndefined(event.oldIndex) || isUndefined(event.newIndex)) return
const needsRefresh = moveArrayElement(event.oldIndex, event.newIndex)
emit('onEnd', needsRefresh)
Expand Down
1 change: 1 addition & 0 deletions src/components/sortable/sortableActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export function useSortableActions(
if (!isUndefined(props.updatePosition)) {
returnData = updatePositions(clonedData, from, to)
}
forceRerenderWidgetHtml()
emit('update:modelValue', clonedData)
return returnData
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/sortable/sortableUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import type { DocId, IntegerId } from '@/types/common'
export const WIDGET_HTML_ID_PREFIX = 'a-sortable-'

export interface SortableItemDataAware {
id?: DocId | IntegerId
position: number
id: DocId | IntegerId
}

export interface SortableItemWithParentDataAware {
position: number
id: DocId | IntegerId
position: number
parent: DocId | IntegerId | null // if null, no parent
}

export interface SortableItemNewPosition {
id: DocId | IntegerId
id?: DocId | IntegerId
position: number
}

Expand Down
22 changes: 22 additions & 0 deletions src/playground/sortable/SortableView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import { isNull } from '@/utils/common'
import type { SortableItemNewPositions } from '@/components/sortable/sortableUtils'
import type { SortableItem, SortablePropItem } from '@/components/sortable/sortableActions'
interface ItemWithoutIdDemo extends Record<string, any> {
title: string
position: number
}
interface BasicItemDemo extends Record<string, any> {
id: number
text: string
Expand All @@ -22,6 +27,13 @@ interface NestedDemoData extends Record<string, any> {
parent: IntegerIdNullable
}
const itemsWithoutId = ref<Array<ItemWithoutIdDemo>>([
{ title: 'One', position: 1 },
{ title: 'Two', position: 2 },
{ title: 'Tree', position: 3 },
{ title: 'Four', position: 4 },
])
const itemsBasic = ref<Array<BasicItemDemo>>([
{ id: 1, text: 'One', position: 1 },
{ id: 2, text: 'Two', position: 2 },
Expand Down Expand Up @@ -310,6 +322,16 @@ const onSortableBasicEnd = (data: SortableItemNewPositions) => {
</template>
</ASortable>

<h2 class="text-h5 mt-5 mb-2">
ASortable items without id
</h2>
<ASortable v-model="itemsWithoutId">
<template #item="{ item }: { item: SortableItem<ItemWithoutIdDemo> }">
{{ item.raw.position }} {{ item.raw.title }}
</template>
</ASortable>
<pre>{{ itemsWithoutId }}</pre>

<h2 class="text-h5 mt-5 mb-2">
ASortable with changing of position field and dirty and all buttons
</h2>
Expand Down
Loading

0 comments on commit 52c87ac

Please sign in to comment.