Merge pull request #4486 from tsiegleauq/amendment-wizzard-fixes

Fix amendment creation
This commit is contained in:
Emanuel Schütze 2019-03-08 20:56:43 +01:00 committed by GitHub
commit fc7a3a7f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 66 additions and 22 deletions

View File

@ -37,13 +37,54 @@
<mat-step> <mat-step>
<ng-template matStepLabel>{{ 'Change paragraph' | translate }}</ng-template> <ng-template matStepLabel>{{ 'Change paragraph' | translate }}</ng-template>
<h5 translate>Amendment text</h5> <!-- Text -->
<!-- The HTML Editor --> <h3
<editor formControlName="text" [init]="tinyMceSettings"></editor> [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> <!-- Reason -->
<!-- The HTML Editor --> <h3
<editor formControlName="reason" [init]="tinyMceSettings"></editor> [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-step>
</mat-horizontal-stepper> </mat-horizontal-stepper>
</form> </form>

View File

@ -57,16 +57,16 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent {
*/ */
public contentForm: FormGroup; public contentForm: FormGroup;
/**
* Motions meta-info
*/
public metaInfoForm: FormGroup;
/** /**
* Indicates the maximum line length as defined in the configuration. * Indicates the maximum line length as defined in the configuration.
*/ */
public lineLength: number; public lineLength: number;
/**
* Determine, from the config service, if a reason is required
*/
public reasonRequired: boolean;
/** /**
* Constructs this component. * Constructs this component.
* *
@ -100,6 +100,10 @@ export class AmendmentCreateWizardComponent extends BaseViewComponent {
this.lineLength = lineLength; this.lineLength = lineLength;
this.getMotionByUrl(); 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], text: ['', Validators.required],
reason: ['', 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 = { const newMotionValues = {
...this.metaInfoForm.value,
...this.contentForm.value, ...this.contentForm.value,
title: this.translate.instant('Amendment to') + ' ' + this.motion.identifier, title: this.translate.instant('Amendment to') + ' ' + this.motion.identifier,
parent_id: this.motion.id, parent_id: this.motion.id,
category_id: this.motion.category_id,
motion_block_id: this.motion.motion_block_id,
amendment_paragraphs: amendedParagraphs amendment_paragraphs: amendedParagraphs
}; };

View File

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

View File

@ -337,6 +337,13 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit,
*/ */
private editNotificationSubscription: Subscription; 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. * Constructs the detail view.
* *