Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1372002 - Set attached subscriptions to 0 if input is not valid. #1238

Merged
merged 1 commit into from
Sep 27, 2016
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
17 changes: 12 additions & 5 deletions fusor-ember-cli/app/components/tr-subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@ export default Ember.Component.extend({
}),

isQtyValid: Ember.computed('subscription.qtyAvailable', 'subscription.qtyToAttach', function() {
if ((this.get('subscription.qtyToAttach') >= 0) && (this.get('subscription.qtyAvailable') > 0)) {
return (this.get('subscription.qtyToAttach') <= this.get('subscription.qtyAvailable'));
let qtyAvailable = this.get('subscription.qtyAvailable');
let qtyToAttach = this.get('subscription.qtyToAttach');
return Ember.isPresent(qtyToAttach) && qtyToAttach >= 0 && qtyToAttach <= qtyAvailable;
}),

qtyToAttachClass: Ember.computed('isQtyValid', function() {
if (this.get('isQtyValid')) {
return 'center';
} else {
return 'center invalid-input';
}
}),
isQtyInValid: Ember.computed.not('isQtyValid'),

disableQty: Ember.computed('subscription.qtyAvailable', function() {
return (this.get('subscription.qtyAvailable') === 0);
Expand Down Expand Up @@ -76,8 +83,8 @@ export default Ember.Component.extend({

actions: {
setValidQty() {
if (this.get('isQtyInValid')) {
this.set('subscription.qtyToAttach', this.get('subscription.qtyAvailable') );
if (!this.get('isQtyValid')) {
this.set('subscription.qtyToAttach', 0 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cfchase, I understand the rational of this and agree.

}
var pool = this.get('subscription');
this.sendAction('saveSubscription', pool, this.get('subscription.qtyToAttach'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
value=subscription.qtyToAttach
size=5
maxlength=5
class="center {{if isQtyInValid 'invalid-input'}}"
class=qtyToAttachClass
data-qci=attachCssId
disabled=disableQty
focus-out="setValidQty"
Expand Down