diff options
author | Sebastian Reichel <sre@ring0.de> | 2015-02-16 00:28:02 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2015-02-16 00:28:02 +0100 |
commit | ed197e2a5d7ac73ef21d1c8c1db88fb9ddb5f8ca (patch) | |
tree | 893bd75cde8e5a9cee071d483612249d8b079d5b /templates | |
parent | 21d2375adf68c62feb19f7d5b93adf94337fe82c (diff) | |
download | serial-barcode-scanner-ed197e2a5d7ac73ef21d1c8c1db88fb9ddb5f8ca.tar.bz2 |
web: support setting product deprecation state
Diffstat (limited to 'templates')
-rw-r--r-- | templates/products/entry.html | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/templates/products/entry.html b/templates/products/entry.html index a7d0d2f..80c1535 100644 --- a/templates/products/entry.html +++ b/templates/products/entry.html @@ -4,6 +4,7 @@ <th>EAN</th><td>{{{EAN}}}</td></tr> <th>Name</th><td>{{{NAME}}}</td></tr> <th>Amount</th><td>{{{AMOUNT}}}</td></tr> + <th>State</th><td><button id="statebutton" type="button" class="btn {{{BTNSTATE}}}" {{{ISADMIN2}}}>{{{STATE}}}</button></td></tr> </table> </p></p> @@ -38,3 +39,25 @@ <button type="submit" class="btn btn-primary"><i class="icon-plus"></i></button> </form> </div> + +<script> +$('#statebutton').on('click', function (e) { + var req = $.getJSON( + "/products/{{{EAN}}}/togglestate", + function( data ) { + if(data["state"] == "deprecated") { + $('#statebutton').html("Deprecated") + $('#statebutton').addClass("btn-danger") + $('#statebutton').removeClass("btn-success") + } else if(data["state"] == "active") { + $('#statebutton').html("Active") + $('#statebutton').addClass("btn-success") + $('#statebutton').removeClass("btn-danger") + } else { + console.error("unknown state") + console.info(data) + } + } + ); +}); +</script> |