diff --git a/RIGS/templatetags/filters.py b/RIGS/templatetags/filters.py index 7efd42bb..658bd315 100644 --- a/RIGS/templatetags/filters.py +++ b/RIGS/templatetags/filters.py @@ -216,6 +216,8 @@ def button(type, url=None, pk=None, clazz="", icon=None, text="", id=None, style return {'submit': True, 'class': 'btn-info', 'icon': 'fa-search', 'text': 'Search', 'id': id, 'style': style} elif type == 'submit': return {'submit': True, 'class': 'btn-primary', 'icon': 'fa-save', 'text': 'Save', 'id': id, 'style': style} + elif type == 'today': + return {'today': True, 'id': id} return {'target': url, 'pk': pk, 'class': clazz, 'icon': icon, 'text': text, 'id': id, 'style': style} diff --git a/pipeline/source_assets/js/autocompleter.js b/pipeline/source_assets/js/autocompleter.js index e917b7f0..4672fe27 100644 --- a/pipeline/source_assets/js/autocompleter.js +++ b/pipeline/source_assets/js/autocompleter.js @@ -47,14 +47,16 @@ function initPicker(obj) { //log: 3, preprocessData: function (data) { var i, l = data.length, array = []; - array.push({ - text: clearSelectionLabel, - value: '', - data:{ - update_url: '', - subtext:'' - } - }); + if (!obj.data('noclear')) { + array.push({ + text: clearSelectionLabel, + value: '', + data:{ + update_url: '', + subtext:'' + } + }); + } if (l) { for(i = 0; i < l; i++){ @@ -71,11 +73,13 @@ function initPicker(obj) { return array; } }; - - obj.prepend($("") - .attr("value",'') - .text(clearSelectionLabel) - .data('update_url','')); //Add "clear selection" option + console.log(obj.data); + if (!obj.data('noclear')) { + obj.prepend($("") + .attr("value",'') + .text(clearSelectionLabel) + .data('update_url','')); //Add "clear selection" option + } obj.selectpicker().ajaxSelectPicker(options); //Initiaise selectPicker diff --git a/templates/partials/button.html b/templates/partials/button.html index 3a353365..c89e1516 100644 --- a/templates/partials/button.html +++ b/templates/partials/button.html @@ -4,6 +4,8 @@ {{ text }} {% elif copy %} +{% elif today %} + {% else %} {{ text }} {% endif %} diff --git a/training/templates/edit_training_record.html b/training/templates/edit_training_record.html index 5d7c8e6d..c8d9b051 100644 --- a/training/templates/edit_training_record.html +++ b/training/templates/edit_training_record.html @@ -43,7 +43,7 @@ {% render_field form.date|add_class:'form-control'|attr:'type="date"' value=training_date %} {% endwith %} - + {% button 'today' id='id_date' %}