Skip to content

Commit

Permalink
Input filters: added Between operator mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rrighi committed May 29, 2019
1 parent 907eb1e commit ae14702
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.holonplatform.artisan.demo.model;

import java.time.LocalDate;

import com.holonplatform.core.Validator;
import com.holonplatform.core.datastore.DataTarget;
import com.holonplatform.core.property.BooleanProperty;
Expand All @@ -23,6 +25,7 @@
import com.holonplatform.core.property.PropertySet;
import com.holonplatform.core.property.PropertyValueConverter;
import com.holonplatform.core.property.StringProperty;
import com.holonplatform.core.property.TemporalProperty;

public interface Product {

Expand All @@ -48,9 +51,12 @@ public interface Product {
.message("Withdrawn").messageCode("product.withdrawn")
.converter(PropertyValueConverter.numericBoolean(Integer.class));

public static final TemporalProperty<LocalDate> DATE = TemporalProperty.localDate("production_date") // Date
.message("Date").messageCode("product.date");

// Product property set with the ID property as identifier property
public static final PropertySet<?> PRODUCT = PropertySet.builderOf(ID, DESCRIPTION, CATEGORY, UNIT_PRICE, WITHDRAWN)
.identifier(ID).build();
public static final PropertySet<?> PRODUCT = PropertySet
.builderOf(ID, DESCRIPTION, CATEGORY, UNIT_PRICE, WITHDRAWN, DATE).identifier(ID).build();

public static final DataTarget<?> TARGET = DataTarget.named("products");

Expand Down
20 changes: 10 additions & 10 deletions demo/src/main/resources/data.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
INSERT INTO products (description,category,price,withdrawn) VALUES ('Product one', 'C1', 19.90, 0);
INSERT INTO products (description,category,price,withdrawn) VALUES ('Product two', 'C2', 29.90, 0);
INSERT INTO products (description,category,price,withdrawn) VALUES ('Product three', 'C1', 15.00, 0);
INSERT INTO products (description,category,price,withdrawn) VALUES ('Product four', 'C2', 75.50, 1);
INSERT INTO products (description,category,price,withdrawn) VALUES ('Product five', 'C3', 19.90, 0);
INSERT INTO products (description,category,price,withdrawn) VALUES ('Product six', 'C1', 39.90, 0);
INSERT INTO products (description,category,price,withdrawn) VALUES ('Product seven', 'C4', 44.20, 0);
INSERT INTO products (description,category,price,withdrawn) VALUES ('Product eight', 'C1', 77.00, 0);
INSERT INTO products (description,category,price,withdrawn) VALUES ('Product nine', 'C3', 23.70, 1);
INSERT INTO products (description,category,price,withdrawn) VALUES ('Product ten', 'C2', 92.20, 0);
INSERT INTO products (description,category,price,withdrawn,production_date) VALUES ('Product one', 'C1', 19.90, 0, parsedatetime('19-03-2016', 'dd-MM-yyyy'));
INSERT INTO products (description,category,price,withdrawn,production_date) VALUES ('Product two', 'C2', 29.90, 0, parsedatetime('29-05-2019', 'dd-MM-yyyy'));
INSERT INTO products (description,category,price,withdrawn,production_date) VALUES ('Product three', 'C1', 15.00, 0, null);
INSERT INTO products (description,category,price,withdrawn,production_date) VALUES ('Product four', 'C2', 75.50, 1, null);
INSERT INTO products (description,category,price,withdrawn,production_date) VALUES ('Product five', 'C3', 19.90, 0, parsedatetime('02-04-2019', 'dd-MM-yyyy'));
INSERT INTO products (description,category,price,withdrawn,production_date) VALUES ('Product six', 'C1', 39.90, 0, parsedatetime('30-04-2016', 'dd-MM-yyyy'));
INSERT INTO products (description,category,price,withdrawn,production_date) VALUES ('Product seven', 'C4', 44.20, 0, null);
INSERT INTO products (description,category,price,withdrawn,production_date) VALUES ('Product eight', 'C1', 77.00, 0, null);
INSERT INTO products (description,category,price,withdrawn,production_date) VALUES ('Product nine', 'C3', 23.70, 1, null);
INSERT INTO products (description,category,price,withdrawn,production_date) VALUES ('Product ten', 'C2', 92.20, 0, parsedatetime('30-04-2016', 'dd-MM-yyyy'));
3 changes: 2 additions & 1 deletion demo/src/main/resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ create table products (
description varchar(500),
category varchar(10),
price double,
withdrawn integer default 0
withdrawn integer default 0,
production_date date
);
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ public void build(Input<T> input, Input<T> additionalInput) {
filterComponent = new HolonInputFilter();
filterComponent.setOperatorComponent(getOperatorSelect());
filterComponent.setInputComponent(input.getComponent());
filterComponent.getElement().getStyle().set("flex-grow", "1");
// check between input
if (isSupportsBetween()) {
Obj.argumentNotNull(additionalInput, "Additional Input must be not null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ public void setOperatorComponent(Component operator) {
public void setInputComponent(Component input) {
Obj.argumentNotNull(input, "Component must be not null");
if (input != null) {
input.getElement().getStyle().set("flex-grow", "1");
//input.getElement().getStyle().set("flex-grow", "1");
input.getElement().getStyle().set("width", "100%");
addToSlot("input", input);
}
}

public void setAdditionalInputComponent(Component input) {
Obj.argumentNotNull(input, "Component must be not null");
if (input != null) {
input.getElement().getStyle().set("flex-grow", "1");
//input.getElement().getStyle().set("flex-grow", "1");
input.getElement().getStyle().set("width", "100%");
addToSlot("additional-input", input);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,45 @@
}

[part="operator"] {
display: inline-flex;
flex-grow: 0;
flex-shrink: 0;
margin-right: 1px;
}

[part="input"] {
display: inline-flex;
[part="input-container"] {
display: block;
flex-grow: 1;
}

[part="input"] {
float: left;
width: 100%;
}

[part="additional-input"] {
display: none;
}

:host([with-additional-input]) [part="input"] {
width: 50%;
}

:host([with-additional-input]) [part="additional-input"] {
display: inline-flex;
flex-grow: 1;
margin-left: 1px;
display: block;
width: calc(50% - 1px);
float: right;
}
</style>
<div part="operator">
<slot name="operator"></slot>
</div>
<div part="input">
<slot name="input"></slot>
</div>
<div part="additional-input">
<slot name="additional-input"></slot>
<div part="input-container">
<div part="input">
<slot name="input"></slot>
</div>
<div part="additional-input">
<slot name="additional-input"></slot>
</div>
</div>
</template>

Expand Down

0 comments on commit ae14702

Please sign in to comment.