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

document editor: fix bnf import #322

Merged
merged 1 commit into from
Jul 23, 2020
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,4 +15,4 @@
 along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<ng-core-editor [model]="model"></ng-core-editor>
<ng-core-editor (loadingChange)="loadingChanged($event)" [model]="model"></ng-core-editor>
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { Component, OnInit } from '@angular/core';
import {ToastrService} from 'ngx-toastr';
import { TranslateService } from '@ngx-translate/core';
import { EditorService } from '../../../service/editor.service';
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';
import { combineLatest } from 'rxjs';
import { EditorService } from '../../../service/editor.service';

@Component({
selector: 'admin-document-editor',
Expand All @@ -30,27 +30,18 @@ import { combineLatest } from 'rxjs';
/**
* Show Document Editor with a specific input: EAN import.
*/
export class DocumentEditorComponent implements OnInit {
export class DocumentEditorComponent {

// initial editor values
model = {};

constructor(
private editorService: EditorService,
private toastrService: ToastrService,
private translateService: TranslateService,
private _route: ActivatedRoute
) { }

) {}

ngOnInit() {
combineLatest([this._route.params, this._route.queryParams])
.subscribe(([params, queryParams]) => {
if (queryParams.source != null && queryParams.pid != null) {
this.importFromExternalSource(queryParams.source, queryParams.pid);
}
}
);
}
/**
* Retrieve information about an item regarding its EAN code using EditorService
* @param source string - the external source
Expand All @@ -68,6 +59,25 @@ export class DocumentEditorComponent implements OnInit {
);
}
}
);
);
}

/**
* To be notified when the child editor loading state change.
*
* An other approach can be to display the child component only when the
* external source data are retrieved.
*
* @param value - true if the child editor component is currently loading data
*/
loadingChanged(value: boolean) {
if (value === false) {
combineLatest([this._route.params, this._route.queryParams])
.subscribe(([params, queryParams]) => {
if (queryParams.source != null && queryParams.pid != null) {
this.importFromExternalSource(queryParams.source, queryParams.pid);
}
});
}
}
}