feat: refs #6367 add new class
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
422042f8ab
commit
bc1c4e39ab
|
@ -19,6 +19,7 @@ module.exports = Self => {
|
|||
};
|
||||
|
||||
Self.printEmail = async function(ctx, id, templateName) {
|
||||
console.log('printEmail');
|
||||
const {accessToken} = ctx.req;
|
||||
const args = Object.assign({}, ctx.args);
|
||||
const params = {lang: ctx.req.getLocale()};
|
||||
|
|
|
@ -50,5 +50,5 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.incotermsAuthorizationHtml = (ctx, id) => Self.printEmail(ctx, id, 'incoterms-authorization');
|
||||
Self.incotermsAuthorizationHtml = (ctx, id) => Self.printEmail(ctx, id, 'simple-notification');
|
||||
};
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
const Stylesheet = require(`vn-print/core/stylesheet`);
|
||||
|
||||
const path = require('path');
|
||||
const vnPrintPath = path.resolve('print');
|
||||
|
||||
module.exports = new Stylesheet([
|
||||
`${vnPrintPath}/common/css/spacing.css`,
|
||||
`${vnPrintPath}/common/css/misc.css`,
|
||||
module.exports = [
|
||||
`${vnPrintPath}/common/css/email.css`,
|
||||
`${vnPrintPath}/common/css/layout.css`,
|
||||
`${vnPrintPath}/common/css/email.css`])
|
||||
.mergeStyles();
|
||||
`${vnPrintPath}/common/css/misc.css`,
|
||||
`${vnPrintPath}/common/css/report.css`,
|
||||
`${vnPrintPath}/common/css/spacing.css`,
|
||||
];
|
|
@ -0,0 +1,19 @@
|
|||
const Component = require(`vn-print/core/component`);
|
||||
|
||||
const path = require('path');
|
||||
const vnPrintPath = path.resolve('print');
|
||||
|
||||
const blankTemplate = new Component(`blank-template`);
|
||||
class Template {
|
||||
constructor() {
|
||||
this._template = `${vnPrintPath}/core/components/blank-template/blank-template.html`;
|
||||
}
|
||||
build(ass) {
|
||||
console.log('ass: ', ass);
|
||||
console.log('Building blank notification');
|
||||
console.log('this._template: ', this._template);
|
||||
blankTemplate.build(this._template);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Template;
|
|
@ -10,8 +10,12 @@ const path = require('path');
|
|||
const config = require('./config');
|
||||
|
||||
class Component {
|
||||
constructor(name) {
|
||||
constructor(name, template) {
|
||||
console.log('cosntructor Component');
|
||||
console.log('template: ', template);
|
||||
console.log('name: ', name);
|
||||
this.name = name;
|
||||
this._template = template;
|
||||
}
|
||||
|
||||
get path() {
|
||||
|
@ -19,8 +23,18 @@ class Component {
|
|||
}
|
||||
|
||||
get template() {
|
||||
console.log('this._template: ', this._template);
|
||||
if (this._template) return this._template;
|
||||
const templatePath = `${this.path}/${this.name}.html`;
|
||||
const fullPath = path.resolve(__dirname, templatePath);
|
||||
console.log('fullPath: ', fullPath);
|
||||
|
||||
if (!fs.existsSync(fullPath)) {
|
||||
const path = require('path');
|
||||
const vnPrintPath = path.resolve('print');
|
||||
|
||||
return fs.readFileSync(`${vnPrintPath}/core/components/blank-template/blank-template.html`, 'utf8');
|
||||
}
|
||||
|
||||
return fs.readFileSync(fullPath, 'utf8');
|
||||
}
|
||||
|
@ -74,12 +88,21 @@ class Component {
|
|||
}
|
||||
|
||||
get stylesheet() {
|
||||
const stylePath = path.resolve(__dirname, `${this.path}/assets/css`);
|
||||
let css = [];
|
||||
|
||||
if (!fs.existsSync(stylePath))
|
||||
return '';
|
||||
const path = require('path');
|
||||
const vnPrintPath = path.resolve('print');
|
||||
|
||||
return require(`${stylePath}/import`);
|
||||
const styles = require(`${vnPrintPath}/common/css/index.js`);
|
||||
|
||||
for (const style of styles)
|
||||
css.push(fs.readFileSync(style));
|
||||
|
||||
const style = `${path.resolve(__dirname, this.path)}/assets/css/style.css`; // regex to match css files
|
||||
|
||||
if (fs.existsSync(style)) css.push(fs.readFileSync(style));
|
||||
|
||||
return css.join('\n');
|
||||
}
|
||||
|
||||
get attachments() {
|
||||
|
@ -93,17 +116,22 @@ class Component {
|
|||
}
|
||||
|
||||
build() {
|
||||
console.log('this.name ', this.name);
|
||||
console.log('this._template: ', this._template);
|
||||
const fullPath = path.resolve(__dirname, this.path);
|
||||
if (!fs.existsSync(fullPath))
|
||||
throw new Error(`Template "${this.name}" not found`);
|
||||
|
||||
const component = require(`${this.path}/${this.name}`);
|
||||
let component = {};
|
||||
if (this.template !== undefined) {
|
||||
component = require(`${this.path}/${this.name}`);
|
||||
component.template = juice.inlineContent(this.template, this.stylesheet, {
|
||||
inlinePseudoElements: true
|
||||
});
|
||||
}
|
||||
|
||||
component.i18n = this.locale;
|
||||
component.attachments = this.attachments;
|
||||
console.log('this.stylesheet: ', this.stylesheet);
|
||||
component.template = juice.inlineContent(this.template, this.stylesheet, {
|
||||
inlinePseudoElements: true
|
||||
});
|
||||
const tplPath = this.path;
|
||||
if (!component.computed) component.computed = {};
|
||||
component.computed.path = function() {
|
||||
|
@ -134,9 +162,11 @@ class Component {
|
|||
* @return {Promise} Rendered component
|
||||
*/
|
||||
async render() {
|
||||
return renderer.renderToString(
|
||||
const render = await renderer.renderToString(
|
||||
this.component()
|
||||
);
|
||||
|
||||
return render;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,14 +7,16 @@ module.exports = {
|
|||
},
|
||||
props: {
|
||||
subject: {
|
||||
type: String
|
||||
type: String,
|
||||
default: 'Subject'
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
required: true
|
||||
default: 'title'
|
||||
},
|
||||
text: {
|
||||
type: String
|
||||
type: String,
|
||||
default: 'text'
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
const Stylesheet = require(`vn-print/core/stylesheet`);
|
||||
|
||||
const path = require('path');
|
||||
const vnPrintPath = path.resolve('print');
|
||||
|
||||
module.exports = new Stylesheet([
|
||||
`${vnPrintPath}/common/css/spacing.css`,
|
||||
`${vnPrintPath}/common/css/misc.css`,
|
||||
`${vnPrintPath}/common/css/layout.css`,
|
||||
`${vnPrintPath}/common/css/email.css`])
|
||||
.mergeStyles();
|
|
@ -0,0 +1,3 @@
|
|||
.red{
|
||||
background-color: red;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<email-body v-bind="$props">
|
||||
<div class="grid-row">
|
||||
<div class="grid-block vn-pa-ml">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<h1 class="red">{{ $t('title') }}</h1>
|
||||
<p>{{$t('description.dear')}},</p>
|
||||
<p>{{$t('description.instructions')}}</p>
|
||||
<p>{{$t('description.conclusion')}}</p>
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
<div class="line"><span>{{$t('transferAccount') }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
<h1>pinga</h1>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
.div{
|
||||
background-color: red;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
const Template = require('vn-print/core/blank-template');
|
||||
const blankTemplate = new Template('blank-template');
|
||||
|
||||
module.exports = {
|
||||
name: 'blank-notification',
|
||||
components: {
|
||||
'email-body': blankTemplate.build()
|
||||
},
|
||||
props: {
|
||||
subject: {
|
||||
type: String,
|
||||
default: 'Subject'
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: 'title'
|
||||
},
|
||||
text: {
|
||||
type: String,
|
||||
default: 'text'
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue