diff --git a/src/html/index.html b/src/html/index.html
index d1a0140..e1322fe 100644
--- a/src/html/index.html
+++ b/src/html/index.html
@@ -157,7 +157,7 @@
|
|
|
- |
+ |
@@ -174,7 +174,7 @@
| |
|
|
- |
+ |
diff --git a/src/html/js/entries.js b/src/html/js/entries.js
index 5510ff0..8ac27e0 100644
--- a/src/html/js/entries.js
+++ b/src/html/js/entries.js
@@ -151,6 +151,22 @@ var ListViewModel = function() {
});
};
+ self.categories = ko.computed(function() {
+ var unwrap = ko.utils.unwrapObservable;
+
+ var entries=unwrap(self.entries);
+
+ var categories = ko.observableArray([]);
+
+ $.each(entries, function(index, entry) {
+ if(entry.category() && entry.category() != '' && categories.indexOf(entry.category()) == -1) {
+ categories.push(entry.category());
+ }
+ });
+
+ return categories();
+ });
+
// Returns the data for the categories by summing values with same category
self.expenseCategoriesChart = ko.computed(function() {
var unwrap = ko.utils.unwrapObservable;
@@ -620,6 +636,24 @@ $(document).ajaxError(function(event, xhr, settings) {
message("error", xhr.statusText, xhr.responseText);
});
+// Bootstrap.Typeahead binding.
+// Use like so: data-bind="typeahead: { source: namespaces }"
+ko.bindingHandlers.typeahead = {
+ init: function(element, valueAccessor, allBindingsAccessor, viewModel) {
+ $(element).typeahead({
+ source: function() { return ko.utils.unwrapObservable(valueAccessor().source); },
+ onselect: function(value) { allBindingsAccessor().value(value); }
+ });
+ },
+
+ update: function(element, valueAccessor, allBindingsAccessor, viewModel) {
+ $(element).typeahead({
+ source: function() { ko.utils.unwrapObservable(valueAccessor().source); },
+ onselect: function(value) { allBindingsAccessor().value(value); }
+ });
+ }
+};
+
// Resize callback.
$(window).resize(function() {
if(window.chart) {
|