From 667a7a4285d4e97ed5242e60df909f3ecdd35d59 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Mon, 11 Jan 2016 21:42:45 +0100 Subject: Started to include const expense groups --- static/js/kosten.js | 20 +++++++++++++++++++- static/js/kosten.ls | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'static') diff --git a/static/js/kosten.js b/static/js/kosten.js index 7d6582c..b1ce683 100644 --- a/static/js/kosten.js +++ b/static/js/kosten.js @@ -1,6 +1,6 @@ // Generated by LiveScript 1.4.0 (function(){ - var jq, setLang, extendDate, addJS, showJS, statJS, catsJS, out$ = typeof exports != 'undefined' && exports || this; + var jq, setLang, editConstsJS, extendDate, addJS, showJS, statJS, catsJS, out$ = typeof exports != 'undefined' && exports || this; jQuery.fn.extend({ copy: function(){ return this.clone().removeAttr('id class'); @@ -59,6 +59,24 @@ $('form.search').hide(); }); }); + out$.editConstJS = editConstJS = jq(function(){ + var group, category; + group = $('select#group'); + category = $('select#category'); + group.change(function(){ + var val, x$; + val = group.find('option:selected').val(); + if (category_data[val] === void 8) { + category.prop('disabled', false); + } else { + x$ = category; + x$.find('option:selected').prop('selected', false); + x$.find("option[value=" + category_data[val] + "]").prop('selected', true); + x$.prop('disabled', true); + } + }); + group.change(); + }); out$.addJS = addJS = jq(function(){ var x$; x$ = $('input[name=date]'); diff --git a/static/js/kosten.ls b/static/js/kosten.ls index ea433a4..f9876f8 100644 --- a/static/js/kosten.ls +++ b/static/js/kosten.ls @@ -58,6 +58,24 @@ $ !-> $ \input.search .focusout !-> $ \form.search .hide! +# Consts +export editConstJS = jq !-> + group = $ \select#group + category = $ \select#category + + group .change !-> + val = group .find \option:selected .val! + if category_data[val] == void # no group selected + category .prop \disabled false + else + category + ..find \option:selected .prop \selected false + ..find "option[value=#{category_data[val]}]" .prop \selected true + ..prop \disabled true + + # initial + group .change! + # Add export addJS = jq !-> $ 'input[name=date]' -- cgit v1.2.3-54-g00ecf