enforce wizzard start at first step

This commit is contained in:
jelhan 2016-08-18 01:09:58 +02:00
parent 94ded4e723
commit c4a1b99c75
6 changed files with 13 additions and 41 deletions

View file

@ -12,7 +12,12 @@ export default Ember.Route.extend({
}
},
beforeModel() {
beforeModel(transition) {
// enforce that wizzard is started at create.index
if (transition.targetName !== 'create.index') {
this.transitionTo('create.index');
}
// set encryption key
this.get('encryption').generateKey();
},

View file

@ -3,12 +3,5 @@ import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.modelFor('create');
},
// redirect to create/index if poll type is not set
afterModel(create) {
if (create.get('pollType') === null) {
this.transitionTo('create.index');
}
}
});

View file

@ -3,15 +3,5 @@ import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.modelFor('create');
},
// redirect to create/meta if title is not set
afterModel(create) {
if (
!Ember.isArray(create.get('options')) ||
create.get('options.length') < 1
) {
this.transitionTo('create.options');
}
}
});

View file

@ -3,12 +3,5 @@ import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.modelFor('create');
},
// redirect to create/meta if title is not set
afterModel(create) {
if (Ember.isEmpty(create.get('title'))) {
this.transitionTo('create.meta');
}
}
});

View file

@ -3,21 +3,5 @@ import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.modelFor('create');
},
// redirect to create/options if not enough options are defined
afterModel(create) {
// check if only default options are defined
if (create.get('options.length') === 2) {
create.get('options').forEach((option) => {
if (option.title === '') {
this.transitionTo('create.options');
}
});
}
// check if less then two options are defined
else if (create.get('options.length') < 1) {
this.transitionTo('create.options');
}
}
});

View file

@ -900,3 +900,10 @@ test('create a poll and using back button (find a date)', function(assert) {
});
});
});
test('Start at first step is enforced', function(assert) {
visit('create/settings');
andThen(() => {
assert.equal(currentPath(), 'create.index');
});
});