Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sorting flexible groups #6

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion dist/css/field.css
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
.flexible-search-menu-multiselect{--ms-font-size:0.875rem;--ms-option-font-size:0.875rem;--ms-ring-color:rgb(var(--colors-primary-100));--ms-border-color:rgb(var(--colors-gray-300))}html.dark .flexible-search-menu-multiselect{--ms-ring-color:rgb(var(--colors-gray-700));--ms-border-color:rgb(var(--colors-gray-700));--ms-dropdown-border-color:var(--ms-border-color);--ms-bg:rgb(var(--colors-gray-900));--ms-dropdown-bg:var(--ms-bg);--ms-option-bg-pointed:rgb(var(--colors-gray-700));--ms-option-color-pointed:rgb(var(--colors-gray-400))}.hover\:bg-gray-50:hover{--tw-bg-opacity:1;background-color:rgba(var(--colors-gray-50),var(--tw-bg-opacity))}.dark .dark\:hover\:bg-gray-900:hover{--tw-bg-opacity:1;background-color:rgba(var(--colors-gray-900),var(--tw-bg-opacity))}.nova-flexible-content-sortable-ghost{opacity:.5}.nova-flexible-content-sortable-drag{background-color:rgba(var(--colors-gray-100),var(--tw-bg-opacity));border-radius:10px}.dark .nova-flexible-content-sortable-drag{background-color:rgba(var(--colors-gray-900),var(--tw-bg-opacity))}
.flexible-search-menu-multiselect {
--ms-font-size: 0.875rem;
--ms-option-font-size: 0.875rem;
--ms-ring-color: rgb(var(--colors-primary-100));
--ms-border-color: rgb(var(--colors-gray-300));
}
html.dark .flexible-search-menu-multiselect {
--ms-ring-color: rgb(var(--colors-gray-700));
--ms-border-color: rgb(var(--colors-gray-700));
--ms-dropdown-border-color: var(--ms-border-color);
--ms-bg: rgb(var(--colors-gray-900));
--ms-dropdown-bg: var(--ms-bg);
--ms-option-bg-pointed: rgb(var(--colors-gray-700));
--ms-option-color-pointed: rgb(var(--colors-gray-400));
}

.hover\:bg-gray-50:hover {
--tw-bg-opacity: 1;
background-color: rgba(var(--colors-gray-50), var(--tw-bg-opacity));
}

.dark .dark\:hover\:bg-gray-900:hover {
--tw-bg-opacity: 1;
background-color: rgba(var(--colors-gray-900), var(--tw-bg-opacity));
}

.nova-flexible-content-sortable-ghost {
opacity: 0.5;
}

.nova-flexible-content-sortable-drag {
background-color: rgba(var(--colors-gray-100), var(--tw-bg-opacity));
border-radius: 10px;
}

.dark .nova-flexible-content-sortable-drag {
background-color: rgba(var(--colors-gray-900), var(--tw-bg-opacity));
}
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production",
"production": "mix --production --mix-config=webpack.mix.js.dist",
"nova:install": "npm --prefix='../../vendor/laravel/nova' ci"
},
"devDependencies": {
Expand Down
16 changes: 7 additions & 9 deletions resources/js/components/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -272,16 +272,14 @@ export default {
scrollSpeed: 5,
animation: 500,
onEnd: (evt) => {
const item = evt.item;
const key = item.id;
const oldIndex = evt.oldIndex;
const newIndex = evt.newIndex;

if (newIndex < oldIndex) {
this.moveUp(key);
} else if (newIndex > oldIndex) {
this.moveDown(key);
let neighborIndex;
this.order.splice(this.order.indexOf(evt.item.id), 1);
if (evt.oldIndex < evt.newIndex) {
neighborIndex = this.order.indexOf(evt.item.previousElementSibling.id) + 1;
} else {
neighborIndex = this.order.indexOf(evt.item.nextElementSibling.id);
}
this.order.splice(neighborIndex, 0, evt.item.id);
}
});
},
Expand Down