Wtx ~ Wt Extension Library
WtxLib
ManagerWidget.cpp
1 
2 #include <Wt/WText.h>
3 #include <Wt/WHBoxLayout.h>
4 
5 #include <Wtx/Sys/Session.h>
6 #include <Wtx/Dbo/TableViewManager.h>
7 #include <Wtx/Dbo/TemplateFormView.h>
8 #include <Wtx/Dbo/DetailForm.h>
9 #include <Wtx/Sys/User/ItemDelegate.h>
10 
11 #include "Item.h"
12 #include "ManagerWidget.h"
13 
14 namespace Wtx {
15  namespace Sys {
16  namespace Log {
17 
18 class Detail
19 : public Wtx::Dbo::DetailForm<Wtx::Sys::Log::Item>
20 {
21  public:
22 
23  Detail( Wt::Dbo::ptr<Wtx::Sys::Log::Item> & item )
25  (
26  "sysLog.detailForm",
27  item
28  )
29  {
30  }
31 
32 };
33 
34 class View
35 : public Wt::WContainerWidget
36 {
37  public:
38 
39  View( Wtx::Sys::Session * session );
40 
41  void setFilter( const std::string & filter );
42 
44 
45 };
46 
47 View::View( Wtx::Sys::Session * session )
48 : Wt::WContainerWidget()
49 {
50  auto lw = std::make_unique< Wt::WVBoxLayout >();
51 
53  {
54  /* title */ "Log",
55  /* tip */ "",
56  /* headerCount */ 0,
57  /* selectionMode */ Wt::SelectionMode::Single,
58  /* columnResizeEnabled */ true,
59  /* alternatingRowColors */ true,
60  /* sql */ "",
61  /* filter */ "",
62  /* subFilter */ "",
63  /* idin */ {},
64  /* doubleClick */ 0,
65  /* showHeader */ false,
66  /* showFooter */ true,
67  /* showPrevNext */ false,
68  /* hideSearch */ true,
69  /* allowFilter */ false,
70  /* allowAdd */ false,
71  /* allowChange */ false,
72  /* allowDelete */ false,
73  /* allowExport */ false,
74  /* allowSearch */ false,
75  /* allowPrint */ false,
76  /* allowUnlock */ false,
77  /* additional */ "",
78  /* itemDelegate */ nullptr,
79 
80 
81  /* sortFields */
82  {
83  "id DESC"
84  },
85 
86  /* search fields */
87  {
88  },
89 
90  /* column defs */
91  {
92  { "id", "", 75, Wt::AlignmentFlag::Left, "", nullptr },
93  { "createdOn", "", 150, Wt::AlignmentFlag::Left, "", nullptr },
94  { "clip", "", 125, Wt::AlignmentFlag::Left, "", nullptr },
95  { "sysUser_id", "", 125, Wt::AlignmentFlag::Left, "", &Wtx::Sys::User::ItemDelegate::create },
96  { "keyField", "", 150, Wt::AlignmentFlag::Left, "", nullptr },
97  { "cfyField", "", 450, Wt::AlignmentFlag::Left, "", nullptr },
98  },
99 
100  /* column names */
101  {
102  "id",
103  "version"
104  }
105  };
106 
107  m_view = lw-> addWidget( std::make_unique< Wtx::Dbo::TableViewManager< Wtx::Sys::Log::Item, Detail > >( viewDef, session ) );
108 
109  setLayout( std::move(lw) );
110 
111 }
112 
113 void View::setFilter( const std::string & filter )
114 {
115  m_view-> tableView()-> setFilter( filter );
116 }
117 
118  } // endnamespace Log
119  } // endnamespace Sys
120 } // endnamespace Wtx
121 
122 Wtx::Sys::Log::ManagerWidget::ManagerWidget( Wtx::Sys::Session * session )
123 {
124  auto layout = std::make_unique<Wt::WHBoxLayout>();
125 
126  m_view = layout-> addWidget( std::make_unique< View >( session ) );
127 
128  setLayout( std::move(layout) );
129 
130 } // endWtx::Sys::Log::ManagerWidget::ManagerWidget()
131 
132 
133 void Wtx::Sys::Log::ManagerWidget::setFilter( const std::string & filter )
134 {
135  m_view-> setFilter( filter );
136 
137 }
138 
Table View Definition.
Definition: TableViewDef.h:171
witty extension library
Definition: Activity.h:51