Skip to content

Commit 8c7aed3

Browse files
Raxel Gutierrezstephenfin
Raxel Gutierrez
authored andcommitted
views: Style modification forms as an action bar
Add styling to the new patch list html code to make the change property and bundle action forms more usable. Before [1] and after [2] images for reference. [1] https://i.imgur.com/Pzelipp.png [2] https://i.imgur.com/UtNJXuf.png Signed-off-by: Raxel Gutierrez <[email protected]> Signed-off-by: Stephen Finucane <[email protected]> [stephenfin: Addressed merge conflicts, tweak CSS slightly]
1 parent 17726d7 commit 8c7aed3

File tree

2 files changed

+94
-21
lines changed

2 files changed

+94
-21
lines changed

htdocs/css/style.css

+60-13
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,6 @@ a.col-inactive:hover {
174174
div.filters {
175175
}
176176

177-
div.patch-forms {
178-
margin-top: 1em;
179-
}
180-
181177
/* list order manipulation */
182178

183179
table.patch-list tr.draghover {
@@ -201,7 +197,7 @@ input#reorder-change {
201197
.paginator {
202198
text-align: right;
203199
clear: both;
204-
margin: 8px 0 15px;
200+
margin: 16px 0;
205201
}
206202

207203
.paginator .prev-na,
@@ -433,13 +429,62 @@ table.bundlelist td
433429
padding-right: 2em;
434430
}
435431

432+
.patch-list-actions {
433+
width: 100%;
434+
display: inline-flex;
435+
flex-wrap: wrap;
436+
justify-content: space-between;
437+
}
438+
436439
/* forms that appear for a patch */
440+
.patch-forms {
441+
display: inline-flex;
442+
flex-wrap: wrap;
443+
margin: 16px 0;
444+
}
445+
437446
div.patch-form {
438-
border: thin solid #080808;
439-
padding-left: 0.6em;
440-
padding-right: 0.6em;
441-
float: left;
442-
margin: 0.5em 5em 0.5em 10px;
447+
display: flex;
448+
flex-wrap: wrap;
449+
align-items: center;
450+
}
451+
452+
select[class^=change-property-], .archive-patch-select, .add-bundle {
453+
padding: 4px;
454+
margin-right: 8px;
455+
box-sizing: border-box;
456+
border-radius: 4px;
457+
background-color: var(--light-color);
458+
}
459+
460+
#patch-form-archive {
461+
display: flex;
462+
align-items: center;
463+
margin-right: 4px;
464+
}
465+
466+
#patch-form-archive > label {
467+
margin: 0px;
468+
}
469+
470+
#patch-form-archive > select, #patch-form-archive > input {
471+
margin: 0px 4px 0px 4px;
472+
}
473+
474+
.patch-form-submit {
475+
font-weight: bold;
476+
padding: 4px;
477+
}
478+
479+
#patch-form-bundle, #add-to-bundle, #remove-bundle {
480+
margin-left: 16px;
481+
}
482+
483+
.create-bundle {
484+
padding: 4px;
485+
margin-right: 8px;
486+
box-sizing: border-box;
487+
border-radius: 4px;
443488
}
444489

445490
div.patch-form h3 {
@@ -458,15 +503,17 @@ div.patch-form ul {
458503
margin-top: 0em;
459504
}
460505

461-
/* forms */
462-
table.form {
506+
.create-bundle {
507+
padding: 4px;
508+
margin-right: 8px;
509+
box-sizing: border-box;
510+
border-radius: 4px;
463511
}
464512

465513
span.help_text {
466514
font-size: 80%;
467515
}
468516

469-
470517
table.form td {
471518
padding: 0.6em;
472519
vertical-align: top;

patchwork/forms.py

+34-8
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class BundleForm(forms.ModelForm):
6666
max_length=50,
6767
required=False,
6868
error_messages={'invalid': "Bundle names can't contain slashes"},
69+
widget=forms.TextInput(
70+
attrs={'class': 'create-bundle', 'placeholder': 'Bundle name'}
71+
),
6972
)
7073

7174
class Meta:
@@ -136,19 +139,29 @@ class PatchForm(forms.ModelForm):
136139
def __init__(self, instance=None, project=None, *args, **kwargs):
137140
super(PatchForm, self).__init__(instance=instance, *args, **kwargs)
138141
self.fields['delegate'] = forms.ModelChoiceField(
139-
queryset=_get_delegate_qs(project, instance), required=False
142+
queryset=_get_delegate_qs(project, instance),
143+
widget=forms.Select(attrs={'class': 'change-property-delegate'}),
144+
required=False,
140145
)
141146

142147
class Meta:
143148
model = Patch
144149
fields = ['state', 'archived', 'delegate']
150+
widgets = {
151+
'state': forms.Select(attrs={'class': 'change-property-state'}),
152+
'archived': forms.CheckboxInput(
153+
attrs={'class': 'archive-patch-check'}
154+
),
155+
}
145156

146157

147158
class OptionalModelChoiceField(forms.ModelChoiceField):
148-
no_change_choice = ('*', 'no change')
159+
no_change_choice = ('*', 'No change')
149160
to_field_name = None
150161

151-
def __init__(self, *args, **kwargs):
162+
def __init__(self, *args, placeholder, className, **kwargs):
163+
self.no_change_choice = ('*', placeholder)
164+
self.widget = forms.Select(attrs={'class': className})
152165
super(OptionalModelChoiceField, self).__init__(
153166
initial=self.no_change_choice[0], *args, **kwargs
154167
)
@@ -181,29 +194,42 @@ def clean(self, value):
181194

182195

183196
class OptionalBooleanField(forms.TypedChoiceField):
197+
def __init__(self, className, *args, **kwargs):
198+
self.widget = forms.Select(attrs={'class': className})
199+
super(OptionalBooleanField, self).__init__(*args, **kwargs)
200+
184201
def is_no_change(self, value):
185202
return value == self.empty_value
186203

187204

188205
class MultiplePatchForm(forms.Form):
189206
action = 'update'
190207
archived = OptionalBooleanField(
208+
className='archive-patch-select',
191209
choices=[
192-
('*', 'no change'),
193-
('True', 'Archived'),
194-
('False', 'Unarchived'),
210+
('*', 'No change'),
211+
('True', 'Archive'),
212+
('False', 'Unarchive'),
195213
],
196214
coerce=lambda x: x == 'True',
197215
empty_value='*',
216+
label='Archived',
198217
)
199218

200219
def __init__(self, project, *args, **kwargs):
201220
super(MultiplePatchForm, self).__init__(*args, **kwargs)
202221
self.fields['delegate'] = OptionalModelChoiceField(
203-
queryset=_get_delegate_qs(project=project), required=False
222+
queryset=_get_delegate_qs(project=project),
223+
placeholder='Delegate to',
224+
className='change-property-delegate',
225+
label='Delegate to',
226+
required=False,
204227
)
205228
self.fields['state'] = OptionalModelChoiceField(
206-
queryset=State.objects.all()
229+
queryset=State.objects.all(),
230+
placeholder='Change state',
231+
className='change-property-state',
232+
label='Change state',
207233
)
208234

209235
def save(self, instance, commit=True):

0 commit comments

Comments
 (0)