Skip to content

Commit

Permalink
Merge pull request #734 from tf/disable-reference-input
Browse files Browse the repository at this point in the history
Add disabled option to ReferenceInputView
  • Loading branch information
tf authored Apr 19, 2017
2 parents 7101f4c + a329cb0 commit 9a42174
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<span class="inline_help"></span>
</label>
<div class="title"></div>
<a href="" class="unset" title="<%= I18n.t('pageflow.editor.templates.inputs.reference.reset') %>"></a>
<a href="" class="choose" title="<%= I18n.t('pageflow.editor.templates.inputs.reference.edit') %>"></a>
<button class="unset" title="<%= I18n.t('pageflow.editor.templates.inputs.reference.reset') %>"></button>
<button class="choose" title="<%= I18n.t('pageflow.editor.templates.inputs.reference.edit') %>"></button>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ pageflow.ReferenceInputView = Backbone.Marionette.ItemView.extend(

ui: {
title: '.title',
unsetButton: '.unset'
unsetButton: '.unset',
buttons: 'button'
},

events: {
Expand Down Expand Up @@ -63,6 +64,8 @@ pageflow.ReferenceInputView = Backbone.Marionette.ItemView.extend(
this.ui.title.text(target ? target.title() : I18n.t('pageflow.editor.views.inputs.reference_input_view.none'));
this.ui.unsetButton.toggle(!!target);

this.updateDisabledAttribute(this.ui.buttons);

if (this.thumbnailView) {
this.thumbnailView.close();
}
Expand Down
4 changes: 2 additions & 2 deletions app/assets/stylesheets/pageflow/editor/inputs/reference.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
overflow: hidden;
}

a.choose {
.choose {
@include icon-only-button;
@include pencil-icon;

Expand All @@ -36,7 +36,7 @@
right: 0;
}

a.unset {
.unset {
@include icon-only-button($base-color: #d00);
@include cancel-circled-icon;

Expand Down
25 changes: 25 additions & 0 deletions spec/javascripts/views/inputs/reference_input_view_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
describe('pageflow.ReferenceInputView', function() {
var Model = Backbone.Model.extend({
i18nKey: 'page'
});

var TestView = pageflow.ReferenceInputView.extend({
getTarget: function() {
return null;
}
});

describe('with disabled option', function() {
it('sets disabled attributes on buttons', function() {
var view = new TestView({
model: new Model(),
propertyName: 'some_id',
disabled: true
});

view.render();

expect(view.ui.buttons).to.have.$attr('disabled');
});
});
});

0 comments on commit 9a42174

Please sign in to comment.