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 #include <Wt/WMessageBox.h>
15 
16 #include <Wtx/MessageBox.h>
17 #include <Wtx/PopupMessage.h>
18 #include <Wtx/Dbo/TableViewManager.h>
19 #include <Wtx/Dbo/TemplateFormView.h>
20 #include <Wtx/Dbo/LookupItemDelegate.h>
21 #include <Wtx/Dbo/DetailForm.h>
22 
23 #include <Wtx/Sys/Lookup/ItemDelegate.h>
24 #include <Wtx/Sys/Lookup/Lookup.h>
25 
26 #include "Person.h"
27 #include "ManagerWidget.h"
28 #include "Item.h"
29 
30 namespace {
31 
32 class BaseDesktop
33 : public Wt::WContainerWidget
34 {
35  public:
36 
38 
39  Wtx::Dbo::Session * session() const { return m_session; }
40 
41  private:
42 
43  Wtx::Dbo::Session * m_session = nullptr;
44 
45 }; // endclass BaseDesktop( Wtx::Dbo::Session * s )
46 
47 BaseDesktop::BaseDesktop( Wtx::Dbo::Session * s )
48 : Wt::WContainerWidget(),
49  m_session(s)
50 {
51 }
52 
53 } // endnamespace
54 
56 : public Wtx::Dbo::DetailForm< Wtx::Crm::Person::Item >
57 {
58 
59  public:
60 
61  PersonDetail( Wt::Dbo::ptr< Wtx::Crm::Person::Item > & item )
63  (
64  "crmPerson.detailForm",
65  item
66  )
67  {
68  std::cout << __FILE__ << ":" << __LINE__ << " Wtx::Dbo::DetailForm< Wtx::Crm::Person::Item >" << std::endl;
69 
70 
71 // updateView();
72 
73  } // endInboundDetail( Wt::Dbo::ptr< Mrp::Inbound::Item > & item )
74 
75 }; // endclass PersonDetail
76 
78 : public BaseDesktop
79 {
80  public:
81 
84 
85  void setFilter( const std::string & value );
86  void updateFooter( );
87 
88  void init( Wtx::TableViewDef::ViewDef & viewDef );
89 
90  void openDetail( Wt::Dbo::ptr<Wtx::Crm::Person::Item> & item );
91 
92  void setOpenDetail( bool value );
93 
95 };
96 
97 void Wtx::Crm::Person::Desktop::openDetail( Wt::Dbo::ptr<Wtx::Crm::Person::Item> & item )
98 {
99  m_view-> openDetail( item );
100 }
101 
102 void Wtx::Crm::Person::Desktop::setOpenDetail( bool value )
103 {
104  m_view-> m_openDetail = value;
105 }
106 
107 
108 
109 void Wtx::Crm::Person::Desktop::init( Wtx::TableViewDef::ViewDef & viewDef )
110 {
111  auto layout = std::make_unique< Wt::WVBoxLayout >();
112 
113  auto u_ = std::make_unique< Wtx::Dbo::TableViewManager< Wtx::Crm::Person::Item, PersonDetail > >( viewDef, session() );
114  m_view = u_.get();
115  layout-> addWidget( std::move( u_ ) );
116 
117  setLayout( std::move(layout) );
118 
119 }
120 
121 Wtx::Crm::Person::Desktop::Desktop( Wtx::TableViewDef::ViewDef & viewDef, Wtx::Dbo::Session * s )
122 : BaseDesktop( s )
123 {
124  init( viewDef );
125 }
126 
127 Wtx::Crm::Person::Desktop::Desktop( Wtx::Dbo::Session * s )
128 : BaseDesktop( s )
129 {
131  {
132  /* title */ "Person",
133  /* tip */ "",
134  /* headerCount */ 0,
135  /* selectionMode */ Wt::SelectionMode::Single,
136  /* columnResizeEnabled */ true,
137  /* alternatingRowColors */ true,
138  /* sql */ "",
139  /* filter */ "",
140  /* subFilter */ "",
141  /* idin */ {},
142  /* doubleClick */ 0,
143  /* showHeader */ true,
144  /* showFooter */ true,
145  /* showPrevNext */ false,
146  /* hideSearch */ false,
147  /* allowFilter */ false,
148  /* allowAdd */ true,
149  /* allowChange */ true,
150  /* allowDelete */ true,
151  /* allowExport */ true,
152  /* allowSearch */ true,
153  /* allowPrint */ false,
154  /* allowUnlock */ false,
155  /* additional */ "",
156  /* itemDelegate */ nullptr,
157 
158 
159  /* sortFields */
160  {
161  "\"keyField\", \"cfyField\""
162  },
163 
164  /* search fields */
165  {
166  "phone",
167  "cell",
168  "email",
169  "street1",
170  "street2",
171  "city",
172  "state",
173  "zip",
174 
175  },
176 
177  /* column defs */
178  {
179  { "keyField", "", 190, Wt::AlignmentFlag::Left, "", nullptr },
180  { "cfyField", "", 190, Wt::AlignmentFlag::Left, "", nullptr },
181  { "phone", "", 120, Wt::AlignmentFlag::Left, "", nullptr },
182  { "cell", "", 120, Wt::AlignmentFlag::Left, "", nullptr },
183  { "email", "", 170, Wt::AlignmentFlag::Left, "", nullptr },
184  { "street1", "", 170, Wt::AlignmentFlag::Left, "", nullptr },
185  { "street2", "", 170, Wt::AlignmentFlag::Left, "", nullptr },
186  { "city", "", 170, Wt::AlignmentFlag::Left, "", nullptr },
187  { "state", "", 170, Wt::AlignmentFlag::Left, "", nullptr },
188  { "zip", "", 170, Wt::AlignmentFlag::Left, "", nullptr },
189  },
190 
191  /* column names */
192  {
193  "id",
194  "keyField",
195  "cfyField",
196  }
197  };
198 
199  init( viewDef );
200 
201 } // endWtx::Crm::Person::Desktop::Desktop( Wtx::Dbo::Session * s )
202 
203 
204 Wtx::Crm::Person::ManagerWidget::ManagerWidget( Wtx::Dbo::Session * session )
205 : Wt::WCompositeWidget()
206 {
207  m_desktop = setImplementation( std::make_unique<Wtx::Crm::Person::Desktop>( session ) );
208 
209 } // endWarehouse::Order::ManagerWidget::ManagerWidget()
210 
211 
212 Wtx::Crm::Person::ManagerWidget::ManagerWidget( Wtx::TableViewDef::ViewDef & viewDef, Wtx::Dbo::Session * session )
213 : Wt::WCompositeWidget()
214 {
215  m_desktop = setImplementation( std::make_unique< Wtx::Crm::Person::Desktop >( viewDef, session ) );
216 
217 } // endWarehouse::Order::ManagerWidget::ManagerWidget()
218 
219 Wt::Signal< Wtx::Crm::Person::Item::Ptr > & Wtx::Crm::Person::ManagerWidget::clicked()
220 {
221  return m_desktop-> m_view-> itemClicked();
222 }
223 
224 Wt::Signal< Wtx::Crm::Person::Item::Ptr > & Wtx::Crm::Person::ManagerWidget::doubleClicked()
225 {
226  return m_desktop-> m_view-> doubleClicked();
227 }
228 
229 Wt::Signal< Wtx::Crm::Person::Item::Ptr > & Wtx::Crm::Person::ManagerWidget::addClicked()
230 {
231  return m_desktop-> m_view-> addClicked();
232 }
233 
234 Wt::Signal< std::string > & Wtx::Crm::Person::ManagerWidget::additionalClicked()
235 {
236  return m_desktop-> m_view-> additionalClicked();
237 }
238 
239 void Wtx::Crm::Person::ManagerWidget::setFilter( const std::string & value )
240 {
241  m_desktop-> m_view-> tableView()-> setFilter( value );
242 }
243 
244 void Wtx::Crm::Person::ManagerWidget::clearFilter()
245 {
246  m_desktop-> m_view-> tableView()-> setFilter( "true" );
247 }
248 
249 void Wtx::Crm::Person::ManagerWidget::openDetail( Wt::Dbo::ptr<Wtx::Crm::Person::Item> & item )
250 {
251  m_desktop-> openDetail( item );
252 }
253 
254 void Wtx::Crm::Person::ManagerWidget::setOpenDetail( bool value )
255 {
256  m_desktop-> setOpenDetail( value );
257 }
258 
259 Wtx::Dbo::TableView< Wtx::Crm::Person::Item > * Wtx::Crm::Person::ManagerWidget::tableView()
260 {
261  m_desktop-> m_view-> tableView();
262 }
263 
Table View Definition.
Definition: TableViewDef.h:171
Dbo Table View.
Definition: TableView.h:68