-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
222 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
paper_admin/static/paper_admin/src/widgets/select-multiple-field/checkbox-tree.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@import "css/env"; | ||
|
||
.pct-tree { | ||
width: 100%; | ||
font-size: $input-font-size; | ||
line-height: $input-line-height; | ||
border-color: $input-border-color; | ||
border-radius: $input-border-radius-lg; | ||
|
||
@at-root .paper-widget--invalid & { | ||
border-color: $input-invalid-border-color; | ||
box-shadow: $input-invalid-box-shadow; | ||
} | ||
} | ||
|
||
.pct-group__text { | ||
color: $gray-700; | ||
font-size: 16px; | ||
font-weight: 500; | ||
} |
File renamed without changes.
21 changes: 16 additions & 5 deletions
21
paper_admin/static/paper_admin/src/widgets/select-multiple-field/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,27 @@ | ||
import XClass from "data-xclass"; | ||
import CheckboxTree from "paper-checkbox-tree"; | ||
import multi from "multi.js/dist/multi-es6.min.js"; | ||
|
||
// CSS | ||
import "multi.js/src/multi.css"; | ||
import "./index.scss"; | ||
import "./filtered-select-multiple.scss"; | ||
|
||
XClass.register("select-multiple-field", { | ||
import "paper-checkbox-tree/dist/style.css"; | ||
import "./checkbox-tree.scss"; | ||
|
||
XClass.register("filtered-select-multiple", { | ||
init: function (element) { | ||
const select = element.querySelector("select"); | ||
select && | ||
multi(select, { | ||
hide_empty_groups: true | ||
}); | ||
multi(select, { | ||
hide_empty_groups: true | ||
}); | ||
} | ||
}); | ||
|
||
XClass.register("checkbox-tree", { | ||
init: function (element) { | ||
const select = element.querySelector("select"); | ||
select && new CheckboxTree(select); | ||
} | ||
}); |
19 changes: 19 additions & 0 deletions
19
paper_admin/templates/django/forms/widgets/checkbox_tree.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div class="select-multiple-field" data-xclass="checkbox-tree"> | ||
<select name="{{ widget.name }}" {% include "django/forms/widgets/attrs.html" %}> | ||
{% for group_name, group_choices, group_index in widget.optgroups %} | ||
{% if group_name %} | ||
<optgroup label="{{ group_name }}"> | ||
{% endif %} | ||
|
||
{% for option in group_choices %} | ||
{% with widget=option %} | ||
{% include option.template_name %} | ||
{% endwith %} | ||
{% endfor %} | ||
|
||
{% if group_name %} | ||
</optgroup> | ||
{% endif %} | ||
{% endfor %} | ||
</select> | ||
</div> |
2 changes: 1 addition & 1 deletion
2
...django/forms/widgets/select_multiple.html → ...rms/widgets/filtered_select_multiple.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 3.2.25 on 2024-05-25 10:04 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('app', '0008_alter_message_sender'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='widgets', | ||
name='f_checkbox_tree_m2m', | ||
field=models.ManyToManyField(blank=True, help_text='<code>ManyToManyField</code> with <code>AdminCheckboxTree</code> widget', related_name='_app_widgets_f_checkbox_tree_m2m_+', to='app.Tag', verbose_name='Checkbox Tree M2M'), | ||
), | ||
migrations.AlterField( | ||
model_name='widgets', | ||
name='f_checkbox_m2m', | ||
field=models.ManyToManyField(blank=True, help_text='<code>ManyToManyField</code> with <code>AdminCheckboxSelectMultiple</code> widget', related_name='_app_widgets_f_checkbox_m2m_+', to='app.Tag', verbose_name='Checkbox M2M'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,8 @@ | |
"logentry_admin", | ||
|
||
"app", | ||
"sortables" | ||
"sortables", | ||
"users" | ||
] | ||
|
||
MIDDLEWARE = [ | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.contrib import admin | ||
from django.contrib.auth.admin import UserAdmin | ||
from django.contrib.auth.forms import UserChangeForm | ||
from django.contrib.auth.models import User | ||
|
||
from paper_admin.admin.widgets import AdminCheckboxTree | ||
|
||
|
||
class CustomUserChangeForm(UserChangeForm): | ||
class Meta: | ||
widgets = { | ||
"user_permissions": AdminCheckboxTree, | ||
} | ||
|
||
|
||
class CustomUserAdmin(UserAdmin): | ||
form = CustomUserChangeForm | ||
|
||
|
||
admin.site.unregister(User) | ||
admin.site.register(User, CustomUserAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters