Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Remove autocomplete functionality #16

Merged
merged 2 commits into from Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,2 @@
## 2017-02-22, Version 4.0.0 (Stable), @lennym
* Removes auto-completion of steps without fields. If needed declare this in a custom behaviour.
8 changes: 0 additions & 8 deletions lib/base-controller.js
Expand Up @@ -57,7 +57,6 @@ module.exports = class BaseController extends EventEmitter {
this._getErrors.bind(this),
this._getValues.bind(this),
this._locals.bind(this),
this._checkEmpty.bind(this),
this.render.bind(this),
// eslint-disable-next-line no-shadow
(err, req, res, next) => {
Expand Down Expand Up @@ -227,13 +226,6 @@ module.exports = class BaseController extends EventEmitter {
return this._getForkTarget(req, res);
}

_checkEmpty(req, res, callback) {
if (_.isEmpty(req.form.options.fields) && req.form.options.next) {
this.emit('complete', req, res);
}
callback();
}

getNextStep(req, res) {
let next = req.form.options.next || req.path;
if (req.form.options.forks && Array.isArray(req.form.options.forks)) {
Expand Down
34 changes: 0 additions & 34 deletions test/spec/spec.base-controller.js
Expand Up @@ -296,40 +296,6 @@ describe('Form Controller', () => {
res.locals.options.should.eql(form.options);
});

it('emits "complete" event if form has no fields', () => {
form.options.fields = {};
form.get(req, res, cb);
form.emit.withArgs('complete').should.have.been.calledOnce;
form.emit.withArgs('complete').should.have.been.calledOn(form);
form.emit.should.have.been.calledWithExactly('complete', req, res);
});

it('does not emit "complete" event if form has dynamic fields added at configure step', () => {
form.options.fields = {};
// eslint-disable-next-line no-shadow
form.configure = (req, res, next) => {
req.form.options.fields.name = {
mixin: 'input-text',
validate: 'required'
};
next();
};
form.get(req, res, cb);
form.emit.withArgs('complete').should.not.have.been.called;
});

it('does not emit "complete" event if form has fields', () => {
form = new Form({ template: 'index', fields: { key: {} } });
form.get(req, res, cb);
form.emit.withArgs('complete').should.not.have.been.called;
});

it('does not emit "complete" event if form has no defined next step', () => {
delete form.options.next;
form.get(req, res, cb);
form.emit.withArgs('complete').should.not.have.been.called;
});

it('sets the action property on res.locals', () => {
form.get(req, res, cb);
res.locals.action.should.equal('/base/index');
Expand Down