Skip to content

Commit

Permalink
New config param to hide original colunm in inlines
Browse files Browse the repository at this point in the history
  • Loading branch information
darklow committed Nov 23, 2016
1 parent 7f7917f commit e997f71
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 9 deletions.
4 changes: 3 additions & 1 deletion demo/demo/admin.py
Expand Up @@ -31,6 +31,7 @@ class CityInline(admin.TabularInline):
extra = 0
verbose_name_plural = 'Cities'
suit_classes = 'suit-tab suit-tab-cities'
suit_form_inlines_hide_original = True


class CountryForm(ModelForm):
Expand Down Expand Up @@ -129,6 +130,7 @@ class CountryInline(SortableTabularInline):
extra = 1
verbose_name_plural = 'Countries (Sortable example)'
sortable = 'order'
show_change_link = True


class ContinentAdmin(SortableModelAdmin):
Expand Down Expand Up @@ -193,6 +195,7 @@ class BookInline(SortableTabularInline):
min_num = 1
extra = 0
verbose_name_plural = 'Books (Tabular inline)'
suit_form_inlines_hide_original = True


class MovieInlineForm(ModelForm):
Expand Down Expand Up @@ -228,7 +231,6 @@ class ShowcaseAdmin(admin.ModelAdmin):
# list_display = ('name', 'help_text', 'choices', 'horizontal_choices', 'boolean')
list_display = ('name', 'help_text')
readonly_fields = ('readonly_field',)
# raw_id_fields = ('raw_id_field',)
fieldsets = [
(None, {'fields': ['name', 'help_text', 'textfield',
('multiple_in_row', 'multiple2'),
Expand Down
4 changes: 4 additions & 0 deletions suit/apps.py
Expand Up @@ -41,6 +41,10 @@ class DjangoSuitConfig(AppConfig):
# Enables two column layout for change forms with submit row on the right
form_submit_on_right = True

# Hide name/"original" column for all tabular inlines.
# May be overridden in Inline class by suit_form_inlines_hide_original = False
form_inlines_hide_original = False

# For size
form_size = {
'default': SUIT_FORM_SIZE_X_LARGE,
Expand Down
19 changes: 16 additions & 3 deletions suit/sass/components/_forms.scss
Expand Up @@ -276,9 +276,22 @@ fieldset {
tbody {
td {
&.original {
font-size: 0;
width: 0;
padding: 0;
p {
margin: 0;
@extend .form-control-static;
a {
float: right;
font-size: $font-size-xs;
}
}
.suit-inlines-hide-original:not(.suit-inlines-show-original) & {
font-size: 0;
width: 0;
padding: 0;
> * {
display: none;
}
}
}
.errorlist {
margin: 0;
Expand Down

0 comments on commit e997f71

Please sign in to comment.