Remove redundant Submits

Remove concurrent ngSubmit
Some cleanup and code alignment
This commit is contained in:
Sean Engelhardt 2019-02-14 14:17:17 +01:00
parent 98dc105f46
commit 6a78d65dc3
11 changed files with 193 additions and 165 deletions

View File

@ -82,7 +82,6 @@ export class ItemRepositoryService extends BaseRepository<ViewItem, Item> {
/** /**
* Returns the corresponding content object to a given {@link Item} as an {@link AgendaBaseViewModel} * Returns the corresponding content object to a given {@link Item} as an {@link AgendaBaseViewModel}
* Used dynamically because of heavy race conditions
* *
* @param agendaItem the target agenda Item * @param agendaItem the target agenda Item
* @returns the content object of the given item. Might be null if it was not found. * @returns the content object of the given item. Might be null if it was not found.

View File

@ -111,14 +111,13 @@ export class AgendaListComponent extends ListViewBaseComponent<ViewItem> impleme
/** /**
* Links to the content object. * Links to the content object.
* Gets content object from the repository rather than from the model
* to avoid race conditions
* *
* @param item the item that was selected from the list view * @param item the item that was selected from the list view
*/ */
public singleSelectAction(item: ViewItem): void { public singleSelectAction(item: ViewItem): void {
const contentObject = this.repo.getContentObject(item.item); if (item.contentObject) {
this.router.navigate([contentObject.getDetailStateURL()]); this.router.navigate([item.contentObject.getDetailStateURL()]);
}
} }
/** /**

View File

@ -1,6 +1,6 @@
<h1 mat-dialog-title>{{ 'Edit details for' | translate }} {{ item.getTitle() }}</h1> <h1 mat-dialog-title>{{ 'Edit details for' | translate }} {{ item.getTitle() }}</h1>
<div mat-dialog-content> <div mat-dialog-content>
<form class="itemDialogForm" [formGroup]="agendaInfoForm" (keydown)="onKeyDown($event)" (ngSubmit)="saveItemInfo()"> <form class="itemDialogForm" [formGroup]="agendaInfoForm" (keydown)="onKeyDown($event)">
<!-- Visibility --> <!-- Visibility -->
<mat-form-field> <mat-form-field>
<mat-select formControlName="type" placeholder="{{ 'Agenda visibility' | translate }}"> <mat-select formControlName="type" placeholder="{{ 'Agenda visibility' | translate }}">

View File

@ -24,9 +24,7 @@
</div> </div>
</os-head-bar> </os-head-bar>
<mat-card *ngIf="topic || editTopic" <mat-card *ngIf="topic || editTopic" [ngClass]="editTopic ? 'os-form-card' : 'os-card'" class="on-transition-fade">
[ngClass]="editTopic ? 'os-form-card' : 'os-card'"
class="on-transition-fade">
<div *ngIf="!editTopic"> <div *ngIf="!editTopic">
<h1>{{ topic.title }}</h1> <h1>{{ topic.title }}</h1>
</div> </div>
@ -49,7 +47,7 @@
</h3> </h3>
</div> </div>
<form *ngIf="editTopic" [formGroup]="topicForm" (keydown)="onKeyDown($event)" (ngSubmit)="saveTopic()"> <form *ngIf="editTopic" [formGroup]="topicForm" (keydown)="onKeyDown($event)">
<div> <div>
<mat-form-field> <mat-form-field>
<input <input

View File

@ -2,14 +2,28 @@
<form [formGroup]="newPasswordForm" (ngSubmit)="submitNewPassword()"> <form [formGroup]="newPasswordForm" (ngSubmit)="submitNewPassword()">
<h3 translate>Please enter your new password</h3> <h3 translate>Please enter your new password</h3>
<mat-form-field> <mat-form-field>
<input matInput required placeholder="{{ 'New password' | translate }}" formControlName="password" type="password"> <input
matInput
required
placeholder="{{ 'New password' | translate }}"
formControlName="password"
type="password"
/>
<mat-error *ngIf="newPasswordForm.get('password').hasError('required')" translate> <mat-error *ngIf="newPasswordForm.get('password').hasError('required')" translate>
A password is required A password is required
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
<br> <br />
<button mat-raised-button color="primary" class="submit-button" [disabled]="newPasswordForm.invalid" <button
type="submit" translate>Reset password</button> type="submit"
<button mat-button class="back-button" routerLink="/login" translate>Back to login</button> mat-raised-button
color="primary"
class="submit-button"
[disabled]="newPasswordForm.invalid"
translate
>
Reset password
</button>
<button type="button" class="back-button" routerLink="/login" translate>Back to login</button>
</form> </form>
</div> </div>

View File

@ -2,14 +2,21 @@
<form [formGroup]="resetPasswordForm" (ngSubmit)="resetPassword()"> <form [formGroup]="resetPasswordForm" (ngSubmit)="resetPassword()">
<h3 translate>Enter your email to send the password reset link</h3> <h3 translate>Enter your email to send the password reset link</h3>
<mat-form-field> <mat-form-field>
<input matInput required placeholder="{{ 'Email' | translate }}" formControlName="email" type="email"> <input matInput required placeholder="{{ 'Email' | translate }}" formControlName="email" type="email" />
<mat-error *ngIf="resetPasswordForm.get('email').invalid" translate> <mat-error *ngIf="resetPasswordForm.get('email').invalid" translate>
Please enter a valid email address! Please enter a valid email address!
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
<br> <br />
<button mat-raised-button color="primary" class="submit-button" [disabled]="resetPasswordForm.invalid" <button
type="submit">{{ 'Reset password' | translate }}</button>&nbsp; type="submit"
<button mat-button routerLink="/login">{{ 'Back' | translate }}</button> mat-raised-button
color="primary"
class="submit-button"
[disabled]="resetPasswordForm.invalid"
>
{{ 'Reset password' | translate }}</button
>&nbsp;
<button type="button" mat-button routerLink="/login">{{ 'Back' | translate }}</button>
</form> </form>
</div> </div>

View File

@ -3,7 +3,8 @@
[editMode]="editFile" [editMode]="editFile"
[multiSelectMode]="isMultiSelect" [multiSelectMode]="isMultiSelect"
(mainEvent)="onMainEvent()" (mainEvent)="onMainEvent()"
(saveEvent)="onSaveEditedFile()"> (saveEvent)="onSaveEditedFile()"
>
<!-- Title --> <!-- Title -->
<div class="title-slot"> <div class="title-slot">
<h2 *ngIf="!editFile" translate>Files</h2> <h2 *ngIf="!editFile" translate>Files</h2>
@ -13,7 +14,8 @@
*ngIf="editFile" *ngIf="editFile"
[formGroup]="fileEditForm" [formGroup]="fileEditForm"
(ngSubmit)="onSaveEditedFile()" (ngSubmit)="onSaveEditedFile()"
(keydown)="keyDownFunction($event)"> (keydown)="keyDownFunction($event)"
>
<mat-form-field> <mat-form-field>
<input <input
type="text" type="text"
@ -21,7 +23,8 @@
osAutofocus osAutofocus
required required
formControlName="title" formControlName="title"
placeholder="{{ 'New file name' | translate }}"/> placeholder="{{ 'New file name' | translate }}"
/>
<mat-error *ngIf="fileEditForm.invalid" translate>Required</mat-error> <mat-error *ngIf="fileEditForm.invalid" translate>Required</mat-error>
</mat-form-field> </mat-form-field>
@ -45,12 +48,15 @@
<button mat-icon-button (click)="toggleMultiSelect()"><mat-icon>arrow_back</mat-icon></button> <button mat-icon-button (click)="toggleMultiSelect()"><mat-icon>arrow_back</mat-icon></button>
<span>{{ selectedRows.length }}&nbsp;</span><span translate>selected</span> <span>{{ selectedRows.length }}&nbsp;</span><span translate>selected</span>
</div> </div>
</os-head-bar> </os-head-bar>
<mat-drawer-container class="on-transition-fade"> <mat-drawer-container class="on-transition-fade">
<os-sort-filter-bar [filterCount]="filteredCount" [sortService]="sortService" [filterService]="filterService" <os-sort-filter-bar
(searchFieldChange)="searchFilter($event)"> [filterCount]="filteredCount"
[sortService]="sortService"
[filterService]="filterService"
(searchFieldChange)="searchFilter($event)"
>
</os-sort-filter-bar> </os-sort-filter-bar>
<mat-table class="os-listview-table on-transition-fade" [dataSource]="dataSource" matSort> <mat-table class="os-listview-table on-transition-fade" [dataSource]="dataSource" matSort>
<!-- Selector Column --> <!-- Selector Column -->
@ -88,7 +94,8 @@
*ngIf="getFileSettings(file).length > 0" *ngIf="getFileSettings(file).length > 0"
[matMenuTriggerFor]="singleFileMenu" [matMenuTriggerFor]="singleFileMenu"
[matMenuTriggerData]="{ file: file }" [matMenuTriggerData]="{ file: file }"
[matTooltip]="formatIndicatorTooltip(file)"> [matTooltip]="formatIndicatorTooltip(file)"
>
<mat-icon *ngIf="file.isFont()">text_fields</mat-icon> <mat-icon *ngIf="file.isFont()">text_fields</mat-icon>
<mat-icon *ngIf="file.isImage()">insert_photo</mat-icon> <mat-icon *ngIf="file.isImage()">insert_photo</mat-icon>
</div> </div>
@ -119,14 +126,18 @@
<!-- Exclusive for images --> <!-- Exclusive for images -->
<div *ngIf="file.isImage()"> <div *ngIf="file.isImage()">
<div *ngFor="let action of logoActions"> <div *ngFor="let action of logoActions">
<ng-container *ngTemplateOutlet="manageButton; context: { file: file, action: action }"></ng-container> <ng-container
*ngTemplateOutlet="manageButton; context: { file: file, action: action }"
></ng-container>
</div> </div>
</div> </div>
<!-- Exclusive for fonts --> <!-- Exclusive for fonts -->
<div *ngIf="file.isFont()"> <div *ngIf="file.isFont()">
<div *ngFor="let action of fontActions"> <div *ngFor="let action of fontActions">
<ng-container *ngTemplateOutlet="manageButton; context: { file: file, action: action }"></ng-container> <ng-container
*ngTemplateOutlet="manageButton; context: { file: file, action: action }"
></ng-container>
</div> </div>
</div> </div>
@ -170,7 +181,7 @@
<span translate>Deselect all</span> <span translate>Deselect all</span>
</button> </button>
<mat-divider></mat-divider> <mat-divider></mat-divider>
<button mat-menu-item *ngIf="canEdit" (click)="deleteSelected()"> <button mat-menu-item *osPerms="'mediafiles.can_manage'" (click)="deleteSelected()">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
<span translate>Delete</span> <span translate>Delete</span>
</button> </button>

View File

@ -26,7 +26,8 @@
type="button" type="button"
mat-button mat-button
matStepperNext matStepperNext
[disabled]="contentForm.value.selectedParagraph === null"> [disabled]="contentForm.value.selectedParagraph === null"
>
<span translate>Next</span> <span translate>Next</span>
</button> </button>
</div> </div>

View File

@ -420,13 +420,7 @@
</ng-template> </ng-template>
<ng-template #contentTemplate> <ng-template #contentTemplate>
<form <form class="motion-content" [formGroup]="contentForm" (keydown)="onKeyDown($event)" *ngIf="motion">
class="motion-content"
[formGroup]="contentForm"
(keydown)="onKeyDown($event)"
(ngSubmit)="saveMotion()"
*ngIf="motion"
>
<!-- Line Number and Diff buttons --> <!-- Line Number and Diff buttons -->
<div *ngIf="!editMotion && !motion.isStatuteAmendment()" class="motion-text-controls"> <div *ngIf="!editMotion && !motion.isStatuteAmendment()" class="motion-text-controls">
<mat-form-field class="motion-goto-line" *ngIf="highlightedLineOpened"> <mat-form-field class="motion-goto-line" *ngIf="highlightedLineOpened">

View File

@ -1,12 +1,24 @@
<os-head-bar [mainButton]="true" [nav]="true" [editMode]="editTag" <os-head-bar
(mainEvent)="setEditMode(!editTag)" (saveEvent)="saveTag()" [multiSelectMode]="isMultiSelect">> [mainButton]="true"
[nav]="true"
[editMode]="editTag"
(mainEvent)="setEditMode(!editTag)"
(saveEvent)="saveTag()"
[multiSelectMode]="isMultiSelect"
>
<!-- Title --> <!-- Title -->
<div class="title-slot"> <div class="title-slot">
<h2 *ngIf="!editTag && !newTag" translate>Tags</h2> <h2 *ngIf="!editTag && !newTag" translate>Tags</h2>
<form *ngIf="editTag" [formGroup]="tagForm" (ngSubmit)="saveTag()" (keydown)="keyDownFunction($event)"> <form *ngIf="editTag" [formGroup]="tagForm" (keydown)="keyDownFunction($event)">
<mat-form-field> <mat-form-field>
<input type="text" matInput osAutofocus required formControlName="name" <input
placeholder="{{ 'New tag name' | translate}}"> type="text"
matInput
osAutofocus
required
formControlName="name"
placeholder="{{ 'New tag name' | translate }}"
/>
<mat-error *ngIf="tagForm.invalid" translate>Required</mat-error> <mat-error *ngIf="tagForm.invalid" translate>Required</mat-error>
</mat-form-field> </mat-form-field>
</form> </form>
@ -14,12 +26,11 @@
<!-- remove button --> <!-- remove button -->
<div class="extra-controls-slot on-transition-fade"> <div class="extra-controls-slot on-transition-fade">
<button *ngIf="!isMultiSelect && editTag && !newTag" type="button" mat-button (click)="deleteSelectedTag()"> <button type="button" mat-button *ngIf="!isMultiSelect && editTag && !newTag" (click)="deleteSelectedTag()">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
<span translate>Delete</span> <span translate>Delete</span>
</button> </button>
</div> </div>
</os-head-bar> </os-head-bar>
<mat-table class="os-listview-table on-transition-fade" [dataSource]="dataSource" matSort> <mat-table class="os-listview-table on-transition-fade" [dataSource]="dataSource" matSort>
@ -28,7 +39,7 @@
<mat-cell *matCellDef="let tag">{{ tag.getTitle() }}</mat-cell> <mat-cell *matCellDef="let tag">{{ tag.getTitle() }}</mat-cell>
</ng-container> </ng-container>
<mat-header-row *matHeaderRowDef="['name']"></mat-header-row> <mat-header-row *matHeaderRowDef="['name']"></mat-header-row>
<mat-row (click)='selectItem(row, $event)' *matRowDef="let row; columns: ['name']"></mat-row> <mat-row (click)="selectItem(row, $event)" *matRowDef="let row; columns: ['name']"></mat-row>
</mat-table> </mat-table>
<mat-paginator class="on-transition-fade" [pageSizeOptions]="[25, 50, 75, 100, 125]"></mat-paginator> <mat-paginator class="on-transition-fade" [pageSizeOptions]="[25, 50, 75, 100, 125]"></mat-paginator>

View File

@ -15,12 +15,7 @@
<!-- Menu --> <!-- Menu -->
<div class="menu-slot"> <div class="menu-slot">
<button <button type="button" mat-icon-button *ngIf="isAllowed('changePersonal')" [matMenuTriggerFor]="userExtraMenu">
type="button"
mat-icon-button
*ngIf="isAllowed('changePersonal')"
[matMenuTriggerFor]="userExtraMenu"
>
<mat-icon>more_vert</mat-icon> <mat-icon>more_vert</mat-icon>
</button> </button>
</div> </div>
@ -49,7 +44,6 @@
<form <form
[ngClass]="{ 'mat-form-field-enabled': editUser }" [ngClass]="{ 'mat-form-field-enabled': editUser }"
[formGroup]="personalInfoForm" [formGroup]="personalInfoForm"
(ngSubmit)="saveUser()"
*ngIf="user" *ngIf="user"
(keydown)="onKeyDown($event)" (keydown)="onKeyDown($event)"
> >