Merge pull request #4898 from FinnStutzenstein/cascadeCategories
Cascade categories on delete
This commit is contained in:
commit
ed99fc8c91
@ -158,7 +158,7 @@ export class CategoryDetailComponent extends BaseViewComponent implements OnInit
|
||||
* Click handler to delete a category
|
||||
*/
|
||||
public async onDeleteButton(): Promise<void> {
|
||||
const title = this.translate.instant('Are you sure you want to delete this category?');
|
||||
const title = this.translate.instant('Are you sure you want to delete this category and all subcategories?');
|
||||
const content = this.selectedCategory.prefixedName;
|
||||
if (await this.promptService.open(title, content)) {
|
||||
await this.repo.delete(this.selectedCategory);
|
||||
|
@ -80,7 +80,7 @@ export class CategoryListComponent extends BaseViewComponent implements OnInit {
|
||||
|
||||
this.dataSource = new MatTableDataSource();
|
||||
this.repo.getViewModelListObservable().subscribe(viewCategories => {
|
||||
if (viewCategories && viewCategories.length && this.dataSource) {
|
||||
if (viewCategories && this.dataSource) {
|
||||
this.dataSource.data = viewCategories;
|
||||
}
|
||||
});
|
||||
|
@ -0,0 +1,24 @@
|
||||
# Generated by Django 2.2.3 on 2019-08-05 10:50
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
import openslides.utils.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [("motions", "0031_state_css_classes_2")]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="category",
|
||||
name="parent",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=openslides.utils.models.CASCADE_AND_AUTOUPDATE,
|
||||
related_name="children",
|
||||
to="motions.Category",
|
||||
),
|
||||
)
|
||||
]
|
@ -804,14 +804,14 @@ class Category(RESTModelMixin, models.Model):
|
||||
"""Name of the category."""
|
||||
|
||||
prefix = models.CharField(blank=True, max_length=32)
|
||||
"""Prefix of the category.
|
||||
|
||||
"""
|
||||
Prefix of the category.
|
||||
Used to build the identifier of a motion.
|
||||
"""
|
||||
|
||||
parent = models.ForeignKey(
|
||||
"self",
|
||||
on_delete=SET_NULL_AND_AUTOUPDATE,
|
||||
on_delete=CASCADE_AND_AUTOUPDATE,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name="children",
|
||||
|
Loading…
Reference in New Issue
Block a user