Wtx ~ Wt Extension Library
WtxLib
DetailForm.h
1 
2 #ifndef __WTX_DBO_DETAILFORM_H___
3 #define __WTX_DBO_DETAILFORM_H___
4 
5 #include <Wtx/MessageBox.h>
6 #include <Wtx/PopupMessage.h>
7 #include <Wtx/Dbo/TemplateFormView.h>
8 
9 namespace Wtx {
10  namespace Dbo {
11 
12 template <class C>
15 {
16  public:
17 
18  DetailForm( const std::string & tn )
20  (
21  Wt::WString::tr(tn)
22  ),
23  m_templateName(tn)
24  {
25  }
26 
27  DetailForm( const std::string & tn, Wt::Dbo::ptr<C> & item )
29  (
30  Wt::WString::tr(tn),
31  std::make_unique< Wtx::Dbo::FormModel<C> >( item.id(), item.session() )
32  ),
33  m_templateName(tn)
34  {
35 
36  /*
37  ** check the item on disk to make sure we've got the
38  ** latest copy of the item, and if not, reload it.
39  **
40  */
42  {
44  }
45 
46 // Wtx::Dbo::TemplateFormView<C>:: template bindNew<Wt::WPushButton>( "submit", "submit" );
47 // Wtx::Dbo::TemplateFormView<C>:: template bindNew<Wt::WPushButton>( "close", "close" );
48 // Wtx::Dbo::TemplateFormView<C>:: template bindNew<Wt::WPushButton>( "print", "print" );
49 
50  this-> updateView();
52 
53  } // endDetailForm( const std::string & tn, Wt::Dbo::ptr<C> & item )
54 
55  const std::string & templateName() const
56  {
57  return m_templateName;
58  }
59 
65  virtual bool allowChange() const
66  {
67  return false;
68  }
69 
75  virtual bool allowDelete() const
76  {
77  return false;
78  }
79 
85  virtual bool allowPrint() const
86  {
87  return false;
88  }
89 
95  virtual bool allowUnlock() const
96  {
97  return false;
98  }
99 
109  virtual bool beforeUpdate()
110  {
111  return true;
112  }
113 
121  virtual bool afterUpdate()
122  {
123  return true;
124  }
125 
133  virtual bool beforeAccept()
134  {
135  return true;
136  }
137 
145  virtual bool afterAccept()
146  {
147  return true;
148  }
149 
159  virtual bool refreshTableOnSave()
160  {
161  return true;
162  }
163 
169  virtual bool onDelete()
170  {
171  return true;
172  }
173 
179  virtual bool onPrint()
180  {
181  return true;
182  }
183 
189  virtual bool onUnlock()
190  {
191  return true;
192  }
193 
194  virtual std::string additional()
195  {
196  return "";
197  }
198 
199  virtual bool onAdditional( const std::string & buttonText )
200  {
201  return true;
202  }
203 
204  virtual void popupMessage( const std::string & message )
205  {
206  Wt::WObject::addChild( std::make_unique<Wtx::PopupMessage>(message) );
207  }
208 
209  virtual Wtx::MessageBox * messageBox( const std::string & message )
210  {
211  return Wt::WObject::addChild( std::make_unique<Wtx::MessageBox>(message) );
212  }
213 
214  void save()
215  {
216  m_doSave.emit();
217  }
218 
219  void close()
220  {
221  m_doClose.emit();
222  }
223 
224  void deleteItem( bool noask = true )
225  {
226  m_doDeleteItem.emit( noask );
227  }
228 
229  void refresh()
230  {
231  m_doRefresh.emit();
232  }
233 
234  Wt::Signal<> & doSave() { return m_doSave ; }
235  Wt::Signal<> & doClose() { return m_doClose ; }
236  Wt::Signal< bool > & doDeleteItem() { return m_doDeleteItem ; }
237  Wt::Signal<> & doRefresh() { return m_doRefresh ; }
238 
239  protected:
240 
241  Wt::Signal<> m_doSave ;
242  Wt::Signal<> m_doClose ;
243  Wt::Signal< bool > m_doDeleteItem ;
244  Wt::Signal<> m_doRefresh ;
245 
246  private:
247 
248  std::string m_templateName;
249 
250 }; // endclass DetailForm
251 
252 
253  } // endnamespace Dbo
254 } // endnamespace Wtx
255 
256 #endif // __WTX_DBO_DETAILFORM_H___
virtual bool beforeAccept()
before accept stub
Definition: DetailForm.h:133
virtual bool onDelete()
when the delete button is pushed
Definition: DetailForm.h:169
virtual bool afterAccept()
after accept stub
Definition: DetailForm.h:145
virtual bool onPrint()
when the print button is pushed
Definition: DetailForm.h:179
virtual bool beforeUpdate()
before update stub
Definition: DetailForm.h:109
virtual bool allowUnlock() const
Allow Unlock.
Definition: DetailForm.h:95
Wtx::Dbo::FormModel< C > * formModel() const
Internal Form Model.
virtual bool allowPrint() const
Allow Print.
Definition: DetailForm.h:85
virtual bool onUnlock()
when the unlock button is pushed
Definition: DetailForm.h:189
virtual bool refreshTableOnSave()
refresh underlying table on save
Definition: DetailForm.h:159
virtual bool allowChange() const
Allow Change.
Definition: DetailForm.h:65
witty extension library
Definition: Activity.h:51
virtual bool afterUpdate()
after update stub
Definition: DetailForm.h:121
virtual bool allowDelete() const
Allow Delete.
Definition: DetailForm.h:75