Created
January 11, 2016 01:49
-
-
Save superlou/c81d49d607063e13f893 to your computer and use it in GitHub Desktop.
Sortable Issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle' | |
}); | |
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['schedule-grid'], | |
placesSorting: ['order'], | |
placesSorted: Ember.computed.sort('places', 'placesSorting'), | |
selected: null, | |
hours: function() { | |
var start = this.get('start').reset('minutes'); | |
var finish = this.get('finish'); | |
var current = new Date(start.getTime()); | |
var hours = []; | |
while (current.isBefore(finish)) { | |
hours.push(new Date(current.getTime())); | |
current.advance('hour'); | |
} | |
return hours; | |
}.property('start', 'finish'), | |
tracksWidthStyle: function() { | |
var width = this.get('hourWidth') * this.get('hours').length; | |
return ("width:" + width + 'px').htmlSafe(); | |
}.property('hours', 'hourWidth'), | |
hourWidthStyle: function() { | |
var width = this.get('hourWidth'); | |
return ("width:" + width + "px").htmlSafe(); | |
}.property('hourWidth'), | |
actions: { | |
moveReservation: function(reservation, reservable, schedule) { | |
this.sendAction('moveReservation', reservation, reservable, schedule); | |
}, | |
addEvent: function(startTime, reservable) { | |
this.sendAction('addEvent', startTime, reservable); | |
}, | |
newPlace: function() { | |
this.sendAction('newPlace'); | |
}, | |
resizeReservation: function(session, hours) { | |
this.sendAction('resizeReservation', session, hours); | |
}, | |
select: function(session) { | |
if (this.get('selected')) { | |
this.set('selected.isSelected', false); | |
this.set('selected', null); | |
} | |
session.set('isSelected', true); | |
this.set('selected', session); | |
// Have been passing component | |
this.sendAction('select', session.get('reservation')); | |
}, | |
editDetails: function() { | |
this.sendAction('editDetails'); | |
}, | |
reorderPlaces: function(places, draggedPlace) { | |
places.forEach((place, index) => { | |
place.set('order', index); | |
place.save(); | |
}); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['schedule-grid'], | |
placesSorting: ['order'], | |
placesSorted: Ember.computed.sort('places', 'placesSorting'), | |
selected: null, | |
hours: function() { | |
var start = this.get('start').reset('minutes'); | |
var finish = this.get('finish'); | |
var current = new Date(start.getTime()); | |
var hours = []; | |
while (current.isBefore(finish)) { | |
hours.push(new Date(current.getTime())); | |
current.advance('hour'); | |
} | |
return hours; | |
}.property('start', 'finish'), | |
tracksWidthStyle: function() { | |
var width = this.get('hourWidth') * this.get('hours').length; | |
return ("width:" + width + 'px').htmlSafe(); | |
}.property('hours', 'hourWidth'), | |
hourWidthStyle: function() { | |
var width = this.get('hourWidth'); | |
return ("width:" + width + "px").htmlSafe(); | |
}.property('hourWidth'), | |
actions: { | |
moveReservation: function(reservation, reservable, schedule) { | |
this.sendAction('moveReservation', reservation, reservable, schedule); | |
}, | |
addEvent: function(startTime, reservable) { | |
this.sendAction('addEvent', startTime, reservable); | |
}, | |
newPlace: function() { | |
this.sendAction('newPlace'); | |
}, | |
resizeReservation: function(session, hours) { | |
this.sendAction('resizeReservation', session, hours); | |
}, | |
select: function(session) { | |
if (this.get('selected')) { | |
this.set('selected.isSelected', false); | |
this.set('selected', null); | |
} | |
session.set('isSelected', true); | |
this.set('selected', session); | |
// Have been passing component | |
this.sendAction('select', session.get('reservation')); | |
}, | |
editDetails: function() { | |
this.sendAction('editDetails'); | |
}, | |
reorderPlaces: function(places, draggedPlace) { | |
places.forEach((place, index) => { | |
place.set('order', index); | |
place.save(); | |
}); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.5.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.2.0/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.2.0/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment