You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/03/22 23:54:34 UTC
[07/21] git commit: [#4299] ticket:281 Select current value by default
[#4299] ticket:281 Select current value by default
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/590ce54f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/590ce54f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/590ce54f
Branch: refs/heads/master
Commit: 590ce54ffe58a5fcd0a76580479c476674ac0b47
Parents: 0f9a52e
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 4 12:11:03 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Fri Mar 22 21:55:16 2013 +0000
----------------------------------------------------------------------
Allura/allura/lib/widgets/form_fields.py | 9 ++++-----
Allura/allura/lib/widgets/resources/js/combobox.js | 12 ++++++++----
ForgeTracker/forgetracker/widgets/ticket_form.py | 8 ++++++++
3 files changed, 20 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/590ce54f/Allura/allura/lib/widgets/form_fields.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/form_fields.py b/Allura/allura/lib/widgets/form_fields.py
index f6ee98b..25c2e32 100644
--- a/Allura/allura/lib/widgets/form_fields.py
+++ b/Allura/allura/lib/widgets/form_fields.py
@@ -97,16 +97,15 @@ class ProjectUserSelect(ew.InputField):
class ProjectUserCombo(ew.SingleSelectField):
template = 'jinja:allura:templates/widgets/project_user_combo.html'
+ # No options for widget initially.
+ # It'll be populated later via ajax call.
+ options = []
+
def to_python(self, value, state):
# Skipping validation, 'cause widget has no values initially.
# All values loaded later via ajax.
return value
- def options(self):
- # No options for widget initially.
- # It'll be populated later via ajax call.
- return []
-
def resources(self):
for r in super(ProjectUserCombo, self).resources():
yield r
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/590ce54f/Allura/allura/lib/widgets/resources/js/combobox.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/combobox.js b/Allura/allura/lib/widgets/resources/js/combobox.js
index b441f7b..1a59e35 100644
--- a/Allura/allura/lib/widgets/resources/js/combobox.js
+++ b/Allura/allura/lib/widgets/resources/js/combobox.js
@@ -23,12 +23,16 @@
for (var i = 0; i < data.options.length; i++) {
var label = data.options[i].label,
value = data.options[i].value;
- $('<option>' + label + '</option>')
- .val(value)
- .appendTo(select);
+ var option = $('<option>' + label + '</option>').val(value);
+ if (selected.val() === value) {
+ option.attr('selected', 'selected'); // select initial value, if any
+ }
+ option.appendTo(select);
}
loaded = true;
- input.autocomplete('search', input.val()); // trigger search to re-render options
+ if (wasOpen) {
+ input.autocomplete('search', input.val()); // trigger search to re-render options
+ }
}
// Load options list with ajax and populate underlying select with loaded data
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/590ce54f/ForgeTracker/forgetracker/widgets/ticket_form.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/widgets/ticket_form.py b/ForgeTracker/forgetracker/widgets/ticket_form.py
index 79b5513..de44f8a 100644
--- a/ForgeTracker/forgetracker/widgets/ticket_form.py
+++ b/ForgeTracker/forgetracker/widgets/ticket_form.py
@@ -38,6 +38,14 @@ class GenericTicketForm(ew.SimpleForm):
if milestone.complete and (milestone.py_value != milestone_value):
del field.options[field.options.index(milestone)]
ctx = self.context_for(field)
+ elif idx == 'assigned_to':
+ user = ctx.get('value')
+ if user:
+ field.options = [
+ ew.Option(
+ py_value=user.username,
+ label='%s (%s)' % (user.display_name, user.username))
+ ]
display = field.display(**ctx)
if ctx['errors'] and field.show_errors and not ignore_errors: