Git Product home page Git Product logo

Comments (9)

fmcarvalho avatar fmcarvalho commented on May 30, 2024

Hi @Buchx ,

There is no direct support for this Issue in HtmlFlow. But maybe you can work around it with:

  1. Merge the arraylists in a single List with: man.addAll(tir) or Iterable<SkemaLektion > res = () -> Stream.concat(man.stream(), tir.stream()).iterator();. Then pass the resulting iterable to the view taskView.setPrintStream(out).write(res);

  2. Instead of printing the week day value in a th, just print “Week Day” on the th and then print the values "Mandag", "Tirsdag", etc in td bellow. In that case maybe the type SkemaLektion should have a property getWeekDay() which provides the data to that td: "Mandag", "Tirsdag", etc. Thus you can control inside the lambda if you have already printed the Week Day or not, like:

WeekDay last = {""}; 
…
skemaLektion -> {
   if(last[0].equals(skemaLektion.getWeekDay())) return "&nbsp;"
   last[0] = skemaLektion.getWeekDay();
   return skemaLektion.getWeekDay().getText();
}

Hope this helps.

from htmlflow.

Buchx avatar Buchx commented on May 30, 2024

Hi, @fmcarvalho

It now works flawlessly!
image

Maybe a bit out of context, but do you know If I can merge thoose cells with the dates OR give it attributes so I can style it a bit more? Or should I just target it with CSS children?

Kind regards

from htmlflow.

fmcarvalho avatar fmcarvalho commented on May 30, 2024

In current version of HtmlFlow td s are automatically created by trFromIterable() method and there is no way to specify further attributes on those td.s

On next version 2.0 of HtmlFlow which is in development branch and is being prepared for release this method trFromIterable() is removed and you have a completely different approach which you can check at the unit test TestTable.java and it is like:

    table.<List<Task>>binder((tbl, list) -> {
            list.forEach(item -> {
                tbl.tr()
                        .td().text(item.getTitle()).º()
                        .td().text(item.getDescription()).º()
                        .td().text(item.getPriority().toString());
            });
        });

In this way you can do whatever you want with each td.

See the README.md of development branch for further details.

from htmlflow.

Buchx avatar Buchx commented on May 30, 2024

Brilliant! Looking forward to version 2.0!
Thank you for all the help!

from htmlflow.

Buchx avatar Buchx commented on May 30, 2024

@fmcarvalho
When will version 2.0 be released? Really eager to style my tds :)
So I can get it more looking like this:
layout

Here is what I've made it to currently.
current

Source for above output.

