Wtx ~ Wt Extension Library
WtxLib
ManagerWidget.cpp
1 
2 #include <Wt/WWidget.h>
3 #include <Wt/WModelIndex.h>
4 #include <Wt/WItemDelegate.h>
5 #include <Wt/WText.h>
6 #include <Wt/WTemplate.h>
7 #include <Wt/WMenu.h>
8 #include <Wt/WStackedWidget.h>
9 #include <Wt/WGridLayout.h>
10 #include <Wt/WVBoxLayout.h>
11 #include <Wt/WHBoxLayout.h>
12 #include <Wt/WFitLayout.h>
13 #include <Wt/WPushButton.h>
14 
15 #include <Wtx/Dbo/TableViewManager.h>
16 #include <Wtx/Dbo/TemplateFormView.h>
17 #include <Wtx/Dbo/LookupItemDelegate.h>
18 #include <Wtx/Dbo/DetailForm.h>
19 
20 #include "ManagerWidget.h"
21 #include "Item.h"
22 
23 namespace {
24 
25 class BaseDesktop
26 : public Wt::WContainerWidget
27 {
28  public:
29 
31 
32  Wtx::Dbo::Session * session() const { return m_session; }
33 
34  private:
35 
36  Wtx::Dbo::Session * m_session = nullptr;
37 
38 }; // endclass BaseDesktop( Wtx::Dbo::Session * s )
39 
40 BaseDesktop::BaseDesktop( Wtx::Dbo::Session * s )
41 : Wt::WContainerWidget(),
42  m_session(s)
43 {
44 }
45 
46 } // endnamespace
47 
49 : public Wtx::Dbo::DetailForm< Wtx::Sys::Lookup::Item >
50 {
51  public:
52 
53  LookupDetail( Wt::Dbo::ptr< Wtx::Sys::Lookup::Item > & item )
55  (
56  "sysLookup.detailForm",
57  item
58  )
59  {
60  }
61 
62 };
63 
64 
66 : public BaseDesktop
67 {
68  public:
69 
71 
72 }; // endclass LookupDesktop( Wtx::Dbo::Session * s )
73 
74 LookupDesktop::LookupDesktop( Wtx::Dbo::Session * s )
75 : BaseDesktop( s )
76 {
77  auto layout = std::make_unique< Wt::WHBoxLayout >();
78  layout-> setContentsMargins( 0,0,0,0 );
79 
80  {
82  {
83  /* title */ "Categories",
84  /* tip */ "",
85  /* headerCount */ 0,
86  /* selectionMode */ Wt::SelectionMode::Single,
87  /* columnResizeEnabled */ true,
88  /* alternatingRowColors */ true,
89  /* sql */ "",
90  /* filter */ "",
91  /* subFilter */ "",
92  /* idin */ {},
93  /* doubleClick */ 0,
94  /* showHeader */ true,
95  /* showFooter */ true,
96  /* showPrevNext */ false,
97  /* hideSearch */ true,
98  /* allowFilter */ false,
99  /* allowAdd */ true,
100  /* allowChange */ true,
101  /* allowDelete */ false,
102  /* allowExport */ true,
103  /* allowSearch */ true,
104  /* allowPrint */ false,
105  /* allowUnlock */ false,
106  /* additional */ "",
107  /* itemDelegate */ nullptr,
108 
109  /* sortFields */
110  {
111  "\"keyField\""
112  },
113 
114  /* search fields */
115  {
116  },
117 
118  /* column defs */
119  {
120 // { "id", "", 50, Wt::AlignmentFlag::Left, "", nullptr },
121 // { "isActive", "", 75, Wt::AlignmentFlag::Left, "", nullptr },
122 
123  { "id", "", 50, Wt::AlignmentFlag::Left, "", nullptr },
124  { "keyField", "", 100, Wt::AlignmentFlag::Left, "", nullptr },
125  { "cfyField", Wtx::Sys::Lookup::Item::TableDef().CfyFieldDef.label(), 300, Wt::AlignmentFlag::Left, "", nullptr },
126  { "description", "", 300, Wt::AlignmentFlag::Left, "", nullptr }
127 
128  },
129 
130  /* column names */
131  {
132  "id",
133  "keyField",
134  "cfyField",
135  }
136  };
137 
138  layout-> addWidget( std::make_unique< Wtx::Dbo::TableViewManager< Wtx::Sys::Lookup::Item, LookupDetail > >( viewDef, session() ) );
139 
140  }
141 
142  setLayout( std::move(layout) );
143 
144 } // endLookupDesktop::LookupDesktop( Wtx::Dbo::Session * s )
145 
146 
147 
148 Wtx::Sys::Lookup::ManagerWidget::ManagerWidget( Wtx::Dbo::Session * s )
149 : Wt::WContainerWidget(),
150  m_session(s)
151 {
152 
153  auto layout = std::make_unique<Wt::WHBoxLayout>();
154  layout-> setContentsMargins( 0,0,0,0 );
155 
156  layout-> addWidget( std::make_unique< LookupDesktop >( s ) );
157 
158  setLayout( std::move(layout) );
159 
160 } // endWtx::Sys::Lookup::ManagerWidget::ManagerWidget( Wtx::Dbo::Session * s )
161 
162 
Wtx::Dbo::FieldDefLineEdit CfyFieldDef
Item Clarify Field.
Definition: BaseTableDef.h:140
Table View Definition.
Definition: TableViewDef.h:171