File tree Expand file tree Collapse file tree
templates/patchwork/partials Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3535 } ) ( ) ;
3636} ) ;
3737
38+ // Submit form on shift+enter or ctrl+enter
39+ Selectize . define ( 'mod_enter_key_submit' , function ( options ) {
40+ var self = this ;
41+
42+ this . onKeyDown = ( function ( e ) {
43+ var original = self . onKeyDown ;
44+
45+ return function ( e ) {
46+ var wasOpened = this . isOpen ;
47+
48+ if ( e . keyCode === 13 && ( e . shiftKey || e . ctrlKey ) ) {
49+ self . trigger ( 'submit' ) ;
50+ return ;
51+ }
52+
53+ original . apply ( this , arguments ) ;
54+ } ;
55+ } ) ( ) ;
56+ } ) ;
57+
3858$ ( document ) . ready ( function ( ) {
3959 $ ( '#submitter_input' ) . selectize ( {
4060 plugins : [ 'enter_key_submit' ] ,
7696 } ) ;
7797 }
7898 } ) ;
99+
100+ $ ( '#labels_input' ) . selectize ( {
101+ plugins : [ 'mod_enter_key_submit' ] ,
102+ maxItems : null ,
103+ persist : false ,
104+ hideSelected : true ,
105+ // Search for options that begin with a minus sign
106+ respect_word_boundaries : false ,
107+ delimiter : ' ' ,
108+ options : [
109+ { % for label in project_labels % }
110+ {
111+ value : "{{ label.name }}" ,
112+ text : "{{ label.name }}" ,
113+ } ,
114+ { % endfor % }
115+ { % for label in project_labels % }
116+ {
117+ value : "-{{ label.name }}" ,
118+ text : "-{{ label.name }}" ,
119+ } ,
120+ { % endfor % }
121+ ] ,
122+ } ) ;
79123} ) ;
80124</ script >
81125
Original file line number Diff line number Diff line change 77
88from django .contrib import messages
99from django .shortcuts import get_object_or_404
10- from django .db .models import Prefetch
10+ from django .db .models import Prefetch , Q
1111
1212from patchwork .filters import Filters
1313from patchwork .forms import CreateBundleForm
@@ -189,10 +189,15 @@ def generic_list(
189189 if not filter_settings :
190190 filter_settings = []
191191
192+ project_labels = Label .objects .filter (
193+ Q (project = project ) | Q (project__isnull = True )
194+ ).all ()
195+
192196 filters = Filters (request )
193197 context = {
194198 'project' : project ,
195199 'projects' : Project .objects .all (),
200+ 'project_labels' : project_labels ,
196201 'filters' : filters ,
197202 }
198203
You can’t perform that action at this time.
0 commit comments