category prefix is currently optional
This commit is contained in:
parent
c6bddd06f7
commit
8796d728d9
@ -16,7 +16,7 @@ export class Category extends BaseModel<Category> implements Searchable {
|
||||
}
|
||||
|
||||
public getTitle(): string {
|
||||
return this.prefix + ' - ' + this.name;
|
||||
return this.prefix ? this.prefix + ' - ' + this.name : this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,10 +14,7 @@
|
||||
<p>
|
||||
<!-- Prefix field -->
|
||||
<mat-form-field>
|
||||
<input formControlName="prefix" matInput placeholder="{{'Prefix' | translate}}" required>
|
||||
<mat-hint *ngIf="!createForm.controls.prefix.valid">
|
||||
<span translate>Required</span>
|
||||
</mat-hint>
|
||||
<input formControlName="prefix" matInput placeholder="{{'Prefix' | translate}}">
|
||||
</mat-form-field>
|
||||
|
||||
<!-- Name field -->
|
||||
@ -78,10 +75,7 @@
|
||||
<span translate>Edit category</span>:<br>
|
||||
|
||||
<mat-form-field>
|
||||
<input formControlName="prefix" matInput placeholder="{{'Prefix' | translate}}" required>
|
||||
<mat-hint *ngIf="!updateForm.controls.prefix.valid">
|
||||
<span translate>Required</span>
|
||||
</mat-hint>
|
||||
<input formControlName="prefix" matInput placeholder="{{'Prefix' | translate}}">
|
||||
</mat-form-field>
|
||||
<mat-form-field>
|
||||
<input formControlName="name" matInput placeholder="{{'Name' | translate}}" required>
|
||||
|
@ -78,12 +78,12 @@ export class CategoryListComponent extends BaseViewComponent implements OnInit {
|
||||
super(titleService, translate, matSnackBar);
|
||||
|
||||
this.createForm = this.formBuilder.group({
|
||||
prefix: ['', Validators.required],
|
||||
prefix: [''],
|
||||
name: ['', Validators.required]
|
||||
});
|
||||
|
||||
this.updateForm = this.formBuilder.group({
|
||||
prefix: ['', Validators.required],
|
||||
prefix: [''],
|
||||
name: ['', Validators.required]
|
||||
});
|
||||
}
|
||||
@ -131,7 +131,12 @@ export class CategoryListComponent extends BaseViewComponent implements OnInit {
|
||||
*/
|
||||
public onCreateButton(): void {
|
||||
if (this.createForm.valid) {
|
||||
this.categoryToCreate.patchValues(this.createForm.value as Category);
|
||||
const cat: Partial<Category> = { name: this.createForm.get('name').value };
|
||||
if (this.createForm.get('prefix').value) {
|
||||
cat.prefix = this.createForm.get('prefix').value;
|
||||
}
|
||||
this.categoryToCreate.patchValues(cat);
|
||||
|
||||
this.repo.create(this.categoryToCreate).then(() => (this.categoryToCreate = null), this.raiseError);
|
||||
}
|
||||
}
|
||||
@ -144,7 +149,7 @@ export class CategoryListComponent extends BaseViewComponent implements OnInit {
|
||||
this.editId = viewCategory.id;
|
||||
this.updateForm.reset();
|
||||
this.updateForm.patchValue({
|
||||
prefix: viewCategory.prefix,
|
||||
prefix: viewCategory.category.prefix,
|
||||
name: viewCategory.name
|
||||
});
|
||||
}
|
||||
@ -167,8 +172,12 @@ export class CategoryListComponent extends BaseViewComponent implements OnInit {
|
||||
}
|
||||
|
||||
if (this.updateForm.valid) {
|
||||
const cat: Partial<Category> = { name: this.updateForm.get('name').value };
|
||||
if (this.updateForm.get('prefix').value) {
|
||||
cat.prefix = this.updateForm.get('prefix').value;
|
||||
}
|
||||
// wait for the category to update; then the (maybe) changed prefix can be applied to the motions
|
||||
await this.repo.update(this.updateForm.value as Partial<Category>, viewCategory);
|
||||
await this.repo.update(cat, viewCategory);
|
||||
this.onCancelButton();
|
||||
|
||||
if (this.sortSelector) {
|
||||
|
@ -24,7 +24,7 @@ export class ViewCategory extends BaseViewModel {
|
||||
}
|
||||
|
||||
public get prefix(): string {
|
||||
return this.category ? this.category.prefix : null;
|
||||
return this.category && this.category.prefix ? this.category.prefix : null;
|
||||
}
|
||||
|
||||
public set prefix(pref: string) {
|
||||
|
@ -150,7 +150,7 @@ export class MotionPdfCatalogService {
|
||||
body: [
|
||||
[
|
||||
{
|
||||
text: category.prefix + ' - ' + category.name,
|
||||
text: category.prefix ? category.prefix + ' - ' + category.name : category.name,
|
||||
style: 'tocCategoryTitle'
|
||||
}
|
||||
]
|
||||
|
@ -199,7 +199,9 @@ export class MotionPdfService {
|
||||
style: 'boldText'
|
||||
},
|
||||
{
|
||||
text: `${motion.category.prefix} - ${motion.category.name}`
|
||||
text: motion.category.prefix
|
||||
? `${motion.category.prefix} - ${motion.category.name}`
|
||||
: `${motion.category.name}`
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user