Canned responses should be grouped and sorted (Bug 626489)
This commit is contained in:
Родитель
2bc499045d
Коммит
af882dc09b
|
@ -1,4 +1,5 @@
|
|||
from datetime import timedelta
|
||||
import re
|
||||
|
||||
from django import forms
|
||||
from django.forms import widgets
|
||||
|
@ -209,8 +210,26 @@ class ReviewAddonForm(happyforms.Form):
|
|||
super(ReviewAddonForm, self).__init__(*args, **kw)
|
||||
self.fields['addon_files'].queryset = self.helper.all_files
|
||||
|
||||
self.fields['canned_response'].choices = ([(c.response, c.name)
|
||||
for c in CannedResponse.objects.all()])
|
||||
# We're starting with an empty one, which will be hidden via CSS.
|
||||
canned_choices = [['', [('', _('Choose a canned response...'))]]]
|
||||
|
||||
responses = CannedResponse.objects.all()
|
||||
|
||||
# Loop through the actions (prelim, public, etc).
|
||||
for k, action in self.helper.actions.iteritems():
|
||||
action_choices = [[c.response, c.name] for c in responses
|
||||
if c.sort_group and k in c.sort_group.split(',')]
|
||||
|
||||
# Add the group of responses to the canned_choices array.
|
||||
if action_choices:
|
||||
canned_choices.append([action['label'], action_choices])
|
||||
|
||||
# Now, add everything not in a group.
|
||||
for r in responses:
|
||||
if not r.sort_group:
|
||||
canned_choices.append([r.response, r.name])
|
||||
|
||||
self.fields['canned_response'].choices = canned_choices
|
||||
self.fields['action'].choices = [(k, v['label']) for k, v
|
||||
in self.helper.actions.items()]
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ class CannedResponse(amo.models.ModelBase):
|
|||
|
||||
name = TranslatedField()
|
||||
response = TranslatedField()
|
||||
sort_group = models.CharField(max_length=255)
|
||||
|
||||
class Meta:
|
||||
db_table = 'cannedresponses'
|
||||
|
|
|
@ -530,6 +530,10 @@ tr.comments {
|
|||
text-align: right;
|
||||
}
|
||||
|
||||
.review-actions-canned #id_canned_response optgroup[label=""] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.review-actions-canned select {
|
||||
padding: 0;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ $(function() {
|
|||
}
|
||||
|
||||
if($('#review-actions').length > 0) {
|
||||
var groups = $('#id_canned_response').find('optgroup');
|
||||
function showForm(element, pageload) {
|
||||
var $element = $(element),
|
||||
value = $element.find('input').val(),
|
||||
|
@ -50,10 +51,16 @@ $(function() {
|
|||
|
||||
$data_toggle.hide();
|
||||
$data_toggle.filter('[data-value*="' + value + '"]').show();
|
||||
|
||||
/* Fade out canned responses */
|
||||
var label = $element.text().trim();
|
||||
groups.css('color', '#AAA');
|
||||
groups.filter("[label='"+label+"']").css('color', '#444');
|
||||
}
|
||||
|
||||
$('#review-actions .action_nav ul li').click(function(){ showForm(this); });
|
||||
|
||||
/* Canned Response stuff */
|
||||
$('.review-actions-canned select').change(function() {
|
||||
$('#id_comments').val($(this).val());
|
||||
});
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
ALTER TABLE cannedresponses ADD COLUMN `sort_group` varchar(255) default NULL;
|
||||
|
||||
UPDATE cannedresponses SET sort_group=CONCAT_WS(',', sort_group, 'public') WHERE id IN (29, 33, 36, 34);
|
||||
UPDATE cannedresponses SET sort_group=CONCAT_WS(',', sort_group, 'prelim') WHERE id IN (30, 31, 47, 37, 39, 44, 45, 36, 42, 46, 48, 34);
|
||||
UPDATE cannedresponses SET sort_group=CONCAT_WS(',', sort_group, 'reject') WHERE id IN (32, 35, 43, 41, 37, 40, 39, 44, 45, 36, 42, 46, 34);
|
||||
UPDATE cannedresponses SET sort_group=CONCAT_WS(',', sort_group, 'info') WHERE id IN (38);
|
||||
|
Загрузка…
Ссылка в новой задаче