@retikolo/drag-drop-content-types 1.7.0 β†’ 2.0.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 (86) hide show
  1. package/README.md +40 -22
  2. package/dist/_chunks/Settings-BUJ6OWyE.js +3632 -0
  3. package/dist/_chunks/Settings-Cx22s5Bk.mjs +3615 -0
  4. package/dist/_chunks/en-I3-CH3Sy.js +31 -0
  5. package/dist/_chunks/en-bxpER_P-.mjs +31 -0
  6. package/dist/_chunks/fr-C8Qw4iPZ.js +4 -0
  7. package/dist/_chunks/fr-hkSxFuzl.mjs +4 -0
  8. package/dist/_chunks/index-CxWC49Ye.mjs +477 -0
  9. package/dist/_chunks/index-D5Ne-GrP.js +478 -0
  10. package/dist/admin/index.js +3 -0
  11. package/dist/admin/index.mjs +4 -0
  12. package/dist/admin/src/components/Initializer.d.ts +5 -0
  13. package/dist/admin/src/components/PluginIcon.d.ts +2 -0
  14. package/dist/admin/src/components/SettingsTextField.d.ts +14 -0
  15. package/dist/admin/src/components/SettingsToggleField.d.ts +13 -0
  16. package/dist/admin/src/components/SortModal/CustomItem.d.ts +12 -0
  17. package/dist/admin/src/components/SortModal/SortMenu.d.ts +3 -0
  18. package/dist/admin/src/components/SortModal/SortableList.d.ts +3 -0
  19. package/dist/admin/src/components/SortModal/SortableListItem.d.ts +7 -0
  20. package/dist/admin/src/components/SortModal/index.d.ts +2 -0
  21. package/dist/admin/src/components/SortModal/utils.d.ts +2 -0
  22. package/dist/admin/src/components/TooltipIconButton.d.ts +11 -0
  23. package/dist/admin/src/index.d.ts +13 -0
  24. package/dist/admin/src/pages/App.d.ts +2 -0
  25. package/dist/admin/src/pages/HomePage.d.ts +2 -0
  26. package/dist/admin/src/pages/Settings.d.ts +2 -0
  27. package/dist/admin/src/permissions.d.ts +7 -0
  28. package/dist/admin/src/pluginId.d.ts +1 -0
  29. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  30. package/dist/admin/src/utils/strapi.d.ts +13 -0
  31. package/dist/admin/src/utils/useQueryParams.d.ts +7 -0
  32. package/dist/server/index.js +266 -0
  33. package/dist/server/index.mjs +267 -0
  34. package/dist/server/src/bootstrap.d.ts +5 -0
  35. package/dist/server/src/config/index.d.ts +5 -0
  36. package/dist/server/src/content-types/index.d.ts +2 -0
  37. package/dist/server/src/controllers/dragdrop.d.ts +9 -0
  38. package/dist/server/src/controllers/index.d.ts +16 -0
  39. package/dist/server/src/controllers/settings.d.ts +8 -0
  40. package/dist/server/src/destroy.d.ts +5 -0
  41. package/dist/server/src/index.d.ts +79 -0
  42. package/dist/server/src/middlewares/index.d.ts +2 -0
  43. package/dist/server/src/policies/index.d.ts +2 -0
  44. package/dist/server/src/register.d.ts +5 -0
  45. package/dist/server/src/routes/dragdrop.d.ts +13 -0
  46. package/dist/server/src/routes/index.d.ts +26 -0
  47. package/dist/server/src/routes/settings.d.ts +12 -0
  48. package/dist/server/src/services/dragdrop.d.ts +21 -0
  49. package/dist/server/src/services/index.d.ts +21 -0
  50. package/dist/server/src/services/settings.d.ts +8 -0
  51. package/package.json +73 -38
  52. package/.eslintrc.js +0 -56
  53. package/.prettierrc +0 -7
  54. package/admin/src/api/sort.js +0 -18
  55. package/admin/src/components/Initializer/index.js +0 -26
  56. package/admin/src/components/SortModal/SortMenu.js +0 -152
  57. package/admin/src/components/SortModal/index.js +0 -270
  58. package/admin/src/components/SortModal/types.d.js +0 -34
  59. package/admin/src/components/SortModal/utils.js +0 -25
  60. package/admin/src/index.js +0 -73
  61. package/admin/src/pages/App/index.js +0 -24
  62. package/admin/src/pages/Settings/index.js +0 -216
  63. package/admin/src/permissions.js +0 -4
  64. package/admin/src/pluginId.js +0 -5
  65. package/admin/src/translations/en.json +0 -1
  66. package/admin/src/translations/fr.json +0 -1
  67. package/admin/src/utils/axiosInstance.js +0 -40
  68. package/admin/src/utils/getTrad.js +0 -5
  69. package/admin/src/utils/strapi.js +0 -18
  70. package/admin/src/utils/useQueryParams.js +0 -18
  71. package/jsconfig.json +0 -18
  72. package/server/bootstrap.js +0 -14
  73. package/server/config/index.js +0 -6
  74. package/server/content-types/index.js +0 -4
  75. package/server/controllers/index.js +0 -7
  76. package/server/controllers/sort.js +0 -198
  77. package/server/destroy.js +0 -5
  78. package/server/index.js +0 -25
  79. package/server/middlewares/index.js +0 -3
  80. package/server/policies/index.js +0 -3
  81. package/server/register.js +0 -12
  82. package/server/routes/index.js +0 -7
  83. package/server/routes/sort.js +0 -50
  84. package/server/services/index.js +0 -3
  85. package/strapi-admin.js +0 -3
  86. package/strapi-server.js +0 -3
package/README.md CHANGED
@@ -5,55 +5,73 @@
5
5
 
