Remove SortedMixin

This commit is contained in:
Robin Ward 2016-12-01 11:33:33 -05:00
parent 0dbcb4ec8a
commit 69ff0e48b4
3 changed files with 11 additions and 21 deletions

View File

@ -6,12 +6,8 @@ export default Ember.Controller.extend({
fieldTypes: null,
createDisabled: Em.computed.gte('model.length', MAX_FIELDS),
arrangedContent: function() {
return Ember.ArrayProxy.extend(Ember.SortableMixin).create({
sortProperties: ['position'],
content: this.get('model')
});
}.property('model'),
fieldSortOrder: ['position'],
sortedFields: Ember.computed.sort('model', 'fieldSortOrder'),
actions: {
createField() {
@ -20,9 +16,9 @@ export default Ember.Controller.extend({
},
moveUp(f) {
const idx = this.get('arrangedContent').indexOf(f);
const idx = this.get('sortedFields').indexOf(f);
if (idx) {
const prev = this.get('arrangedContent').objectAt(idx-1);
const prev = this.get('sortedFields').objectAt(idx-1);
const prevPos = prev.get('position');
prev.update({ position: f.get('position') });
@ -31,9 +27,9 @@ export default Ember.Controller.extend({
},
moveDown(f) {
const idx = this.get('arrangedContent').indexOf(f);
const idx = this.get('sortedFields').indexOf(f);
if (idx > -1) {
const next = this.get('arrangedContent').objectAt(idx+1);
const next = this.get('sortedFields').objectAt(idx+1);
const nextPos = next.get('position');
next.update({ position: f.get('position') });

View File

@ -4,11 +4,11 @@
<p class="desc">{{i18n 'admin.user_fields.help'}}</p>
{{#if model}}
{{#each arrangedContent as |uf|}}
{{#each sortedFields as |uf|}}
{{admin-user-field-item userField=uf
fieldTypes=fieldTypes
firstField=arrangedContent.firstObject
lastField=arrangedContent.lastObject
firstField=sortedFields.firstObject
lastField=sortedFields.lastObject
destroyAction="destroy"
moveUpAction="moveUp"
moveDownAction="moveDown"}}

View File

@ -5,8 +5,6 @@ import { popupAjaxError } from 'discourse/lib/ajax-error';
import { on, default as computed } from "ember-addons/ember-computed-decorators";
import Ember from 'ember';
const SortableArrayProxy = Ember.ArrayProxy.extend(Ember.SortableMixin);
export default Ember.Controller.extend(ModalFunctionality, Ember.Evented, {
@on('init')
@ -20,12 +18,8 @@ export default Ember.Controller.extend(ModalFunctionality, Ember.Evented, {
return categories.map(c => bufProxy.create({ content: c }));
},
categoriesOrdered: function() {
return SortableArrayProxy.create({
sortProperties: ['content.position'],
content: this.get('categoriesBuffered')
});
}.property('categoriesBuffered'),
categoriesSorting: ['position'],
categoriesOrdered: Ember.computed.sort('categoriesBuffered', 'categoriesSorting'),
showFixIndices: function() {
const cats = this.get('categoriesOrdered');