@@ -42,8 +42,9 @@ type DocActionID int64
4242//
4343// N.B. All document actions must be defined as constant strings.
4444type DocAction struct {
45- ID DocActionID `json:"ID"` // Unique identifier of this action
46- Name string `json:"Name"` // Globally-unique name of this action
45+ ID DocActionID `json:"ID"` // Unique identifier of this action
46+ Name string `json:"Name"` // Globally-unique name of this action
47+ Reconfirm bool `json:"Reconfirm"` // Should the user be prompted for a reconfirmation of this action?
4748}
4849
4950// Unexported type, only for convenience methods.
@@ -54,7 +55,7 @@ type _DocActions struct{}
5455var DocActions _DocActions
5556
5657// New creates and registers a new document action in the system.
57- func (_DocActions ) New (otx * sql.Tx , name string ) (DocActionID , error ) {
58+ func (_DocActions ) New (otx * sql.Tx , name string , reconfirm bool ) (DocActionID , error ) {
5859name = strings .TrimSpace (name )
5960if name == "" {
6061return 0 , errors .New ("document action cannot be empty" )
@@ -71,7 +72,13 @@ func (_DocActions) New(otx *sql.Tx, name string) (DocActionID, error) {
7172tx = otx
7273}
7374
74- res , err := tx .Exec ("INSERT INTO wf_docactions_master(name) VALUES(?)" , name )
75+ var res sql.Result
76+ var err error
77+ if reconfirm {
78+ res , err = tx .Exec ("INSERT INTO wf_docactions_master(name, reconfirm) VALUES(?, ?)" , name , 1 )
79+ } else {
80+ res , err = tx .Exec ("INSERT INTO wf_docactions_master(name, reconfirm) VALUES(?, ?)" , name , 0 )
81+ }
7582if err != nil {
7683return 0 , err
7784}
@@ -106,7 +113,7 @@ func (_DocActions) List(offset, limit int64) ([]*DocAction, error) {
106113}
107114
108115q := `
109- SELECT *
116+ SELECT id, name, reconfirm
110117FROM wf_docactions_master
111118ORDER BY id
112119LIMIT ? OFFSET ?
@@ -120,7 +127,7 @@ func (_DocActions) List(offset, limit int64) ([]*DocAction, error) {
120127ary := make ([]* DocAction , 0 , 10 )
121128for rows .Next () {
122129var elem DocAction
123- err = rows .Scan (& elem .ID , & elem .Name )
130+ err = rows .Scan (& elem .ID , & elem .Name , & elem . Reconfirm )
124131if err != nil {
125132return nil , err
126133}
@@ -140,8 +147,8 @@ func (_DocActions) Get(id DocActionID) (*DocAction, error) {
140147}
141148
142149var elem DocAction
143- row := db .QueryRow ("SELECT id, name FROM wf_docactions_master WHERE id = ?" , id )
144- err := row .Scan (& elem .ID , & elem .Name )
150+ row := db .QueryRow ("SELECT id, name, reconfirm FROM wf_docactions_master WHERE id = ?" , id )
151+ err := row .Scan (& elem .ID , & elem .Name , & elem . Reconfirm )
145152if err != nil {
146153return nil , err
147154}
@@ -158,8 +165,8 @@ func (_DocActions) GetByName(name string) (*DocAction, error) {
158165}
159166
160167var elem DocAction
161- row := db .QueryRow ("SELECT id, name FROM wf_docactions_master WHERE name = ?" , name )
162- err := row .Scan (& elem .ID , & elem .Name )
168+ row := db .QueryRow ("SELECT id, name, reconfirm FROM wf_docactions_master WHERE name = ?" , name )
169+ err := row .Scan (& elem .ID , & elem .Name , & elem . Reconfirm )
163170if err != nil {
164171return nil , err
165172}
0 commit comments