Skip to content

Commit

Permalink
docs: added link to wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
melistik committed Aug 3, 2020
1 parent 7147313 commit 4cb363f
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 68 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,6 @@ HtmlTextEmail htmlTextEmail = builder

### preview HTML-Version

![sample-table](assets/v2-mail-sample-table-image.png)
![sample-table](assets/v2-mail-sample-table-image.png)

A custom table example could be found in [wiki](https://github.com/rocketbase-io/email-template-builder/wiki/Custom-Table).
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,13 @@ public void customTableTest() {
// given
EmailTemplateBuilder.EmailTemplateConfigBuilder builder = EmailTemplateBuilder.builder();

String header = "Invoice {{invoice_id}}";
// when
// when
TbConfiguration config = TbConfiguration.newInstance();
config.getContent().setWidth(800);

builder
.configuration(config)
.header().text(header).and()
.header().text("Invoice {{invoice_id}}").and()
.text("Hi {{name}},").and()
.text("Thanks for using [Product Name]. This is an invoice for your recent purchase");

Expand Down Expand Up @@ -298,79 +297,79 @@ public void forcedHtml() {
sentEmail("forcedHtml", htmlTextEmail);
}

@Getter
public static class CustomTable implements TableLine {
@Getter
public static class CustomTable implements TableLine {

List<List<Object>> headerRows = new ArrayList<>();
List<List<Object>> itemRows = new ArrayList<>();
List<List<Object>> footerRows = new ArrayList<>();
@Getter(AccessLevel.PRIVATE)
EmailTemplateBuilder.EmailTemplateConfigBuilder builder;
private AtomicInteger posCounter = new AtomicInteger(1);
List<List<Object>> headerRows = new ArrayList<>();
List<List<Object>> itemRows = new ArrayList<>();
List<List<Object>> footerRows = new ArrayList<>();
@Getter(AccessLevel.PRIVATE)
EmailTemplateBuilder.EmailTemplateConfigBuilder builder;
private AtomicInteger posCounter = new AtomicInteger(1);

public CustomTable(EmailTemplateBuilder.EmailTemplateConfigBuilder builder) {
this.builder = builder;
public CustomTable(EmailTemplateBuilder.EmailTemplateConfigBuilder builder) {
this.builder = builder;

headerRows.add(Arrays.asList("Pos", "Description", "Tax", "Amount"));
}
headerRows.add(Arrays.asList("Pos", "Description", "Tax", "Amount"));
}

@Override
public EmailTemplateBuilder.EmailTemplateConfigBuilder and() {
return builder;
}
@Override
public EmailTemplateBuilder.EmailTemplateConfigBuilder and() {
return builder;
}

@Override
public HtmlTextEmail build() {
return builder.build();
}
@Override
public HtmlTextEmail build() {
return builder.build();
}

public CustomTable itemRow(TableCellImage image, TableCellLink description, BigDecimal tax, BigDecimal amount) {
itemRows.add(Arrays.asList(posCounter.getAndIncrement(), image, description, tax, amount));
return this;
}
public CustomTable itemRow(TableCellImage image, TableCellLink description, BigDecimal tax, BigDecimal amount) {
itemRows.add(Arrays.asList(posCounter.getAndIncrement(), image, description, tax, amount));
return this;
}

public CustomTable footerRow(TableCellHtml label, TableCellHtml amount) {
footerRows.add(Arrays.asList(label, amount));
return this;
}
public CustomTable footerRow(TableCellHtml label, TableCellHtml amount) {
footerRows.add(Arrays.asList(label, amount));
return this;
}

@Override
public List<ColumnConfig> getHeader() {
return Arrays.asList(new ColumnConfig()
.center(),
new ColumnConfig()
.colspan(2)
.width("60%"),
new ColumnConfig()
.alignment(Alignment.RIGHT),
new ColumnConfig()
.width("20%")
.alignment(Alignment.RIGHT));
}
@Override
public List<ColumnConfig> getHeader() {
return Arrays.asList(new ColumnConfig()
.center(),
new ColumnConfig()
.colspan(2)
.width("60%"),
new ColumnConfig()
.alignment(Alignment.RIGHT),
new ColumnConfig()
.width("20%")
.alignment(Alignment.RIGHT));
}

@Override
public List<ColumnConfig> getItem() {
return Arrays.asList(new ColumnConfig().center(),
new ColumnConfig()
.width(90),
new ColumnConfig()
.lighter(),
new ColumnConfig()
.numberFormat("# '%'")
.italic()
.right(),
new ColumnConfig()
.numberFormat("#.## '€'")
.right());
}
@Override
public List<ColumnConfig> getItem() {
return Arrays.asList(new ColumnConfig().center(),
new ColumnConfig()
.width(90),
new ColumnConfig()
.lighter(),
new ColumnConfig()
.numberFormat("# '%'")
.italic()
.right(),
new ColumnConfig()
.numberFormat("#.## '€'")
.right());
}

@Override
public List<ColumnConfig> getFooter() {
return Arrays.asList(new ColumnConfig()
.colspan(4)
.alignment(Alignment.RIGHT),
new ColumnConfig()
.alignment(Alignment.RIGHT));
@Override
public List<ColumnConfig> getFooter() {
return Arrays.asList(new ColumnConfig()
.colspan(4)
.alignment(Alignment.RIGHT),
new ColumnConfig()
.alignment(Alignment.RIGHT));
}
}
}
}

0 comments on commit 4cb363f

Please sign in to comment.