Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libraries: Fix form reset creation #67

Merged
merged 1 commit into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
 along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<ng-container *ngIf="libForm">
<h1 translate>Library</h1>
<form [formGroup]="libForm" (ngSubmit)="onSubmit()">
<div class="form-group row">
Expand Down Expand Up @@ -167,3 +168,4 @@ <h1 translate>Library</h1>
</div>
</div>
</form>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export class LibraryComponent implements OnInit {
) { }

ngOnInit() {
this.libForm = this.libraryForm.form;
this.route.params.subscribe( (params) => {
const loggedUser = this.userService.getCurrentUser();
if (loggedUser) {
Expand All @@ -61,10 +60,13 @@ export class LibraryComponent implements OnInit {
this.recordService.getRecord('libraries', params.pid, 1).subscribe(record => {
this.library = new Library(record.metadata);
this.libraryForm.populate(record.metadata);
this.libForm = this.libraryForm.form;
this.setAsyncValidator();
});
} else {
this.libraryForm.reset();
this.library = new Library({});
this.libForm = this.libraryForm.form;
this.setAsyncValidator();
}
});
Expand Down