Skip to content
This repository has been archived by the owner on Jul 6, 2022. It is now read-only.

Commit

Permalink
PEXOVS-562 Submit button default ID (#99)
Browse files Browse the repository at this point in the history
ID on input-submit will default to submit-button unless overridden.
  • Loading branch information
sdonaghey03 authored and msjhall138 committed Aug 24, 2017
1 parent 48e2cd0 commit b484b45
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/template-mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ module.exports = function (options, deprecated) {

var obj = {
value: t('buttons.' + value),
id: id
id: id ? id : 'submit-button'
};
return compiled['partials/forms/input-submit'].render(obj);
};
Expand Down
4 changes: 2 additions & 2 deletions partials/forms/input-submit.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="form-group">
<input type="submit" {{#id}}id="{{id}}"{{/id}} value="{{{value}}}" class="button"{{#attributes}} {{attribute}}="{{value}}"{{/attributes}}>
</div>
<input type="submit" id="{{{id}}}" value="{{{value}}}" class="button"{{#attributes}} {{attribute}}="{{value}}"{{/attributes}}>
</div>
18 changes: 18 additions & 0 deletions test/spec.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,24 @@ describe('Template Mixins', function () {
}));
});

it('id is defaulted to submit-button', function () {
middleware(req, res, next);
res.locals['input-submit']().call(res.locals, 'button-id');
render.should.have.been.calledWith(sinon.match({
value: 'buttons.button-id',
id: 'submit-button'
}));
});

it('id is overridden if provided', function () {
middleware(req, res, next);
res.locals['input-submit']().call(res.locals, 'button-id overridden-id');
render.should.have.been.calledWith(sinon.match({
value: 'buttons.button-id',
id: 'overridden-id'
}));
});

it('prefixes translation lookup with namespace if provided', function () {
middleware = mixins({ translate: translate, sharedTranslationsKey: 'name.space' });
middleware(req, res, next);
Expand Down

0 comments on commit b484b45

Please sign in to comment.