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 
10 #include "Item.h"
11 #include "ManagerWidget.h"
12 
14 : public Wtx::Dbo::DetailForm<Wtx::Sys::User::Item>
15 {
16  public:
17 
18  UserDetail( Wt::Dbo::ptr<Wtx::Sys::User::Item> & item )
20  (
21  "sysUser.detailForm",
22  item
23  )
24  {
25  }
26 
27 };
28 
29 
30 
31 Wtx::Sys::User::ManagerWidget::ManagerWidget( Wtx::Sys::Session * session )
32 {
33 
34  auto layout = std::make_unique<Wt::WHBoxLayout>();
35 
36  {
38  {
39  /* title */ "Users",
40  /* tip */ "",
41  /* headerCount */ 0,
42  /* selectionMode */ Wt::SelectionMode::Single,
43  /* columnResizeEnabled */ true,
44  /* alternatingRowColors */ true,
45  /* sql */ "",
46  /* filter */ "",
47  /* subFilter */ "",
48  /* idin */ {},
49  /* doubleClick */ 0,
50  /* showHeader */ true,
51  /* showFooter */ true,
52  /* showPrevNext */ false,
53  /* hideSearch */ true,
54  /* allowFilter */ false,
55  /* allowAdd */ false,
56  /* allowChange */ true,
57  /* allowDelete */ false,
58  /* allowExport */ true,
59  /* allowSearch */ true,
60  /* allowPrint */ false,
61  /* allowUnlock */ false,
62  /* additional */ "",
63  /* itemDelegate */ nullptr,
64 
65 
66  /* sortFields */
67  {
68  "id"
69  },
70 
71  /* search fields */
72  {
73  },
74 
75  /* column defs */
76  {
77  { "id", "", 50, Wt::AlignmentFlag::Left, "", nullptr },
78  { "isActive", "", 75, Wt::AlignmentFlag::Left, "", nullptr },
79  { "keyField", "", 350, Wt::AlignmentFlag::Left, "", nullptr }
80  },
81 
82  /* column names */
83  {
84  "id",
85  "version"
86  }
87  };
88 
89  auto view = layout-> addWidget( std::make_unique< Wtx::Dbo::TableViewManager< Wtx::Sys::User::Item, UserDetail > >( viewDef, session ) );
90 
91  view-> tableView()-> clicked().connect( [=]( Wt::WModelIndex index, Wt::WMouseEvent event )
92  {
93  auto userItem =
94  view->
95  tableView()->
96  model()->
97  stableResultRow( index.row() );
98 
99  std::cout << __FILE__ << ":" << __LINE__ << " " << userItem.id() << std::endl;
100 
101  });
102 
103  }
104 
105  setLayout( std::move(layout) );
106 
107 } // endWtx::Sys::User::ManagerWidget::ManagerWidget()
108 
109 
110 
111 
112 
Table View Definition.
Definition: TableViewDef.h:171