Merge pull request #4197 from MaximilianKrambach/optionalCategoryPrefix
category prefix is currently optional
This commit is contained in:
commit
1bee3aa509
@ -16,7 +16,7 @@ export class Category extends BaseModel<Category> implements Searchable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getTitle(): string {
|
public getTitle(): string {
|
||||||
return this.prefix + ' - ' + this.name;
|
return this.prefix ? this.prefix + ' - ' + this.name : this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,10 +14,7 @@
|
|||||||
<p>
|
<p>
|
||||||
<!-- Prefix field -->
|
<!-- Prefix field -->
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input formControlName="prefix" matInput placeholder="{{'Prefix' | translate}}" required>
|
<input formControlName="prefix" matInput placeholder="{{'Prefix' | translate}}">
|
||||||
<mat-hint *ngIf="!createForm.controls.prefix.valid">
|
|
||||||
<span translate>Required</span>
|
|
||||||
</mat-hint>
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<!-- Name field -->
|
<!-- Name field -->
|
||||||
@ -78,10 +75,7 @@
|
|||||||
<span translate>Edit category</span>:<br>
|
<span translate>Edit category</span>:<br>
|
||||||
|
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input formControlName="prefix" matInput placeholder="{{'Prefix' | translate}}" required>
|
<input formControlName="prefix" matInput placeholder="{{'Prefix' | translate}}">
|
||||||
<mat-hint *ngIf="!updateForm.controls.prefix.valid">
|
|
||||||
<span translate>Required</span>
|
|
||||||
</mat-hint>
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input formControlName="name" matInput placeholder="{{'Name' | translate}}" required>
|
<input formControlName="name" matInput placeholder="{{'Name' | translate}}" required>
|
||||||
|
@ -78,12 +78,12 @@ export class CategoryListComponent extends BaseViewComponent implements OnInit {
|
|||||||
super(titleService, translate, matSnackBar);
|
super(titleService, translate, matSnackBar);
|
||||||
|
|
||||||
this.createForm = this.formBuilder.group({
|
this.createForm = this.formBuilder.group({
|
||||||
prefix: ['', Validators.required],
|
prefix: [''],
|
||||||
name: ['', Validators.required]
|
name: ['', Validators.required]
|
||||||
});
|
});
|
||||||
|
|
||||||
this.updateForm = this.formBuilder.group({
|
this.updateForm = this.formBuilder.group({
|
||||||
prefix: ['', Validators.required],
|
prefix: [''],
|
||||||
name: ['', Validators.required]
|
name: ['', Validators.required]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -131,7 +131,12 @@ export class CategoryListComponent extends BaseViewComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
public onCreateButton(): void {
|
public onCreateButton(): void {
|
||||||
if (this.createForm.valid) {
|
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);
|
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.editId = viewCategory.id;
|
||||||
this.updateForm.reset();
|
this.updateForm.reset();
|
||||||
this.updateForm.patchValue({
|
this.updateForm.patchValue({
|
||||||
prefix: viewCategory.prefix,
|
prefix: viewCategory.category.prefix,
|
||||||
name: viewCategory.name
|
name: viewCategory.name
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -167,8 +172,12 @@ export class CategoryListComponent extends BaseViewComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.updateForm.valid) {
|
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
|
// 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();
|
this.onCancelButton();
|
||||||
|
|
||||||
if (this.sortSelector) {
|
if (this.sortSelector) {
|
||||||
|
@ -24,7 +24,7 @@ export class ViewCategory extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get prefix(): string {
|
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) {
|
public set prefix(pref: string) {
|
||||||
|
@ -150,7 +150,7 @@ export class MotionPdfCatalogService {
|
|||||||
body: [
|
body: [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
text: category.prefix + ' - ' + category.name,
|
text: category.prefix ? category.prefix + ' - ' + category.name : category.name,
|
||||||
style: 'tocCategoryTitle'
|
style: 'tocCategoryTitle'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -199,7 +199,9 @@ export class MotionPdfService {
|
|||||||
style: 'boldText'
|
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