Skip to content

Commit

Permalink
Fix unit tests, add online preview (Fixes #26)
Browse files Browse the repository at this point in the history
PHPCS clean up.
  • Loading branch information
wilr committed Aug 12, 2018
1 parent b69dc04 commit def77f2
Show file tree
Hide file tree
Showing 29 changed files with 849 additions and 538 deletions.
23 changes: 13 additions & 10 deletions _config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
*
* @package newsletter
*/
if(!(defined('NEWSLETTER_DIR'))) {
define('NEWSLETTER_DIR', basename(dirname(__FILE__)));
if (!(defined('NEWSLETTER_DIR'))) {
define('NEWSLETTER_DIR', basename(dirname(__FILE__)));
}

if (class_exists('MessageQueue')) {
MessageQueue::add_interface("default", array( "queues" => "/.*/",
"implementation" => "SimpleDBMQ",
"encoding" => "php_serialize",
"send" => array( "onShutdown" => "all" ),
"delivery" => array( "onerror" => array( "log" ) ),
"retrigger" => "yes", // on consume, retrigger if there are more items
"onShutdownMessageLimit" => "1" // one message per async process
));
MessageQueue::add_interface(
"default",
array( "queues" => "/.*/",
"implementation" => "SimpleDBMQ",
"encoding" => "php_serialize",
"send" => array( "onShutdown" => "all" ),
"delivery" => array( "onerror" => array( "log" ) ),
"retrigger" => "yes", // on consume, retrigger if there are more items
"onShutdownMessageLimit" => "1" // one message per async process
)
);
}

//SS_Log::add_writer(new SS_LogFileWriter(BASE_PATH . '/logN.txt'), SS_Log::NOTICE);
Expand Down
1 change: 1 addition & 0 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SilverStripe\CMS\Controllers\ContentController:
SilverStripe\Control\Director:
rules:
'newsletterlinks/$Hash': 'SilverStripe\Newsletter\Control\TrackLinkController'
'viewnewsletteronline/$ID!/$Hash!': 'SilverStripe\Newsletter\Control\NewsletterViewController'
'unsubscribe//$Action/$ValidateHash/$IDs': 'SilverStripe\Newsletter\Control\UnsubscribeController'
SilverStripe\Newsletter\Control\NewsletterAdmin:
extra_requirements_javascript:
Expand Down
110 changes: 64 additions & 46 deletions client/javascript/ActionOnConfirmation.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,70 @@
(function($){
/*"use strict";*/
$.entwine('ss', function($) {
$('#action_doSend').entwine({
onclick: function(e) {
var message = ss.i18n._t('NEWSLETTER.SENDCONFIRMMESSAGE',
'Are you sure you want to send this newsletter?');
if (confirm(message)) {
this._super(e);
} else {
e.preventDefault();
return false;
}
}
});
(function ($) {
/*"use strict";*/
$.entwine(
'ss',
function ($) {
$('#action_doSend').entwine(
{
onclick: function (e) {
var message = ss.i18n._t(
'NEWSLETTER.SENDCONFIRMMESSAGE',
'Are you sure you want to send this newsletter?'
);
if (confirm(message)) {
this._super(e);
} else {
e.preventDefault();
return false;
}
}
}
);

$("#Form_ItemEditForm_action_doDelete").entwine({
onclick: function(e) {
// customise confirm delete messages for clarity
var item = 'record';
var pageAction = $('#Form_ItemEditForm').attr('action');
if(pageAction.indexOf('ItemEditForm/field/Recipients/item/') != -1){
item = 'Recipient';
}else if(pageAction.indexOf('admin/newsletter/MailingList/EditForm/field/MailingList/') == 0){
item = 'Mailing List';
}
var message = ss.i18n._t('NEWSLETTERADMIN.DELETECONFIRMMESSAGE',
'Are you sure you want to delete this '+item+'?');

if (confirm(message)) {
this._super(e);
} else {
e.preventDefault();
return false;
}
}
});
$("#Form_ItemEditForm_action_doDelete").entwine(
{
onclick: function (e) {
// customise confirm delete messages for clarity
var item = 'record';
var pageAction = $('#Form_ItemEditForm').attr('action');
if (pageAction.indexOf('ItemEditForm/field/Recipients/item/') != -1) {
item = 'Recipient';
} else if (pageAction.indexOf('admin/newsletter/MailingList/EditForm/field/MailingList/') == 0) {
item = 'Mailing List';
}
var message = ss.i18n._t(
'NEWSLETTERADMIN.DELETECONFIRMMESSAGE',
'Are you sure you want to delete this '+item+'?'
);

if (confirm(message)) {
this._super(e);
} else {
e.preventDefault();
return false;
}
}
}
);

/** Hide the success message when the other tab is clicked */
$('.message.good').entwine({
onmatch: function() {
var self = this;
$('a[href$="Root_SentTo"]').on('click', function(e){
self.hide();
});
}
/**
* Hide the success message when the other tab is clicked
*/
$('.message.good').entwine(
{
onmatch: function () {
var self = this;
$('a[href$="Root_SentTo"]').on(
'click',
function (e) {
self.hide();
}
);
}

});
}
);

});
}
);

}(jQuery));
79 changes: 44 additions & 35 deletions client/javascript/CheckboxSetWithExtraField.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,46 @@

(function($){
$.entwine('ss', function($) {
$('table.checkboxsetwithextrafield').entwine({
UUID: null,
onmatch: function() {
this._super();
this.tableDnD({
onDragClass: "DnD_whiledragging",
dragHandle: ".dragHandle",
onDragStart: function(table, row) {
indicator = document.createElement('div');
$(indicator).html('Moving ...');
$(row).append($(indicator));
},
onDrop:function(table, row){
jQuery($(row).find(".dragHandle")[0]).empty();
}
});
},
onunmatch: function() {
this._super();
}
});
$('table.checkboxsetwithextrafield tbody tr').entwine({
onmouseover: function() {
jQuery($(this).children(".dragHandle")[0]).addClass('showDragHandle');
},
onmouseout: function() {
jQuery($(this).children(".dragHandle")[0]).removeClass('showDragHandle');
},
onmouseup: function() {
jQuery($(this).find(".dragHandle")[0]).empty();
}
});
});
(function ($) {
$.entwine(
'ss',
function ($) {
$('table.checkboxsetwithextrafield').entwine(
{
UUID: null,
onmatch: function () {
this._super();
this.tableDnD(
{
onDragClass: "DnD_whiledragging",
dragHandle: ".dragHandle",
onDragStart: function (table, row) {
indicator = document.createElement('div');
$(indicator).html('Moving ...');
$(row).append($(indicator));
},
onDrop:function (table, row) {
jQuery($(row).find(".dragHandle")[0]).empty();
}
}
);
},
onunmatch: function () {
this._super();
}
}
);
$('table.checkboxsetwithextrafield tbody tr').entwine(
{
onmouseover: function () {
jQuery($(this).children(".dragHandle")[0]).addClass('showDragHandle');
},
onmouseout: function () {
jQuery($(this).children(".dragHandle")[0]).removeClass('showDragHandle');
},
onmouseup: function () {
jQuery($(this).find(".dragHandle")[0]).empty();
}
}
);
}
);
}(jQuery));
38 changes: 21 additions & 17 deletions client/javascript/NewsletterAdminEmailPreview.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
(function($){
"use strict";
(function ($) {
"use strict";

$.entwine('ss', function($) {
$('#Form_ItemEditForm_action_doSendPreview').entwine({
onclick: function(e) {
var prompt = this.sendPrompt();
$.entwine(
'ss',
function ($) {
$('#Form_ItemEditForm_action_doSendPreview').entwine(
{
onclick: function (e) {
var prompt = this.sendPrompt();

if (prompt !== null) {
if (prompt !== null) {
}

}

return false;
},
sendPrompt: function() {
var message = 'Send a test email to:';
return false;
},
sendPrompt: function () {
var message = 'Send a test email to:';

return prompt(message);
}
});
});
return prompt(message);
}
}
);
}
);
}(jQuery));
64 changes: 36 additions & 28 deletions client/javascript/SubscriptionPage.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
(function($) {
/*"use strict";*/
(function ($) {
/*"use strict";*/

$.entwine('ss', function($) {
$('#SendNotificationControlls ul li').entwine({
onmatch: function() {
this._super();
if($('#Form_EditForm_SendNotification').val()==='0'){
$('.SendNotificationControlledPanel').hide();
if (this.hasClass('no')) this.addClass('active');
}else{
$('.SendNotificationControlledPanel').show();
if (this.hasClass('yes')) this.addClass('active');
}
},
$.entwine(
'ss',
function ($) {
$('#SendNotificationControlls ul li').entwine(
{
onmatch: function () {
this._super();
if ($('#Form_EditForm_SendNotification').val()==='0') {
$('.SendNotificationControlledPanel').hide();
if (this.hasClass('no')) {
this.addClass('active');
}
} else {
$('.SendNotificationControlledPanel').show();
if (this.hasClass('yes')) {
this.addClass('active');
}
}
},

onclick: function(e) {
this.addClass('active');
this.siblings('.active').removeClass('active');
onclick: function (e) {
this.addClass('active');
this.siblings('.active').removeClass('active');

if(this.hasClass('yes')){
$('.SendNotificationControlledPanel').show();
$('#Form_EditForm_SendNotification').val('1');

}else{
$('.SendNotificationControlledPanel').hide();
$('#Form_EditForm_SendNotification').val('0');
}
}
});
});
if (this.hasClass('yes')) {
$('.SendNotificationControlledPanel').show();
$('#Form_EditForm_SendNotification').val('1');
} else {
$('.SendNotificationControlledPanel').hide();
$('#Form_EditForm_SendNotification').val('0');
}
}
}
);
}
);
}(jQuery));
Loading

0 comments on commit def77f2

Please sign in to comment.