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

MainPage redesigned

parent 35df3b27
No related branches found
No related tags found
No related merge requests found
...@@ -20,13 +20,18 @@ button { ...@@ -20,13 +20,18 @@ button {
   
.navigation a { .navigation a {
display: block; display: block;
background-color: #D3D3D3; background-color: #ffffff;
text-decoration: none; text-decoration: none;
padding: 10px; padding: 10px;
} }
   
.navigation a:hover { .navigation a:hover {
background-color: #A9A9A9; background-color: #dcdcdc;
}
.navigation > li > a {
border-radius: 5px;
margin-top: 3px;
} }
   
.navigation > .itemselected > a { .navigation > .itemselected > a {
......
...@@ -26,29 +26,22 @@ MainPage::MainPage(const Wt::WEnvironment& env) ...@@ -26,29 +26,22 @@ MainPage::MainPage(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>Available books to display</h1>");
auto buttonPtr = Wt::cpp14::make_unique<Wt::WPushButton>("Show me more!"); auto buttonPtr = Wt::cpp14::make_unique<Wt::WPushButton>("Show me more!");
auto button = buttonPtr.get(); auto button = buttonPtr.get();
auto contents = Wt::cpp14::make_unique<Wt::WStackedWidget>();
std::string path;
   
Wt::WMenu *menu = container->addNew<Wt::WMenu>(contents.get()); container->addNew<Wt::WText>("<h1>Available books to display</h1>");
Wt::WMenu *menu = container->addNew<Wt::WMenu>();
menu->setStyleClass("navigation"); menu->setStyleClass("navigation");
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++) {
{ menu->addItem(getName(availableDocuments.at(i).name));
path = availableDocuments.at(i).name;
menu->addItem(getName(path), Wt::cpp14::make_unique<Wt::WText>(getDocument(path)));
} }
menu->select(0);
   
container->addWidget(std::move(buttonPtr)); container->addWidget(std::move(buttonPtr));
container->addWidget(std::move(contents));
   
button->clicked().connect([=] { button->clicked().connect([=] {
container->clear(); // deletes everything from current container displayDetail(container, availableDocuments.at(menu->currentIndex()).name);
std::string path = availableDocuments.at(menu->currentIndex()).name;
container->addNew<Wt::WText>("<h1>" + getName(path) + "</h1>");
container->addNew<Wt::WText>(getDocument(path));
}); });
} }
   
...@@ -97,3 +90,12 @@ void MainPage::encode(std::string & data) { ...@@ -97,3 +90,12 @@ void MainPage::encode(std::string & data) {
} }
data.swap(buffer); data.swap(buffer);
} }
void MainPage::displayDetail(Wt::WContainerWidget * container, const std::string & path)
{
// deletes everything from current container
container->clear();
// Show similar books
container->addNew<Wt::WText>("<h1>" + getName(path) + "</h1>");
container->addNew<Wt::WText>(getDocument(path));
}
...@@ -12,4 +12,5 @@ private: ...@@ -12,4 +12,5 @@ private:
std::string getName(const std::string & path); std::string getName(const std::string & path);
std::string getDocument(const std::string & path); std::string getDocument(const std::string & path);
void encode(std::string & content); void encode(std::string & content);
void displayDetail(Wt::WContainerWidget * container, 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