summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/boards/components/board.js.coffee
blob: 6a468ea2554b31705396abee1d438d38a0c081d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Board = Vue.extend
  props:
    disabled: Boolean
    board: Object
  data: ->
    dragging: BoardsStore.dragging
  methods:
    clearSearch: ->
      this.query = ''
  ready: ->
    Sortable.create this.$els.list,
      group: 'boards'
      disabled: this.disabled
      animation: 150
      scroll: document.getElementById('board-app')
      scrollSensitivity: 150
      scrollSpeed: 50
      forceFallback: true
      fallbackClass: 'is-dragging'
      ghostClass: 'is-ghost'
      onAdd: (e) ->
        fromBoardId = e.from.getAttribute('data-board')
        fromBoardId = parseInt(fromBoardId) || fromBoardId
        toBoardId = e.to.getAttribute('data-board')
        toBoardId = parseInt(toBoardId) || toBoardId
        issueId = parseInt(e.item.getAttribute('data-issue'))

        BoardsStore.moveCardToBoard(fromBoardId, toBoardId, issueId, e.newIndex)
      onUpdate: (e) ->
        console.log e.newIndex, e.oldIndex
      onStart: ->
        BoardsStore.dragging = true

Vue.component('board', Board)