Fix amendment creation

Categories and blocks not appear after (paragraph based) amendment
creation.
Reason for amendments is now required if the config was set
accordingly
This commit is contained in:
Sean Engelhardt 2019-03-08 16:45:45 +01:00
parent 3490ff3ca4
commit 07d3ea4c25
4 changed files with 66 additions and 22 deletions

View File

@ -37,13 +37,54 @@
<mat-step>
<ng-template matStepLabel>{{ 'Change paragraph' | translate }}</ng-template>
<h5 translate>Amendment text</h5>
<!-- The HTML Editor -->
<editor formControlName="text" [init]="tinyMceSettings"></editor>
<!-- Text -->
<h3
[ngClass]="
contentForm.get('text').invalid &&
(contentForm.get('text').dirty || contentForm.get('text').touched)
? 'red-warning-text'
: ''
"
>
<span translate>Amendment text</span>&nbsp;<span>*</span>
</h3>
<editor formControlName="text" [init]="tinyMceSettings" required></editor>
<div
*ngIf="
contentForm.get('text').invalid &&
(contentForm.get('text').dirty || contentForm.get('text').touched)
"
class="red-warning-text"
translate
>
This field is required.
</div>
<h5 translate>Reason</h5>
<!-- The HTML Editor -->
<editor formControlName="reason" [init]="tinyMceSettings"></editor>
<!-- Reason -->
<h3
[ngClass]="
reasonRequired &&
contentForm.get('reason').invalid &&
(contentForm.get('reason').dirty || contentForm.get('reason').touched)
? 'red-warning-text'
: ''
"
>
<span translate>Reason</span>&nbsp;<span *ngIf="reasonRequired">*</span>
</h3>
<editor formControlName="reason" [init]="tinyMceSettings" required></editor>
<div
*ngIf="
reasonRequired &&
contentForm.get('reason').invalid &&
(contentForm.get('reason').dirty || contentForm.get('reason').touched)
"
class="red-warning-text"
translate
>
This field is required.
</div>
</mat-step>
</mat-horizontal-stepper>
</form>

View File

@ -57,16 +57,16 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent {
*/
public contentForm: FormGroup;
/**
* Motions meta-info
*/
public metaInfoForm: FormGroup;
/**
* Indicates the maximum line length as defined in the configuration.
*/
public lineLength: number;
/**
* Determine, from the config service, if a reason is required
*/
public reasonRequired: boolean;
/**
* Constructs this component.
*
@ -100,6 +100,10 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent {
this.lineLength = lineLength;
this.getMotionByUrl();
});
this.configService.get<boolean>('motions_reason_required').subscribe(required => {
this.reasonRequired = required;
});
}
/**
@ -133,15 +137,6 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent {
text: ['', Validators.required],
reason: ['', Validators.required]
});
this.metaInfoForm = this.formBuilder.group({
identifier: [''],
category_id: [''],
state_id: [''],
recommendation_id: [''],
submitters_id: [],
supporters_id: [[]],
origin: ['']
});
}
/**
@ -172,10 +167,11 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent {
}
);
const newMotionValues = {
...this.metaInfoForm.value,
...this.contentForm.value,
title: this.translate.instant('Amendment to') + ' ' + this.motion.identifier,
parent_id: this.motion.id,
category_id: this.motion.category_id,
motion_block_id: this.motion.motion_block_id,
amendment_paragraphs: amendedParagraphs
};

View File

@ -1,7 +1,7 @@
<os-head-bar
[mainButton]="perms.isAllowed('update', motion)"
mainButtonIcon="edit"
prevUrl="../.."
[prevUrl]="backTarget"
[nav]="false"
[editMode]="editMotion"
(mainEvent)="setEditMode(!editMotion)"

View File

@ -337,6 +337,13 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
*/
private editNotificationSubscription: Subscription;
/**
* Determine what to "return" to.
* Handles the target for clicking the back button
* Several angular peculiarities prevent dynamic changing from working right now
*/
public backTarget = '../..';
/**
* Constructs the detail view.
*