Wtx ~ Wt Extension Library
WtxLib
ManagerWidget.cpp
1 
2 #include <Wt/WText.h>
3 #include <Wt/WTemplate.h>
4 #include <Wt/WMenu.h>
5 #include <Wt/WStackedWidget.h>
6 #include <Wt/WGridLayout.h>
7 #include <Wt/WVBoxLayout.h>
8 #include <Wt/WHBoxLayout.h>
9 #include <Wt/WFitLayout.h>
10 #include <Wt/WPushButton.h>
11 
12 #include <Wtx/Dbo/TableViewManager.h>
13 #include <Wtx/Dbo/TemplateFormView.h>
14 
15 #include "ManagerWidget.h"
16 #include "Item.h"
17 
18 class BaseDesktop
19 : public Wt::WContainerWidget
20 {
21  public:
22 
24 
25  Wtx::Dbo::Session * session() const { return m_session; }
26 
27  private:
28 
29  Wtx::Dbo::Session * m_session = nullptr;
30 
31 }; // endclass BaseDesktop( Wtx::Dbo::Session * s )
32 
33 BaseDesktop::BaseDesktop( Wtx::Dbo::Session * s )
34 : Wt::WContainerWidget(),
35  m_session(s)
36 {
37 }
38 
39 template <class C>
41 : public Wtx::Dbo::TemplateFormView< C >
42 {
43  public:
44 
45  DetailForm( const std::string & templateName, Wt::Dbo::ptr<C> & item )
47  (
48  Wt::WString::tr(templateName),
49  new Wtx::Dbo::FormModel< C >( item.id(), item.session() )
50  )
51  {
52  Wtx::Dbo::TemplateFormView< C >:: template bindNew<Wt::WPushButton>( "submit", "submit" );
53  Wtx::Dbo::TemplateFormView< C >:: template bindNew<Wt::WPushButton>( "close", "close" );
54 
55  this-> updateView();
56  }
57 
58  private:
59 
60 };
61 
62 class CompanyDetail
63 : public DetailForm< Wtx::Crm::Company::Item >
64 {
65  public:
66 
67  CompanyDetail( Wt::Dbo::ptr< Wtx::Crm::Company::Item > & item )
69  (
70  "crmCompany.detailForm",
71  item
72  )
73  {
74  }
75 
76 };
77 
78 class CompanyDesktop
79 : public BaseDesktop
80 {
81  public:
82 
84 
85 }; // endclass CustomerDesktop( Wtx::Dbo::Session * s )
86 
87 CompanyDesktop::CompanyDesktop( Wtx::Dbo::Session * s )
88 : BaseDesktop( s )
89 {
90  auto layout = std::make_unique< Wt::WHBoxLayout >();
91 
92  {
94  {
95  /* title */ "Customers",
96  /* tip */ "",
97  /* headerCount */ 0,
98  /* selectionMode */ Wt::SelectionMode::Single,
99  /* columnResizeEnabled */ true,
100  /* alternatingRowColors */ true,
101  /* sql */ "",
102  /* filter */ "\"isActive\"",
103  /* doubleClick */ 0,
104  /* showHeader */ true,
105  /* showFooter */ true,
106  /* allowFilter */ false,
107  /* allowAdd */ true,
108  /* allowChange */ false,
109  /* allowDelete */ false,
110  /* allowExport */ true,
111  /* allowSearch */ true,
112  /* itemDelegate */ nullptr,
113 
114 
115  /* sortFields */
116  {
117  "keyField"
118  },
119 
120  /* search fields */
121  {
122  "city",
123  "state",
124  "zip",
125  "phone",
126  "buyer",
127  "buyerPhone",
128  "email",
129  "contact",
130  "contactPhone"
131  },
132 
133  /* column defs */
134  {
135 // { "id", "", 50, Wt::AlignmentFlag::Left, "", nullptr },
136 // { "isActive", "", 75, Wt::AlignmentFlag::Left, "", nullptr },
137 
138  { "custType", "type", 50, Wt::AlignmentFlag::Left, "", nullptr },
139  { "keyField", "code", 100, Wt::AlignmentFlag::Left, "", nullptr },
140  { "cfyField", "Name", 300, Wt::AlignmentFlag::Left, "", nullptr },
141  { "addr", "Address", 150, Wt::AlignmentFlag::Left, "", nullptr },
142  { "city", "", 100, Wt::AlignmentFlag::Left, "", nullptr },
143  { "state", "", 100, Wt::AlignmentFlag::Left, "", nullptr },
144  { "zip", "", 100, Wt::AlignmentFlag::Left, "", nullptr },
145  { "contact", "", 100, Wt::AlignmentFlag::Left, "", nullptr },
146  { "contactPhone", "", 100, Wt::AlignmentFlag::Left, "", nullptr }
147 
148  },
149 
150  /* column names */
151  {
152  "id",
153  "keyField",
154  "cfyField",
155  "phone"
156  }
157  };
158 
159  layout-> addWidget( std::make_unique< Wtx::Dbo::TableViewManager< Wtx::Crm::Company::Item, CompanyDetail > >( viewDef, session() ) );
160 
161  }
162 
163 #ifdef NEVER
164  auto vlw = std::make_unique<Wt::WVBoxLayout>();
165 
166  {
168  {
169  /* title */ "Invoices for Account",
170  /* tip */ "",
171  /* headerCount */ 0,
172  /* selectionMode */ Wt::SelectionMode::Single,
173  /* columnResizeEnabled */ true,
174  /* alternatingRowColors */ true,
175  /* sql */ "",
176  /* filter */ "",
177  /* doubleClick */ 0,
178  /* showHeader */ true,
179  /* showFooter */ true,
180  /* allowFilter */ false,
181  /* allowAdd */ false,
182  /* allowChange */ false,
183  /* allowDelete */ false,
184  /* allowExport */ true,
185  /* allowSearch */ true,
186  /* itemDelegate */ nullptr,
187 
188 
189  /* sortFields */
190  {
191  "id DESC"
192  },
193 
194  /* search fields */
195  {
196  },
197 
198  /* column defs */
199  {
200  { "id", "", 50, Wt::AlignmentFlag::Left, "", nullptr },
201  { "keyField", "", 350, Wt::AlignmentFlag::Left, "", nullptr }
202  },
203 
204  /* column names */
205  {
206  "id",
207  "version",
208  "versionSync",
209  "isActive",
210  "isVisible",
211  "isDeleted",
212  "keyField",
213  "cfyField",
214  "varField",
215  "uidField",
216  "pMode",
217  "createdOn",
218  "changedOn",
219  "pUser",
220  "pGroup",
221  "sessionLock",
222  "datePosted",
223  "summary",
224  "thumbnail",
225  "body"
226  }
227  };
228 
229  vlw-> addWidget( std::make_unique< Wtx::Dbo::TableViewManager< Wtx::Fms::Invoice::Item, InvoiceDetail > >( viewDef, session() ) );
230 
231  }
232 
233  {
235  {
236  /* title */ "Activity for Account",
237  /* tip */ "",
238  /* headerCount */ 0,
239  /* selectionMode */ Wt::SelectionMode::Single,
240  /* columnResizeEnabled */ true,
241  /* alternatingRowColors */ true,
242  /* sql */ "",
243  /* filter */ "",
244  /* doubleClick */ 0,
245  /* showHeader */ true,
246  /* showFooter */ true,
247  /* allowFilter */ false,
248  /* allowAdd */ false,
249  /* allowChange */ false,
250  /* allowDelete */ false,
251  /* allowExport */ true,
252  /* allowSearch */ true,
253  /* itemDelegate */ nullptr,
254 
255 
256  /* sortFields */
257  {
258  "id DESC"
259  },
260 
261  /* search fields */
262  {
263  },
264 
265  /* column defs */
266  {
267  { "id", "", 50, Wt::AlignmentFlag::Left, "", nullptr },
268  { "keyField", "", 350, Wt::AlignmentFlag::Left, "", nullptr }
269  },
270 
271  /* column names */
272  {
273  "id",
274  "version",
275  "versionSync",
276  "isActive",
277  "isVisible",
278  "isDeleted",
279  "keyField",
280  "cfyField",
281  "varField",
282  "uidField",
283  "pMode",
284  "createdOn",
285  "changedOn",
286  "pUser",
287  "pGroup",
288  "sessionLock",
289  "datePosted",
290  "summary",
291  "thumbnail",
292  "body"
293  }
294  };
295 
296  vlw-> addWidget( std::make_unique< Wtx::Dbo::TableViewManager< Wtx::Fms::Activity::Item, ActivityDetail > >( viewDef, session() ) );
297  }
298 
299  {
301  {
302  /* title */ "Transactions for Activity",
303  /* tip */ "",
304  /* headerCount */ 0,
305  /* selectionMode */ Wt::SelectionMode::Single,
306  /* columnResizeEnabled */ true,
307  /* alternatingRowColors */ true,
308  /* sql */ "",
309  /* filter */ "",
310  /* doubleClick */ 0,
311  /* showHeader */ true,
312  /* showFooter */ true,
313  /* allowFilter */ false,
314  /* allowAdd */ false,
315  /* allowChange */ false,
316  /* allowDelete */ false,
317  /* allowExport */ true,
318  /* allowSearch */ true,
319  /* itemDelegate */ nullptr,
320 
321 
322  /* sortFields */
323  {
324  "id DESC"
325  },
326 
327  /* search fields */
328  {
329  },
330 
331  /* column defs */
332  {
333  { "id", "", 50, Wt::AlignmentFlag::Left, "", nullptr },
334  { "keyField", "", 350, Wt::AlignmentFlag::Left, "", nullptr }
335  },
336 
337  /* column names */
338  {
339  "id",
340  "version",
341  "versionSync",
342  "isActive",
343  "isVisible",
344  "isDeleted",
345  "keyField",
346  "cfyField",
347  "varField",
348  "uidField",
349  "pMode",
350  "createdOn",
351  "changedOn",
352  "pUser",
353  "pGroup",
354  "sessionLock",
355  "datePosted",
356  "summary",
357  "thumbnail",
358  "body"
359  }
360  };
361 
362  vlw-> addWidget( std::make_unique< Wtx::Dbo::TableViewManager< Wtx::Fms::Transaction::Item, TransactionDetail > >( viewDef, session() ) );
363  }
364 
365  vlw-> setResizable( 0 );
366  vlw-> setResizable( 1 );
367 
368  layout-> addLayout( std::move(vlw) );
369  layout-> setResizable( 0 );
370 #endif
371 
372  setLayout( std::move(layout) );
373 
374 } // endCompanyDesktop::CompanyDesktop( Wtx::Dbo::Session * s )
375 
376 
377 
378 Wtx::Crm::Company::ManagerWidget::ManagerWidget( Wtx::Dbo::Session * s )
379 : Wt::WContainerWidget(),
380  m_session(s)
381 {
382 
383  auto lw_u = std::make_unique<Wt::WHBoxLayout>();
384  auto lw = lw_u.get();
385  setLayout( std::move(lw_u) );
386 
387  lw-> addWidget( std::make_unique< CompanyDesktop >( s ) );
388 
389 } // endWarehouse::Customer::ManagerWidget::ManagerWidget( Wtx::Dbo::Session * s )
390 
391 
Table View Definition.
Definition: TableViewDef.h:171