Skip to content

Commit

Permalink
Replace amount-field with vaadin-integer-field (#980)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezguille authored Dec 4, 2019
1 parent 7ac51cf commit dfab770
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 172 deletions.
124 changes: 0 additions & 124 deletions frontend/src/components/amount-field.js

This file was deleted.

6 changes: 3 additions & 3 deletions frontend/src/views/orderedit/order-item-editor.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
import '@polymer/iron-icon/iron-icon.js';
import '@vaadin/vaadin-text-field/src/vaadin-integer-field.js';
import '@vaadin/vaadin-text-field/src/vaadin-text-field.js';
import '@vaadin/vaadin-button/src/vaadin-button.js';
import '@vaadin/vaadin-form-layout/src/vaadin-form-layout.js';
import '@vaadin/vaadin-combo-box/src/vaadin-combo-box.js';
import '../../components/amount-field.js';
import '../../../styles/shared-styles.js';
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
class OrderItemEditor extends PolymerElement {
Expand Down Expand Up @@ -41,8 +41,8 @@ class OrderItemEditor extends PolymerElement {
<vaadin-form-layout id="form2" colspan="16" class="product" style="flex: auto;">
<vaadin-combo-box id="products" colspan="8" index="[[index]]"></vaadin-combo-box>
<amount-field id="amount" colspan="4" index="[[index]]" class="self-start" min="1" max="15" editable=""
pattern="|1[0-5]?|[2-9]"></amount-field>
<vaadin-integer-field id="amount" colspan="4" index="[[index]]" class="self-start"
min="1" max="15" has-controls prevent-invalid-input></vaadin-integer-field>
<div id="price" colspan="4" class="money">[[price]]</div>
<vaadin-text-field id="comment" colspan="12" placeholder="Details" index="[[index]]"></vaadin-text-field>
</vaadin-form-layout>
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.vaadin.flow.component.internal.AbstractFieldSupport;
import com.vaadin.flow.component.polymertemplate.Id;
import com.vaadin.flow.component.polymertemplate.PolymerTemplate;
import com.vaadin.flow.component.textfield.IntegerField;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.BeanValidationBinder;
import com.vaadin.flow.data.binder.BindingValidationStatus;
Expand All @@ -23,7 +24,6 @@
import com.vaadin.flow.templatemodel.TemplateModel;
import com.vaadin.starter.bakery.backend.data.entity.OrderItem;
import com.vaadin.starter.bakery.backend.data.entity.Product;
import com.vaadin.starter.bakery.ui.components.AmountField;
import com.vaadin.starter.bakery.ui.utils.FormattingUtils;
import com.vaadin.starter.bakery.ui.views.storefront.events.CommentChangeEvent;
import com.vaadin.starter.bakery.ui.views.storefront.events.DeleteEvent;
Expand All @@ -41,7 +41,7 @@ public class OrderItemEditor extends PolymerTemplate<TemplateModel> implements H
private Button delete;

@Id("amount")
private AmountField amount;
private IntegerField amount;

@Id("price")
private Div price;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private void clickAmountFieldPlusOrMinus(int value) {
if (value == 0) {
throw new IllegalArgumentException("Value should be -1 or 1");
}
final int idx = value < 0 ? 0 : 1;
$("amount-field").first().$("iron-icon").get(idx).click();
final String part = value < 0 ? "decrease-button" : "increase-button";
$("vaadin-integer-field").first().$("div").attribute("part", part).first().click();
}
}

0 comments on commit dfab770

Please sign in to comment.