import {ProgressInlineComponent} from '@eg/share/dialog/progress-inline.component';
import {ProgressDialogComponent} from '@eg/share/dialog/progress.component';
import {BoolDisplayComponent} from '@eg/share/util/bool.component';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {ToastComponent} from '@eg/share/toast/toast.component';
+import {StringComponent} from '@eg/share/string/string.component';
+import {StringService} from '@eg/share/string/string.service';
+
@NgModule({
declarations: [
PromptDialogComponent,
ProgressInlineComponent,
ProgressDialogComponent,
+ ToastComponent,
+ StringComponent,
BoolDisplayComponent
],
imports: [
ProgressInlineComponent,
ProgressDialogComponent,
BoolDisplayComponent,
+ ToastComponent,
+ StringComponent
]
})
ngModule: EgCommonModule,
providers: [
HatchService,
- PrintService
+ PrintService,
+ StringService,
+ ToastService
]
};
}
There should only be one print component active in a page.
-->
+<ng-template #notFound let-name="name" i18n>
+No activate template found named "{{name}}"
+</ng-template>
+<eg-string key='eg.print.template.not_found' [template]="notFound"></eg-string>
+
+<ng-template #notWorking let-name="name" let-id="id" i18n>
+Error generating print content for template name="{{name}}" / id="{{id}}"
+</ng-template>
+<eg-string key='eg.print.template.error' [template]="notWorking"></eg-string>
+
<div id='eg-print-container'>
<!-- container for inline template compilation -->
<ng-container *ngIf="template">
import {StoreService} from '@eg/core/store.service';
import {ServerStoreService} from '@eg/core/server-store.service';
import {HatchService, HatchMessage} from './hatch.service';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {StringService} from '@eg/share/string/string.service';
@Component({
selector: 'eg-print',
private store: StoreService,
private serverStore: ServerStoreService,
private hatch: HatchService,
+ private toast: ToastService,
+ private strings: StringService,
private printer: PrintService) {
this.isPrinting = false;
this.printQueue = [];
printReq.contentType = response.contentType;
},
err => {
- console.error('Error compiling template', printReq);
+
+ if (err && err.notFound) {
+
+ this.strings.interpolate(
+ 'eg.print.template.not_found',
+ {name: printReq.templateName}
+ ).then(msg => this.toast.danger(msg));
+
+ } else {
+
+ console.error('Print generation failed', printReq);
+
+ this.strings.interpolate(
+ 'eg.print.template.error',
+ {name: printReq.templateName, id: printReq.templateId}
+ ).then(msg => this.toast.danger(msg));
+ }
+
return Promise.reject(new Error(
'Error compiling server-hosted print template'));
}
content: xhttp.responseText,
contentType: this.getResponseHeader('content-type')
});
- } else {
- reject('Error compiling print template');
+ } else if (this.status === 404) {
+ console.error('No active template found: ', printReq);
+ reject({notFound: true});
}
+ reject({});
}
};
xhttp.open('POST', PRINT_TEMPLATE_PATH, true);
import {AccessKeyService} from '@eg/share/accesskey/accesskey.service';
import {AccessKeyInfoComponent} from '@eg/share/accesskey/accesskey-info.component';
import {OpChangeComponent} from '@eg/staff/share/op-change/op-change.component';
-import {ToastService} from '@eg/share/toast/toast.service';
-import {ToastComponent} from '@eg/share/toast/toast.component';
-import {StringComponent} from '@eg/share/string/string.component';
-import {StringService} from '@eg/share/string/string.service';
import {TitleComponent} from '@eg/share/title/title.component';
import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
import {BucketDialogComponent} from '@eg/staff/share/buckets/bucket-dialog.component';
OrgFamilySelectComponent,
AccessKeyDirective,
AccessKeyInfoComponent,
- ToastComponent,
- StringComponent,
TitleComponent,
OpChangeComponent,
FmRecordEditorComponent,
OrgFamilySelectComponent,
AccessKeyDirective,
AccessKeyInfoComponent,
- ToastComponent,
- StringComponent,
TitleComponent,
OpChangeComponent,
FmRecordEditorComponent,
ngModule: StaffCommonModule,
providers: [ // Export staff-wide services
AccessKeyService,
- AudioService,
- StringService,
- ToastService
+ AudioService
]
};
}