public static void saveWeek(
            String weekNum,
            String header,
            String footer,
            String extrasFooter,
            ArrayList<SkemaLektion> lektures) {

        footer = footer.replaceAll("[\n]", "<br />");
        header = header.replaceAll("[\n]", "<br />");
        extrasFooter = extrasFooter.replaceAll("[\n]", "<br />");

        HtmlView<Iterable<SkemaLektion>> taskView = new HtmlView<Iterable<SkemaLektion>>();


        taskView
                .head()
                .title(weekNum)
                .linkCss("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css")
                .scriptBlock()
                .code("</script>\n<meta charset='UTF-8'>\n<script>");

        HtmlBody<Iterable<SkemaLektion>> body = taskView
                .body()
                .classAttr("container");

        // Set header text
        body
                .div()
                .text(header);

        HtmlTable<Iterable<SkemaLektion>> table = body
                .heading(2, "Øvelsesliste for uge " + weekNum.replaceAll("[-]", " "))
                .table().classAttr("table");

        // Set footer text
        body
                .br()
                .div()
                .text(footer);

        if (!extrasFooter.isEmpty()) {
            body
                    .br()
                    .div()
                    .text(extrasFooter);
        }

        String[] last = {""};
        HtmlTr<Iterable<SkemaLektion>> headerRow = table.tr();
        headerRow.th().text("Uge " + weekNum.replaceAll("[-]", " ") + " - " + SkemaController.dp.getValue().getYear());
        headerRow.th().text("Tid");
        headerRow.th().text("Enhed");
        headerRow.th().text("Fag");
        headerRow.th().text("Lek Nr");
        headerRow.th().text("Aktivitet");
        headerRow.th().text("Leder");
        headerRow.th().text("Påklædning");
        headerRow.th().text("Sted");
        table.trFromIterable(
                skemaLektion -> {
                    if (last[0].equals(skemaLektion.getWeekDay())) return "&nbsp;";
                    last[0] = skemaLektion.getWeekDay();
                    return "<div id='" + skemaLektion.getWeekDay().replaceAll("[\n]]","").substring(0, skemaLektion.getWeekDay().length() - 8) + "' style='white-space: pre-wrap;'>" + skemaLektion.getWeekDay() + "</div>";
                },
                skemaLektion -> skemaLektion.getLektid().getText(),
                skemaLektion -> skemaLektion.getEnhedValue(),
                skemaLektion -> skemaLektion.getFagValue(),
                skemaLektion -> skemaLektion.getLekNummerValue(),
                skemaLektion -> skemaLektion.getAktivitet().getText(),
                skemaLektion -> skemaLektion.getAnsvar().getText(),
                skemaLektion -> skemaLektion.getPaaklaedning().getText(),
                (SkemaLektion skemaLektion2) -> skemaLektion2.getLokation().getText());


        String fileName = "Uge_" + weekNum + "_" + SkemaController.dp.getValue().getYear() + ".html";
        try {
            PrintStream out = new PrintStream(new FileOutputStream(fileName), true, "UTF-8");
            taskView.setPrintStream(out).write(lektures);

            Desktop.getDesktop().browse(URI.create(fileName));

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

Maybe if you have time you could help me setting up the code for reaching an output similar to picture1?

from htmlflow.

fmcarvalho avatar fmcarvalho commented on May 30, 2024

@Buchx

When will version 2.0 be released? Really eager to style my tds :)

Maybe at the end of this week... In meanwhile you can clone this repository, checkout development branch , open a console and run mvn clean install and then add a reference to htmlflow-2.0-SNAPSHOT in your project.

I can help you with any issue that you find. But I am overwhelmed and I have no time to translate your source code to current version 2.0 HtmlFlow. Try yourself and open an Issue if you have any doubt.

Thanks,
Miguel

from htmlflow.

fmcarvalho avatar fmcarvalho commented on May 30, 2024

@Buchx

Just to let you know that version 2.0 of HtmlFlow has been released right now.

Now we just have to wait for the synchronization process with Maven Central.

Note that now we are on xmlet oganization: http://repo1.maven.org/maven2/com/github/xmlet/ and
https://github.com/xmlet/

Thanks

from htmlflow.

fmcarvalho avatar fmcarvalho commented on May 30, 2024

@Buchx As you may be aware, I am the author and primary advocate for the HtmlFlow Java library. As part of my continuous endeavors, I am required to provide justification for this project to my university.

HtmlFlow serves as a versatile auxiliary tool utilized across various sectors, facilitating software development by streamlining tasks such as HTML reporting automation, web templating, and more.

If you have utilized HtmlFlow, I kindly request your testimony regarding my dedication to addressing issues, implementing new features, or otherwise aligning with your requirements and/or your company within the scope of a specific project, task, or work that utilized HtmlFlow during a certain timeframe.

Your testimony will play a crucial role in demonstrating my work to my university.

Please feel free to send your testimonial to my email address at ISEL: [email protected]

Thank you in advance for your attention and assistance.

from htmlflow.

fmcarvalho avatar fmcarvalho commented on May 30, 2024

@Buchx Even if you are not currently using HtmlFlow, I kindly request your acknowledgment that I was actively engaged in maintaining, tracking issues, or new features during the time of this issue. It is imperative for me to justify my efforts on HtmlFlow during the period of this issue to my university.

I would greatly appreciate it if you could once again provide your acknowledgment to my email address at ISEL: [email protected].

Thank you in advance for your attention and assistance.

from htmlflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.