diff --git a/tailbone/static/js/tailbone.mobile.js b/tailbone/static/js/tailbone.mobile.js
index 728185d7..0bd1f824 100644
--- a/tailbone/static/js/tailbone.mobile.js
+++ b/tailbone/static/js/tailbone.mobile.js
@@ -37,6 +37,17 @@ $(document).on('pagecreate', function() {
});
+// submit "quick row" form upon autocomplete selection
+$(document).on('autocompleteitemselected', function(event, uuid) {
+ var field = $(event.target);
+ if (field.hasClass('quick-row')) {
+ var form = field.parents('form:first');
+ form.find('[name="quick_row_entry"]').val(uuid);
+ form.submit();
+ }
+});
+
+
/**
* Automatically set focus to certain fields, on various pages
* TODO: this should accept selector params instead of hard-coding..?
diff --git a/tailbone/templates/mobile/master/view.mako b/tailbone/templates/mobile/master/view.mako
index ff29b78d..f9aac0f8 100644
--- a/tailbone/templates/mobile/master/view.mako
+++ b/tailbone/templates/mobile/master/view.mako
@@ -20,12 +20,21 @@ ${form.render()|n}
% if master.mobile_rows_creatable_via_browse:
${h.link_to(add_item_title, url('mobile.{}.create_row'.format(route_prefix), uuid=instance.uuid), class_='ui-btn ui-corner-all')}
% endif
- % if master.mobile_rows_quickable:
- ${h.form(url('mobile.{}.quick_row'.format(route_prefix), uuid=instance.uuid))}
- ${h.csrf_token(request)}
+ % endif
+ % if master.mobile_rows_quickable and master.rows_quickable_for(instance):
+ ${h.form(url('mobile.{}.quick_row'.format(route_prefix), uuid=instance.uuid))}
+ ${h.csrf_token(request)}
+ % if quick_row_autocomplete:
+
+ ${h.hidden('quick_row_entry')}
+ ${h.text('quick_row_autocomplete_text', placeholder=quick_row_entry_placeholder, autocomplete='off', data_type='search')}
+
+
+
+ % else:
${h.text('quick_row_entry', placeholder=quick_row_entry_placeholder, autocomplete='off', **{'data-type': 'search', 'data-url': url('mobile.{}.quick_row'.format(route_prefix), uuid=instance.uuid)})}
- ${h.end_form()}
% endif
+ ${h.end_form()}
% endif
diff --git a/tailbone/views/batch/core.py b/tailbone/views/batch/core.py
index d49d3fe7..0dfa1124 100644
--- a/tailbone/views/batch/core.py
+++ b/tailbone/views/batch/core.py
@@ -152,9 +152,9 @@ class BatchMasterView(MasterView):
if kwargs['mobile']:
if self.mobile_rows_creatable:
kwargs.setdefault('add_item_title', "Add Item")
- if self.mobile_rows_quickable:
- kwargs.setdefault('quick_row_entry_placeholder', "Enter {}".format(
- self.rattail_config.product_key_title()))
+ if self.mobile_rows_quickable:
+ kwargs.setdefault('quick_row_entry_placeholder', "Enter {}".format(
+ self.rattail_config.product_key_title()))
if kwargs['execute_enabled']:
url = self.get_action_url('execute', batch)
kwargs['execute_form'] = self.make_execute_form(batch, action_url=url)
@@ -490,6 +490,18 @@ class BatchMasterView(MasterView):
return False
return True
+ def rows_quickable_for(self, batch):
+ """
+ Must return boolean indicating whether the "quick row" feature should
+ be allowed for the given batch. By default, returns ``False`` if batch
+ has already been executed or marked complete, and ``True`` otherwise.
+ """
+ if batch.executed:
+ return False
+ if batch.complete:
+ return False
+ return True
+
def configure_row_grid(self, g):
super(BatchMasterView, self).configure_row_grid(g)
diff --git a/tailbone/views/master.py b/tailbone/views/master.py
index ce027447..e75b9409 100644
--- a/tailbone/views/master.py
+++ b/tailbone/views/master.py
@@ -1790,6 +1790,18 @@ class MasterView(View):
context['row_model_title_plural'] = self.get_row_model_title_plural()
context['row_action_url'] = self.get_row_action_url
+ if mobile:
+
+ if self.mobile_rows_creatable:
+ context['add_item_title'] = "Add Record"
+
+ if self.mobile_rows_quickable:
+ context['quick_row_entry_placeholder'] = "Enter search text"
+
+ # quick row does *not* use autocomplete by default
+ context['quick_row_autocomplete'] = False
+ context['quick_row_autocomplete_url'] = '#'
+
context.update(data)
context.update(self.template_kwargs(**context))
if hasattr(self, 'template_kwargs_{}'.format(template)):
@@ -2552,6 +2564,13 @@ class MasterView(View):
"""
return True
+ def rows_quickable_for(self, instance):
+ """
+ Must return boolean indicating whether the "quick row" feature should
+ be allowed for the given instance. Returns ``True`` by default.
+ """
+ return True
+
def row_editable(self, row):
"""
Returns boolean indicating whether or not the given row can be