From 4dfa6ec279e459374c321f73e4ee571e2d22af7c Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Thu, 24 Jan 2013 21:19:07 +0100 Subject: [PATCH] Fixed date picker on new entry fields. --- src/html/index.html | 23 ++++++++++++++++++++--- src/html/js/entries.js | 12 +++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/html/index.html b/src/html/index.html index 016a7de..d1a0140 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -148,7 +148,24 @@ - + + + + diff --git a/src/html/js/entries.js b/src/html/js/entries.js index e6022f5..5510ff0 100644 --- a/src/html/js/entries.js +++ b/src/html/js/entries.js @@ -214,6 +214,16 @@ var ListViewModel = function() { var entries = [self.newEntry()].concat(ko.utils.arrayMap($.parseJSON(data), ko.mapping.fromJS)); self.entries(entries); + + // Initialize date picker for value date column. + $("#new_value_date").datepicker().on('changeDate', function(ev){ + self.newEntry().value_date(ev.date.format(ev.currentTarget.dataset.dateFormat)); + }); + + // Initialize date picker for operation date column. + $("#new_operation_date").datepicker().on('changeDate', function(ev){ + self.newEntry().operation_date(ev.date.format(ev.currentTarget.dataset.dateFormat)); + }); }); } else { // If no month, just remove all entries. @@ -293,7 +303,7 @@ var ListViewModel = function() { // Function to select template in function of selected item. self.templateToUse = function (item) { - return self.selectedItem() === item || self.newEntry() === item ? 'editTmpl' : 'itemsTmpl'; + return self.newEntry() === item ? 'newTmpl' : self.selectedItem() === item ? 'editTmpl' : 'itemsTmpl'; }; // Function to edit an item