mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-01 20:04:09 +03:00
lock dragging when sorted
This commit is contained in:
parent
b4a80eb17f
commit
b95a282b22
@ -5,6 +5,9 @@ WorkActions = require '../actions/WorkActions.coffee'
|
||||
|
||||
module.exports = recl
|
||||
onDragStart: (e) ->
|
||||
unless @props.draggable
|
||||
e.preventDefault()
|
||||
return
|
||||
$t = $(e.target)
|
||||
@dragged = $t.closest('.item')
|
||||
e.dataTransfer.effectAllowed = 'move'
|
||||
|
@ -11,8 +11,9 @@ FilterComponent = require './FilterComponent.coffee'
|
||||
SortComponent = require './SortComponent.coffee'
|
||||
|
||||
module.exports = recl
|
||||
stateFromStore: -> {
|
||||
stateFromStore: -> window.canSort = WorkStore.canSort(); {
|
||||
list:WorkStore.getList()
|
||||
canSort:WorkStore.canSort()
|
||||
listening:WorkStore.getListening()
|
||||
sorts:WorkStore.getSorts()
|
||||
filters:WorkStore.getFilters()
|
||||
@ -144,6 +145,7 @@ module.exports = recl
|
||||
item
|
||||
@_focus
|
||||
@_keyDown
|
||||
draggable:@state.canSort
|
||||
@_dragStart
|
||||
@_dragEnd})
|
||||
)
|
||||
|
@ -253,6 +253,10 @@ WorkActions = require('../actions/WorkActions.coffee');
|
||||
module.exports = recl({
|
||||
onDragStart: function(e) {
|
||||
var $t;
|
||||
if (!this.props.draggable) {
|
||||
e.preventDefault();
|
||||
return;
|
||||
}
|
||||
$t = $(e.target);
|
||||
this.dragged = $t.closest('.item');
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
@ -571,8 +575,10 @@ SortComponent = require('./SortComponent.coffee');
|
||||
|
||||
module.exports = recl({
|
||||
stateFromStore: function() {
|
||||
window.canSort = WorkStore.canSort();
|
||||
return {
|
||||
list: WorkStore.getList(),
|
||||
canSort: WorkStore.canSort(),
|
||||
listening: WorkStore.getListening(),
|
||||
sorts: WorkStore.getSorts(),
|
||||
filters: WorkStore.getFilters(),
|
||||
@ -762,6 +768,7 @@ module.exports = recl({
|
||||
item: item,
|
||||
_focus: _this._focus,
|
||||
_keyDown: _this._keyDown,
|
||||
draggable: _this.state.canSort,
|
||||
_dragStart: _this._dragStart,
|
||||
_dragEnd: _this._dragEnd
|
||||
}));
|
||||
@ -1465,6 +1472,18 @@ WorkStore = assign({}, EventEmitter.prototype, {
|
||||
}
|
||||
return _sorts[key] = val;
|
||||
},
|
||||
canSort: function() {
|
||||
var k, v;
|
||||
for (k in _sorts) {
|
||||
v = _sorts[k];
|
||||
if (k === "sort" && v === 1) {
|
||||
return true;
|
||||
} else if (v !== 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
itemFromData: function(item, index) {
|
||||
var _item;
|
||||
if (index == null) {
|
||||
|
@ -102,18 +102,21 @@ WorkStore = assign {},EventEmitter.prototype,{
|
||||
list
|
||||
|
||||
getListening: -> _listening
|
||||
|
||||
getFilters: -> _filters
|
||||
|
||||
setFilter: ({key,val}) -> _filters[key] = val
|
||||
|
||||
getSorts: -> _sorts
|
||||
|
||||
setSort: ({key,val}) ->
|
||||
for k,v of _sorts
|
||||
_sorts[k] = 0
|
||||
_sorts[key] = val
|
||||
|
||||
|
||||
canSort: ->
|
||||
for k,v of _sorts
|
||||
if k is "sort" and v is 1
|
||||
return true
|
||||
else if v isnt 0
|
||||
return false
|
||||
true
|
||||
|
||||
itemFromData: (item,index=0)->
|
||||
_item = _.extend {sort:index}, item
|
||||
|
Loading…
Reference in New Issue
Block a user