Guest User

Untitled

a guest
Jul 16th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. <draggable
  2. class="dragArea"
  3. v-model="sections"
  4. :options="{ group: { name: 'g1', put: 'g1'}, handle: '.drag-handle' }"
  5. v-if="sections && hasWriteAccess">
  6.  
  7. <section-component
  8. v-for="(section, i) in sections"
  9. :component="section">
  10.  
  11. <draggable
  12. class="dragArea"
  13. :sections="section.components_under_section"
  14. slot="component_under_section"
  15. :options="{ group: { name: 'g2', put: 'g2'}, handle: '.drag-handle' }">
  16.  
  17. <lesson-component
  18. v-for="(comp, i) in section.components_under_section"
  19. :component="comp">
  20. </lesson-component>
  21. </draggable>
  22.  
  23. </section-component>
  24.  
  25. </draggable>
  26.  
  27.  
  28. computed: Object.assign({},
  29. sections: {
  30. get(){
  31. // returns state._array (see below)
  32. return this.componentsSortable
  33. },
  34. set(value){
  35. // store updated array of components (generated by VueDraggable) to store/state
  36. this.storeUpdatedComponents(value)
  37. // update position attribute of every component in store/state, then update postgres
  38. this.saveComponentPositions(value)
  39. return
  40. }
  41. }
  42. )
  43.  
  44. [
  45. {
  46. "id": 52,
  47. "type": "section",
  48. "content": "How to Fly?",
  49. "position": 1,
  50. "project_id": 128,
  51. "section_id": null,
  52. "components_under_section": [
  53. {
  54. "id": 53,
  55. "type": "component",
  56. "content": "AAA",
  57. "section_id": 52
  58. },
  59. {
  60. "id": 54,
  61. "type": "component",
  62. "content": "BBB",
  63. "section_id": 52
  64. }
  65. },
  66. { ... },
  67. { ... }
  68. ]
Add Comment
Please, Sign In to add comment