summaryrefslogtreecommitdiffstats
path: root/templates/products/entry.html
diff options
context:
space:
mode:
Diffstat (limited to 'templates/products/entry.html')
-rw-r--r--templates/products/entry.html23
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>