6
6
  ![dragdropcrop](https://user-images.githubusercontent.com/37687705/212884821-356ec68c-b71a-4b89-9e99-8a625f84cfbe.gif)
7
7
 
8
+ Inspired by the [Drag-Drop-Content-Type Strapi 4 plugin](https://github.com/plantagoIT/strapi-drag-drop-content-type-plugin).
9
+ Drag-drop feature completely rewritten to use dndkit because react-sortable-hoc is deprecated and not compatible with React 18.
10
+
11
+ ## πŸ”„ Strapi 5 Compatibility
12
+
13
+ This version (2.0.0) has been updated for **Strapi 5** compatibility with the following changes:
14
+
15
+ ### Key Updates
16
+ - **Removed Redux dependency**: Strapi 5 changed its internal architecture, so the Redux-based list view refresh has been replaced with a page reload mechanism that triggers when closing the sort modal after making changes
17
+ - **Updated @dnd-kit**: Migrated from react-sortable-hoc to @dnd-kit for drag-and-drop functionality (React 18 compatible)
18
+ - **Strapi 5 Admin API**: Updated to use new Strapi 5 admin hooks (`useFetchClient`, `useNotification`, `useAPIErrorHandler`)
19
+ - **Improved UX**: You can now drag and reorder multiple items in one session - the page only refreshes once when you close the modal, preserving your changes
20
+
21
+ ### Known Considerations
22
+ - After sorting items, the content manager list view refreshes when you close the sort modal to display the updated order
23
+ - Uses Strapi 5's new Popover component with controlled state for better stability
24
+
25
+ ###Β Strapi 4 Compatibility
26
+ If you are still using Strapi 4, you can use version 1.7.1 of this plugin, which is available on the `strapi4` branch.
27
+
8
28
  ## ⏳ Installation
9
29
 
30
+ Install with NPM.
31
+ ```bash
32
+ npm i @retikolo/drag-drop-content-types-strapi
33
+ ```
34
+ Install with Yarn.
10
35
  ```bash
11
- # with npm
12
- npm i @retikolo/drag-drop-content-types
13
- # with yarn
14
- yarn add @retikolo/drag-drop-content-types
36
+ yarn add @retikolo/drag-drop-content-types-strapi
15
37
  ```
16
38
 
17
39
  ## πŸ”§ Configuration
18
40
 
19
41
  ### In your config
20
- 1. Add this to your `config/plugins.js` file (create it, if it doesn't exist yet):
42
+ 1. Add the following to your `config/plugins.ts` file. Create the file, if it doesn't exist.
21
43
  ```js
22
- module.exports = {
44
+ export default () => ({
23
45
  // ...
24
46
  'drag-drop-content-types': {
25
47
  enabled: true
26
48
  }
27
- }
49
+ })
28
50
  ```
29
- 2. Run `npm run build` and (re)start the app
51
+ 2. Run `npm run build` and restart the app using `npm run develop`.
30
52
 
31
53
  ### In the app
32
- Go to `Settings` -> `Drag Drop Content Type` -> `Configuration`:
33
- * Specify how the rank field is called in your content-types. Default value is `rank`.
34
- * Add the `rank` fields to your content type. With the default value this would be `rank` (Number (Number format: integer)).
35
- * (Give permissions for the `rank` field to roles such as "Editor" if needed).
54
+ 1. Go to `Settings` β†’ `Drag Drop Content Type` β†’ `Configuration`.
55
+ 2. Specify the `Rank Field Name` used for sorting or leave the default field name `rank`.
56
+ 3. Add a `Number` field with `Name: myRankFieldName` and `Number format: integer` to the sortable _ContentType_.
57
+ 4. Configure the view of your _ContentType_ by adding `Default sort attribute β†’ rank` and `Default sort order β†’ ASC` to update the view after dragging.
58
+ 5. If needed: grant permissions for the `rank` field to your roles.
36
59
 
37
60
  #### Hints
38
- * Add "Default sort attribute" `rank`, "Default sort order" `ASC` and remove the `rank` attribute from the view using "Configure the view" button.
39
- * You can also set a `title` value that is displayed in the menu instead of the default.
40
- * If you want a second field to be displayed in the drag and drop menu, you can add s `subtitle` in the settings. The subtitle should either be:
41
- - A field containing a string or number or something like that.
42
- - It can be an object (like a relation), but it must have the `title` field specified in the settings (it won't recognize automatically!).
61
+ * You can set a `title` value that will be displayed in the menu instead of the default field.
62
+ * A second field can be displayed in the menu via the `subtitle` setting. It can be either a string-like field or an object such as a relation, that has a `title` field as configured in the settings.
63
+ * You can enable webhooks to trigger something after updating the order.
43
64
 
44
65
  ### In your frontend
45
- Assuming you go with the default settings, you can make a request on the following url to get the ordered items:
66
+ You can make a request in the frontend to get the ordered items. In this example the _ContentType_ is called `Foo` and ordered via the `rank` field.
46
67
 
47
68
  ```
48
69
  http://localhost:1337/api/foo?sort=rank:asc
49
70
  ```
50
71
 
51
- ## 🐞 Known issues
52
- Due to changes in the Strapi core, the plugin causes a full page reload after sorting. This is a known issue, and will be fixed ASAP if possible.
53
-
54
72
  ## 🀝 Contribute
55
73
  Feel free to fork and make pull requests to this plugin. All input is welcome - thanks for all contributions so far!
56
74
 
57
75
 
58
76
  ## ⭐️ Support
59
- I you like this project, please give it a star. Maybe this will help it getting integrated to strapi's core some day 😊.
77
+ I you like this project, please give it a star ⭐️. Maybe this will help it getting integrated to strapi's core some day 😊.