Skip to content
Snippets Groups Projects
Commit 259ddf12 authored by Lukáš Paukert's avatar Lukáš Paukert
Browse files

WIP: It is possible to choose document and display it on separate page

parent ba761994
No related branches found
No related tags found
No related merge requests found
...@@ -6,13 +6,9 @@ body { ...@@ -6,13 +6,9 @@ body {
margin: 0; margin: 0;
} }
   
h1 { button {
margin-bottom: 0; font-size: 20px;
} margin: 20px;
hr {
color: #19222a;
width: 800px;
} }
   
.navigation { .navigation {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <Wt/WText.h> #include <Wt/WText.h>
#include <Wt/WMenu.h> #include <Wt/WMenu.h>
#include <Wt/WStackedWidget.h> #include <Wt/WStackedWidget.h>
#include <Wt/WPushButton.h>
   
#include <fstream> #include <fstream>
#include <vector> #include <vector>
...@@ -25,20 +26,31 @@ MainForm::MainForm(const Wt::WEnvironment& env) ...@@ -25,20 +26,31 @@ MainForm::MainForm(const Wt::WEnvironment& env)
auto availableDocuments = collection.fetchCollection(); auto availableDocuments = collection.fetchCollection();
   
auto container = root()->addWidget(Wt::cpp14::make_unique<Wt::WContainerWidget>()); auto container = root()->addWidget(Wt::cpp14::make_unique<Wt::WContainerWidget>());
container->addNew<Wt::WText>("<h1>Choose document to display</h1><hr/>"); container->addNew<Wt::WText>("<h1>Available books to display</h1>");
   
auto buttonPtr = Wt::cpp14::make_unique<Wt::WPushButton>("Show me more!");
auto button = buttonPtr.get();
auto contents = Wt::cpp14::make_unique<Wt::WStackedWidget>(); auto contents = Wt::cpp14::make_unique<Wt::WStackedWidget>();
std::string path;
   
Wt::WMenu *menu = container->addNew<Wt::WMenu>(contents.get()); Wt::WMenu *menu = container->addNew<Wt::WMenu>(contents.get());
menu->setStyleClass("navigation");
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
std::string path = availableDocuments.at(i).name; path = availableDocuments.at(i).name;
menu->addItem(getName(path), Wt::cpp14::make_unique<Wt::WText>(getDocument(path))); menu->addItem(getName(path), Wt::cpp14::make_unique<Wt::WText>(getDocument(path)));
} }
menu->setStyleClass("navigation");
menu->select(1);
   
container->addWidget(std::move(buttonPtr));
container->addWidget(std::move(contents)); container->addWidget(std::move(contents));
button->clicked().connect([=] {
container->clear(); // vymaze vsechno z aktualniho containeru
std::string path = availableDocuments.at(menu->currentIndex()).name;
container->addNew<Wt::WText>("<h1>" + getName(path) + "</h1>");
container->addNew<Wt::WText>(getDocument(path));
});
} }
   
std::string MainForm::getName(const std::string & path) std::string MainForm::getName(const std::string & path)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment