-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added some comments to break up html table * reorganized data for email template removed all [0]. type variables from new.html email template, so all variables are set in orders.js for easy manipulation * welcome to the shop email template * extract social from template, add on/off switch * invite shop member email * shopName variable updates * update reaction address This was driving me crazy seeing the wrong address in all these emails being tested. * add Collections imports for Accounts, Cart, Shopts * password reset emails * update subject of order confirmation email * lint fix * renamed file for email template * removed test text * path file organization * mail -> SMTP for clarification * Merge branch 'release-0.18.0' into email-template-expansion-v2 # Conflicts: # imports/plugins/included/email-templates/lib/paths.js * i18n for email template admin * publication for Templates * conflict fix * add email subject into saved DB data * add server methods for deleting email templates * Add a duplicate, editable template to the template collection (#1548) Mark one of those templates and an original, which can be used to revert editable templates. * server methods for updating email templates * added check for original template * new translations * Merge branch 'release-0.18.0' into email-template-expansion-v2 * core workflow emails - processing & completed * test - new workflow email exports * Update email schema * shipping email * conflict fixes * removed comments * removed comments * import new email schema * template updates * removed commented code * organize templates * added todo to schema * updated comments * cleanup methods file * updated error messaging * schema update * update comments * i18n updates * removed testing alerts * i18n updates * file organization
- Loading branch information
1 parent
68dca93
commit bca6752
Showing
24 changed files
with
2,111 additions
and
937 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import "./templates/email.html"; | ||
import "./templates/email.js"; |
76 changes: 76 additions & 0 deletions
76
imports/plugins/core/templates/client/templates/email.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<template name="emailTemplatesDashboard"> | ||
<div class="panel panel-default"> | ||
<div class="panel-body"> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr class="info"> | ||
<th>{{i18n "mail.templates.method" "Method"}}</th> | ||
<th>{{i18n "mail.templates.templateName" "Template Name"}}</th> | ||
<th>{{i18n "mail.templates.type" "Type"}}</th> | ||
<th>{{i18n "mail.templates.language" "Language"}}</th> | ||
<th>{{i18n "mail.templates.enabled" "Enabled"}}</th> | ||
<th><i class="fa fa-plus pull-right add-shipping-method" title="{{i18n 'mail.templates.addTemplate' 'Add email template'}}" data-event-action="addShippingMethod"></i></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each emailTemplate}} | ||
<tr class="edit-shipping-method" data-event-action="editEmailTemplate"> | ||
<td>{{name}}</td> | ||
<td>{{title}}</td> | ||
<td>{{type}}</td> | ||
<td>{{language}}</td> | ||
<td> | ||
{{#if enabled}} | ||
<i class="fa fa-check text-success" title="Enabled"></i> | ||
{{else}} | ||
<i class="fa fa-ban text-danger" title="Disabled"></i> | ||
{{/if}} | ||
</td> | ||
<td class="text-right"> | ||
<i class="fa fa-pencil" data-template-id="{{_id}}" title="{{i18n 'mail.templates.edit' 'Edit email template'}}" data-event-action="editEmailTemplate"></i> | ||
<i class="fa fa-files-o" data-template-id="{{_id}}" title="{{i18n 'mail.templates.duplicate' 'Duplicate email template'}}" data-event-action="duplicateEmailTemplate"></i> | ||
<i class="fa fa-trash" data-template-id="{{_id}}" title="{{i18n 'mail.templates.delete' 'Delete email template'}}" data-event-action="deleteEmailTemplate"></i> | ||
</td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
|
||
<template name="emailTemplateSettings"> | ||
{{#autoForm | ||
collection=Collections.Templates | ||
schema=emailTemplateSchema | ||
id="email-template-edit-form" | ||
template="bootstrap3-inline" | ||
doc=this | ||
}} | ||
|
||
<div class="panel panel-default"> | ||
<div class="panel-heading">Update {{name}} template</div> | ||
<div class="panel-body"> | ||
<div class="col-md-12 form-group"> | ||
{{>afQuickField name='subject' class="form-control"}} | ||
{{>afQuickField name='name' class="form-control"}} | ||
{{>afQuickField name='title' class="form-control"}} | ||
{{>afQuickField name='language' class="form-control"}} | ||
{{>afQuickField name='template' label='HTML' class="form-control" type="textarea" rows="10"}} | ||
{{>afQuickField name='enabled'}} | ||
{{>afQuickField name='type' class="form-control"}} | ||
{{>afQuickField name='parser' class="form-control"}} | ||
{{>afQuickField name='_id' class="form-control"}} | ||
</div> | ||
</div> | ||
|
||
<div class="panel-footer"> | ||
<div class="right"> | ||
<button type="submit" class="btn btn-primary">Update</button> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{{/autoForm}} | ||
</template> |
141 changes: 141 additions & 0 deletions
141
imports/plugins/core/templates/client/templates/email.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import { Meteor } from "meteor/meteor"; | ||
import { Session } from "meteor/session"; | ||
import { Template } from "meteor/templating"; | ||
import { Blaze } from "meteor/blaze"; | ||
import { AutoForm } from "meteor/aldeed:autoform"; | ||
import { Reaction, i18next } from "/client/api"; | ||
import { Templates } from "/lib/collections"; | ||
import { EmailTemplates } from "../../lib/collections/schemas"; | ||
|
||
/* | ||
* Subscribe to Templates collections | ||
*/ | ||
Template.emailTemplatesDashboard.onCreated(function () { | ||
this.autorun(() => { | ||
this.subscribe("Templates"); | ||
}); | ||
}); | ||
|
||
|
||
/* | ||
* template emailTemplatesDashboard helpers | ||
*/ | ||
Template.emailTemplatesDashboard.helpers({ | ||
emailTemplate() { | ||
const instance = Template.instance(); | ||
if (instance.subscriptionsReady()) { | ||
return Templates.find({ | ||
shopId: Reaction.getShopId(), | ||
type: "email", | ||
isOriginalTemplate: false | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
|
||
/* | ||
* template emailTemplatesDashboard events | ||
*/ | ||
Template.emailTemplatesDashboard.events({ | ||
// "click [data-event-action=addShippingMethod]"(event) { | ||
// event.preventDefault(); | ||
// | ||
// Reaction.showActionView({ | ||
// label: i18next.t("shipping.addShippingMethod"), | ||
// template: "addShippingMethod" | ||
// }); | ||
// } | ||
|
||
"click [data-event-action=deleteEmailTemplate]"(event) { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
|
||
Alerts.alert({ | ||
title: i18next.t("mail.templates.alerts.removeEmailTemplateTitle"), | ||
type: "warning", | ||
showCancelButton: true, | ||
confirmButtonText: i18next.t("mail.templates.alerts.removeEmailTemplateConfirm", { title: this.title }) | ||
}, (isConfirm) => { | ||
if (isConfirm) { | ||
Meteor.call("templates/email/remove", $(event.currentTarget).data("template-id")); | ||
Reaction.hideActionView(); | ||
} | ||
}); | ||
}, | ||
|
||
// "click [data-event-action=duplicateEmailTemplate]"(event) { | ||
// event.preventDefault(); | ||
// event.stopPropagation(); | ||
// | ||
// Alerts.alert({ | ||
// title: i18next.t("mail.templates.alerts.duplicateEmailTemplateTitle"), | ||
// type: "warning", | ||
// showCancelButton: true, | ||
// confirmButtonText: i18next.t("mail.templates.alerts.duplicateEmailTemplateConfirm", { title: this.title }) | ||
// }, (isConfirm) => { | ||
// if (isConfirm) { | ||
// Meteor.call("templates/email/duplicate", $(event.currentTarget).data("template-id"), this); | ||
// Reaction.hideActionView(); | ||
// } | ||
// }); | ||
// }, | ||
|
||
"click [data-event-action=editEmailTemplate]"(event) { | ||
event.preventDefault(); | ||
|
||
Reaction.showActionView({ | ||
label: i18next.t("mail.templates.edit"), | ||
data: this, | ||
template: "emailTemplateSettings" | ||
}); | ||
|
||
// TODO: What does this do? | ||
Session.set("updatedMethodObj", ""); | ||
Session.set("selectedMethodObj", this); | ||
} | ||
}); | ||
|
||
|
||
/* | ||
* Template emailTemplatesSettings Helpers | ||
*/ | ||
Template.emailTemplateSettings.helpers({ | ||
emailTemplateSchema() { | ||
return EmailTemplates; | ||
} | ||
}); | ||
|
||
|
||
AutoForm.hooks({ | ||
"email-template-edit-form": { | ||
onSubmit: function (insertDoc) { | ||
this.event.preventDefault(); | ||
|
||
const templateId = this.docId; | ||
|
||
Meteor.call("templates/email/update", templateId, insertDoc, (error, result) => { | ||
if (error) { | ||
Alerts.toast(i18next.t("mail.templates.alerts.failedToUpdate", { err: error.message }), "error"); | ||
this.done(new Error("Failed to update template: ", error)); | ||
return false; | ||
} | ||
if (result) { | ||
this.done(); | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
|
||
Blaze.TemplateInstance.prototype.parentTemplate = function (levels = 1) { | ||
let view = Blaze.currentView; | ||
let numLevel = levels; | ||
while (view) { | ||
if (view.name.substring(0, 9) === "Template." && !numLevel--) { | ||
return view.templateInstance(); | ||
} | ||
view = view.parentView; | ||
} | ||
}; |
78 changes: 78 additions & 0 deletions
78
imports/plugins/core/templates/lib/collections/schemas/emailtemplates.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { SimpleSchema } from "meteor/aldeed:simple-schema"; | ||
import { Templates } from "/lib/collections"; | ||
|
||
|
||
/** | ||
* EmailTemplates Schema | ||
* TODO: Update schema with final fields when known | ||
*/ | ||
|
||
export const EmailTemplates = new SimpleSchema({ | ||
name: { | ||
type: String | ||
}, | ||
isOriginalTemplate: { | ||
type: Boolean, | ||
optional: true, | ||
defaultValue: false | ||
}, | ||
priority: { | ||
type: Number, | ||
optional: true, | ||
defaultValue: 1 | ||
}, | ||
enabled: { | ||
type: Boolean, | ||
defaultValue: true | ||
}, | ||
route: { | ||
type: String, | ||
optional: true | ||
}, | ||
audience: { | ||
type: [String], | ||
optional: true | ||
}, | ||
type: { | ||
type: String, | ||
defaultValue: "email" | ||
}, | ||
provides: { | ||
type: String, | ||
defaultValue: "template" | ||
}, | ||
block: { | ||
type: String, | ||
optional: true | ||
}, | ||
defaultData: { | ||
type: Object, | ||
blackbox: true, | ||
optional: true | ||
}, | ||
template: { | ||
type: String, | ||
optional: true | ||
}, | ||
parser: { | ||
type: String | ||
}, | ||
language: { | ||
type: String, | ||
optional: true, | ||
defaultValue: "en" | ||
}, | ||
source: { | ||
type: String, | ||
optional: true | ||
}, | ||
title: { | ||
type: String | ||
}, | ||
subject: { | ||
type: String, | ||
optional: true | ||
} | ||
}); | ||
|
||
Templates.attachSchema(EmailTemplates, { selector: { type: "email" } }); |
1 change: 1 addition & 0 deletions
1
imports/plugins/core/templates/lib/collections/schemas/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./emailtemplates"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Reaction } from "/server/api"; | ||
|
||
Reaction.registerPackage({ | ||
label: "Email", | ||
name: "reaction-templates", | ||
icon: "fa fa-columns", | ||
autoEnable: true, | ||
settings: { | ||
name: "Templates" | ||
}, | ||
registry: [{ | ||
route: "/dashboard/templates", | ||
provides: "dashboard", | ||
workflow: "coreEmailWorkflow", | ||
name: "Templates", | ||
label: "Templates", | ||
description: "App Templates", | ||
icon: "fa fa-columns", | ||
priority: 1, | ||
container: "appearance", | ||
template: "emailTemplatesDashboard" | ||
}, { | ||
label: "Edit Email Template", | ||
name: "templates/email", | ||
provides: "settings", | ||
template: "emailTemplateSettings" | ||
}], | ||
layout: [{ | ||
layout: "coreLayout", | ||
workflow: "coreEmailWorkflow", | ||
theme: "default", | ||
enabled: true, | ||
structure: { | ||
template: "email", | ||
layoutHeader: "layoutHeader", | ||
layoutFooter: "", | ||
notFound: "notFound", | ||
dashboardHeader: "dashboardHeader", | ||
// dashboardHeaderControls: "emailDashboardTabs", // removed until needed for nav tabs | ||
dashboardControls: "dashboardControls", | ||
adminControlsFooter: "adminControlsFooter" | ||
} | ||
}] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import "./methods"; | ||
import "../lib/collections/schemas/emailtemplates"; |
Oops, something went wrong.