diff --git a/app/components/forms/wizard/sessions-speakers-step.js b/app/components/forms/wizard/sessions-speakers-step.js index 60cd1ffe09a..4f364f8eb9e 100644 --- a/app/components/forms/wizard/sessions-speakers-step.js +++ b/app/components/forms/wizard/sessions-speakers-step.js @@ -139,8 +139,13 @@ export default Component.extend(EventWizardMixin, FormMixin, { return grouped; }), - microlocations: computed('data.microlocations.@each.isDeleted', function() { - return this.data.event.microlocations.filterBy('isDeleted', false); + microlocations: computed('data.microlocations.@each.isDeleted', 'data.microlocations.@each.position', function() { + const sortedRooms = this.data.event.microlocations.sortBy('position').filterBy('isDeleted', false); + sortedRooms.forEach((room, idx) => { + room.set('position', idx); + }); + + return sortedRooms; }), complexCustomForms: computed('data.customForms.@each.isComplex', function() { @@ -183,9 +188,6 @@ export default Component.extend(EventWizardMixin, FormMixin, { case 'track': this.data.tracks.addObject(this.store.createRecord('track')); break; - case 'microlocation': - this.data.microlocations.addObject(this.store.createRecord('microlocation')); - break; } }, addCustomField() { @@ -197,6 +199,27 @@ export default Component.extend(EventWizardMixin, FormMixin, { removeField(field) { this.data.customForms.removeObject(field); }, + addRoom(index) { + this.microlocations.forEach(room => { + const pos = room.get('position'); + pos > index && room.set('position', pos + 1); + }); + this.data.event.microlocations.addObject(this.store.createRecord('microlocation', { position: index + 1 })); + }, + removeRoom(room, index) { + room.deleteRecord(); + this.microlocations.forEach(item => { + const pos = item.get('position'); + pos > index && item.set('position', pos - 1); + }); + }, + moveRoom(item, direction) { + const idx = item.get('position'); + const otherIdx = direction === 'up' ? (idx - 1) : (idx + 1); + const other = this.microlocations.find(item => item.get('position') === otherIdx); + other.set('position', idx); + item.set('position', otherIdx); + }, resetCFS() { this.set('data.speakersCall.announcement', null); }, diff --git a/app/controllers/events/view/scheduler.js b/app/controllers/events/view/scheduler.js index b02f23b9d70..77192cbb964 100644 --- a/app/controllers/events/view/scheduler.js +++ b/app/controllers/events/view/scheduler.js @@ -18,6 +18,11 @@ export default class extends Controller { return false; } + @computed('model.microlocations') + get microlocations() { + return this.model.microlocations.sortBy('position'); + } + @computed('model.unscheduled', 'filter') get unscheduledSessions() { if (!this.filter || !this.model.unscheduled) {return this.model.unscheduled} diff --git a/app/models/microlocation.ts b/app/models/microlocation.ts index 9c92b4f277d..bf6d0aff653 100644 --- a/app/models/microlocation.ts +++ b/app/models/microlocation.ts @@ -7,6 +7,7 @@ export default class Microlocation extends ModelBase.extend({ floor : attr('number'), latitude : attr('number'), longitude : attr('number'), + position : attr('number', { defaultValue: 0 }), sessions : hasMany('session'), event : belongsTo('event'), diff --git a/app/templates/components/forms/wizard/sessions-speakers-step.hbs b/app/templates/components/forms/wizard/sessions-speakers-step.hbs index fb169cbd2f8..66928b61032 100644 --- a/app/templates/components/forms/wizard/sessions-speakers-step.hbs +++ b/app/templates/components/forms/wizard/sessions-speakers-step.hbs @@ -58,7 +58,7 @@