Skip to content

Commit

Permalink
Don't show unit conversion field, if there's nothing to convert
Browse files Browse the repository at this point in the history
  • Loading branch information
lentschi committed Jul 8, 2022
1 parent 8f330a7 commit c776081
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/assets/javascripts/unit-conversion-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
this.customUnit = customUnit;

this.loadArticleUnitRatios();
this.unitSelectOptions = this.getUnitSelectOptions();

// if every ratio is the same, don't even bother showing the popover:
// if (this.units[] this.ratios.every(ratio => ratio.quantity === 1)) {
// return;
// }
// if there's less then two options, don't even bother showing the popover:
if (this.unitSelectOptions.length < 2) {
return;
}

this.converter = new UnitsConverter(this.units, this.ratios, this.supplierOrderUnit);

Expand Down Expand Up @@ -96,7 +97,6 @@
this.quantityInput$.val(this.field$.val());
this.conversionResult$ = contents$.find('.conversion-result');
this.unitSelect$ = contents$.find('select.unit');
this.unitSelectOptions = this.getUnitSelectOptions();
this.unitSelect$.append(this.unitSelectOptions.map(option => $(`<option value${option.value === undefined ? '' : `="${option.value}"`}>${option.label}</option>`)))
let initialUnitSelectValue = this.defaultUnit;
if (initialUnitSelectValue === undefined) {
Expand Down

0 comments on commit c776081

Please sign in to comment.