From f3af44fab0b5d59f33e2aebfd75f06a2fd230589 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Tue, 10 Jan 2017 14:46:09 +0000 Subject: [PATCH 1/4] add on-success and on-error handlers to async-form. --- services/web/public/coffee/directives/asyncForm.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/web/public/coffee/directives/asyncForm.coffee b/services/web/public/coffee/directives/asyncForm.coffee index 2c6345d878..b3e13e8d61 100644 --- a/services/web/public/coffee/directives/asyncForm.coffee +++ b/services/web/public/coffee/directives/asyncForm.coffee @@ -33,6 +33,10 @@ define [ response.success = true response.error = false + if onSuccessHandler = scope[attrs.onSuccess] + onSuccessHandler(data, status, headers, config) + return + if data.redir? ga('send', 'event', formName, 'success') window.location = data.redir @@ -50,6 +54,11 @@ define [ scope[attrs.name].inflight = false response.success = false response.error = true + + if onErrorHandler = scope[attrs.onError] + onErrorHandler(data, status, headers, config) + return + if status == 403 # Forbidden response.message = text: "Session error. Please check you have cookies enabled. If the problem persists, try clearing your cache and cookies." From 70c7e32e589e4f5f567a04fb2b5e2ff8351ef3f9 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Tue, 17 Jan 2017 10:52:04 +0000 Subject: [PATCH 2/4] Add a 'testEmail' email type --- .../coffee/Features/Email/EmailBuilder.coffee | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/services/web/app/coffee/Features/Email/EmailBuilder.coffee b/services/web/app/coffee/Features/Email/EmailBuilder.coffee index 306aad3d2a..1aa6f2e413 100644 --- a/services/web/app/coffee/Features/Email/EmailBuilder.coffee +++ b/services/web/app/coffee/Features/Email/EmailBuilder.coffee @@ -123,8 +123,6 @@ Thank you description: "Join #{ opts.project.name } at ShareLaTeX" }) - - templates.completeJoinGroupAccount = subject: _.template "Verify Email to join <%= group_name %> group" layout: BaseWithHeaderEmailLayout @@ -149,6 +147,21 @@ Thank You gmailGoToAction: null }) +templates.testEmail = + subject: _.template "Test Email from ShareLaTeX" + layout: PersonalEmailLayout + type: 'notification' + plainTextTemplate: _.template """ +Hi, + +This is a test email, from ShareLaTeX. + +#{settings.appName} - <%= siteUrl %> +""" + compiledTemplate: _.template """ +

This is a test email, from ShareLaTeX.

+ """ + module.exports = templates: templates @@ -163,4 +176,4 @@ module.exports = html: template.layout(opts) text: template?.plainTextTemplate?(opts) type:template.type - } \ No newline at end of file + } From 8922c9dbf57d8fbe55650d467457a3706c041ae0 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Wed, 18 Jan 2017 15:28:51 +0000 Subject: [PATCH 3/4] New email layout for "testEmail" --- .../coffee/Features/Email/EmailBuilder.coffee | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/services/web/app/coffee/Features/Email/EmailBuilder.coffee b/services/web/app/coffee/Features/Email/EmailBuilder.coffee index 1aa6f2e413..0a06a2a175 100644 --- a/services/web/app/coffee/Features/Email/EmailBuilder.coffee +++ b/services/web/app/coffee/Features/Email/EmailBuilder.coffee @@ -147,20 +147,29 @@ Thank You gmailGoToAction: null }) + templates.testEmail = - subject: _.template "Test Email from ShareLaTeX" - layout: PersonalEmailLayout - type: 'notification' + subject: _.template "A Test Email from ShareLaTeX" + layout: BaseWithHeaderEmailLayout + type:"notification" plainTextTemplate: _.template """ Hi, -This is a test email, from ShareLaTeX. +This is a test email sent from ShareLaTeX. #{settings.appName} - <%= siteUrl %> """ - compiledTemplate: _.template """ -

This is a test email, from ShareLaTeX.

- """ + compiledTemplate: (opts) -> + SingleCTAEmailBody({ + title: "A Test Email from ShareLaTeX" + greeting: "Hi," + message: "This is a test email sent from ShareLaTeX" + secondaryMessage: null + ctaText: "Open ShareLaTeX" + ctaURL: "/" + gmailGoToAction: null + }) + module.exports = templates: templates From 36eb453aed4b3cc7fd407429116f94926cdca2ad Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 20 Jan 2017 13:52:31 +0000 Subject: [PATCH 4/4] Clarify logic of asyncform onsuccess and onerror handlers --- services/web/public/coffee/directives/asyncForm.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/web/public/coffee/directives/asyncForm.coffee b/services/web/public/coffee/directives/asyncForm.coffee index b3e13e8d61..d9ca11231b 100644 --- a/services/web/public/coffee/directives/asyncForm.coffee +++ b/services/web/public/coffee/directives/asyncForm.coffee @@ -33,7 +33,8 @@ define [ response.success = true response.error = false - if onSuccessHandler = scope[attrs.onSuccess] + onSuccessHandler = scope[attrs.onSuccess] + if onSuccessHandler onSuccessHandler(data, status, headers, config) return @@ -55,7 +56,8 @@ define [ response.success = false response.error = true - if onErrorHandler = scope[attrs.onError] + onErrorHandler = scope[attrs.onError] + if onErrorHandler onErrorHandler(data, status, headers, config) return