Wapp

Check-in [43323e55a9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add an edit function to the shopping list application.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:43323e55a962200a60001bceaedfc5b893ff9b19aaaedffd3eff96ad839fd076
User & Date: drh 2018-02-10 20:21:12
Context
2018-02-14
01:52
In the formajax02.tcl example, use the encodeURIComponent() javascript function instead of escape() so that the "+" character is correctly escaped. Fix for ticket [a38160c72116b1ba04c] check-in: 9580d1fedb user: drh tags: trunk
2018-02-10
20:21
Add an edit function to the shopping list application. check-in: 43323e55a9 user: drh tags: trunk
2018-02-08
12:31
More improvements to test01.tcl. check-in: cea1360863 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to examples/shoplist.tcl.

125
126
127
128
129
130
131

132
133
134
135
136
137
138
...
148
149
150
151
152
153
154


























155
156
157
158
159
160
161
  db eval {SELECT delid FROM done ORDER BY delid DESC limit 1} {
    wapp-trim {
      <p><a class="button" href="%url($base/list?undel=$delid)">Undelete</a>
    }
  }
  wapp-trim {
    <p><a class="button" href="%url($base/list)">Refresh</a>

    <p><a class="button" href="%url($base/list?logout=1)">Logout</a>
  }
  shopping-list-footer
}

# This page shows recent purchases with an opportunity to re-add those
# purchases to the shopping list.  The idea is that to have easy access
................................................................................
    wapp-trim {
      <p>%html($x)
      <a class="button" href="%url($base/list?add=)%qp($x)">Add</a><br>
    }
  }
  shopping-list-footer
}



























# The /env page shows the CGI environment.  This is for testing only.
# There are no links to this page.
#
proc wapp-page-env {} {
  if {[shopping-list-header]} return
  wapp-trim {







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
  db eval {SELECT delid FROM done ORDER BY delid DESC limit 1} {
    wapp-trim {
      <p><a class="button" href="%url($base/list?undel=$delid)">Undelete</a>
    }
  }
  wapp-trim {
    <p><a class="button" href="%url($base/list)">Refresh</a>
    <p><a class="button" href="%url($base/edit)">Edit</a>
    <p><a class="button" href="%url($base/list?logout=1)">Logout</a>
  }
  shopping-list-footer
}

# This page shows recent purchases with an opportunity to re-add those
# purchases to the shopping list.  The idea is that to have easy access
................................................................................
    wapp-trim {
      <p>%html($x)
      <a class="button" href="%url($base/list?add=)%qp($x)">Add</a><br>
    }
  }
  shopping-list-footer
}

# provide forms to edit all current entries.
#
proc wapp-page-edit {} {
  if {[shopping-list-header]} return
  set id [wapp-param id]
  set x [wapp-param x]
  if {[string is int -strict $id] && $x!=""} {
    db eval {
      UPDATE shoplist SET x=$x WHERE id=$id;
    }
    wapp-redirect list
    shopping-list-footer
    return
  }
  db eval {SELECT id, x FROM shoplist ORDER BY x} {
    wapp-trim {
      <p><form method="POST">
      <input type="hidden" name="id" value="%html($id)">
      <input type="text" width="20" name="x" value="%html($x)">&nbsp;&nbsp;
      &nbsp;<input type="submit" value="Change"></form></p>
    }
  }
  wapp-subst {<p><a class="button" href="list">Cancel</a>\n}
  shopping-list-footer
}

# The /env page shows the CGI environment.  This is for testing only.
# There are no links to this page.
#
proc wapp-page-env {} {
  if {[shopping-list-header]} return
  wapp-trim {