Compare commits
610 Commits
0.0.33
...
3.0.0-beta
Author | SHA1 | Date | |
---|---|---|---|
1220f47d87 | |||
583b34a5c1 | |||
b36d13a087 | |||
1a3aa7a4e4 | |||
6ce13df2f3 | |||
4eb85c5d7e | |||
6eb6636e8b | |||
9635fb5365 | |||
d4b39cb1f4 | |||
af36e7a0d9 | |||
1db8626e35 | |||
61c255564f | |||
7e5047d98f | |||
4698d5a4db | |||
864c9cbe95 | |||
011b6f9b3c | |||
e45fc0c0a0 | |||
6bebdd6e95 | |||
8df4da768a | |||
67f4c21aa8 | |||
5eba0e2731 | |||
3efa429a1b | |||
3a78441a83 | |||
c05be7d987 | |||
b8cb1da777 | |||
ac8d1d808f | |||
9cd7b1a204 | |||
0d32c09df3 | |||
9f288ae11a | |||
e87ccd6b92 | |||
8a2b6ac69b | |||
43bd2d4413 | |||
9fdb99a06b | |||
f3c69c8353 | |||
29a32d3da9 | |||
8412cc852d | |||
b4e4320508 | |||
dbd6e6f310 | |||
bdcb7f0e58 | |||
85c9b121f5 | |||
069bc95297 | |||
0b711e6341 | |||
2a961cca01 | |||
e855fdbbaf | |||
288464e8cb | |||
1331ed70f1 | |||
411188c345 | |||
ee275532b1 | |||
b2eef93516 | |||
40ca54c447 | |||
b65db1afbf | |||
c258b1c3a2 | |||
7a5a726400 | |||
e553922eca | |||
04e9e8a45d | |||
f037e1271d | |||
f4563e18cd | |||
feaac5eb54 | |||
a6059d5bc3 | |||
f2104ef30f | |||
e7f760328e | |||
c09bcd51ad | |||
01af4d3401 | |||
2ba9d95a2e | |||
b2d4bfc760 | |||
57f5f16bb6 | |||
7d2e13b9a3 | |||
6d39f9fa78 | |||
a4395f2350 | |||
411969b3eb | |||
1868ca3155 | |||
e765471f5d | |||
bdce7c5e5a | |||
773be9f5c8 | |||
6ae46b05e5 | |||
217894745d | |||
a03891895c | |||
3368e84a99 | |||
e90df2f08d | |||
2391ae1cad | |||
83114a8be4 | |||
d08d5a3b6c | |||
8330bfc884 | |||
ef21a8cca7 | |||
e32c46a755 | |||
092f69538a | |||
7a75367d75 | |||
0b2701ade2 | |||
1ac288d286 | |||
516bc73092 | |||
4088abef68 | |||
f6cefc3f5c | |||
202e4b90e1 | |||
ee89bf0722 | |||
876d21300a | |||
0ca5b7a79f | |||
5d0ee43921 | |||
cc523a3c0b | |||
2787998d32 | |||
38f6c95059 | |||
cc03b631ff | |||
a3c77fb685 | |||
3817e28960 | |||
c3a78b1ea3 | |||
42877236c8 | |||
6e87f3539c | |||
7704ea4b68 | |||
12a3931b7b | |||
25a55dbb67 | |||
6758f60a81 | |||
5e9e53ec41 | |||
1285252a8c | |||
98f95f72ad | |||
09ca788371 | |||
b48cc5a959 | |||
812d138c4e | |||
07bc35d4cd | |||
90b95a2c25 | |||
78c50c41e3 | |||
7eee7def63 | |||
9ba6e9806f | |||
8c28dc3d8a | |||
9197e39fb4 | |||
37f59814e5 | |||
bf894fc26f | |||
0b2b42cf4d | |||
542015a4f6 | |||
f5a8323f5d | |||
55942cd88b | |||
f26a2cbd26 | |||
4402f826c3 | |||
b9745b555a | |||
f923a8063b | |||
f4367b9146 | |||
a3395e41c9 | |||
be61135daf | |||
21b4187a11 | |||
1c3c1e35e7 | |||
ded373557e | |||
280c4762bb | |||
bbd02260be | |||
1b1e9abd68 | |||
b0ab9e0408 | |||
d32abff78d | |||
7fbf84db1f | |||
8c5aebc7d6 | |||
42202f676a | |||
ba6198f956 | |||
120af4170b | |||
1faa53b978 | |||
e565a7a234 | |||
90b6b57a8d | |||
548253d68e | |||
e1c5f609ff | |||
226befdef6 | |||
a9d57654b4 | |||
ed00ae0516 | |||
48d738e8c4 | |||
132b4ed2e8 | |||
9a513cb27b | |||
5d692c0395 | |||
991ab67fff | |||
dd00640119 | |||
fa04173cfb | |||
a328d3b48a | |||
d5cff4f0d3 | |||
52bf24b6db | |||
50e134d696 | |||
ea5c73721b | |||
4799882b80 | |||
2e4c5ca39a | |||
13ed3aa3b9 | |||
6091751a4b | |||
c4d9e85dff | |||
1a85914c1b | |||
0ba48234de | |||
1c2a532949 | |||
9087be6ee8 | |||
5b2ede8b83 | |||
2fa5e5ead2 | |||
d5107be65e | |||
379dfb5f6e | |||
8360377992 | |||
4538cab6c8 | |||
1bf0988297 | |||
e1caf49ea5 | |||
0dfae97b32 | |||
ef2187c175 | |||
6157d17c5b | |||
8e879047c2 | |||
bff6aecd0d | |||
a121583c2d | |||
e11fd66fec | |||
b37e85eeb5 | |||
f88dabffe8 | |||
8c436180d9 | |||
b834a6af4d | |||
1bd8aed192 | |||
cfdf72867e | |||
5888620fc1 | |||
55ba605eb0 | |||
7a73ca7d1a | |||
1918894c5c | |||
0c5589a3e3 | |||
d6eaa4ac8a | |||
b0571b97f5 | |||
6d51ca8011 | |||
d3289dfb84 | |||
bfffdd7274 | |||
c5b8b2aef0 | |||
d7bcf1b817 | |||
f30ed153ce | |||
f436088a16 | |||
db8cb7499d | |||
49c4adc754 | |||
405e743171 | |||
3508ac36b4 | |||
f17c8228cd | |||
3dd5ac0536 | |||
4ebdff49e0 | |||
4a72995bf4 | |||
ef27ac0b84 | |||
2b4adef6c2 | |||
f650455a90 | |||
afbe25e215 | |||
d93249f077 | |||
6223ef77d9 | |||
a423123b66 | |||
1b3d3082b0 | |||
fa117cc7dd | |||
acd407c1f1 | |||
9baf4b068f | |||
18d852e147 | |||
b8dc306741 | |||
6ea056c042 | |||
bcf1b37c6a | |||
2986cdba85 | |||
53a8ae74e2 | |||
8bab01506c | |||
c664045444 | |||
6b8149210d | |||
f31d30b318 | |||
d9fbbdc02d | |||
8136ee2d9b | |||
f7cf6e2131 | |||
f2d1787bd5 | |||
fb51765d3f | |||
088ad5fb42 | |||
2f5b3c0c0a | |||
04ac4d896c | |||
f3b96af863 | |||
eb42b0b98d | |||
304667eb49 | |||
dad1082cd7 | |||
37cf0f3d29 | |||
d61c6dff58 | |||
3734ac578d | |||
b3f56c9d8e | |||
3603eeee77 | |||
59d30cc139 | |||
6ff3bbbb72 | |||
a561e10156 | |||
99f2cf6702 | |||
c6b72e729b | |||
c5bc0f36a4 | |||
efc5c34bf9 | |||
3929efbdd9 | |||
0e0c41882e | |||
79cc708fc6 | |||
8fa98879b8 | |||
331ba385e9 | |||
71ce46d78d | |||
c493de6569 | |||
ff2c2ace86 | |||
7fa789cfd1 | |||
ae6269eb63 | |||
a8f4779bfe | |||
6868142e35 | |||
133d123919 | |||
05c128d12d | |||
bdab0c12fa | |||
75b94690e2 | |||
80fddd6c58 | |||
c807ead5fd | |||
f004bb5368 | |||
1d756e95a7 | |||
1fb0da9fda | |||
a0017b91ee | |||
444ab17342 | |||
44f3058326 | |||
ec09fbcb78 | |||
ed352bb1d3 | |||
375bbd2759 | |||
9fb9d25132 | |||
30f79aa589 | |||
69f8daac95 | |||
03f3a6080c | |||
44f84c6cdb | |||
31008a6895 | |||
2490d8c919 | |||
5886dbfd25 | |||
e48d55f0b1 | |||
42339927cf | |||
b492bcecc0 | |||
6ab7debb7b | |||
b76ce6c26f | |||
6fbc7b1593 | |||
69c8670b01 | |||
da44a87415 | |||
9fb17d4a6b | |||
16dd286f9d | |||
5025f10f9f | |||
1278d9648c | |||
289811a595 | |||
916ae97f73 | |||
876e386966 | |||
9582e58dda | |||
213bca8050 | |||
dc97d3115e | |||
90eb443965 | |||
1b40f02715 | |||
c5a02c6136 | |||
492cd8c96b | |||
7f091d7188 | |||
1c081623b9 | |||
87332037c2 | |||
62023397f4 | |||
37ec6dc1a6 | |||
81c277ca93 | |||
f8fea75130 | |||
a4457649f7 | |||
1d6a09f010 | |||
faec553521 | |||
37fcf3a234 | |||
68a56aada8 | |||
f744305834 | |||
7a9402f5b5 | |||
de6d7e0cae | |||
a3c56b84ce | |||
3d4defd563 | |||
52da08abb2 | |||
b9637b52e9 | |||
0369a23fe8 | |||
f690e1a095 | |||
22e8e34213 | |||
12b46736c5 | |||
4950e47297 | |||
d7c5c8c3e7 | |||
46b0fcf37b | |||
b07c4d0e6e | |||
eb107799a7 | |||
4eec0a42f9 | |||
9a5a3a08c6 | |||
151683c632 | |||
fd2103d1aa | |||
7696b6ec5d | |||
d972b96255 | |||
35ccfb8bcf | |||
7ff036b1e9 | |||
983d56c29b | |||
a2528939ba | |||
c136d91dd2 | |||
bf00e82596 | |||
0e10f6c820 | |||
c056e95249 | |||
1be7fda1cf | |||
0b0c0f5759 | |||
59a4428965 | |||
3f5c36d2d4 | |||
3cc5812c1d | |||
3e616201ad | |||
5558ebad45 | |||
63bd093f35 | |||
ec6559b8be | |||
3421406dc7 | |||
a2917c08f6 | |||
5fa9b5a8dd | |||
41ad86ba1f | |||
067b3ff3e6 | |||
9b9cb1455a | |||
a5569a6a55 | |||
71c1026729 | |||
f102e847bf | |||
3158e2c460 | |||
a438f13bb0 | |||
5ed0a5819c | |||
6dd3c6acda | |||
ca2c1c2e6f | |||
1305a10ee0 | |||
5e36eb818b | |||
cfde82ff5f | |||
af98ade650 | |||
598432466e | |||
9469ce83f1 | |||
5624f4c7a0 | |||
82a001dc05 | |||
a9b424fb79 | |||
d31af9d71c | |||
ff7a24590f | |||
ea87a7acf8 | |||
9d36a17261 | |||
9c3cb5a509 | |||
4dd7f32f3a | |||
1c6fca7f83 | |||
c5b376bd21 | |||
5d2800bc25 | |||
6675d5a20d | |||
28c39d301c | |||
afa0d3af63 | |||
b05344b1d3 | |||
2e88d7cce0 | |||
cb558ce2ab | |||
ed30d8f639 | |||
9410d4f10a | |||
354d249e1d | |||
008fdb94c5 | |||
d0fb94b3f8 | |||
a451f00ed3 | |||
0e0c371b28 | |||
2e52f3bb92 | |||
a3a5016278 | |||
cb5d7cb9a0 | |||
a44d4ed0b5 | |||
7bd23288f6 | |||
08c663759c | |||
c46ee07674 | |||
18398a3bfb | |||
88d9315f8b | |||
8bc95db0c9 | |||
c05a20cff9 | |||
08cb994252 | |||
543ad81e28 | |||
641ba04685 | |||
8e4d07c658 | |||
420650f37f | |||
775f7faee4 | |||
13b91ad051 | |||
2d3ec13473 | |||
3094cfc076 | |||
6aadd1fdc4 | |||
13589a4660 | |||
5f124659d0 | |||
d3ebc9706c | |||
e83d01ff28 | |||
9600e4f220 | |||
3e746d1545 | |||
3cc43aa302 | |||
c610d87e85 | |||
362ee49ce4 | |||
515515ba9f | |||
ed7da1a8fe | |||
12c036dbef | |||
1dd4ade04d | |||
0706450f9a | |||
b837a153d1 | |||
6d22a85fd7 | |||
3d706414b7 | |||
ef0cbb3e9f | |||
f5552847a3 | |||
101ef0cff4 | |||
9e70ba5e6e | |||
8f1a7ed3de | |||
6aa976ba1f | |||
db85604f18 | |||
7605fc71ac | |||
2c98270084 | |||
a5300624c2 | |||
2714c7fa9a | |||
49b65729db | |||
e053b62a70 | |||
88113cf22e | |||
5bf352e9fc | |||
5a7d5ac3f0 | |||
05848ce7aa | |||
b58d996ac7 | |||
16fa4491a5 | |||
456deede14 | |||
4ef50ca551 | |||
5ff7d98b00 | |||
3018dff1ff | |||
9386fe8328 | |||
e4213437e9 | |||
386bdceed3 | |||
87eda71931 | |||
cef9f1dcf8 | |||
c78b2088eb | |||
150364de3a | |||
1cd9f3eb67 | |||
89253125af | |||
e7ee356f90 | |||
a88017400b | |||
f557881462 | |||
8dba4727c4 | |||
8ec094089f | |||
3c353e715b | |||
ab33a9c352 | |||
406b509ac4 | |||
bd814baf28 | |||
2db681d908 | |||
37e3af584e | |||
5fc863bd82 | |||
76649f9590 | |||
cb2faec8b2 | |||
e8604284fe | |||
d2ccdef6c7 | |||
38199dc96f | |||
630b219e96 | |||
64155bc121 | |||
7fb45a15ee | |||
ed5294477f | |||
d152b073a6 | |||
f8efb3934b | |||
5a21d3fdc8 | |||
710ede15ce | |||
150286ab6b | |||
9e758e8a33 | |||
059165e5d2 | |||
fe154d9251 | |||
a8ffbc2d0e | |||
9de3a245b0 | |||
5eef709af5 | |||
7b0c130d0a | |||
7f265675b0 | |||
ba15db9829 | |||
d15473a8e4 | |||
d9f93dc6e7 | |||
634c5b699d | |||
23e8ce38dd | |||
c62ae2ce80 | |||
d0813bb4e2 | |||
0ac701eb20 | |||
607395be6f | |||
55d48df8a4 | |||
e0282ae45b | |||
235fdea00f | |||
b8c6d54f48 | |||
67661e3aad | |||
c03facdc45 | |||
9ddc1ef555 | |||
9cfc2fd940 | |||
24e108bce7 | |||
48f0c03425 | |||
0bfbe6dc79 | |||
ad0a9838bc | |||
81ec293e54 | |||
b8b3d76a1d | |||
805e641d40 | |||
18326f9df1 | |||
46dda84012 | |||
9979261cb6 | |||
e8887e2aa5 | |||
4a91fae984 | |||
0fe975f614 | |||
c7fd7b8a32 | |||
b7e3c3ae81 | |||
b2c3206185 | |||
b7d8d482fe | |||
8a9d14319b | |||
c396254e64 | |||
e4dbeca664 | |||
168540d6d2 | |||
c62cd6c023 | |||
033e0581f1 | |||
9f978d3362 | |||
841340a42d | |||
9595e9629f | |||
56ba543f8d | |||
1cead6c6cd | |||
f5f7ce4c42 | |||
b13075b8f2 | |||
c4db9e3227 | |||
f47bfb5439 | |||
cc4639cb23 | |||
69094f57fd | |||
ffe7b80888 | |||
fc846b808e | |||
1cbf6b67b2 | |||
286c02bdd9 | |||
5f1d76225b | |||
c05ea1b968 | |||
2d45ab2e88 | |||
ca9b1e25a7 | |||
2927875e16 | |||
486a97fa30 | |||
c22d434dff | |||
306cdeb68f | |||
7ee83dad06 | |||
d414313749 | |||
66d329f630 | |||
f524ffcb28 | |||
264b7e180b | |||
88dc7f4199 | |||
9652f75028 | |||
36c32db2d1 | |||
fd12bd557e | |||
7bd8ed4639 | |||
ca0e511efd | |||
e5f3fabcda | |||
efc9bac760 | |||
ce6327c3d5 | |||
f32d6bb331 | |||
e807aad814 | |||
b87754ca30 | |||
22dfb372ec | |||
674bbd728e | |||
68c09b8678 | |||
c83ab0886f | |||
999a0b3ede | |||
6daecd6466 | |||
7af2775972 |
15
.circle_ci/apache/mailpoet.loc.conf
Normal file
@ -0,0 +1,15 @@
|
||||
Listen 8080
|
||||
|
||||
<VirtualHost *:8080>
|
||||
UseCanonicalName Off
|
||||
ServerName mailpoet.loc
|
||||
DocumentRoot /home/ubuntu/mailpoet/wordpress
|
||||
DirectoryIndex index.php
|
||||
LogLevel notice
|
||||
|
||||
<Directory /home/ubuntu/mailpoet/wordpress>
|
||||
AllowOverride All
|
||||
Allow from All
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
|
3
.gitignore
vendored
@ -12,8 +12,9 @@ npm-debug.log
|
||||
/views/cache/**
|
||||
temp
|
||||
.idea
|
||||
wysija-newsletters.zip
|
||||
mailpoet.zip
|
||||
tests/javascript/testBundles
|
||||
assets/css/*.css
|
||||
assets/js/*.js
|
||||
.vagrant
|
||||
lang
|
104
RoboFile.php
@ -3,14 +3,21 @@
|
||||
class RoboFile extends \Robo\Tasks {
|
||||
|
||||
function install() {
|
||||
$this->_exec('./composer.phar install');
|
||||
$this->_exec('npm install');
|
||||
return $this->taskExecStack()
|
||||
->stopOnFail()
|
||||
->exec('./composer.phar install')
|
||||
->exec('npm install')
|
||||
->run();
|
||||
}
|
||||
|
||||
function update() {
|
||||
$this->say(getenv('WP_TEST_URL'));
|
||||
$this->_exec('./composer.phar update');
|
||||
$this->_exec('npm update');
|
||||
|
||||
return $this->taskExecStack()
|
||||
->stopOnFail()
|
||||
->exec('./composer.phar update')
|
||||
->exec('npm update')
|
||||
->run();
|
||||
}
|
||||
|
||||
protected function rsearch($folder, $extensions = array()) {
|
||||
@ -61,12 +68,14 @@ class RoboFile extends \Robo\Tasks {
|
||||
}
|
||||
|
||||
function compileAll() {
|
||||
$this->compileJs();
|
||||
$this->compileCss();
|
||||
$collection = $this->collection();
|
||||
$collection->add(array($this, 'compileJs'));
|
||||
$collection->add(array($this, 'compileCss'));
|
||||
return $collection->run();
|
||||
}
|
||||
|
||||
function compileJs() {
|
||||
$this->_exec('./node_modules/webpack/bin/webpack.js');
|
||||
return $this->_exec('./node_modules/webpack/bin/webpack.js --bail');
|
||||
}
|
||||
|
||||
function compileCss() {
|
||||
@ -78,7 +87,7 @@ class RoboFile extends \Robo\Tasks {
|
||||
'assets/css/src/importExport.styl'
|
||||
);
|
||||
|
||||
$this->_exec(join(' ', array(
|
||||
return $this->_exec(join(' ', array(
|
||||
'./node_modules/stylus/bin/stylus',
|
||||
'--include ./node_modules',
|
||||
'--include-css',
|
||||
@ -89,60 +98,109 @@ class RoboFile extends \Robo\Tasks {
|
||||
}
|
||||
|
||||
function makepot() {
|
||||
$this->_exec('./node_modules/.bin/grunt makepot'.
|
||||
return $this->_exec('./node_modules/.bin/grunt makepot'.
|
||||
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
|
||||
' --base_path '.__DIR__
|
||||
);
|
||||
}
|
||||
|
||||
function pushpot() {
|
||||
$this->_exec('./node_modules/.bin/grunt pushpot'.
|
||||
return $this->_exec('./node_modules/.bin/grunt pushpot'.
|
||||
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
|
||||
' --base_path '.__DIR__
|
||||
);
|
||||
}
|
||||
|
||||
function testUnit($file = null) {
|
||||
function testUnit($opts=['file' => null, 'xml' => false]) {
|
||||
$this->loadEnv();
|
||||
$this->_exec('vendor/bin/codecept build');
|
||||
$this->_exec('vendor/bin/codecept run unit -f '.(($file) ? $file : ''));
|
||||
|
||||
$command = 'vendor/bin/codecept run unit -f '.(($opts['file']) ? $opts['file'] : '');
|
||||
|
||||
if($opts['xml']) {
|
||||
$command .= ' --xml';
|
||||
}
|
||||
return $this->_exec($command);
|
||||
}
|
||||
|
||||
function testCoverage($file = null) {
|
||||
function testCoverage($opts=['file' => null, 'xml' => false]) {
|
||||
$this->loadEnv();
|
||||
$this->_exec('vendor/bin/codecept build');
|
||||
$this->_exec(join(' ', array(
|
||||
$command = join(' ', array(
|
||||
'vendor/bin/codecept run',
|
||||
(($file) ? $file : ''),
|
||||
(($opts['file']) ? $opts['file'] : ''),
|
||||
'--coverage',
|
||||
'--coverage-html'
|
||||
)));
|
||||
($opts['xml']) ? '--coverage-xml' : '--coverage-html'
|
||||
));
|
||||
|
||||
if($opts['xml']) {
|
||||
$command .= ' --xml';
|
||||
}
|
||||
return $this->_exec($command);
|
||||
}
|
||||
|
||||
function testJavascript() {
|
||||
function testJavascript($xml_output_file = null) {
|
||||
$this->compileJs();
|
||||
|
||||
$this->_exec(join(' ', array(
|
||||
$command = join(' ', array(
|
||||
'./node_modules/.bin/mocha',
|
||||
'-r tests/javascript/mochaTestHelper.js',
|
||||
'tests/javascript/testBundles/**/*.js'
|
||||
)));
|
||||
));
|
||||
|
||||
if(!empty($xml_output_file)) {
|
||||
$command .= sprintf(
|
||||
' --reporter xunit --reporter-options output="%s"',
|
||||
$xml_output_file
|
||||
);
|
||||
}
|
||||
|
||||
return $this->_exec($command);
|
||||
}
|
||||
|
||||
function testDebug() {
|
||||
$this->_exec('vendor/bin/codecept build');
|
||||
$this->loadEnv();
|
||||
$this->_exec('vendor/bin/codecept run unit --debug');
|
||||
return $this->_exec('vendor/bin/codecept run unit --debug');
|
||||
}
|
||||
|
||||
function testFailed() {
|
||||
$this->loadEnv();
|
||||
$this->_exec('vendor/bin/codecept build');
|
||||
$this->_exec('vendor/bin/codecept run -g failed');
|
||||
return $this->_exec('vendor/bin/codecept run -g failed');
|
||||
}
|
||||
|
||||
function qa() {
|
||||
$collection = $this->collection();
|
||||
$collection->add(array($this, 'qaLint'));
|
||||
$collection->add(function() {
|
||||
return $this->qaCodeSniffer('all');
|
||||
});
|
||||
return $collection->run();
|
||||
}
|
||||
|
||||
function qaLint() {
|
||||
return $this->_exec('./tasks/php_lint.sh lib/ tests/ mailpoet.php');
|
||||
}
|
||||
|
||||
function qaCodeSniffer($severity='errors') {
|
||||
if ($severity === 'all') {
|
||||
$severityFlag = '-w';
|
||||
} else {
|
||||
$severityFlag = '-n';
|
||||
}
|
||||
return $this->_exec(
|
||||
'./vendor/bin/phpcs '.
|
||||
'--standard=./tasks/code_sniffer/MailPoet '.
|
||||
'--ignore=./lib/Util/Sudzy/*,./lib/Util/CSS.php,./lib/Util/XLSXWriter.php,'.
|
||||
'./lib/Config/PopulatorData/Templates/* '.
|
||||
'lib/ '.
|
||||
$severityFlag
|
||||
);
|
||||
}
|
||||
|
||||
protected function loadEnv() {
|
||||
$dotenv = new Dotenv\Dotenv(__DIR__);
|
||||
$dotenv->load();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,15 @@
|
||||
$box-width = 425px
|
||||
$box-height = 150px
|
||||
$thumbnail-width = $box-height
|
||||
$thumbnail-height = $thumbnail-width
|
||||
$box-description-space-between-heading-and-paragraph = 5px
|
||||
$box-description-height = 110px
|
||||
$box-description-text-height = $box-description-height - $box-description-space-between-heading-and-paragraph
|
||||
$box-heading-line-height = $box-description-text-height / 4
|
||||
$box-heading-font-size = $box-heading-line-height * 5/7
|
||||
$box-description-line-height = $box-heading-line-height / 2
|
||||
$box-description-font-size = $box-description-line-height
|
||||
|
||||
.mailpoet_boxes.mailpoet_boxes_loading
|
||||
opacity: 0.2
|
||||
|
||||
@ -6,8 +18,8 @@
|
||||
position: relative
|
||||
padding: 15px
|
||||
margin: 15px 25px 0 0
|
||||
width: 425px
|
||||
height: 150px
|
||||
width: $box-width
|
||||
height: $box-height
|
||||
border: 1px solid #dedede
|
||||
background-color: #fff
|
||||
|
||||
@ -18,22 +30,21 @@
|
||||
background-position: center
|
||||
color: #222
|
||||
border: 1px solid #ccc
|
||||
width: 150px
|
||||
height: 150px
|
||||
width: $thumbnail-height
|
||||
height: $thumbnail-width
|
||||
margin-right: 15px
|
||||
float: left
|
||||
overflow: hidden
|
||||
position: relative
|
||||
|
||||
img
|
||||
min-width: 150px
|
||||
min-height: 150px
|
||||
min-width: $thumbnail-width
|
||||
height: auto
|
||||
width: 110%
|
||||
position: relative
|
||||
top: 0
|
||||
top: 50%
|
||||
left: 50%
|
||||
transform: translate(-50%, 0%)
|
||||
transform: translate(-50%, -50%)
|
||||
|
||||
.mailpoet_overlay
|
||||
position: absolute
|
||||
@ -61,16 +72,21 @@
|
||||
.mailpoet_boxes .mailpoet_description
|
||||
float:left
|
||||
width: 245px
|
||||
max-height: calc(110px - 2em)
|
||||
padding-bottom: 2em
|
||||
max-height: $box-description-height
|
||||
padding-bottom: 0
|
||||
overflow: hidden
|
||||
|
||||
.mailpoet_boxes .mailpoet_description h3
|
||||
margin: 0 0 1em 0
|
||||
overflow: hidden
|
||||
white-space: nowrap
|
||||
text-overflow: ellipsis
|
||||
max-width: 220px
|
||||
h3
|
||||
margin: 0 0 $box-description-space-between-heading-and-paragraph 0
|
||||
overflow: hidden
|
||||
max-width: 210px
|
||||
line-height: $box-heading-line-height
|
||||
font-size: $box-heading-font-size
|
||||
|
||||
p
|
||||
font-size: $box-description-font-size
|
||||
line-height: $box-description-line-height
|
||||
margin: 0
|
||||
|
||||
.mailpoet_boxes .mailpoet_actions
|
||||
position: absolute
|
||||
|
@ -1,6 +1,6 @@
|
||||
$tool-inactive-color = #bbbbbb
|
||||
$tool-inactive-color = #333333
|
||||
$tool-inactive-secondary-color = #ffffff
|
||||
$tool-hover-color = #333333
|
||||
$tool-hover-color = #bbbbbb
|
||||
$tool-hover-secondary-color = #ffffff
|
||||
$tool-active-color = #d2d2d4
|
||||
$tool-active-secondary-color = #ffffff
|
||||
@ -12,21 +12,42 @@ $master-column-tool-width = 24px
|
||||
position: absolute
|
||||
top: 0
|
||||
right: 0
|
||||
display: none
|
||||
z-index: 20
|
||||
padding: 2px
|
||||
text-align: right
|
||||
overflow: hidden
|
||||
|
||||
.mailpoet_tool_slider
|
||||
position: relative
|
||||
right: -100%
|
||||
transition: all 250ms cubic-bezier(0.420, 0.000, 0.580, 1.000)
|
||||
opacity: 0
|
||||
|
||||
&.mailpoet_display_tools
|
||||
.mailpoet_tool_slider
|
||||
right: 0
|
||||
opacity: 1
|
||||
|
||||
a
|
||||
vertical-align: top
|
||||
|
||||
.mailpoet_container_horizontal + &
|
||||
left: 100%
|
||||
right: initial
|
||||
padding-left: 5px
|
||||
|
||||
.mailpoet_tool_slider
|
||||
left: -100%
|
||||
right: initial
|
||||
|
||||
&.mailpoet_display_tools
|
||||
.mailpoet_tool_slider
|
||||
left: 0
|
||||
|
||||
.mailpoet_tool
|
||||
width: $master-column-tool-width
|
||||
height: $master-column-tool-width
|
||||
display: block
|
||||
|
||||
.mailpoet_tool_icon
|
||||
width: $master-column-tool-width
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
.mailpoet_input_title,
|
||||
.mailpoet_input_preheader
|
||||
width: 400px
|
||||
width: 500px
|
||||
padding: 3px
|
||||
line-height: normal
|
||||
|
||||
|
@ -5,8 +5,8 @@ $active-social-icon-set-border-color = #adadad
|
||||
$active-social-icon-set-background-color = #daebf2
|
||||
$social-icon-set-hover-border-color = $primary-active-color
|
||||
|
||||
$tool-inactive-color = #bbbbbb
|
||||
$tool-hover-color = #333333
|
||||
$tool-inactive-color = #333333
|
||||
$tool-hover-color = #bbbbbb
|
||||
$tool-active-color = #d2d2d4
|
||||
|
||||
$tool-width = 16px
|
||||
|
@ -1,12 +1,12 @@
|
||||
animation-slide-open-downwards()
|
||||
animation-slide-open-downwards($max-height = 2000px)
|
||||
transition: all 250ms cubic-bezier(0.420, 0.000, 0.580, 1.000) /* ease-in-out */
|
||||
max-height: 2000px
|
||||
max-height: $max-height
|
||||
opacity: 1
|
||||
overflow-y: hidden
|
||||
|
||||
&.mailpoet_closed
|
||||
max-height: 0
|
||||
max-height: 0px
|
||||
opacity: 0
|
||||
overflow-y: hidden
|
||||
|
||||
animation-background-color()
|
||||
transition: background 250ms cubic-bezier(0.420, 0.000, 0.580, 1.000) /* ease-in-out */
|
||||
|
@ -18,6 +18,7 @@ textarea.parsley-error
|
||||
list-style-type none
|
||||
font-size 0.9em
|
||||
line-height 0.9em
|
||||
color #B94A48
|
||||
opacity 0
|
||||
transition all .3s ease-in
|
||||
-o-transition all .3s ease-in
|
||||
|
@ -1,14 +1,10 @@
|
||||
#mailpoet_settings
|
||||
// common
|
||||
.mailpoet_panel
|
||||
display: none
|
||||
display none
|
||||
|
||||
.form-table th
|
||||
width:20em
|
||||
|
||||
// advanced
|
||||
#mailpoet_role_permissions
|
||||
margin-top: 20px;
|
||||
width 20em
|
||||
|
||||
// sending methods
|
||||
.mailpoet_sending_methods
|
||||
@ -28,8 +24,7 @@
|
||||
line-height 54px
|
||||
font-size 1.5em
|
||||
.mailpoet_description
|
||||
line-height 1.5em
|
||||
font-size 1.1em
|
||||
font-size 14px
|
||||
.mailpoet_status
|
||||
background-color #2f2f2f
|
||||
color #fff
|
||||
@ -60,11 +55,11 @@
|
||||
// responsive
|
||||
@media screen and (max-width: 782px)
|
||||
.form-table th
|
||||
width: auto
|
||||
width auto
|
||||
|
||||
.mailpoet_sending_methods
|
||||
li
|
||||
float none
|
||||
width: auto
|
||||
margin-right: 0
|
||||
width auto
|
||||
margin-right 0
|
||||
|
||||
|
BIN
assets/img/blank_templates/fake-logo.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 178 KiB After Width: | Height: | Size: 178 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 130 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
BIN
assets/img/sample_templates/discount/bicycle-header2.png
Normal file
After Width: | Height: | Size: 9.8 KiB |
BIN
assets/img/sample_templates/discount/bicycle-header3.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
assets/img/sample_templates/discount/orange-bicycle.jpg
Normal file
After Width: | Height: | Size: 78 KiB |
BIN
assets/img/sample_templates/discount/red-icycle.jpg
Normal file
After Width: | Height: | Size: 70 KiB |
BIN
assets/img/sample_templates/restaurant/boyga-1329911-639x852.jpg
Normal file
After Width: | Height: | Size: 303 KiB |
BIN
assets/img/sample_templates/restaurant/burger.jpg
Normal file
After Width: | Height: | Size: 289 KiB |
BIN
assets/img/sample_templates/restaurant/header.jpg
Normal file
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 498 KiB |
BIN
assets/img/sample_templates/travel/gallery1.jpg
Normal file
After Width: | Height: | Size: 69 KiB |
BIN
assets/img/sample_templates/travel/gallery2.jpg
Normal file
After Width: | Height: | Size: 106 KiB |
BIN
assets/img/sample_templates/travel/gallery3.jpg
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
assets/img/sample_templates/travel/gallery4.jpg
Normal file
After Width: | Height: | Size: 156 KiB |
BIN
assets/img/sample_templates/travel/glow-worms.jpg
Normal file
After Width: | Height: | Size: 145 KiB |
BIN
assets/img/sample_templates/travel/header.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
assets/img/sample_templates/travel/holiday-park.jpg
Normal file
After Width: | Height: | Size: 136 KiB |
BIN
assets/img/sample_templates/travel/luge.jpg
Normal file
After Width: | Height: | Size: 77 KiB |
BIN
assets/img/welcome_template/beacon.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 4.8 KiB |
BIN
assets/img/welcome_template/mailpoet-logo.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
@ -1,4 +1,4 @@
|
||||
define('ajax', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
||||
define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery, _) {
|
||||
'use strict';
|
||||
MailPoet.Ajax = {
|
||||
version: 0.5,
|
||||
@ -8,19 +8,11 @@ define('ajax', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
||||
endpoint: null,
|
||||
action: null,
|
||||
token: null,
|
||||
data: {},
|
||||
onSuccess: function(data, textStatus, xhr) {},
|
||||
onError: function(xhr, textStatus, errorThrown) {}
|
||||
},
|
||||
get: function(options) {
|
||||
return this.request('get', options);
|
||||
data: {}
|
||||
},
|
||||
post: function(options) {
|
||||
return this.request('post', options);
|
||||
},
|
||||
delete: function(options) {
|
||||
return this.request('delete', options);
|
||||
},
|
||||
init: function(options) {
|
||||
// merge options
|
||||
this.options = jQuery.extend({}, this.defaults, options);
|
||||
@ -50,31 +42,31 @@ define('ajax', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
|
||||
|
||||
// set request params
|
||||
var params = this.getParams();
|
||||
var jqXHR;
|
||||
var deferred = jQuery.Deferred();
|
||||
|
||||
// make ajax request depending on method
|
||||
if(method === 'get') {
|
||||
jqXHR = jQuery.get(
|
||||
this.options.url,
|
||||
params,
|
||||
this.options.onSuccess,
|
||||
'json'
|
||||
);
|
||||
} else {
|
||||
jqXHR = jQuery.ajax({
|
||||
url: this.options.url,
|
||||
type : 'post',
|
||||
data: params,
|
||||
dataType: 'json',
|
||||
success : this.options.onSuccess,
|
||||
error : this.options.onError
|
||||
});
|
||||
// remove null values from the data object
|
||||
if (_.isObject(params.data)) {
|
||||
params.data = _.pick(params.data, function(value) {
|
||||
return (value !== null)
|
||||
})
|
||||
}
|
||||
|
||||
// ajax request
|
||||
deferred = jQuery.post(
|
||||
this.options.url,
|
||||
params,
|
||||
null,
|
||||
'json'
|
||||
).then(function(data) {
|
||||
return data;
|
||||
}, function(xhr) {
|
||||
return xhr.responseJSON;
|
||||
});
|
||||
|
||||
// clear options
|
||||
this.options = {};
|
||||
|
||||
return jqXHR;
|
||||
return deferred;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -1,100 +0,0 @@
|
||||
define(
|
||||
[
|
||||
'react',
|
||||
'react-dom',
|
||||
'mailpoet'
|
||||
],
|
||||
function(
|
||||
React,
|
||||
ReactDOM,
|
||||
MailPoet
|
||||
) {
|
||||
var CronControl = React.createClass({
|
||||
getInitialState: function() {
|
||||
return {
|
||||
status: 'loading'
|
||||
};
|
||||
},
|
||||
getCronData: function() {
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'cron',
|
||||
action: 'getStatus'
|
||||
})
|
||||
.done(function(response) {
|
||||
jQuery('.button-primary')
|
||||
.removeClass('disabled');
|
||||
if(response.status !== undefined) {
|
||||
this.setState(response);
|
||||
} else {
|
||||
this.replaceState();
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
componentDidMount: function() {
|
||||
if(this.isMounted()) {
|
||||
this.getCronData();
|
||||
setInterval(this.getCronData, 5000);
|
||||
}
|
||||
},
|
||||
controlCron: function(action) {
|
||||
if(jQuery('.button-primary').hasClass('disabled')) {
|
||||
return;
|
||||
}
|
||||
jQuery('.button-primary')
|
||||
.addClass('disabled');
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'cron',
|
||||
action: action,
|
||||
})
|
||||
.done(function(response) {
|
||||
if(!response.result) {
|
||||
MailPoet.Notice.error(MailPoet.I18n.t('daemonControlError'));
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
render: function() {
|
||||
if(this.state.status === 'loading') {
|
||||
return(<div>{MailPoet.I18n.t('loadingDaemonStatus')}</div>);
|
||||
}
|
||||
switch(this.state.status) {
|
||||
case 'started':
|
||||
return(
|
||||
<div>
|
||||
{MailPoet.I18n.t('cronDaemonIsRunning')}
|
||||
<br/>
|
||||
<br/>
|
||||
<a href="#" className="button-primary" onClick={this.controlCron.bind(null, 'stop')}>{MailPoet.I18n.t('stop')}</a>
|
||||
</div>
|
||||
);
|
||||
break;
|
||||
case 'starting':
|
||||
case 'stopping':
|
||||
return(
|
||||
<div>
|
||||
{MailPoet.I18n.t('cronDaemonState').replace('%$1s', this.state.status)}
|
||||
</div>
|
||||
);
|
||||
break;
|
||||
case 'stopped':
|
||||
return(
|
||||
<div>
|
||||
{MailPoet.I18n.t('cronDaemonState').replace('%$1s', this.state.status)}
|
||||
<br />
|
||||
<br />
|
||||
<a href="#" className="button-primary" onClick={this.controlCron.bind(null, 'start')}>{MailPoet.I18n.t('start')}</a>
|
||||
</div>
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const container = document.getElementById('cron_container');
|
||||
|
||||
if(container) {
|
||||
ReactDOM.render(
|
||||
<CronControl />,
|
||||
container
|
||||
);
|
||||
}
|
||||
});
|
@ -43,8 +43,9 @@ define('date',
|
||||
options = options || {};
|
||||
this.init(options);
|
||||
|
||||
return Moment(date, this.convertFormat(options.parseFormat))
|
||||
.format(this.convertFormat(this.options.format));
|
||||
var date = Moment(date, this.convertFormat(options.parseFormat));
|
||||
if (options.offset === 0) date = date.utc();
|
||||
return date.format(this.convertFormat(this.options.format));
|
||||
},
|
||||
toDate: function(date, options) {
|
||||
options = options || {};
|
||||
@ -68,32 +69,45 @@ define('date',
|
||||
});
|
||||
},
|
||||
convertFormat: function(format) {
|
||||
const format_mappings = {
|
||||
var format_mappings = {
|
||||
date: {
|
||||
D: 'ddd',
|
||||
l: 'dddd',
|
||||
d: 'DD',
|
||||
D: 'ddd',
|
||||
j: 'D',
|
||||
z: 'DDDD',
|
||||
l: 'dddd',
|
||||
N: 'E',
|
||||
S: '',
|
||||
M: 'MMM',
|
||||
S: 'o',
|
||||
w: 'e',
|
||||
z: 'DDD',
|
||||
W: 'W',
|
||||
F: 'MMMM',
|
||||
m: 'MM',
|
||||
n: '',
|
||||
t: '',
|
||||
y: 'YY',
|
||||
M: 'MMM',
|
||||
n: 'M',
|
||||
t: '', // no equivalent
|
||||
L: '', // no equivalent
|
||||
o: 'YYYY',
|
||||
Y: 'YYYY',
|
||||
H: 'HH',
|
||||
h: 'hh',
|
||||
g: 'h',
|
||||
y: 'YY',
|
||||
a: 'a',
|
||||
A: 'A',
|
||||
B: '', // no equivalent
|
||||
g: 'h',
|
||||
G: 'H',
|
||||
h: 'hh',
|
||||
H: 'HH',
|
||||
i: 'mm',
|
||||
s: 'ss',
|
||||
T: 'z',
|
||||
O: 'ZZ',
|
||||
w: 'd',
|
||||
W: 'WW'
|
||||
u: 'SSS',
|
||||
e: 'zz', // deprecated since version 1.6.0 of moment.js
|
||||
I: '', // no equivalent
|
||||
O: '', // no equivalent
|
||||
P: '', // no equivalent
|
||||
T: '', // no equivalent
|
||||
Z: '', // no equivalent
|
||||
c: '', // no equivalent
|
||||
r: '', // no equivalent
|
||||
U: 'X'
|
||||
},
|
||||
strftime: {
|
||||
a: 'ddd',
|
||||
@ -124,22 +138,31 @@ define('date',
|
||||
|
||||
if (!format || format.length <= 0) return format;
|
||||
|
||||
const replacements = format_mappings['date'];
|
||||
var replacements = format_mappings['date'];
|
||||
|
||||
let outputFormat = '';
|
||||
var convertedFormat = [];
|
||||
var escapeToken = false;
|
||||
|
||||
Object.keys(replacements).forEach(function(key) {
|
||||
if (format.indexOf(key) !== -1) {
|
||||
format = format.replace(key, '%'+key);
|
||||
for (var index in format) {
|
||||
var token = format[index];
|
||||
|
||||
if (escapeToken === true) {
|
||||
convertedFormat.push('['+token+']');
|
||||
escapeToken = false;
|
||||
} else {
|
||||
if (token === '\\') {
|
||||
// Slash escapes the next symbol to be treated as literal
|
||||
escapeToken = true;
|
||||
continue;
|
||||
} else if (replacements[token] !== undefined) {
|
||||
convertedFormat.push(replacements[token]);
|
||||
} else {
|
||||
convertedFormat.push('['+token+']');
|
||||
}
|
||||
}
|
||||
});
|
||||
outputFormat = format;
|
||||
Object.keys(replacements).forEach(function(key) {
|
||||
if (outputFormat.indexOf('%'+key) !== -1) {
|
||||
outputFormat = outputFormat.replace('%'+key, replacements[key]);
|
||||
}
|
||||
});
|
||||
return outputFormat;
|
||||
}
|
||||
|
||||
return convertedFormat.join('');
|
||||
}
|
||||
};
|
||||
});
|
||||
|
@ -6,7 +6,7 @@ function(
|
||||
) {
|
||||
const FormFieldCheckbox = React.createClass({
|
||||
onValueChange: function(e) {
|
||||
e.target.value = this.refs.checkbox.checked ? '1' : '';
|
||||
e.target.value = this.refs.checkbox.checked ? '1' : '0';
|
||||
return this.props.onValueChange(e);
|
||||
},
|
||||
render: function() {
|
||||
@ -14,7 +14,9 @@ function(
|
||||
return false;
|
||||
}
|
||||
|
||||
const isChecked = !!(this.props.item[this.props.field.name]);
|
||||
// isChecked will be true only if the value is "1"
|
||||
// it will be false in case value is "0" or empty
|
||||
const isChecked = !!(~~(this.props.item[this.props.field.name]));
|
||||
const options = Object.keys(this.props.field.values).map(
|
||||
(value, index) => {
|
||||
return (
|
||||
|
@ -27,7 +27,7 @@ define([
|
||||
}
|
||||
return (
|
||||
<select
|
||||
name={ this.props.name + '[year]' }
|
||||
name={ `${this.props.name}[year]` }
|
||||
value={ this.props.year }
|
||||
onChange={ this.props.onValueChange }
|
||||
>
|
||||
@ -57,7 +57,7 @@ define([
|
||||
}
|
||||
return (
|
||||
<select
|
||||
name={ this.props.name + '[month]' }
|
||||
name={ `${this.props.name}[month]` }
|
||||
value={ this.props.month }
|
||||
onChange={ this.props.onValueChange }
|
||||
>
|
||||
@ -88,7 +88,7 @@ define([
|
||||
|
||||
return (
|
||||
<select
|
||||
name={ this.props.name + '[day]' }
|
||||
name={ `${this.props.name}[day]` }
|
||||
value={ this.props.day }
|
||||
onChange={ this.props.onValueChange }
|
||||
>
|
||||
@ -102,46 +102,74 @@ define([
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
year: undefined,
|
||||
month: undefined,
|
||||
day: undefined
|
||||
year: '',
|
||||
month: '',
|
||||
day: ''
|
||||
}
|
||||
}
|
||||
componentDidMount() {
|
||||
this.extractDateParts();
|
||||
}
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
if (
|
||||
(this.props.item !== undefined && prevProps.item !== undefined)
|
||||
&& (this.props.item.id !== prevProps.item.id)
|
||||
) {
|
||||
this.extractTimeStamp();
|
||||
this.extractDateParts();
|
||||
}
|
||||
}
|
||||
extractTimeStamp() {
|
||||
const timeStamp = parseInt(this.props.item[this.props.field.name], 10);
|
||||
extractDateParts() {
|
||||
const value = (this.props.item[this.props.field.name] !== undefined)
|
||||
? this.props.item[this.props.field.name].trim()
|
||||
: '';
|
||||
|
||||
if(value === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
const dateTime = Moment(value);
|
||||
|
||||
this.setState({
|
||||
year: Moment.unix(timeStamp).year(),
|
||||
// Moment returns the month as [0..11]
|
||||
// We increment it to match PHP's mktime() which expects [1..12]
|
||||
month: Moment.unix(timeStamp).month() + 1,
|
||||
day: Moment.unix(timeStamp).date()
|
||||
year: dateTime.format('YYYY'),
|
||||
month: dateTime.format('M'),
|
||||
day: dateTime.format('D')
|
||||
});
|
||||
}
|
||||
updateTimeStamp(field) {
|
||||
let newTimeStamp = Moment(
|
||||
`${this.state.month}/${this.state.day}/${this.state.year}`,
|
||||
'M/D/YYYY'
|
||||
).valueOf();
|
||||
if (~~(newTimeStamp) > 0) {
|
||||
// convert milliseconds to seconds
|
||||
newTimeStamp /= 1000;
|
||||
return this.props.onValueChange({
|
||||
target: {
|
||||
name: field,
|
||||
value: newTimeStamp
|
||||
}
|
||||
});
|
||||
formatValue() {
|
||||
const dateType = this.props.field.params.date_type;
|
||||
|
||||
let value;
|
||||
|
||||
switch(dateType) {
|
||||
case 'year_month_day':
|
||||
value = {
|
||||
'year': this.state.year,
|
||||
'month': this.state.month,
|
||||
'day': this.state.day
|
||||
};
|
||||
break;
|
||||
|
||||
case 'year_month':
|
||||
value = {
|
||||
'year': this.state.year,
|
||||
'month': this.state.month
|
||||
};
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
value = {
|
||||
'month': this.state.month
|
||||
};
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
value = {
|
||||
'year': this.state.year
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
onValueChange(e) {
|
||||
// extract property from name
|
||||
@ -153,25 +181,29 @@ define([
|
||||
field = matches[1];
|
||||
property = matches[2];
|
||||
|
||||
let value = parseInt(e.target.value, 10);
|
||||
let value = ~~(e.target.value);
|
||||
|
||||
this.setState({
|
||||
[`${property}`]: value
|
||||
}, () => {
|
||||
this.updateTimeStamp(field);
|
||||
this.props.onValueChange({
|
||||
target: {
|
||||
name: field,
|
||||
value: this.formatValue()
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
render() {
|
||||
const monthNames = window.mailpoet_month_names || [];
|
||||
|
||||
const dateFormats = window.mailpoet_date_formats || {};
|
||||
const dateType = this.props.field.params.date_type;
|
||||
|
||||
const dateSelects = dateType.split('_');
|
||||
const dateSelects = dateFormats[dateType][0].split('/');
|
||||
|
||||
const fields = dateSelects.map(type => {
|
||||
switch(type) {
|
||||
case 'year':
|
||||
case 'YYYY':
|
||||
return (<FormFieldDateYear
|
||||
onValueChange={ this.onValueChange.bind(this) }
|
||||
ref={ 'year' }
|
||||
@ -182,7 +214,7 @@ define([
|
||||
/>);
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
case 'MM':
|
||||
return (<FormFieldDateMonth
|
||||
onValueChange={ this.onValueChange.bind(this) }
|
||||
ref={ 'month' }
|
||||
@ -194,7 +226,7 @@ define([
|
||||
/>);
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
case 'DD':
|
||||
return (<FormFieldDateDay
|
||||
onValueChange={ this.onValueChange.bind(this) }
|
||||
ref={ 'day' }
|
||||
|
@ -1,4 +1,5 @@
|
||||
import React from 'react'
|
||||
import _ from 'underscore'
|
||||
|
||||
const FormFieldSelect = React.createClass({
|
||||
render() {
|
||||
@ -8,6 +9,7 @@ const FormFieldSelect = React.createClass({
|
||||
|
||||
let filter = false;
|
||||
let placeholder = false;
|
||||
let sortBy = false;
|
||||
|
||||
if (this.props.field.placeholder !== undefined) {
|
||||
placeholder = (
|
||||
@ -19,7 +21,27 @@ const FormFieldSelect = React.createClass({
|
||||
filter = this.props.field.filter;
|
||||
}
|
||||
|
||||
const options = Object.keys(this.props.field.values).map(
|
||||
if (_.isFunction(this.props.field.sortBy)) {
|
||||
sortBy = this.props.field.sortBy;
|
||||
}
|
||||
|
||||
let keys;
|
||||
if (sortBy) {
|
||||
// Extract keys from sorted [key, value] select value pairs, sorted by
|
||||
// provided sorting order.
|
||||
keys =
|
||||
_.map(
|
||||
_.sortBy(
|
||||
_.pairs(this.props.field.values),
|
||||
(item) => sortBy(item[0], item[1])
|
||||
),
|
||||
(item) => item[0]
|
||||
);
|
||||
} else {
|
||||
keys = Object.keys(this.props.field.values)
|
||||
}
|
||||
|
||||
const options = keys.map(
|
||||
(value, index) => {
|
||||
|
||||
if (filter !== false && filter(this.props.item, value) === false) {
|
||||
@ -51,4 +73,4 @@ const FormFieldSelect = React.createClass({
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = FormFieldSelect;
|
||||
module.exports = FormFieldSelect;
|
||||
|
@ -89,10 +89,17 @@ function(
|
||||
if(this.props.field['selected'] !== undefined) {
|
||||
return this.props.field['selected'](this.props.item);
|
||||
} else if(this.props.item !== undefined && this.props.field.name !== undefined) {
|
||||
return this.props.item[this.props.field.name];
|
||||
} else {
|
||||
return null;
|
||||
if (this.allowMultipleValues()) {
|
||||
if (Array.isArray(this.props.item[this.props.field.name])) {
|
||||
return this.props.item[this.props.field.name].map(function(item) {
|
||||
return item.id;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return this.props.item[this.props.field.name];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
loadCachedItems: function() {
|
||||
if(typeof(window['mailpoet_'+this.props.field.endpoint]) !== 'undefined') {
|
||||
@ -115,9 +122,10 @@ function(
|
||||
} else {
|
||||
value = e.target.value;
|
||||
}
|
||||
var transformedValue = this.transformChangedValue(value);
|
||||
this.props.onValueChange({
|
||||
target: {
|
||||
value: value,
|
||||
value: transformedValue,
|
||||
name: this.props.field.name
|
||||
}
|
||||
});
|
||||
@ -141,6 +149,16 @@ function(
|
||||
}
|
||||
return item.id;
|
||||
},
|
||||
// When it's impossible to represent the desired value in DOM,
|
||||
// this function may be used to transform the placeholder value into
|
||||
// desired value.
|
||||
transformChangedValue: function(value) {
|
||||
if(typeof this.props.field['transformChangedValue'] === 'function') {
|
||||
return this.props.field.transformChangedValue.call(this, value);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
render: function() {
|
||||
const options = this.state.items.map((item, index) => {
|
||||
let label = this.getLabel(item);
|
||||
|
@ -66,22 +66,22 @@ define(
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'get',
|
||||
data: id
|
||||
}).done(function(response) {
|
||||
if(response === false) {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: {}
|
||||
}, function() {
|
||||
this.context.router.push('/new');
|
||||
}.bind(this));
|
||||
} else {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: response
|
||||
});
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
}.bind(this));
|
||||
}).done((response) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: response.data
|
||||
});
|
||||
}).fail((response) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: {}
|
||||
}, function() {
|
||||
this.context.router.push('/new');
|
||||
});
|
||||
});
|
||||
},
|
||||
handleSubmit: function(e) {
|
||||
e.preventDefault();
|
||||
@ -115,29 +115,25 @@ define(
|
||||
endpoint: this.props.endpoint,
|
||||
action: 'save',
|
||||
data: item
|
||||
}).done(function(response) {
|
||||
}).always(() => {
|
||||
this.setState({ loading: false });
|
||||
|
||||
if(response.result === true) {
|
||||
if(this.props.onSuccess !== undefined) {
|
||||
this.props.onSuccess();
|
||||
} else {
|
||||
this.context.router.push('/');
|
||||
}
|
||||
|
||||
if(this.props.params.id !== undefined) {
|
||||
this.props.messages.onUpdate();
|
||||
} else {
|
||||
this.props.messages.onCreate();
|
||||
}
|
||||
}).done((response) => {
|
||||
if(this.props.onSuccess !== undefined) {
|
||||
this.props.onSuccess();
|
||||
} else {
|
||||
if(response.result === false) {
|
||||
if(response.errors.length > 0) {
|
||||
this.setState({ errors: response.errors });
|
||||
}
|
||||
}
|
||||
this.context.router.push('/');
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
if(this.props.params.id !== undefined) {
|
||||
this.props.messages.onUpdate();
|
||||
} else {
|
||||
this.props.messages.onCreate();
|
||||
}
|
||||
}).fail((response) => {
|
||||
if(response.errors.length > 0) {
|
||||
this.setState({ errors: response.errors });
|
||||
}
|
||||
});
|
||||
},
|
||||
handleValueChange: function(e) {
|
||||
if (this.props.onChange) {
|
||||
@ -159,7 +155,7 @@ define(
|
||||
var errors = this.getErrors().map(function(error, index) {
|
||||
return (
|
||||
<p key={ 'error-'+index } className="mailpoet_error">
|
||||
{ error }
|
||||
{ error.message }
|
||||
</p>
|
||||
);
|
||||
});
|
||||
|
@ -13,8 +13,11 @@ const columns = [
|
||||
},
|
||||
{
|
||||
name: 'segments',
|
||||
label: MailPoet.I18n.t('segments'),
|
||||
sortable: false
|
||||
label: MailPoet.I18n.t('segments')
|
||||
},
|
||||
{
|
||||
name: 'signups',
|
||||
label: MailPoet.I18n.t('signups')
|
||||
},
|
||||
{
|
||||
name: 'created_at',
|
||||
@ -24,48 +27,48 @@ const columns = [
|
||||
];
|
||||
|
||||
const messages = {
|
||||
onTrash: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneFormTrashed')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleFormsTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneFormDeleted')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleFormsDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneFormRestored')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleFormsRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -96,14 +99,21 @@ const item_actions = [
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'forms',
|
||||
action: 'duplicate',
|
||||
data: item.id
|
||||
}).done(function(response) {
|
||||
if (response !== false && response['name'] !== undefined) {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('formDuplicated')).replace('%$1s', response.name)
|
||||
data: {
|
||||
id: item.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('formDuplicated')).replace('%$1s', response.data.name)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -117,9 +127,14 @@ const FormList = React.createClass({
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'forms',
|
||||
action: 'create'
|
||||
}).done(function(response) {
|
||||
if(response.result && response.form_id) {
|
||||
window.location = mailpoet_form_edit_url + response.form_id;
|
||||
}).done((response) => {
|
||||
window.location = mailpoet_form_edit_url + response.data.id;
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
@ -136,6 +151,10 @@ const FormList = React.createClass({
|
||||
return segment.name;
|
||||
}).join(', ');
|
||||
|
||||
if (form.settings.segments_selected_by === 'user') {
|
||||
segments = MailPoet.I18n.t('userChoice') + ' ' + segments;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<td className={ row_classes }>
|
||||
@ -147,9 +166,12 @@ const FormList = React.createClass({
|
||||
</strong>
|
||||
{ actions }
|
||||
</td>
|
||||
<td className="column-format" data-colname={MailPoet.I18n.t('segments')}>
|
||||
<td className="column" data-colname={MailPoet.I18n.t('segments')}>
|
||||
{ segments }
|
||||
</td>
|
||||
<td className="column" data-colname={MailPoet.I18n.t('signups')}>
|
||||
{ form.signups }
|
||||
</td>
|
||||
<td className="column-date" data-colname={MailPoet.I18n.t('createdOn')}>
|
||||
<abbr>{ MailPoet.Date.format(form.created_at) }</abbr>
|
||||
</td>
|
||||
|
@ -47,13 +47,16 @@ function(
|
||||
|
||||
data.action = this.state.action;
|
||||
|
||||
var callback = function() {};
|
||||
var onSuccess = function() {};
|
||||
if(action['onSuccess'] !== undefined) {
|
||||
callback = action.onSuccess;
|
||||
onSuccess = action.onSuccess;
|
||||
}
|
||||
|
||||
if(data.action) {
|
||||
this.props.onBulkAction(selected_ids, data, callback);
|
||||
const promise = this.props.onBulkAction(selected_ids, data);
|
||||
if (promise !== false) {
|
||||
promise.then(onSuccess);
|
||||
};
|
||||
}
|
||||
|
||||
this.setState({
|
||||
|
@ -10,10 +10,10 @@ function(
|
||||
) {
|
||||
var ListingFilters = React.createClass({
|
||||
handleFilterAction: function() {
|
||||
let filters = {}
|
||||
let filters = {};
|
||||
this.getAvailableFilters().map((filter, i) => {
|
||||
filters[this.refs['filter-'+i].name] = this.refs['filter-'+i].value
|
||||
})
|
||||
});
|
||||
return this.props.onSelectFilter(filters);
|
||||
},
|
||||
handleEmptyTrash: function() {
|
||||
@ -21,7 +21,6 @@ function(
|
||||
},
|
||||
getAvailableFilters: function() {
|
||||
let filters = this.props.filters;
|
||||
|
||||
return Object.keys(filters).filter(function(filter) {
|
||||
return !(
|
||||
filters[filter].length === 0
|
||||
@ -30,26 +29,29 @@ function(
|
||||
&& !filters[filter][0].value
|
||||
)
|
||||
);
|
||||
})
|
||||
});
|
||||
},
|
||||
componentDidUpdate: function() {
|
||||
const selected_filters = this.props.filter;
|
||||
const available_filters = this.getAvailableFilters().map(
|
||||
function(filter, i) {
|
||||
if (selected_filters[filter] !== undefined && selected_filters[filter]) {
|
||||
jQuery(this.refs['filter-'+i])
|
||||
.val(selected_filters[filter])
|
||||
.trigger('change');
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
render: function() {
|
||||
const filters = this.props.filters;
|
||||
const selected_filters = this.props.filter;
|
||||
|
||||
const available_filters = this.getAvailableFilters()
|
||||
.map(function(filter, i) {
|
||||
let default_value = false;
|
||||
if (selected_filters[filter] !== undefined && selected_filters[filter]) {
|
||||
default_value = selected_filters[filter]
|
||||
} else {
|
||||
jQuery(`select[name="${filter}"]`).val('');
|
||||
}
|
||||
return (
|
||||
<select
|
||||
ref={ `filter-${i}` }
|
||||
key={ `filter-${i}` }
|
||||
name={ filter }
|
||||
defaultValue={ default_value }
|
||||
>
|
||||
{ filters[filter].map(function(option, j) {
|
||||
return (
|
||||
@ -63,7 +65,7 @@ function(
|
||||
);
|
||||
}.bind(this));
|
||||
|
||||
let button = false;
|
||||
let button;
|
||||
|
||||
if (available_filters.length > 0) {
|
||||
button = (
|
||||
@ -76,7 +78,7 @@ function(
|
||||
);
|
||||
}
|
||||
|
||||
let empty_trash = false;
|
||||
let empty_trash;
|
||||
if (this.props.group === 'trash') {
|
||||
empty_trash = (
|
||||
<input
|
||||
|
@ -1,98 +1,91 @@
|
||||
define([
|
||||
'react',
|
||||
'classnames',
|
||||
'mailpoet'
|
||||
], function(
|
||||
React,
|
||||
classNames,
|
||||
MailPoet
|
||||
) {
|
||||
|
||||
var ListingHeader = React.createClass({
|
||||
handleSelectItems: function() {
|
||||
return this.props.onSelectItems(
|
||||
this.refs.toggle.checked
|
||||
);
|
||||
},
|
||||
render: function() {
|
||||
var columns = this.props.columns.map(function(column, index) {
|
||||
column.is_primary = (index === 0);
|
||||
column.sorted = (this.props.sort_by === column.name)
|
||||
? this.props.sort_order
|
||||
: 'desc';
|
||||
return (
|
||||
<ListingColumn
|
||||
onSort={this.props.onSort}
|
||||
sort_by={this.props.sort_by}
|
||||
key={ 'column-' + index }
|
||||
column={column} />
|
||||
);
|
||||
}.bind(this));
|
||||
|
||||
var checkbox = false;
|
||||
|
||||
if(this.props.is_selectable === true) {
|
||||
checkbox = (
|
||||
<th
|
||||
className="manage-column column-cb check-column">
|
||||
<label className="screen-reader-text">
|
||||
{MailPoet.I18n.t('selectAll')}
|
||||
</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="select_all"
|
||||
ref="toggle"
|
||||
checked={ this.props.selection }
|
||||
onChange={ this.handleSelectItems } />
|
||||
</th>
|
||||
);
|
||||
}
|
||||
import MailPoet from 'mailpoet'
|
||||
import React from 'react'
|
||||
import classNames from 'classnames'
|
||||
|
||||
const ListingHeader = React.createClass({
|
||||
handleSelectItems: function() {
|
||||
return this.props.onSelectItems(
|
||||
this.refs.toggle.checked
|
||||
);
|
||||
},
|
||||
render: function() {
|
||||
const columns = this.props.columns.map(function(column, index) {
|
||||
column.is_primary = (index === 0);
|
||||
column.sorted = (this.props.sort_by === column.name)
|
||||
? this.props.sort_order
|
||||
: 'desc';
|
||||
return (
|
||||
<tr>
|
||||
{checkbox}
|
||||
{columns}
|
||||
</tr>
|
||||
<ListingColumn
|
||||
onSort={this.props.onSort}
|
||||
sort_by={this.props.sort_by}
|
||||
key={ 'column-' + index }
|
||||
column={column} />
|
||||
);
|
||||
}
|
||||
});
|
||||
}.bind(this));
|
||||
|
||||
var ListingColumn = React.createClass({
|
||||
handleSort: function() {
|
||||
var sort_by = this.props.column.name,
|
||||
sort_order = (this.props.column.sorted === 'asc') ? 'desc' : 'asc';
|
||||
this.props.onSort(sort_by, sort_order);
|
||||
},
|
||||
render: function() {
|
||||
var classes = classNames(
|
||||
'manage-column',
|
||||
{ 'column-primary': this.props.column.is_primary },
|
||||
{ 'sortable': this.props.column.sortable },
|
||||
this.props.column.sorted,
|
||||
{ 'sorted': (this.props.sort_by === this.props.column.name) }
|
||||
);
|
||||
var label;
|
||||
let checkbox;
|
||||
|
||||
if(this.props.column.sortable === true) {
|
||||
label = (
|
||||
<a onClick={this.handleSort}>
|
||||
<span>{ this.props.column.label }</span>
|
||||
<span className="sorting-indicator"></span>
|
||||
</a>
|
||||
);
|
||||
} else {
|
||||
label = this.props.column.label;
|
||||
}
|
||||
return (
|
||||
if(this.props.is_selectable === true) {
|
||||
checkbox = (
|
||||
<th
|
||||
className={ classes }
|
||||
id={this.props.column.name }
|
||||
scope="col"
|
||||
width={ this.props.column.width || null }
|
||||
>{label}</th>
|
||||
className="manage-column column-cb check-column">
|
||||
<label className="screen-reader-text">
|
||||
{MailPoet.I18n.t('selectAll')}
|
||||
</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
name="select_all"
|
||||
ref="toggle"
|
||||
checked={ this.props.selection }
|
||||
onChange={ this.handleSelectItems } />
|
||||
</th>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return ListingHeader;
|
||||
return (
|
||||
<tr>
|
||||
{checkbox}
|
||||
{columns}
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const ListingColumn = React.createClass({
|
||||
handleSort: function() {
|
||||
const sort_by = this.props.column.name;
|
||||
const sort_order = (this.props.column.sorted === 'asc') ? 'desc' : 'asc';
|
||||
this.props.onSort(sort_by, sort_order);
|
||||
},
|
||||
render: function() {
|
||||
const classes = classNames(
|
||||
'manage-column',
|
||||
{ 'column-primary': this.props.column.is_primary },
|
||||
{ 'sortable': this.props.column.sortable },
|
||||
this.props.column.sorted,
|
||||
{ 'sorted': (this.props.sort_by === this.props.column.name) }
|
||||
);
|
||||
let label;
|
||||
|
||||
if(this.props.column.sortable === true) {
|
||||
label = (
|
||||
<a onClick={ this.handleSort }>
|
||||
<span>{ this.props.column.label }</span>
|
||||
<span className="sorting-indicator"></span>
|
||||
</a>
|
||||
);
|
||||
} else {
|
||||
label = this.props.column.label;
|
||||
}
|
||||
return (
|
||||
<th
|
||||
className={ classes }
|
||||
id={this.props.column.name }
|
||||
scope="col"
|
||||
width={ this.props.column.width || null }
|
||||
>{label}</th>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = ListingHeader;
|
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Show Settings Behavior
|
||||
*
|
||||
* Opens up settings of a BlockView if contents are clicked upon
|
||||
*/
|
||||
define([
|
||||
'backbone.marionette',
|
||||
'jquery',
|
||||
'newsletter_editor/behaviors/BehaviorsLookup',
|
||||
], function(Marionette, jQuery, BehaviorsLookup) {
|
||||
|
||||
BehaviorsLookup.ShowSettingsBehavior = Marionette.Behavior.extend({
|
||||
defaults: {
|
||||
ignoreFrom: '', // selector
|
||||
},
|
||||
events: {
|
||||
'click .mailpoet_content': 'showSettings',
|
||||
},
|
||||
showSettings: function(event) {
|
||||
if(!this.isIgnoredElement(event.target)) {
|
||||
this.view.triggerMethod('showSettings');
|
||||
}
|
||||
},
|
||||
isIgnoredElement: function(element) {
|
||||
return this.options.ignoreFrom
|
||||
&& this.options.ignoreFrom.length > 0
|
||||
&& jQuery(element).is(this.options.ignoreFrom);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
@ -35,7 +35,12 @@ define([
|
||||
|
||||
Module.ALCSupervisor = SuperModel.extend({
|
||||
initialize: function() {
|
||||
this.listenTo(App.getChannel(), 'automatedLatestContentRefresh', this.refresh);
|
||||
var DELAY_REFRESH_FOR_MS = 500;
|
||||
this.listenTo(
|
||||
App.getChannel(),
|
||||
'automatedLatestContentRefresh',
|
||||
_.debounce(this.refresh, DELAY_REFRESH_FOR_MS)
|
||||
);
|
||||
},
|
||||
refresh: function() {
|
||||
var models = App.findModels(function(model) {
|
||||
@ -107,9 +112,7 @@ define([
|
||||
this.on('change:amount change:contentType change:terms change:inclusionType change:displayType change:titleFormat change:featuredImagePosition change:titleAlignment change:titleIsLink change:imageFullWidth change:showAuthor change:authorPrecededBy change:showCategories change:categoriesPrecededBy change:readMoreType change:readMoreText change:sortBy change:showDivider', this._scheduleFetchPosts, this);
|
||||
this.listenTo(this.get('readMoreButton'), 'change', this._scheduleFetchPosts);
|
||||
this.listenTo(this.get('divider'), 'change', this._scheduleFetchPosts);
|
||||
this.on('add remove update reset', function(model, collection, options) {
|
||||
App.getChannel().trigger('automatedLatestContentRefresh');
|
||||
});
|
||||
this.on('add remove update reset', this._scheduleFetchPosts);
|
||||
this.on('refreshPosts', this.updatePosts, this);
|
||||
},
|
||||
updatePosts: function(posts) {
|
||||
@ -120,16 +123,7 @@ define([
|
||||
* ALC posts on each model change
|
||||
*/
|
||||
_scheduleFetchPosts: function() {
|
||||
var TIMEOUT = 500,
|
||||
that = this;
|
||||
if (this._fetchPostsTimer !== undefined) {
|
||||
clearTimeout(this._fetchPostsTimer);
|
||||
}
|
||||
this._fetchPostsTimer = setTimeout(function() {
|
||||
//that.fetchPosts();
|
||||
App.getChannel().trigger('automatedLatestContentRefresh');
|
||||
that._fetchPostsTimer = undefined;
|
||||
}, TIMEOUT);
|
||||
App.getChannel().trigger('automatedLatestContentRefresh');
|
||||
},
|
||||
});
|
||||
|
||||
@ -180,17 +174,17 @@ define([
|
||||
"change .mailpoet_automated_latest_content_title_format": 'changeTitleFormat',
|
||||
"change .mailpoet_automated_latest_content_title_as_links": _.partial(this.changeBoolField, 'titleIsLink'),
|
||||
"change .mailpoet_automated_latest_content_show_divider": _.partial(this.changeBoolField, 'showDivider'),
|
||||
"keyup .mailpoet_automated_latest_content_show_amount": _.partial(this.changeField, "amount"),
|
||||
"input .mailpoet_automated_latest_content_show_amount": _.partial(this.changeField, "amount"),
|
||||
"change .mailpoet_automated_latest_content_content_type": _.partial(this.changeField, "contentType"),
|
||||
"change .mailpoet_automated_latest_content_include_or_exclude": _.partial(this.changeField, "inclusionType"),
|
||||
"change .mailpoet_automated_latest_content_title_alignment": _.partial(this.changeField, "titleAlignment"),
|
||||
"change .mailpoet_automated_latest_content_image_full_width": _.partial(this.changeBoolField, "imageFullWidth"),
|
||||
"change .mailpoet_automated_latest_content_featured_image_position": _.partial(this.changeField, "featuredImagePosition"),
|
||||
"change .mailpoet_automated_latest_content_show_author": _.partial(this.changeField, "showAuthor"),
|
||||
"keyup .mailpoet_automated_latest_content_author_preceded_by": _.partial(this.changeField, "authorPrecededBy"),
|
||||
"input .mailpoet_automated_latest_content_author_preceded_by": _.partial(this.changeField, "authorPrecededBy"),
|
||||
"change .mailpoet_automated_latest_content_show_categories": _.partial(this.changeField, "showCategories"),
|
||||
"keyup .mailpoet_automated_latest_content_categories": _.partial(this.changeField, "categoriesPrecededBy"),
|
||||
"keyup .mailpoet_automated_latest_content_read_more_text": _.partial(this.changeField, "readMoreText"),
|
||||
"input .mailpoet_automated_latest_content_categories": _.partial(this.changeField, "categoriesPrecededBy"),
|
||||
"input .mailpoet_automated_latest_content_read_more_text": _.partial(this.changeField, "readMoreText"),
|
||||
"change .mailpoet_automated_latest_content_sort_by": _.partial(this.changeField, "sortBy"),
|
||||
"click .mailpoet_done_editing": "close",
|
||||
};
|
||||
@ -217,8 +211,10 @@ define([
|
||||
};
|
||||
},
|
||||
transport: function(options, success, failure) {
|
||||
var taxonomies,
|
||||
promise = CommunicationComponent.getTaxonomies(that.model.get('contentType')).then(function(tax) {
|
||||
var taxonomies;
|
||||
var promise = CommunicationComponent.getTaxonomies(
|
||||
that.model.get('contentType')
|
||||
).then(function(tax) {
|
||||
taxonomies = tax;
|
||||
// Fetch available terms based on the list of taxonomies already fetched
|
||||
var promise = CommunicationComponent.getTerms({
|
||||
@ -227,7 +223,7 @@ define([
|
||||
}).then(function(terms) {
|
||||
return {
|
||||
taxonomies: taxonomies,
|
||||
terms: terms,
|
||||
terms: terms
|
||||
};
|
||||
});
|
||||
return promise;
|
||||
|
@ -99,12 +99,12 @@ define([
|
||||
},
|
||||
showTools: function(_event) {
|
||||
if (!this.showingToolsDisabled) {
|
||||
this.$('> .mailpoet_tools').show();
|
||||
this.$('> .mailpoet_tools').addClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('showTools');
|
||||
}
|
||||
},
|
||||
hideTools: function(e) {
|
||||
this.$('> .mailpoet_tools').hide();
|
||||
this.$('> .mailpoet_tools').removeClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('hideTools');
|
||||
},
|
||||
enableShowingTools: function() {
|
||||
|
@ -19,7 +19,7 @@ define([
|
||||
return this._getDefaults({
|
||||
type: 'button',
|
||||
text: 'Button',
|
||||
url: 'http://google.com',
|
||||
url: '',
|
||||
styles: {
|
||||
block: {
|
||||
backgroundColor: '#ff0000',
|
||||
@ -44,6 +44,9 @@ define([
|
||||
className: "mailpoet_block mailpoet_button_block mailpoet_droppable_block",
|
||||
getTemplate: function() { return templates.buttonBlock; },
|
||||
onDragSubstituteBy: function() { return Module.ButtonWidgetView; },
|
||||
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
||||
ShowSettingsBehavior: {},
|
||||
}),
|
||||
initialize: function() {
|
||||
base.BlockView.prototype.initialize.apply(this, arguments);
|
||||
|
||||
@ -65,8 +68,8 @@ define([
|
||||
getTemplate: function() { return templates.buttonBlockSettings; },
|
||||
events: function() {
|
||||
return {
|
||||
"keyup .mailpoet_field_button_text": _.partial(this.changeField, "text"),
|
||||
"keyup .mailpoet_field_button_url": _.partial(this.changeField, "url"),
|
||||
"input .mailpoet_field_button_text": _.partial(this.changeField, "text"),
|
||||
"input .mailpoet_field_button_url": _.partial(this.changeField, "url"),
|
||||
"change .mailpoet_field_button_alignment": _.partial(this.changeField, "styles.block.textAlign"),
|
||||
"change .mailpoet_field_button_font_color": _.partial(this.changeColorField, "styles.block.fontColor"),
|
||||
"change .mailpoet_field_button_font_family": _.partial(this.changeField, "styles.block.fontFamily"),
|
||||
@ -77,23 +80,19 @@ define([
|
||||
|
||||
"input .mailpoet_field_button_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
|
||||
"change .mailpoet_field_button_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
|
||||
"change .mailpoet_field_button_border_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
|
||||
"keyup .mailpoet_field_button_border_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
|
||||
"input .mailpoet_field_button_border_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_width', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
|
||||
|
||||
"input .mailpoet_field_button_border_radius": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius_input', _.partial(this.changePixelField, "styles.block.borderRadius").bind(this)),
|
||||
"change .mailpoet_field_button_border_radius": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius_input', _.partial(this.changePixelField, "styles.block.borderRadius").bind(this)),
|
||||
"change .mailpoet_field_button_border_radius_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius', _.partial(this.changePixelField, "styles.block.borderRadius").bind(this)),
|
||||
"keyup .mailpoet_field_button_border_radius_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius', _.partial(this.changePixelField, "styles.block.borderRadius").bind(this)),
|
||||
"input .mailpoet_field_button_border_radius_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_border_radius', _.partial(this.changePixelField, "styles.block.borderRadius").bind(this)),
|
||||
|
||||
"input .mailpoet_field_button_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_width_input', _.partial(this.changePixelField, "styles.block.width").bind(this)),
|
||||
"change .mailpoet_field_button_width": _.partial(this.updateValueAndCall, '.mailpoet_field_button_width_input', _.partial(this.changePixelField, "styles.block.width").bind(this)),
|
||||
"change .mailpoet_field_button_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_width', _.partial(this.changePixelField, "styles.block.width").bind(this)),
|
||||
"keyup .mailpoet_field_button_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_width', _.partial(this.changePixelField, "styles.block.width").bind(this)),
|
||||
"input .mailpoet_field_button_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_width', _.partial(this.changePixelField, "styles.block.width").bind(this)),
|
||||
|
||||
"input .mailpoet_field_button_line_height": _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height_input', _.partial(this.changePixelField, "styles.block.lineHeight").bind(this)),
|
||||
"change .mailpoet_field_button_line_height": _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height_input', _.partial(this.changePixelField, "styles.block.lineHeight").bind(this)),
|
||||
"change .mailpoet_field_button_line_height_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height', _.partial(this.changePixelField, "styles.block.lineHeight").bind(this)),
|
||||
"keyup .mailpoet_field_button_line_height_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height', _.partial(this.changePixelField, "styles.block.lineHeight").bind(this)),
|
||||
"input .mailpoet_field_button_line_height_input": _.partial(this.updateValueAndCall, '.mailpoet_field_button_line_height', _.partial(this.changePixelField, "styles.block.lineHeight").bind(this)),
|
||||
|
||||
"click .mailpoet_field_button_replace_all_styles": "applyToAll",
|
||||
"click .mailpoet_done_editing": "close",
|
||||
|
@ -186,13 +186,13 @@ define([
|
||||
},
|
||||
showTools: function() {
|
||||
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
|
||||
this.$(this.ui.tools).show();
|
||||
this.$(this.ui.tools).addClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('showTools');
|
||||
}
|
||||
},
|
||||
hideTools: function() {
|
||||
if (this.renderOptions.depth === 1 && !this.$el.hasClass('mailpoet_container_layer_active')) {
|
||||
this.$(this.ui.tools).hide();
|
||||
this.$(this.ui.tools).removeClass('mailpoet_display_tools');
|
||||
this.toolsView.triggerMethod('hideTools');
|
||||
}
|
||||
},
|
||||
|
@ -43,6 +43,9 @@ define([
|
||||
minLength: 0, // TODO: Move this number to editor configuration
|
||||
modelField: 'styles.block.padding',
|
||||
},
|
||||
ShowSettingsBehavior: {
|
||||
ignoreFrom: '.mailpoet_resize_handle'
|
||||
},
|
||||
}, base.BlockView.prototype.behaviors),
|
||||
onDragSubstituteBy: function() { return Module.DividerWidgetView; },
|
||||
initialize: function() {
|
||||
@ -88,8 +91,7 @@ define([
|
||||
|
||||
"input .mailpoet_field_divider_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
|
||||
"change .mailpoet_field_divider_border_width": _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width_input', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
|
||||
"change .mailpoet_field_divider_border_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
|
||||
"keyup .mailpoet_field_divider_border_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
|
||||
"input .mailpoet_field_divider_border_width_input": _.partial(this.updateValueAndCall, '.mailpoet_field_divider_border_width', _.partial(this.changePixelField, "styles.block.borderWidth").bind(this)),
|
||||
|
||||
"change .mailpoet_field_divider_border_color": _.partial(this.changeColorField, "styles.block.borderColor"),
|
||||
"change .mailpoet_field_divider_background_color": _.partial(this.changeColorField, "styles.block.backgroundColor"),
|
||||
|
@ -71,11 +71,17 @@ define([
|
||||
that.model.set('text', editor.getContent());
|
||||
});
|
||||
|
||||
editor.on('click', function(e) {
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
editor.on('focus', function(e) {
|
||||
that.disableDragging();
|
||||
that.disableShowingTools();
|
||||
});
|
||||
|
||||
editor.on('blur', function(e) {
|
||||
that.enableDragging();
|
||||
that.enableShowingTools();
|
||||
});
|
||||
},
|
||||
@ -84,6 +90,12 @@ define([
|
||||
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle'),
|
||||
});
|
||||
},
|
||||
disableDragging: function() {
|
||||
this.$('.mailpoet_content').addClass('mailpoet_ignore_drag');
|
||||
},
|
||||
enableDragging: function() {
|
||||
this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag');
|
||||
},
|
||||
});
|
||||
|
||||
Module.FooterBlockToolsView = base.BlockToolsView.extend({
|
||||
|
@ -71,11 +71,17 @@ define([
|
||||
that.model.set('text', editor.getContent());
|
||||
});
|
||||
|
||||
editor.on('click', function(e) {
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
editor.on('focus', function(e) {
|
||||
that.disableDragging();
|
||||
that.disableShowingTools();
|
||||
});
|
||||
|
||||
editor.on('blur', function(e) {
|
||||
that.enableDragging();
|
||||
that.enableShowingTools();
|
||||
});
|
||||
},
|
||||
@ -84,6 +90,12 @@ define([
|
||||
mailpoet_shortcodes_window_title: MailPoet.I18n.t('shortcodesWindowTitle'),
|
||||
});
|
||||
},
|
||||
disableDragging: function() {
|
||||
this.$('.mailpoet_content').addClass('mailpoet_ignore_drag');
|
||||
},
|
||||
enableDragging: function() {
|
||||
this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag');
|
||||
},
|
||||
});
|
||||
|
||||
Module.HeaderBlockToolsView = base.BlockToolsView.extend({
|
||||
|
@ -17,8 +17,8 @@ define([
|
||||
defaults: function() {
|
||||
return this._getDefaults({
|
||||
type: 'image',
|
||||
link: 'http://example.org',
|
||||
src: 'no-image.png',
|
||||
link: '',
|
||||
src: '',
|
||||
alt: 'An image of...',
|
||||
fullWidth: true, // true | false
|
||||
width: '64px',
|
||||
@ -41,6 +41,9 @@ define([
|
||||
imageMissingSrc: App.getConfig().get('urls.imageMissing'),
|
||||
}, base.BlockView.prototype.templateHelpers.apply(this));
|
||||
},
|
||||
behaviors: _.extend({}, base.BlockView.prototype.behaviors, {
|
||||
ShowSettingsBehavior: {},
|
||||
}),
|
||||
onRender: function() {
|
||||
this.toolsView = new Module.ImageBlockToolsView({ model: this.model });
|
||||
this.toolsRegion.show(this.toolsView);
|
||||
@ -61,9 +64,9 @@ define([
|
||||
getTemplate: function() { return templates.imageBlockSettings; },
|
||||
events: function() {
|
||||
return {
|
||||
"keyup .mailpoet_field_image_link": _.partial(this.changeField, "link"),
|
||||
"keyup .mailpoet_field_image_address": _.partial(this.changeField, "src"),
|
||||
"keyup .mailpoet_field_image_alt_text": _.partial(this.changeField, "alt"),
|
||||
"input .mailpoet_field_image_link": _.partial(this.changeField, "link"),
|
||||
"input .mailpoet_field_image_address": _.partial(this.changeField, "src"),
|
||||
"input .mailpoet_field_image_alt_text": _.partial(this.changeField, "alt"),
|
||||
"change .mailpoet_field_image_full_width": _.partial(this.changeBoolCheckboxField, "fullWidth"),
|
||||
"change .mailpoet_field_image_alignment": _.partial(this.changeField, "styles.block.textAlign"),
|
||||
"click .mailpoet_field_image_select_another_image": "showMediaManager",
|
||||
|
@ -273,7 +273,7 @@ define([
|
||||
return {
|
||||
'change .mailpoet_settings_posts_content_type': _.partial(this.changeField, 'contentType'),
|
||||
'change .mailpoet_posts_post_status': _.partial(this.changeField, 'postStatus'),
|
||||
'keyup .mailpoet_posts_search_term': _.partial(this.changeField, 'search'),
|
||||
'input .mailpoet_posts_search_term': _.partial(this.changeField, 'search'),
|
||||
};
|
||||
},
|
||||
constructor: function() {
|
||||
@ -302,8 +302,10 @@ define([
|
||||
};
|
||||
},
|
||||
transport: function(options, success, failure) {
|
||||
var taxonomies,
|
||||
promise = CommunicationComponent.getTaxonomies(that.model.get('contentType')).then(function(tax) {
|
||||
var taxonomies;
|
||||
var promise = CommunicationComponent.getTaxonomies(
|
||||
that.model.get('contentType')
|
||||
).then(function(tax) {
|
||||
taxonomies = tax;
|
||||
// Fetch available terms based on the list of taxonomies already fetched
|
||||
var promise = CommunicationComponent.getTerms({
|
||||
@ -312,7 +314,7 @@ define([
|
||||
}).then(function(terms) {
|
||||
return {
|
||||
taxonomies: taxonomies,
|
||||
terms: terms,
|
||||
terms: terms
|
||||
};
|
||||
});
|
||||
return promise;
|
||||
@ -412,17 +414,17 @@ define([
|
||||
"change .mailpoet_posts_title_format": 'changeTitleFormat',
|
||||
"change .mailpoet_posts_title_as_links": _.partial(this.changeBoolField, 'titleIsLink'),
|
||||
"change .mailpoet_posts_show_divider": _.partial(this.changeBoolField, 'showDivider'),
|
||||
"keyup .mailpoet_posts_show_amount": _.partial(this.changeField, "amount"),
|
||||
"input .mailpoet_posts_show_amount": _.partial(this.changeField, "amount"),
|
||||
"change .mailpoet_posts_content_type": _.partial(this.changeField, "contentType"),
|
||||
"change .mailpoet_posts_include_or_exclude": _.partial(this.changeField, "inclusionType"),
|
||||
"change .mailpoet_posts_title_alignment": _.partial(this.changeField, "titleAlignment"),
|
||||
"change .mailpoet_posts_image_full_width": _.partial(this.changeBoolField, "imageFullWidth"),
|
||||
"change .mailpoet_posts_featured_image_position": _.partial(this.changeField, "featuredImagePosition"),
|
||||
"change .mailpoet_posts_show_author": _.partial(this.changeField, "showAuthor"),
|
||||
"keyup .mailpoet_posts_author_preceded_by": _.partial(this.changeField, "authorPrecededBy"),
|
||||
"input .mailpoet_posts_author_preceded_by": _.partial(this.changeField, "authorPrecededBy"),
|
||||
"change .mailpoet_posts_show_categories": _.partial(this.changeField, "showCategories"),
|
||||
"keyup .mailpoet_posts_categories": _.partial(this.changeField, "categoriesPrecededBy"),
|
||||
"keyup .mailpoet_posts_read_more_text": _.partial(this.changeField, "readMoreText"),
|
||||
"input .mailpoet_posts_categories": _.partial(this.changeField, "categoriesPrecededBy"),
|
||||
"input .mailpoet_posts_read_more_text": _.partial(this.changeField, "readMoreText"),
|
||||
"change .mailpoet_posts_sort_by": _.partial(this.changeField, "sortBy"),
|
||||
};
|
||||
},
|
||||
|
@ -93,6 +93,7 @@ define([
|
||||
return {
|
||||
model: this.model.toJSON(),
|
||||
allIconSets: allIconSets.toJSON(),
|
||||
imageMissingSrc: App.getConfig().get('urls.imageMissing'),
|
||||
};
|
||||
},
|
||||
});
|
||||
@ -140,6 +141,7 @@ define([
|
||||
},
|
||||
},
|
||||
HighlightEditingBehavior: {},
|
||||
ShowSettingsBehavior: {},
|
||||
},
|
||||
onDragSubstituteBy: function() { return Module.SocialWidgetView; },
|
||||
constructor: function() {
|
||||
@ -148,6 +150,7 @@ define([
|
||||
Marionette.CompositeView.apply(this, arguments);
|
||||
},
|
||||
initialize: function() {
|
||||
this.on('showSettings', this.showSettings, this);
|
||||
this.on('dom:refresh', this.showBlock, this);
|
||||
this._isFirstRender = true;
|
||||
},
|
||||
@ -168,13 +171,16 @@ define([
|
||||
this.regionManager.destroy();
|
||||
},
|
||||
showTools: function(_event) {
|
||||
this.$(this.ui.tools).show();
|
||||
this.$(this.ui.tools).addClass('mailpoet_display_tools');
|
||||
_event.stopPropagation();
|
||||
},
|
||||
hideTools: function(_event) {
|
||||
this.$(this.ui.tools).hide();
|
||||
this.$(this.ui.tools).removeClass('mailpoet_display_tools');
|
||||
_event.stopPropagation();
|
||||
},
|
||||
showSettings: function(options) {
|
||||
this.toolsView.triggerMethod('showSettings', options);
|
||||
},
|
||||
getDropFunc: function() {
|
||||
return function() {
|
||||
return this.model.clone();
|
||||
@ -274,9 +280,9 @@ define([
|
||||
return {
|
||||
"click .mailpoet_delete_block": "deleteIcon",
|
||||
"change .mailpoet_social_icon_field_type": _.partial(this.changeField, "iconType"),
|
||||
"keyup .mailpoet_social_icon_field_image": _.partial(this.changeField, "image"),
|
||||
"keyup .mailpoet_social_icon_field_link": this.changeLink,
|
||||
"keyup .mailpoet_social_icon_field_text": _.partial(this.changeField, "text"),
|
||||
"input .mailpoet_social_icon_field_image": _.partial(this.changeField, "image"),
|
||||
"input .mailpoet_social_icon_field_link": this.changeLink,
|
||||
"input .mailpoet_social_icon_field_text": _.partial(this.changeField, "text"),
|
||||
};
|
||||
},
|
||||
modelEvents: {
|
||||
@ -383,7 +389,7 @@ define([
|
||||
{
|
||||
type: 'socialIcon',
|
||||
iconType: 'facebook',
|
||||
link: 'http://example.com',
|
||||
link: 'http://www.facebook.com',
|
||||
image: App.getAvailableStyles().get('socialIconSets.default.facebook'),
|
||||
height: '32px',
|
||||
width: '32px',
|
||||
@ -392,7 +398,7 @@ define([
|
||||
{
|
||||
type: 'socialIcon',
|
||||
iconType: 'twitter',
|
||||
link: 'http://example.com',
|
||||
link: 'http://www.twitter.com',
|
||||
image: App.getAvailableStyles().get('socialIconSets.default.twitter'),
|
||||
height: '32px',
|
||||
width: '32px',
|
||||
|
@ -36,6 +36,9 @@ define([
|
||||
minLength: 20, // TODO: Move this number to editor configuration
|
||||
modelField: 'styles.block.height',
|
||||
},
|
||||
ShowSettingsBehavior: {
|
||||
ignoreFrom: '.mailpoet_resize_handle'
|
||||
},
|
||||
}, base.BlockView.prototype.behaviors),
|
||||
modelEvents: _.omit(base.BlockView.prototype.modelEvents, 'change'),
|
||||
onDragSubstituteBy: function() { return Module.SpacerWidgetView; },
|
||||
|
@ -69,11 +69,17 @@ define([
|
||||
that.model.set('text', editor.getContent());
|
||||
});
|
||||
|
||||
editor.on('click', function(e) {
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
editor.on('focus', function(e) {
|
||||
that.disableDragging();
|
||||
that.disableShowingTools();
|
||||
});
|
||||
|
||||
editor.on('blur', function(e) {
|
||||
that.enableDragging();
|
||||
that.enableShowingTools();
|
||||
});
|
||||
},
|
||||
@ -83,6 +89,12 @@ define([
|
||||
});
|
||||
}
|
||||
},
|
||||
disableDragging: function() {
|
||||
this.$('.mailpoet_content').addClass('mailpoet_ignore_drag');
|
||||
},
|
||||
enableDragging: function() {
|
||||
this.$('.mailpoet_content').removeClass('mailpoet_ignore_drag');
|
||||
},
|
||||
});
|
||||
|
||||
Module.TextBlockToolsView = base.BlockToolsView.extend({
|
||||
|
@ -11,7 +11,7 @@ define([
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'automatedLatestContent',
|
||||
action: args.action,
|
||||
data: args.options || {},
|
||||
data: args.options || {}
|
||||
});
|
||||
};
|
||||
Module._cachedQuery = _.memoize(Module._query, JSON.stringify);
|
||||
@ -19,16 +19,16 @@ define([
|
||||
Module.getNewsletter = function(options) {
|
||||
return Module._query({
|
||||
action: 'get',
|
||||
options: options,
|
||||
options: options
|
||||
});
|
||||
};
|
||||
|
||||
Module.getPostTypes = function() {
|
||||
return Module._cachedQuery({
|
||||
action: 'getPostTypes',
|
||||
options: {},
|
||||
}).then(function(types) {
|
||||
return _.values(types);
|
||||
options: {}
|
||||
}).then(function(response) {
|
||||
return _.values(response.data);
|
||||
});
|
||||
};
|
||||
|
||||
@ -36,36 +36,46 @@ define([
|
||||
return Module._cachedQuery({
|
||||
action: 'getTaxonomies',
|
||||
options: {
|
||||
postType: postType,
|
||||
},
|
||||
postType: postType
|
||||
}
|
||||
}).then(function(response) {
|
||||
return response.data;
|
||||
});
|
||||
};
|
||||
|
||||
Module.getTerms = function(options) {
|
||||
return Module._cachedQuery({
|
||||
action: 'getTerms',
|
||||
options: options,
|
||||
options: options
|
||||
}).then(function(response) {
|
||||
return response.data;
|
||||
});
|
||||
};
|
||||
|
||||
Module.getPosts = function(options) {
|
||||
return Module._cachedQuery({
|
||||
action: 'getPosts',
|
||||
options: options,
|
||||
options: options
|
||||
}).then(function(response) {
|
||||
return response.data;
|
||||
});
|
||||
};
|
||||
|
||||
Module.getTransformedPosts = function(options) {
|
||||
return Module._cachedQuery({
|
||||
action: 'getTransformedPosts',
|
||||
options: options,
|
||||
options: options
|
||||
}).then(function(response) {
|
||||
return response.data;
|
||||
});
|
||||
};
|
||||
|
||||
Module.getBulkTransformedPosts = function(options) {
|
||||
return Module._query({
|
||||
action: 'getBulkTransformedPosts',
|
||||
options: options,
|
||||
options: options
|
||||
}).then(function(response) {
|
||||
return response.data;
|
||||
});
|
||||
};
|
||||
|
||||
@ -73,7 +83,7 @@ define([
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'save',
|
||||
data: options || {},
|
||||
data: options || {}
|
||||
});
|
||||
};
|
||||
|
||||
@ -81,7 +91,7 @@ define([
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'sendPreview',
|
||||
data: options || {},
|
||||
data: options || {}
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -11,15 +11,16 @@ define([
|
||||
// Does not hold newsletter content nor newsletter styles, those are
|
||||
// handled by other components.
|
||||
Module.NewsletterModel = SuperModel.extend({
|
||||
stale: ['body', 'created_at', 'deleted_at', 'updated_at'],
|
||||
whitelisted: ['id', 'subject', 'preheader'],
|
||||
initialize: function(options) {
|
||||
this.on('change', function() {
|
||||
App.getChannel().trigger('autoSave');
|
||||
});
|
||||
},
|
||||
toJSON: function() {
|
||||
// Remove stale attributes from resulting JSON object
|
||||
return _.omit(SuperModel.prototype.toJSON.call(this), this.stale);
|
||||
// Use only whitelisted properties to ensure properties editor
|
||||
// doesn't control don't change.
|
||||
return _.pick(SuperModel.prototype.toJSON.call(this), this.whitelisted);
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -104,7 +104,7 @@ define([
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletterTemplates',
|
||||
action: 'save',
|
||||
data: data,
|
||||
data: data
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -65,10 +65,6 @@ define([
|
||||
var $openRegion = this.$el.find('.mailpoet_sidebar_region:not(.closed)'),
|
||||
$targetRegion = this.$el.find(event.target).closest('.mailpoet_sidebar_region');
|
||||
|
||||
if ($openRegion.get(0) === $targetRegion.get(0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$openRegion.find('.mailpoet_region_content').velocity(
|
||||
'slideUp',
|
||||
{
|
||||
@ -79,16 +75,19 @@ define([
|
||||
}.bind(this)
|
||||
}
|
||||
);
|
||||
$targetRegion.find('.mailpoet_region_content').velocity(
|
||||
'slideDown',
|
||||
{
|
||||
duration: 250,
|
||||
easing: "easeIn",
|
||||
complete: function() {
|
||||
$targetRegion.removeClass('closed');
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if ($openRegion.get(0) !== $targetRegion.get(0)) {
|
||||
$targetRegion.find('.mailpoet_region_content').velocity(
|
||||
'slideDown',
|
||||
{
|
||||
duration: 250,
|
||||
easing: "easeIn",
|
||||
complete: function() {
|
||||
$targetRegion.removeClass('closed');
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
initialize: function(options) {
|
||||
@ -233,6 +232,12 @@ define([
|
||||
'click .mailpoet_show_preview': 'showPreview',
|
||||
'click #mailpoet_send_preview': 'sendPreview',
|
||||
},
|
||||
onBeforeDestroy: function() {
|
||||
if (this.previewView) {
|
||||
this.previewView.destroy();
|
||||
this.previewView = null;
|
||||
}
|
||||
},
|
||||
showPreview: function() {
|
||||
var json = App.toJSON();
|
||||
|
||||
@ -247,18 +252,31 @@ define([
|
||||
endpoint: 'newsletters',
|
||||
action: 'showPreview',
|
||||
data: json,
|
||||
}).done(function(response){
|
||||
}).always(function() {
|
||||
MailPoet.Modal.loading(false);
|
||||
}).done(function(response) {
|
||||
this.previewView = new Module.NewsletterPreviewView({
|
||||
previewUrl: response.meta.preview_url
|
||||
});
|
||||
|
||||
if (response.result === true) {
|
||||
window.open(response.data.url, '_blank')
|
||||
var view = this.previewView.render();
|
||||
|
||||
MailPoet.Modal.popup({
|
||||
template: '',
|
||||
element: this.previewView.$el,
|
||||
title: MailPoet.I18n.t('newsletterPreview'),
|
||||
onCancel: function() {
|
||||
this.previewView.destroy();
|
||||
this.previewView = null;
|
||||
}.bind(this)
|
||||
});
|
||||
}.bind(this)).fail(function(response) {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
MailPoet.Notice.error(response.errors);
|
||||
}).fail(function(error) {
|
||||
MailPoet.Modal.loading(false);
|
||||
MailPoet.Notice.error(
|
||||
MailPoet.I18n.t('newsletterPreviewFailed')
|
||||
);
|
||||
});
|
||||
},
|
||||
sendPreview: function() {
|
||||
@ -283,32 +301,39 @@ define([
|
||||
// send test email
|
||||
MailPoet.Modal.loading(true);
|
||||
|
||||
CommunicationComponent.previewNewsletter(data).done(function(response) {
|
||||
if(response.result !== undefined && response.result === true) {
|
||||
MailPoet.Notice.success(MailPoet.I18n.t('newsletterPreviewSent'), { scroll: true });
|
||||
} else {
|
||||
if (_.isArray(response.errors)) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error, { scroll: true });
|
||||
});
|
||||
} else {
|
||||
MailPoet.Notice.error(
|
||||
MailPoet.I18n.t('newsletterPreviewFailedToSend'),
|
||||
{
|
||||
scroll: true,
|
||||
static: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
CommunicationComponent.previewNewsletter(data).always(function() {
|
||||
MailPoet.Modal.loading(false);
|
||||
}).done(function(response) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('newsletterPreviewSent'),
|
||||
{ scroll: true });
|
||||
}).fail(function(response) {
|
||||
// an error occurred
|
||||
MailPoet.Modal.loading(false);
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true, static: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
Module.NewsletterPreviewView = Marionette.ItemView.extend({
|
||||
getTemplate: function() { return templates.newsletterPreview; },
|
||||
initialize: function(options) {
|
||||
this.previewUrl = options.previewUrl;
|
||||
this.width = App.getConfig().get('newsletterPreview.width');
|
||||
this.height = App.getConfig().get('newsletterPreview.height')
|
||||
},
|
||||
templateHelpers: function() {
|
||||
return {
|
||||
previewUrl: this.previewUrl,
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
App.on('before:start', function(options) {
|
||||
App.registerWidget = Module.registerWidget;
|
||||
App.getWidgets = Module.getWidgets;
|
||||
|
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 26 KiB |
179
assets/js/src/newsletters/listings/mixins.jsx
Normal file
@ -0,0 +1,179 @@
|
||||
import React from 'react'
|
||||
import MailPoet from 'mailpoet'
|
||||
import classNames from 'classnames'
|
||||
import jQuery from 'jquery'
|
||||
|
||||
const _QueueMixin = {
|
||||
pauseSending: function(newsletter) {
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'sendingQueue',
|
||||
action: 'pause',
|
||||
data: {
|
||||
newsletter_id: newsletter.id
|
||||
}
|
||||
}).done(function() {
|
||||
jQuery('#resume_'+newsletter.id).show();
|
||||
jQuery('#pause_'+newsletter.id).hide();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
resumeSending: function(newsletter) {
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'sendingQueue',
|
||||
action: 'resume',
|
||||
data: {
|
||||
newsletter_id: newsletter.id
|
||||
}
|
||||
}).done(function() {
|
||||
jQuery('#pause_'+newsletter.id).show();
|
||||
jQuery('#resume_'+newsletter.id).hide();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
renderQueueStatus: function(newsletter) {
|
||||
if (!newsletter.queue) {
|
||||
return (
|
||||
<span>{MailPoet.I18n.t('notSentYet')}</span>
|
||||
);
|
||||
} else {
|
||||
if (newsletter.queue.status === 'scheduled') {
|
||||
return (
|
||||
<span>
|
||||
{ MailPoet.I18n.t('scheduledFor') } { MailPoet.Date.format(newsletter.queue.scheduled_at) }
|
||||
</span>
|
||||
)
|
||||
}
|
||||
const progressClasses = classNames(
|
||||
'mailpoet_progress',
|
||||
{ 'mailpoet_progress_complete': newsletter.queue.status === 'completed'}
|
||||
);
|
||||
|
||||
// calculate percentage done
|
||||
let percentage = Math.round(
|
||||
(newsletter.queue.count_processed * 100) / (newsletter.queue.count_total)
|
||||
);
|
||||
|
||||
let label;
|
||||
|
||||
if (newsletter.queue.status === 'completed') {
|
||||
label = (
|
||||
<span>
|
||||
{
|
||||
MailPoet.I18n.t('newsletterQueueCompleted')
|
||||
.replace(
|
||||
"%$1d",
|
||||
newsletter.queue.count_processed - newsletter.queue.count_failed
|
||||
)
|
||||
.replace(
|
||||
"%$2d",
|
||||
newsletter.queue.count_total
|
||||
)
|
||||
}
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
label = (
|
||||
<span>
|
||||
{ newsletter.queue.count_processed } / { newsletter.queue.count_total }
|
||||
|
||||
<a
|
||||
id={ 'resume_'+newsletter.id }
|
||||
className="button"
|
||||
style={{ display: (newsletter.queue.status === 'paused')
|
||||
? 'inline-block': 'none' }}
|
||||
href="javascript:;"
|
||||
onClick={ this.resumeSending.bind(null, newsletter) }
|
||||
>{MailPoet.I18n.t('resume')}</a>
|
||||
<a
|
||||
id={ 'pause_'+newsletter.id }
|
||||
className="button mailpoet_pause"
|
||||
style={{ display: (newsletter.queue.status === null)
|
||||
? 'inline-block': 'none' }}
|
||||
href="javascript:;"
|
||||
onClick={ this.pauseSending.bind(null, newsletter) }
|
||||
>{MailPoet.I18n.t('pause')}</a>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
let progress_bar_width = 0;
|
||||
|
||||
if (isNaN(percentage)) {
|
||||
percentage = MailPoet.I18n.t('noSubscribers');
|
||||
} else {
|
||||
progress_bar_width = percentage;
|
||||
percentage += "%";
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={ progressClasses }>
|
||||
<span
|
||||
className="mailpoet_progress_bar"
|
||||
style={ { width: progress_bar_width + "%"} }
|
||||
></span>
|
||||
<span className="mailpoet_progress_label">
|
||||
{ percentage }
|
||||
</span>
|
||||
</div>
|
||||
<p style={{ textAlign:'center' }}>
|
||||
{ label }
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const _StatisticsMixin = {
|
||||
renderStatistics: function(newsletter) {
|
||||
if (
|
||||
newsletter.statistics
|
||||
&& newsletter.queue
|
||||
&& newsletter.queue.status !== 'scheduled'
|
||||
) {
|
||||
const total_sent = ~~(newsletter.queue.count_processed);
|
||||
|
||||
let percentage_clicked = 0;
|
||||
let percentage_opened = 0;
|
||||
let percentage_unsubscribed = 0;
|
||||
|
||||
if (total_sent > 0) {
|
||||
percentage_clicked = Math.round(
|
||||
(~~(newsletter.statistics.clicked) * 100) / total_sent
|
||||
);
|
||||
percentage_opened = Math.round(
|
||||
(~~(newsletter.statistics.opened) * 100) / total_sent
|
||||
);
|
||||
percentage_unsubscribed = Math.round(
|
||||
(~~(newsletter.statistics.unsubscribed) * 100) / total_sent
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<span>
|
||||
{ percentage_opened }%, { percentage_clicked }%, { percentage_unsubscribed }%
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<span>{MailPoet.I18n.t('notSentYet')}</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { _QueueMixin as QueueMixin };
|
||||
export { _StatisticsMixin as StatisticsMixin };
|
@ -17,8 +17,8 @@ import {
|
||||
} from 'newsletters/scheduling/common.jsx'
|
||||
|
||||
const messages = {
|
||||
onTrash(response) {
|
||||
const count = ~~response;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -28,12 +28,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete(response) {
|
||||
const count = ~~response;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -43,12 +43,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore(response) {
|
||||
const count = ~~response;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -58,7 +58,7 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -127,16 +127,23 @@ const newsletter_actions = [
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'duplicate',
|
||||
data: newsletter.id
|
||||
}).done(function(response) {
|
||||
if (response !== false && response.subject !== undefined) {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.subject
|
||||
)
|
||||
data: {
|
||||
id: newsletter.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.data.subject
|
||||
)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -158,20 +165,18 @@ const NewsletterListNotification = React.createClass({
|
||||
id: ~~(e.target.getAttribute('data-id')),
|
||||
status: e.target.value
|
||||
}
|
||||
}).done(function(response) {
|
||||
if (response.result === false) {
|
||||
MailPoet.Notice.error(MailPoet.I18n.t('postNotificationActivationFailed'));
|
||||
|
||||
// reset value to actual newsletter's status
|
||||
e.target.value = response.status;
|
||||
} else {
|
||||
if (response.status === 'active') {
|
||||
MailPoet.Notice.success(MailPoet.I18n.t('postNotificationActivated'));
|
||||
}
|
||||
// force refresh of listing so that groups are updated
|
||||
this.forceUpdate();
|
||||
}).done((response) => {
|
||||
if (response.data.status === 'active') {
|
||||
MailPoet.Notice.success(MailPoet.I18n.t('postNotificationActivated'));
|
||||
}
|
||||
}.bind(this));
|
||||
// force refresh of listing so that groups are updated
|
||||
this.forceUpdate();
|
||||
}).fail((response) => {
|
||||
MailPoet.Notice.error(MailPoet.I18n.t('postNotificationActivationFailed'));
|
||||
|
||||
// reset value to actual newsletter's status
|
||||
e.target.value = response.status;
|
||||
});
|
||||
},
|
||||
renderStatus: function(newsletter) {
|
||||
return (
|
||||
@ -189,53 +194,62 @@ const NewsletterListNotification = React.createClass({
|
||||
let sendingFrequency;
|
||||
let sendingToSegments;
|
||||
|
||||
// set sending frequency
|
||||
switch (newsletter.options.intervalType) {
|
||||
case 'daily':
|
||||
sendingFrequency = MailPoet.I18n.t('sendDaily').replace(
|
||||
'%$1s', timeOfDayValues[newsletter.options.timeOfDay]
|
||||
);
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
sendingFrequency = MailPoet.I18n.t('sendWeekly').replace(
|
||||
'%$1s', weekDayValues[newsletter.options.weekDay]
|
||||
).replace(
|
||||
'%$2s', timeOfDayValues[newsletter.options.timeOfDay]
|
||||
);
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
sendingFrequency = MailPoet.I18n.t('sendMonthly').replace(
|
||||
'%$1s', monthDayValues[newsletter.options.monthDay]
|
||||
).replace(
|
||||
'%$2s', timeOfDayValues[newsletter.options.timeOfDay]
|
||||
);
|
||||
break;
|
||||
|
||||
case 'nthWeekDay':
|
||||
sendingFrequency = MailPoet.I18n.t('sendNthWeekDay').replace(
|
||||
'%$1s', nthWeekDayValues[newsletter.options.nthWeekDay]
|
||||
).replace(
|
||||
'%$2s', weekDayValues[newsletter.options.weekDay]
|
||||
).replace(
|
||||
'%$3s', timeOfDayValues[newsletter.options.timeOfDay]
|
||||
);
|
||||
break;
|
||||
|
||||
case 'immediately':
|
||||
sendingFrequency = MailPoet.I18n.t('sendImmediately');
|
||||
break;
|
||||
}
|
||||
|
||||
// set segments
|
||||
// get list of segments' name
|
||||
const segments = newsletter.segments.map(function(segment) {
|
||||
return segment.name
|
||||
}).join(', ');
|
||||
});
|
||||
|
||||
sendingToSegments = MailPoet.I18n.t('ifNewContentToSegments').replace(
|
||||
'%$1s', segments
|
||||
);
|
||||
// check if the user has specified segments to send to
|
||||
if(segments.length === 0) {
|
||||
return (
|
||||
<span className="mailpoet_error">
|
||||
{ MailPoet.I18n.t('sendingToSegmentsNotSpecified') }
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
sendingToSegments = MailPoet.I18n.t('ifNewContentToSegments').replace(
|
||||
'%$1s', segments.join(', ')
|
||||
);
|
||||
|
||||
// set sending frequency
|
||||
switch (newsletter.options.intervalType) {
|
||||
case 'daily':
|
||||
sendingFrequency = MailPoet.I18n.t('sendDaily').replace(
|
||||
'%$1s', timeOfDayValues[newsletter.options.timeOfDay]
|
||||
);
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
sendingFrequency = MailPoet.I18n.t('sendWeekly').replace(
|
||||
'%$1s', weekDayValues[newsletter.options.weekDay]
|
||||
).replace(
|
||||
'%$2s', timeOfDayValues[newsletter.options.timeOfDay]
|
||||
);
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
sendingFrequency = MailPoet.I18n.t('sendMonthly').replace(
|
||||
'%$1s', monthDayValues[newsletter.options.monthDay]
|
||||
).replace(
|
||||
'%$2s', timeOfDayValues[newsletter.options.timeOfDay]
|
||||
);
|
||||
break;
|
||||
|
||||
case 'nthWeekDay':
|
||||
sendingFrequency = MailPoet.I18n.t('sendNthWeekDay').replace(
|
||||
'%$1s', nthWeekDayValues[newsletter.options.nthWeekDay]
|
||||
).replace(
|
||||
'%$2s', weekDayValues[newsletter.options.weekDay]
|
||||
).replace(
|
||||
'%$3s', timeOfDayValues[newsletter.options.timeOfDay]
|
||||
);
|
||||
break;
|
||||
|
||||
case 'immediately':
|
||||
sendingFrequency = MailPoet.I18n.t('sendImmediately');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<span>
|
||||
@ -243,6 +257,20 @@ const NewsletterListNotification = React.createClass({
|
||||
</span>
|
||||
);
|
||||
},
|
||||
renderHistoryLink: function(newsletter) {
|
||||
const childrenCount = ~~(newsletter.children_count);
|
||||
if (childrenCount === 0) {
|
||||
return (
|
||||
MailPoet.I18n.t('notSentYet')
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<Link
|
||||
to={ `/notification/history/${ newsletter.id }` }
|
||||
>{ MailPoet.I18n.t('viewHistory') }</Link>
|
||||
);
|
||||
}
|
||||
},
|
||||
renderItem: function(newsletter, actions) {
|
||||
const rowClasses = classNames(
|
||||
'manage-column',
|
||||
@ -254,9 +282,10 @@ const NewsletterListNotification = React.createClass({
|
||||
<div>
|
||||
<td className={ rowClasses }>
|
||||
<strong>
|
||||
<a href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }>
|
||||
{ newsletter.subject }
|
||||
</a>
|
||||
<a
|
||||
className="row-title"
|
||||
href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }
|
||||
>{ newsletter.subject }</a>
|
||||
</strong>
|
||||
{ actions }
|
||||
</td>
|
||||
@ -267,7 +296,7 @@ const NewsletterListNotification = React.createClass({
|
||||
{ this.renderSettings(newsletter) }
|
||||
</td>
|
||||
<td className="column" data-colname={ MailPoet.I18n.t('history') }>
|
||||
<a href="#TODO">{ MailPoet.I18n.t('viewHistory') }</a>
|
||||
{ this.renderHistoryLink(newsletter) }
|
||||
</td>
|
||||
<td className="column-date" data-colname={ MailPoet.I18n.t('lastModifiedOn') }>
|
||||
<abbr>{ MailPoet.Date.format(newsletter.updated_at) }</abbr>
|
||||
@ -286,15 +315,19 @@ const NewsletterListNotification = React.createClass({
|
||||
|
||||
<Listing
|
||||
limit={ mailpoet_listing_per_page }
|
||||
location={ this.props.location }
|
||||
params={ this.props.params }
|
||||
endpoint="newsletters"
|
||||
tab="notification"
|
||||
type="notification"
|
||||
base_url="notification"
|
||||
onRenderItem={ this.renderItem }
|
||||
columns={ columns }
|
||||
bulk_actions={ bulk_actions }
|
||||
item_actions={ newsletter_actions }
|
||||
messages={ messages }
|
||||
auto_refresh={ true }
|
||||
sort_by="updated_at"
|
||||
sort_order="desc"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
125
assets/js/src/newsletters/listings/notification_history.jsx
Normal file
@ -0,0 +1,125 @@
|
||||
import React from 'react'
|
||||
import { Router, Link } from 'react-router'
|
||||
import classNames from 'classnames'
|
||||
import jQuery from 'jquery'
|
||||
import MailPoet from 'mailpoet'
|
||||
|
||||
import Listing from 'listing/listing.jsx'
|
||||
import ListingTabs from 'newsletters/listings/tabs.jsx'
|
||||
|
||||
import { QueueMixin, StatisticsMixin } from 'newsletters/listings/mixins.jsx'
|
||||
|
||||
const mailpoet_tracking_enabled = (!!(window['mailpoet_tracking_enabled']));
|
||||
|
||||
const columns = [
|
||||
{
|
||||
name: 'subject',
|
||||
label: MailPoet.I18n.t('subject'),
|
||||
},
|
||||
{
|
||||
name: 'status',
|
||||
label: MailPoet.I18n.t('status')
|
||||
},
|
||||
{
|
||||
name: 'segments',
|
||||
label: MailPoet.I18n.t('lists')
|
||||
},
|
||||
{
|
||||
name: 'statistics',
|
||||
label: MailPoet.I18n.t('statistics'),
|
||||
display: mailpoet_tracking_enabled
|
||||
},
|
||||
{
|
||||
name: 'processed_at',
|
||||
label: MailPoet.I18n.t('sentOn'),
|
||||
}
|
||||
];
|
||||
|
||||
const newsletter_actions = [
|
||||
{
|
||||
name: 'view',
|
||||
link: function(newsletter) {
|
||||
return (
|
||||
<a href={ newsletter.preview_url } target="_blank">
|
||||
{MailPoet.I18n.t('preview')}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
const NewsletterListNotificationHistory = React.createClass({
|
||||
mixins: [QueueMixin, StatisticsMixin],
|
||||
renderItem: function(newsletter, actions) {
|
||||
const rowClasses = classNames(
|
||||
'manage-column',
|
||||
'column-primary',
|
||||
'has-row-actions'
|
||||
);
|
||||
|
||||
const segments = newsletter.segments.map(function(segment) {
|
||||
return segment.name
|
||||
}).join(', ');
|
||||
|
||||
return (
|
||||
<div>
|
||||
<td className={ rowClasses }>
|
||||
<strong>
|
||||
<a
|
||||
href={ newsletter.preview_url }
|
||||
target="_blank"
|
||||
>{ newsletter.queue.newsletter_rendered_subject }</a>
|
||||
</strong>
|
||||
{ actions }
|
||||
</td>
|
||||
<td className="column" data-colname={ MailPoet.I18n.t('status') }>
|
||||
{ this.renderQueueStatus(newsletter) }
|
||||
</td>
|
||||
<td className="column" data-colname={ MailPoet.I18n.t('lists') }>
|
||||
{ segments }
|
||||
</td>
|
||||
{ (mailpoet_tracking_enabled === true) ? (
|
||||
<td className="column" data-colname={ MailPoet.I18n.t('statistics') }>
|
||||
{ this.renderStatistics(newsletter) }
|
||||
</td>
|
||||
) : null }
|
||||
<td className="column-date" data-colname={ MailPoet.I18n.t('lastModifiedOn') }>
|
||||
<abbr>{ MailPoet.Date.format(newsletter.updated_at) }</abbr>
|
||||
</td>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
<div>
|
||||
<h1 className="title">
|
||||
{MailPoet.I18n.t('pageTitle')} <Link className="page-title-action" to="/new">{MailPoet.I18n.t('new')}</Link>
|
||||
</h1>
|
||||
|
||||
<ListingTabs tab="notification" />
|
||||
|
||||
<Link
|
||||
className="page-title-action"
|
||||
to="/notification"
|
||||
>{MailPoet.I18n.t('backToPostNotifications')}</Link>
|
||||
|
||||
<Listing
|
||||
limit={ mailpoet_listing_per_page }
|
||||
location={ this.props.location }
|
||||
params={ this.props.params }
|
||||
endpoint="newsletters"
|
||||
type="notification_history"
|
||||
base_url="notification/history/:parent_id"
|
||||
onRenderItem={ this.renderItem }
|
||||
columns={columns}
|
||||
item_actions={ newsletter_actions }
|
||||
auto_refresh={ true }
|
||||
sort_by="updated_at"
|
||||
sort_order="desc"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = NewsletterListNotificationHistory;
|
@ -1,19 +1,19 @@
|
||||
import React from 'react'
|
||||
import { Router, Route, IndexRoute, Link, useRouterHistory } from 'react-router'
|
||||
import { createHashHistory } from 'history'
|
||||
|
||||
import Listing from 'listing/listing.jsx'
|
||||
import ListingTabs from 'newsletters/listings/tabs.jsx'
|
||||
|
||||
import { Router, Link } from 'react-router'
|
||||
import classNames from 'classnames'
|
||||
import jQuery from 'jquery'
|
||||
import MailPoet from 'mailpoet'
|
||||
|
||||
import Listing from 'listing/listing.jsx'
|
||||
import ListingTabs from 'newsletters/listings/tabs.jsx'
|
||||
|
||||
import { QueueMixin, StatisticsMixin } from 'newsletters/listings/mixins.jsx'
|
||||
|
||||
const mailpoet_tracking_enabled = (!!(window['mailpoet_tracking_enabled']));
|
||||
|
||||
const messages = {
|
||||
onTrash(response) {
|
||||
const count = ~~response;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -23,12 +23,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete(response) {
|
||||
const count = ~~response;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -38,12 +38,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore(response) {
|
||||
const count = ~~response;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -53,7 +53,7 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -122,16 +122,23 @@ const newsletter_actions = [
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'duplicate',
|
||||
data: newsletter.id
|
||||
}).done(function(response) {
|
||||
if (response !== false && response.subject !== undefined) {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.subject
|
||||
)
|
||||
data: {
|
||||
id: newsletter.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.data.subject
|
||||
)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -141,135 +148,7 @@ const newsletter_actions = [
|
||||
];
|
||||
|
||||
const NewsletterListStandard = React.createClass({
|
||||
pauseSending: function(newsletter) {
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'sendingQueue',
|
||||
action: 'pause',
|
||||
data: newsletter.id
|
||||
}).done(function() {
|
||||
jQuery('#resume_'+newsletter.id).show();
|
||||
jQuery('#pause_'+newsletter.id).hide();
|
||||
});
|
||||
},
|
||||
resumeSending: function(newsletter) {
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'sendingQueue',
|
||||
action: 'resume',
|
||||
data: newsletter.id
|
||||
}).done(function() {
|
||||
jQuery('#pause_'+newsletter.id).show();
|
||||
jQuery('#resume_'+newsletter.id).hide();
|
||||
});
|
||||
},
|
||||
renderStatus: function(newsletter) {
|
||||
if (!newsletter.queue) {
|
||||
return (
|
||||
<span>{MailPoet.I18n.t('notSentYet')}</span>
|
||||
);
|
||||
} else {
|
||||
if (newsletter.queue.status === 'scheduled') {
|
||||
return (
|
||||
<span>{MailPoet.I18n.t('scheduledFor')} { MailPoet.Date.format(newsletter.queue.scheduled_at) } </span>
|
||||
)
|
||||
}
|
||||
const progressClasses = classNames(
|
||||
'mailpoet_progress',
|
||||
{ 'mailpoet_progress_complete': newsletter.queue.status === 'completed'}
|
||||
);
|
||||
|
||||
// calculate percentage done
|
||||
const percentage = Math.round(
|
||||
(newsletter.queue.count_processed * 100) / (newsletter.queue.count_total)
|
||||
);
|
||||
|
||||
let label;
|
||||
|
||||
if (newsletter.queue.status === 'completed') {
|
||||
label = (
|
||||
<span>
|
||||
{
|
||||
MailPoet.I18n.t('newsletterQueueCompleted')
|
||||
.replace("%$1d", newsletter.queue.count_processed - newsletter.queue.count_failed)
|
||||
.replace("%$2d", newsletter.queue.count_total)
|
||||
}
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
label = (
|
||||
<span>
|
||||
{ newsletter.queue.count_processed } / { newsletter.queue.count_total }
|
||||
|
||||
<a
|
||||
id={ 'resume_'+newsletter.id }
|
||||
className="button"
|
||||
style={{ display: (newsletter.queue.status === 'paused') ? 'inline-block': 'none' }}
|
||||
href="javascript:;"
|
||||
onClick={ this.resumeSending.bind(null, newsletter) }
|
||||
>{MailPoet.I18n.t('resume')}</a>
|
||||
<a
|
||||
id={ 'pause_'+newsletter.id }
|
||||
className="button mailpoet_pause"
|
||||
style={{ display: (newsletter.queue.status === null) ? 'inline-block': 'none' }}
|
||||
href="javascript:;"
|
||||
onClick={ this.pauseSending.bind(null, newsletter) }
|
||||
>{MailPoet.I18n.t('pause')}</a>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={ progressClasses }>
|
||||
<span
|
||||
className="mailpoet_progress_bar"
|
||||
style={ { width: percentage + "%"} }
|
||||
></span>
|
||||
<span className="mailpoet_progress_label">
|
||||
{ percentage + "%" }
|
||||
</span>
|
||||
</div>
|
||||
<p style={{ textAlign:'center' }}>
|
||||
{ label }
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
},
|
||||
renderStatistics: function(newsletter) {
|
||||
if (mailpoet_tracking_enabled === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newsletter.statistics && newsletter.queue && newsletter.queue.status !== 'scheduled') {
|
||||
const total_sent = ~~(newsletter.queue.count_processed);
|
||||
|
||||
let percentage_clicked = 0;
|
||||
let percentage_opened = 0;
|
||||
let percentage_unsubscribed = 0;
|
||||
|
||||
if (total_sent > 0) {
|
||||
percentage_clicked = Math.round(
|
||||
(~~(newsletter.statistics.clicked) * 100) / total_sent
|
||||
);
|
||||
percentage_opened = Math.round(
|
||||
(~~(newsletter.statistics.opened) * 100) / total_sent
|
||||
);
|
||||
percentage_unsubscribed = Math.round(
|
||||
(~~(newsletter.statistics.unsubscribed) * 100) / total_sent
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<span>
|
||||
{ percentage_opened }%, { percentage_clicked }%, { percentage_unsubscribed }%
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<span>{MailPoet.I18n.t('notSentYet')}</span>
|
||||
);
|
||||
}
|
||||
},
|
||||
mixins: [QueueMixin, StatisticsMixin],
|
||||
renderItem: function(newsletter, actions) {
|
||||
const rowClasses = classNames(
|
||||
'manage-column',
|
||||
@ -285,14 +164,15 @@ const NewsletterListStandard = React.createClass({
|
||||
<div>
|
||||
<td className={ rowClasses }>
|
||||
<strong>
|
||||
<a href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }>
|
||||
{ newsletter.subject }
|
||||
</a>
|
||||
<a
|
||||
className="row-title"
|
||||
href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }
|
||||
>{ newsletter.subject }</a>
|
||||
</strong>
|
||||
{ actions }
|
||||
</td>
|
||||
<td className="column" data-colname={ MailPoet.I18n.t('status') }>
|
||||
{ this.renderStatus(newsletter) }
|
||||
{ this.renderQueueStatus(newsletter) }
|
||||
</td>
|
||||
<td className="column" data-colname={ MailPoet.I18n.t('lists') }>
|
||||
{ segments }
|
||||
@ -319,15 +199,19 @@ const NewsletterListStandard = React.createClass({
|
||||
|
||||
<Listing
|
||||
limit={ mailpoet_listing_per_page }
|
||||
location={ this.props.location }
|
||||
params={ this.props.params }
|
||||
endpoint="newsletters"
|
||||
tab="standard"
|
||||
type="standard"
|
||||
base_url="standard"
|
||||
onRenderItem={this.renderItem}
|
||||
columns={columns}
|
||||
bulk_actions={ bulk_actions }
|
||||
item_actions={ newsletter_actions }
|
||||
messages={ messages }
|
||||
auto_refresh={ true }
|
||||
sort_by="updated_at"
|
||||
sort_order="desc"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
@ -11,11 +11,12 @@ import MailPoet from 'mailpoet'
|
||||
import _ from 'underscore'
|
||||
|
||||
const mailpoet_roles = window.mailpoet_roles || {};
|
||||
const mailpoet_segments = window.mailpoet_segments || {};
|
||||
const mailpoet_tracking_enabled = (!!(window['mailpoet_tracking_enabled']));
|
||||
|
||||
const messages = {
|
||||
onTrash(response) {
|
||||
const count = ~~response;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -25,12 +26,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete(response) {
|
||||
const count = ~~response;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -40,12 +41,12 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore(response) {
|
||||
const count = ~~response;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if (count === 1) {
|
||||
@ -55,7 +56,7 @@ const messages = {
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleNewslettersRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -124,16 +125,23 @@ const newsletter_actions = [
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'duplicate',
|
||||
data: newsletter.id
|
||||
}).done(function(response) {
|
||||
if (response !== false && response.subject !== undefined) {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.subject
|
||||
)
|
||||
data: {
|
||||
id: newsletter.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('newsletterDuplicated')).replace(
|
||||
'%$1s', response.data.subject
|
||||
)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
},
|
||||
@ -155,20 +163,18 @@ const NewsletterListWelcome = React.createClass({
|
||||
id: ~~(e.target.getAttribute('data-id')),
|
||||
status: e.target.value
|
||||
}
|
||||
}).done(function(response) {
|
||||
if (response.result === false) {
|
||||
MailPoet.Notice.error(MailPoet.I18n.t('welcomeEmailActivationFailed'));
|
||||
|
||||
// reset value to actual newsletter's status
|
||||
e.target.value = response.status;
|
||||
} else {
|
||||
if (response.status === 'active') {
|
||||
MailPoet.Notice.success(MailPoet.I18n.t('welcomeEmailActivated'));
|
||||
}
|
||||
// force refresh of listing so that groups are updated
|
||||
this.forceUpdate();
|
||||
}).done((response) => {
|
||||
if (response.data.status === 'active') {
|
||||
MailPoet.Notice.success(MailPoet.I18n.t('welcomeEmailActivated'));
|
||||
}
|
||||
}.bind(this));
|
||||
// force refresh of listing so that groups are updated
|
||||
this.forceUpdate();
|
||||
}).fail((response) => {
|
||||
MailPoet.Notice.error(MailPoet.I18n.t('welcomeEmailActivationFailed'));
|
||||
|
||||
// reset value to actual newsletter's status
|
||||
e.target.value = response.status;
|
||||
});
|
||||
},
|
||||
renderStatus: function(newsletter) {
|
||||
let total_sent;
|
||||
@ -216,39 +222,51 @@ const NewsletterListWelcome = React.createClass({
|
||||
return (~~(segment.id) === ~~(newsletter.options.segment));
|
||||
});
|
||||
|
||||
sendingEvent = MailPoet.I18n.t('welcomeEventSegment').replace(
|
||||
if (segment === undefined) {
|
||||
return (
|
||||
<span className="mailpoet_error">
|
||||
{ MailPoet.I18n.t('sendingToSegmentsNotSpecified') }
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
sendingEvent = MailPoet.I18n.t('welcomeEventSegment').replace(
|
||||
'%$1s', segment.name
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// set sending delay
|
||||
if (newsletter.options.afterTimeType !== 'immediate') {
|
||||
switch (newsletter.options.afterTimeType) {
|
||||
case 'hours':
|
||||
sendingDelay = MailPoet.I18n.t('sendingDelayHours').replace(
|
||||
'%$1d', newsletter.options.afterTimeNumber
|
||||
);
|
||||
break;
|
||||
if (sendingEvent) {
|
||||
if (newsletter.options.afterTimeType !== 'immediate') {
|
||||
switch (newsletter.options.afterTimeType) {
|
||||
case 'hours':
|
||||
sendingDelay = MailPoet.I18n.t('sendingDelayHours').replace(
|
||||
'%$1d', newsletter.options.afterTimeNumber
|
||||
);
|
||||
break;
|
||||
|
||||
case 'days':
|
||||
sendingDelay = MailPoet.I18n.t('sendingDelayDays').replace(
|
||||
'%$1d', newsletter.options.afterTimeNumber
|
||||
);
|
||||
break;
|
||||
case 'days':
|
||||
sendingDelay = MailPoet.I18n.t('sendingDelayDays').replace(
|
||||
'%$1d', newsletter.options.afterTimeNumber
|
||||
);
|
||||
break;
|
||||
|
||||
case 'weeks':
|
||||
sendingDelay = MailPoet.I18n.t('sendingDelayWeeks').replace(
|
||||
'%$1d', newsletter.options.afterTimeNumber
|
||||
);
|
||||
break;
|
||||
case 'weeks':
|
||||
sendingDelay = MailPoet.I18n.t('sendingDelayWeeks').replace(
|
||||
'%$1d', newsletter.options.afterTimeNumber
|
||||
);
|
||||
break;
|
||||
}
|
||||
sendingEvent += ' [' + sendingDelay + ']';
|
||||
}
|
||||
sendingEvent += ' [' + sendingDelay + ']';
|
||||
// add a "period" at the end if we do have a sendingEvent
|
||||
sendingEvent += '.';
|
||||
}
|
||||
|
||||
return (
|
||||
<span>
|
||||
{ sendingEvent }.
|
||||
{ sendingEvent }
|
||||
</span>
|
||||
);
|
||||
},
|
||||
@ -292,9 +310,10 @@ const NewsletterListWelcome = React.createClass({
|
||||
<div>
|
||||
<td className={ rowClasses }>
|
||||
<strong>
|
||||
<a href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }>
|
||||
{ newsletter.subject }
|
||||
</a>
|
||||
<a
|
||||
className="row-title"
|
||||
href={ `?page=mailpoet-newsletter-editor&id=${ newsletter.id }` }
|
||||
>{ newsletter.subject }</a>
|
||||
</strong>
|
||||
{ actions }
|
||||
</td>
|
||||
@ -326,15 +345,19 @@ const NewsletterListWelcome = React.createClass({
|
||||
|
||||
<Listing
|
||||
limit={ mailpoet_listing_per_page }
|
||||
location={ this.props.location }
|
||||
params={ this.props.params }
|
||||
endpoint="newsletters"
|
||||
tab="welcome"
|
||||
type="welcome"
|
||||
base_url="welcome"
|
||||
onRenderItem={ this.renderItem }
|
||||
columns={ columns }
|
||||
bulk_actions={ bulk_actions }
|
||||
item_actions={ newsletter_actions }
|
||||
messages={ messages }
|
||||
auto_refresh={ true }
|
||||
sort_by="updated_at"
|
||||
sort_order="desc"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import { Router, Route, IndexRoute, Link, useRouterHistory } from 'react-router'
|
||||
import { Router, Route, IndexRedirect, Link, useRouterHistory } from 'react-router'
|
||||
import { createHashHistory } from 'history'
|
||||
|
||||
import NewsletterTypes from 'newsletters/types.jsx'
|
||||
@ -14,12 +14,13 @@ import NewsletterTypeNotification from 'newsletters/types/notification/notificat
|
||||
import NewsletterListStandard from 'newsletters/listings/standard.jsx'
|
||||
import NewsletterListWelcome from 'newsletters/listings/welcome.jsx'
|
||||
import NewsletterListNotification from 'newsletters/listings/notification.jsx'
|
||||
import NewsletterListNotificationHistory from 'newsletters/listings/notification_history.jsx'
|
||||
|
||||
const history = useRouterHistory(createHashHistory)({ queryKey: false });
|
||||
|
||||
const App = React.createClass({
|
||||
render() {
|
||||
return this.props.children
|
||||
return this.props.children;
|
||||
}
|
||||
});
|
||||
|
||||
@ -29,23 +30,22 @@ if(container) {
|
||||
ReactDOM.render((
|
||||
<Router history={ history }>
|
||||
<Route path="/" component={ App }>
|
||||
<IndexRoute component={ NewsletterListStandard } />
|
||||
<IndexRedirect to="standard" />
|
||||
{/* Listings */}
|
||||
<Route name="listing/standard" path="standard" component={ NewsletterListStandard } />
|
||||
<Route name="listing/welcome" path="welcome" component={ NewsletterListWelcome } />
|
||||
<Route name="listing/notification" path="notification" component={ NewsletterListNotification } />
|
||||
<Route path="standard(/)**" params={{ tab: 'standard' }} component={ NewsletterListStandard } />
|
||||
<Route path="welcome(/)**" component={ NewsletterListWelcome } />
|
||||
<Route path="notification/history/:parent_id(/)**" component={ NewsletterListNotificationHistory } />
|
||||
<Route path="notification(/)**" component={ NewsletterListNotification } />
|
||||
{/* Newsletter: type selection */}
|
||||
<Route path="new" component={ NewsletterTypes } />
|
||||
{/* New newsletter: types */}
|
||||
<Route name="new/standard" path="new/standard" component={ NewsletterTypeStandard } />
|
||||
<Route name="new/welcome" path="new/welcome" component={ NewsletterTypeWelcome } />
|
||||
<Route name="new/notification" path="new/notification" component={ NewsletterTypeNotification } />
|
||||
<Route path="new/standard" component={ NewsletterTypeStandard } />
|
||||
<Route path="new/welcome" component={ NewsletterTypeWelcome } />
|
||||
<Route path="new/notification" component={ NewsletterTypeNotification } />
|
||||
{/* Template selection */}
|
||||
<Route name="template" path="template/:id" component={ NewsletterTemplates } />
|
||||
{/* Sending options */}
|
||||
<Route path="send/:id" component={ NewsletterSend } />
|
||||
|
||||
<Route path="*" component={ NewsletterListStandard } />
|
||||
</Route>
|
||||
</Router>
|
||||
), container);
|
||||
|
@ -1,6 +1,8 @@
|
||||
import _ from 'underscore'
|
||||
import MailPoet from 'mailpoet'
|
||||
|
||||
const timeFormat = window.mailpoet_time_format || 'H:i';
|
||||
|
||||
// welcome emails
|
||||
const _timeDelayValues = {
|
||||
'immediate': MailPoet.I18n.t('delayImmediately'),
|
||||
@ -28,7 +30,7 @@ const _timeOfDayValues = _.object(_.map(
|
||||
}), function(seconds) {
|
||||
let date = new Date(null);
|
||||
date.setSeconds(seconds);
|
||||
const timeLabel = date.toISOString().substr(11, 5);
|
||||
const timeLabel = MailPoet.Date.format(date, { format: timeFormat, offset: 0 });
|
||||
return [seconds, timeLabel];
|
||||
})
|
||||
);
|
||||
@ -60,7 +62,7 @@ const _monthDayValues = _.object(
|
||||
} else {
|
||||
label = MailPoet.I18n.t('nth').replace("%$1d", day + 1);
|
||||
}
|
||||
return [day, label];
|
||||
return [day + 1, label];
|
||||
}
|
||||
)
|
||||
);
|
||||
@ -77,4 +79,4 @@ export { _intervalValues as intervalValues };
|
||||
export { _timeOfDayValues as timeOfDayValues };
|
||||
export { _weekDayValues as weekDayValues };
|
||||
export { _monthDayValues as monthDayValues };
|
||||
export { _nthWeekDayValues as nthWeekDayValues };
|
||||
export { _nthWeekDayValues as nthWeekDayValues };
|
||||
|
@ -34,15 +34,20 @@ define(
|
||||
};
|
||||
},
|
||||
getFieldsByNewsletter: function(newsletter) {
|
||||
var type = this.getSubtype(newsletter);
|
||||
return type.getFields(newsletter);
|
||||
},
|
||||
getSendButtonOptions: function() {
|
||||
var type = this.getSubtype(this.state.item);
|
||||
return type.getSendButtonOptions(this.state.item);
|
||||
},
|
||||
getSubtype: function(newsletter) {
|
||||
switch(newsletter.type) {
|
||||
case 'notification': return NotificationNewsletterFields;
|
||||
case 'welcome': return WelcomeNewsletterFields;
|
||||
default: return StandardNewsletterFields;
|
||||
}
|
||||
},
|
||||
isAutomatedNewsletter: function() {
|
||||
return this.state.item.type !== 'standard';
|
||||
},
|
||||
isValid: function() {
|
||||
return jQuery('#mailpoet_newsletter').parsley().isValid();
|
||||
},
|
||||
@ -61,22 +66,22 @@ define(
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'get',
|
||||
data: id
|
||||
}).done((response) => {
|
||||
if(response === false) {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: {},
|
||||
}, function() {
|
||||
this.context.router.push('/new');
|
||||
}.bind(this));
|
||||
} else {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: response,
|
||||
fields: this.getFieldsByNewsletter(response),
|
||||
});
|
||||
data: {
|
||||
id: id
|
||||
}
|
||||
}).done((response) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: response.data,
|
||||
fields: this.getFieldsByNewsletter(response.data)
|
||||
});
|
||||
}).fail((response) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
item: {}
|
||||
}, () => {
|
||||
this.context.router.push('/new');
|
||||
});
|
||||
});
|
||||
},
|
||||
handleSend: function(e) {
|
||||
@ -85,66 +90,110 @@ define(
|
||||
if(!this.isValid()) {
|
||||
jQuery('#mailpoet_newsletter').parsley().validate();
|
||||
} else {
|
||||
this.setState({ loading: true });
|
||||
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'save',
|
||||
data: this.state.item,
|
||||
}).then((response) => {
|
||||
if (response.result === true) {
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'sendingQueue',
|
||||
action: 'add',
|
||||
data: _.extend({}, this.state.item, {
|
||||
newsletter_id: this.props.params.id,
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
return response;
|
||||
}
|
||||
this._save(e).done(() => {
|
||||
this.setState({ loading: true });
|
||||
}).done((response) => {
|
||||
this.setState({ loading: false });
|
||||
switch (response.data.type) {
|
||||
case 'notification':
|
||||
case 'welcome':
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'setStatus',
|
||||
data: {
|
||||
id: this.props.params.id,
|
||||
status: 'active'
|
||||
}
|
||||
}).done((response) => {
|
||||
// redirect to listing based on newsletter type
|
||||
this.context.router.push(`/${ this.state.item.type || '' }`);
|
||||
|
||||
if(response.result === true) {
|
||||
this.context.router.push(`/${ this.state.item.type || '' }`);
|
||||
MailPoet.Notice.success(response.data.message);
|
||||
} else {
|
||||
if(response.errors) {
|
||||
MailPoet.Notice.error(response.errors);
|
||||
} else {
|
||||
MailPoet.Notice.error(
|
||||
MailPoet.I18n.t('newsletterSendingError').replace("%$1s", '?page=mailpoet-settings')
|
||||
);
|
||||
}
|
||||
// display success message depending on newsletter type
|
||||
if (response.data.type === 'welcome') {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('welcomeEmailActivated')
|
||||
);
|
||||
} else if (response.data.type === 'notification') {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('postNotificationActivated')
|
||||
);
|
||||
}
|
||||
}).fail(this._showError);
|
||||
default:
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'sendingQueue',
|
||||
action: 'add',
|
||||
data: {
|
||||
newsletter_id: this.props.params.id
|
||||
}
|
||||
}).done((response) => {
|
||||
// redirect to listing based on newsletter type
|
||||
this.context.router.push(`/${ this.state.item.type || '' }`);
|
||||
|
||||
if (response.data.status === 'scheduled') {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('newsletterHasBeenScheduled')
|
||||
);
|
||||
} else {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('newsletterBeingSent')
|
||||
);
|
||||
}
|
||||
}).fail(this._showError);
|
||||
}
|
||||
}).fail(this._showError).always(() => {
|
||||
this.setState({ loading: false });
|
||||
});
|
||||
}
|
||||
return false;
|
||||
},
|
||||
handleSave: function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
this._save(e).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('newsletterUpdated')
|
||||
);
|
||||
}).done(() => {
|
||||
this.context.router.push(`/${ this.state.item.type || '' }`);
|
||||
}).fail(this._showError);
|
||||
},
|
||||
handleRedirectToDesign: function(e) {
|
||||
e.preventDefault();
|
||||
var redirectTo = e.target.href;
|
||||
|
||||
this._save(e).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('newsletterUpdated')
|
||||
);
|
||||
}).done(() => {
|
||||
window.location = redirectTo;
|
||||
}).fail(this._showError);
|
||||
},
|
||||
_save: function(e) {
|
||||
var data = this.state.item;
|
||||
this.setState({ loading: true });
|
||||
|
||||
MailPoet.Ajax.post({
|
||||
// Ensure that body is JSON encoded
|
||||
if (!_.isUndefined(data.body)) {
|
||||
data.body = JSON.stringify(data.body);
|
||||
}
|
||||
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'newsletters',
|
||||
action: 'save',
|
||||
data: this.state.item,
|
||||
}).done((response) => {
|
||||
data: data,
|
||||
}).always(() => {
|
||||
this.setState({ loading: false });
|
||||
|
||||
if(response.result === true) {
|
||||
this.context.router.push(`/${ this.state.item.type || '' }`);
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('newsletterUpdated')
|
||||
);
|
||||
} else {
|
||||
if(response.errors) {
|
||||
MailPoet.Notice.error(response.errors);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
_showError: (response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
},
|
||||
handleFormChange: function(e) {
|
||||
var item = this.state.item,
|
||||
field = e.target.name;
|
||||
@ -176,10 +225,9 @@ define(
|
||||
className="button button-primary"
|
||||
type="button"
|
||||
onClick={ this.handleSend }
|
||||
value={
|
||||
this.isAutomatedNewsletter()
|
||||
? MailPoet.I18n.t('activate')
|
||||
: MailPoet.I18n.t('send')} />
|
||||
value={MailPoet.I18n.t('send')}
|
||||
{...this.getSendButtonOptions()}
|
||||
/>
|
||||
|
||||
<input
|
||||
className="button button-secondary"
|
||||
@ -189,7 +237,8 @@ define(
|
||||
<a
|
||||
href={
|
||||
'?page=mailpoet-newsletter-editor&id='+this.props.params.id
|
||||
}>
|
||||
}
|
||||
onClick={this.handleRedirectToDesign}>
|
||||
{MailPoet.I18n.t('goBackToDesign')}
|
||||
</a>.
|
||||
</p>
|
||||
|
@ -1,11 +1,13 @@
|
||||
define(
|
||||
[
|
||||
'mailpoet',
|
||||
'newsletters/types/notification/scheduling.jsx'
|
||||
'newsletters/types/notification/scheduling.jsx',
|
||||
'underscore'
|
||||
],
|
||||
function(
|
||||
MailPoet,
|
||||
Scheduling
|
||||
Scheduling,
|
||||
_
|
||||
) {
|
||||
|
||||
var settings = window.mailpoet_settings || {};
|
||||
@ -40,11 +42,15 @@ define(
|
||||
return !!(!segment.deleted_at);
|
||||
},
|
||||
getLabel: function(segment) {
|
||||
var name = segment.name;
|
||||
if (segment.subscribers > 0) {
|
||||
name += ' (%$1s)'.replace('%$1s', parseInt(segment.subscribers).toLocaleString());
|
||||
}
|
||||
return name;
|
||||
return segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')';
|
||||
},
|
||||
transformChangedValue: function(segment_ids) {
|
||||
var all_segments = this.state.items;
|
||||
return _.map(segment_ids, function(id) {
|
||||
return _.find(all_segments, function(segment) {
|
||||
return segment.id === id;
|
||||
});
|
||||
});
|
||||
},
|
||||
validation: {
|
||||
'data-parsley-required': true,
|
||||
@ -95,6 +101,15 @@ define(
|
||||
}
|
||||
];
|
||||
|
||||
return fields;
|
||||
return {
|
||||
getFields: function(newsletter) {
|
||||
return fields;
|
||||
},
|
||||
getSendButtonOptions: function(newsletter) {
|
||||
return {
|
||||
value: MailPoet.I18n.t('activate')
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
|
@ -253,7 +253,13 @@ define(
|
||||
|
||||
var StandardScheduling = React.createClass({
|
||||
_getCurrentValue: function() {
|
||||
return this.props.item[this.props.field.name] || {};
|
||||
return _.defaults(
|
||||
this.props.item[this.props.field.name] || {},
|
||||
{
|
||||
isScheduled: '0',
|
||||
scheduledAt: defaultDateTime
|
||||
}
|
||||
);
|
||||
},
|
||||
handleValueChange: function(event) {
|
||||
var oldValue = this._getCurrentValue(),
|
||||
@ -290,7 +296,7 @@ define(
|
||||
<DateTime
|
||||
name="scheduledAt"
|
||||
value={this._getCurrentValue().scheduledAt}
|
||||
onChange={this.handleValueChange}
|
||||
onChange={this.handleValueChange}
|
||||
dateValidation={this.getDateValidation()} />
|
||||
|
||||
<span>
|
||||
@ -340,11 +346,15 @@ define(
|
||||
return !!(!segment.deleted_at);
|
||||
},
|
||||
getLabel: function(segment) {
|
||||
var name = segment.name;
|
||||
if (segment.subscribers > 0) {
|
||||
name += ' (%$1s)'.replace('%$1s', parseInt(segment.subscribers).toLocaleString());
|
||||
}
|
||||
return name;
|
||||
return segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')';
|
||||
},
|
||||
transformChangedValue: function(segment_ids) {
|
||||
var all_segments = this.state.items;
|
||||
return _.map(segment_ids, function(id) {
|
||||
return _.find(all_segments, function(segment) {
|
||||
return segment.id === id;
|
||||
});
|
||||
});
|
||||
},
|
||||
validation: {
|
||||
'data-parsley-required': true,
|
||||
@ -401,6 +411,30 @@ define(
|
||||
}
|
||||
];
|
||||
|
||||
return fields;
|
||||
return {
|
||||
getFields: function(newsletter) {
|
||||
return fields;
|
||||
},
|
||||
getSendButtonOptions: function(newsletter) {
|
||||
newsletter = newsletter || {};
|
||||
|
||||
let isScheduled = (
|
||||
typeof newsletter.options === 'object'
|
||||
&& newsletter.options.isScheduled === '1'
|
||||
);
|
||||
let options = {
|
||||
value: (isScheduled
|
||||
? MailPoet.I18n.t('schedule')
|
||||
: MailPoet.I18n.t('send'))
|
||||
};
|
||||
|
||||
if (newsletter.status === 'sent'
|
||||
|| newsletter.status === 'sending') {
|
||||
options['disabled'] = 'disabled';
|
||||
}
|
||||
|
||||
return options;
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
|
@ -71,7 +71,16 @@ define(
|
||||
}
|
||||
];
|
||||
|
||||
return fields;
|
||||
return {
|
||||
getFields: function(newsletter) {
|
||||
return fields;
|
||||
},
|
||||
getSendButtonOptions: function(newsletter) {
|
||||
return {
|
||||
value: MailPoet.I18n.t('activate')
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -30,33 +30,35 @@ define(
|
||||
endpoint: 'newsletterTemplates',
|
||||
action: 'save',
|
||||
data: template
|
||||
}).done(function(response) {
|
||||
}).always(function() {
|
||||
MailPoet.Modal.loading(false);
|
||||
if(response.result === true) {
|
||||
this.props.onImport(template);
|
||||
} else {
|
||||
response.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}).done((response) => {
|
||||
this.props.onImport(response.data);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
handleSubmit: function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (_.size(this.refs.templateFile.files) <= 0) return false;
|
||||
|
||||
var file = _.first(this.refs.templateFile.files),
|
||||
reader = new FileReader(),
|
||||
saveTemplate = this.saveTemplate;
|
||||
var file = _.first(this.refs.templateFile.files);
|
||||
var reader = new FileReader();
|
||||
var saveTemplate = this.saveTemplate;
|
||||
|
||||
reader.onload = function(e) {
|
||||
reader.onload = (e) => {
|
||||
try {
|
||||
saveTemplate(JSON.parse(e.target.result));
|
||||
} catch (err) {
|
||||
MailPoet.Notice.error(MailPoet.I18n.t('templateFileMalformedError'));
|
||||
}
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
reader.readAsText(file);
|
||||
},
|
||||
@ -97,12 +99,12 @@ define(
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'newsletterTemplates',
|
||||
action: 'getAll',
|
||||
}).done(function(response) {
|
||||
}).always(() => {
|
||||
MailPoet.Modal.loading(false);
|
||||
if(this.isMounted()) {
|
||||
|
||||
if(response.length === 0) {
|
||||
response = [
|
||||
}).done((response) => {
|
||||
if (this.isMounted()) {
|
||||
if (response.data.length === 0) {
|
||||
response.data = [
|
||||
{
|
||||
name:
|
||||
MailPoet.I18n.t('mailpoetGuideTemplateTitle'),
|
||||
@ -110,14 +112,14 @@ define(
|
||||
MailPoet.I18n.t('mailpoetGuideTemplateDescription'),
|
||||
readonly: "1"
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
this.setState({
|
||||
templates: response,
|
||||
templates: response.data,
|
||||
loading: false
|
||||
});
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
handleSelectTemplate: function(template) {
|
||||
var body = template.body;
|
||||
@ -134,19 +136,17 @@ define(
|
||||
id: this.props.params.id,
|
||||
body: body
|
||||
}
|
||||
}).done(function(response) {
|
||||
if(response.result === true) {
|
||||
// TODO: Move this URL elsewhere
|
||||
window.location = 'admin.php?page=mailpoet-newsletter-editor&id=' + this.props.params.id;
|
||||
} else {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}).done((response) => {
|
||||
// TODO: Move this URL elsewhere
|
||||
window.location = 'admin.php?page=mailpoet-newsletter-editor&id=' + response.data.id;
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
handlePreviewTemplate: function(template) {
|
||||
console.log('preview template #'+template.id);
|
||||
});
|
||||
},
|
||||
handleDeleteTemplate: function(template) {
|
||||
this.setState({ loading: true });
|
||||
@ -160,10 +160,12 @@ define(
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'newsletterTemplates',
|
||||
action: 'delete',
|
||||
data: template.id
|
||||
}).done(function(response) {
|
||||
data: {
|
||||
id: template.id
|
||||
}
|
||||
}).done((response) => {
|
||||
this.getTemplates();
|
||||
}.bind(this));
|
||||
});
|
||||
} else {
|
||||
this.setState({ loading: false });
|
||||
}
|
||||
@ -172,7 +174,7 @@ define(
|
||||
MailPoet.Modal.popup({
|
||||
title: template.name,
|
||||
template: '<div class="mailpoet_boxes_preview" style="background-color: {{ body.globalStyles.body.backgroundColor }}"><img src="{{ thumbnail }}" /></div>',
|
||||
data: template,
|
||||
data: template
|
||||
});
|
||||
},
|
||||
handleTemplateImport: function() {
|
||||
@ -213,20 +215,19 @@ define(
|
||||
</div>
|
||||
|
||||
<div className="mailpoet_actions">
|
||||
<a
|
||||
className="button button-secondary"
|
||||
onClick={ this.handleShowTemplate.bind(null, template) }
|
||||
>
|
||||
{MailPoet.I18n.t('preview')}
|
||||
</a>
|
||||
|
||||
<a
|
||||
className="button button-primary"
|
||||
onClick={ this.handleSelectTemplate.bind(null, template) }
|
||||
>
|
||||
{MailPoet.I18n.t('select')}
|
||||
</a>
|
||||
|
||||
<a
|
||||
style={ { display: 'none' }}
|
||||
className="button button-secondary"
|
||||
onClick={ this.handlePreviewTemplate.bind(null, template) }
|
||||
>
|
||||
{MailPoet.I18n.t('preview')}
|
||||
</a>
|
||||
</div>
|
||||
{ (template.readonly === "1") ? false : deleteLink }
|
||||
</li>
|
||||
|
@ -28,17 +28,16 @@ define(
|
||||
type: type,
|
||||
subject: MailPoet.I18n.t('draftNewsletterTitle'),
|
||||
}
|
||||
}).done(function(response) {
|
||||
if(response.result && response.newsletter.id) {
|
||||
this.context.router.push(`/template/${response.newsletter.id}`);
|
||||
} else {
|
||||
if(response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
}).done((response) => {
|
||||
this.context.router.push(`/template/${response.data.id}`);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
|
@ -50,17 +50,16 @@ define(
|
||||
type: 'notification',
|
||||
subject: MailPoet.I18n.t('draftNewsletterTitle'),
|
||||
}),
|
||||
}).done(function(response) {
|
||||
if(response.result && response.newsletter.id) {
|
||||
this.showTemplateSelection(response.newsletter.id);
|
||||
} else {
|
||||
if(response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
}).done((response) => {
|
||||
this.showTemplateSelection(response.data.id);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
showTemplateSelection: function(newsletterId) {
|
||||
this.context.router.push(`/template/${newsletterId}`);
|
||||
|
@ -1,6 +1,5 @@
|
||||
import _ from 'underscore'
|
||||
import React from 'react'
|
||||
import MailPoet from 'mailpoet'
|
||||
import Select from 'form/fields/select.jsx'
|
||||
import {
|
||||
intervalValues,
|
||||
@ -141,4 +140,4 @@ const NotificationScheduling = React.createClass({
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = NotificationScheduling;
|
||||
module.exports = NotificationScheduling;
|
||||
|
@ -25,19 +25,18 @@ define(
|
||||
endpoint: 'newsletters',
|
||||
action: 'create',
|
||||
data: {
|
||||
type: 'standard',
|
||||
type: 'standard'
|
||||
}
|
||||
}).done(function(response) {
|
||||
if(response.result && response.newsletter.id) {
|
||||
this.showTemplateSelection(response.newsletter.id);
|
||||
} else {
|
||||
if(response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
}).done((response) => {
|
||||
this.showTemplateSelection(response.data.id);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
|
@ -9,7 +9,12 @@ import {
|
||||
} from 'newsletters/scheduling/common.jsx'
|
||||
|
||||
const availableRoles = window.mailpoet_roles || {};
|
||||
const availableSegments = window.mailpoet_segments || {};
|
||||
const availableSegments = _.filter(
|
||||
window.mailpoet_segments || [],
|
||||
function (segment) {
|
||||
return segment.type === 'default';
|
||||
}
|
||||
);
|
||||
|
||||
const events = {
|
||||
name: 'event',
|
||||
@ -22,16 +27,14 @@ const events = {
|
||||
const availableSegmentValues = _.object(_.map(
|
||||
availableSegments,
|
||||
function(segment) {
|
||||
let name = segment.name;
|
||||
if (segment.subscribers > 0) {
|
||||
name += ' (%$1s)'.replace('%$1s', parseInt(segment.subscribers).toLocaleString());
|
||||
}
|
||||
let name = segment.name + ' (' + parseInt(segment.subscribers).toLocaleString() + ')';
|
||||
return [segment.id, name];
|
||||
}
|
||||
));
|
||||
const segmentField = {
|
||||
name: 'segment',
|
||||
values: availableSegmentValues
|
||||
values: availableSegmentValues,
|
||||
sortBy: (key, value) => value.toLowerCase()
|
||||
};
|
||||
|
||||
const roleField = {
|
||||
@ -107,17 +110,16 @@ const WelcomeScheduling = React.createClass({
|
||||
type: 'welcome',
|
||||
options: this.state
|
||||
}
|
||||
}).done(function(response) {
|
||||
if (response.result && response.newsletter.id) {
|
||||
this.showTemplateSelection(response.newsletter.id);
|
||||
} else {
|
||||
}).done((response) => {
|
||||
this.showTemplateSelection(response.data.id);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
showTemplateSelection: function(newsletterId) {
|
||||
this.context.router.push(`/template/${ newsletterId }`);
|
||||
@ -171,4 +173,4 @@ const WelcomeScheduling = React.createClass({
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = WelcomeScheduling;
|
||||
module.exports = WelcomeScheduling;
|
||||
|
@ -57,18 +57,17 @@ define(
|
||||
data: _.extend({}, this.state, {
|
||||
type: 'welcome',
|
||||
subject: MailPoet.I18n.t('draftNewsletterTitle'),
|
||||
}),
|
||||
}).done(function(response) {
|
||||
if(response.result && response.newsletter.id) {
|
||||
this.showTemplateSelection(response.newsletter.id);
|
||||
} else {
|
||||
if(response.errors.length > 0) {
|
||||
response.errors.map(function(error) {
|
||||
MailPoet.Notice.error(error);
|
||||
});
|
||||
}
|
||||
})
|
||||
}).done((response) => {
|
||||
this.showTemplateSelection(response.data.id);
|
||||
}).fail((response) => {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
showTemplateSelection: function(newsletterId) {
|
||||
this.context.router.push(`/template/${newsletterId}`);
|
||||
|
@ -40,33 +40,40 @@ function(
|
||||
// ajax request
|
||||
MailPoet.Ajax.post({
|
||||
url: MailPoetForm.ajax_url,
|
||||
token: MailPoetForm.token,
|
||||
token: data.token,
|
||||
endpoint: 'subscribers',
|
||||
action: 'subscribe',
|
||||
data: data
|
||||
}).fail(function(response) {
|
||||
form.find('.mailpoet_validate_error').html(
|
||||
response.errors.map(function(error) {
|
||||
return error.message;
|
||||
}).join('<br />')
|
||||
).show();
|
||||
}).done(function(response) {
|
||||
if(response.result === false) {
|
||||
form.find('.mailpoet_validate_error').html(
|
||||
response.errors.join('<br />')
|
||||
).show();
|
||||
// successfully subscribed
|
||||
if (
|
||||
response.meta !== undefined
|
||||
&& response.meta.redirect_url !== undefined
|
||||
) {
|
||||
// go to page
|
||||
window.location.href = response.meta.redirect_url;
|
||||
} else {
|
||||
// successfully subscribed
|
||||
if(response.page !== undefined) {
|
||||
// go to page
|
||||
window.location.href = response.page;
|
||||
} else {
|
||||
// display success message
|
||||
form.find('.mailpoet_validate_success').show();
|
||||
}
|
||||
|
||||
// reset form
|
||||
form.trigger('reset');
|
||||
// reset validation
|
||||
parsley.reset();
|
||||
// display success message
|
||||
form.find('.mailpoet_validate_success').show();
|
||||
}
|
||||
|
||||
// reset form
|
||||
form.trigger('reset');
|
||||
// reset validation
|
||||
parsley.reset();
|
||||
|
||||
// resize iframe
|
||||
if(window.frameElement !== null) {
|
||||
if (
|
||||
window.frameElement !== null
|
||||
&& MailPoet !== undefined
|
||||
&& MailPoet['Iframe']
|
||||
) {
|
||||
MailPoet.Iframe.autoSize(window.frameElement);
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,5 @@
|
||||
import React from 'react'
|
||||
import { Router, Link } from 'react-router'
|
||||
|
||||
import jQuery from 'jquery'
|
||||
import MailPoet from 'mailpoet'
|
||||
import classNames from 'classnames'
|
||||
@ -15,23 +14,19 @@ var columns = [
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
label: MailPoet.I18n.t('description'),
|
||||
sortable: false
|
||||
label: MailPoet.I18n.t('description')
|
||||
},
|
||||
{
|
||||
name: 'subscribed',
|
||||
label: MailPoet.I18n.t('subscribed'),
|
||||
sortable: false
|
||||
label: MailPoet.I18n.t('subscribed')
|
||||
},
|
||||
{
|
||||
name: 'unconfirmed',
|
||||
label: MailPoet.I18n.t('unconfirmed'),
|
||||
sortable: false
|
||||
label: MailPoet.I18n.t('unconfirmed')
|
||||
},
|
||||
{
|
||||
name: 'unsubscribed',
|
||||
label: MailPoet.I18n.t('unsubscribed'),
|
||||
sortable: false
|
||||
label: MailPoet.I18n.t('unsubscribed')
|
||||
},
|
||||
{
|
||||
name: 'created_at',
|
||||
@ -41,48 +36,48 @@ var columns = [
|
||||
];
|
||||
|
||||
const messages = {
|
||||
onTrash: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSegmentTrashed')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSegmentsTrashed')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSegmentDeleted')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSegmentsDeleted')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore: function(response) {
|
||||
var count = ~~response;
|
||||
var message = null;
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(count === 1) {
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSegmentRestored')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSegmentsRestored')
|
||||
).replace('%$1d', count);
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
@ -111,16 +106,23 @@ const item_actions = [
|
||||
{
|
||||
name: 'duplicate_segment',
|
||||
label: MailPoet.I18n.t('duplicate'),
|
||||
onClick: function(item, refresh) {
|
||||
onClick: (item, refresh) => {
|
||||
return MailPoet.Ajax.post({
|
||||
endpoint: 'segments',
|
||||
action: 'duplicate',
|
||||
data: item.id
|
||||
}).done(function(response) {
|
||||
data: {
|
||||
id: item.id
|
||||
}
|
||||
}).done((response) => {
|
||||
MailPoet.Notice.success(
|
||||
(MailPoet.I18n.t('listDuplicated')).replace('%$1s', response.name)
|
||||
MailPoet.I18n.t('listDuplicated').replace('%$1s', response.data.name)
|
||||
);
|
||||
refresh();
|
||||
}).fail((response) => {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
});
|
||||
},
|
||||
display: function(segment) {
|
||||
@ -132,7 +134,7 @@ const item_actions = [
|
||||
link: function(item) {
|
||||
return (
|
||||
<a
|
||||
href="https://www.mailpoet.com/#TODO"
|
||||
href="http://docs.mailpoet.com/article/133-the-wordpress-users-list"
|
||||
target="_blank"
|
||||
>{MailPoet.I18n.t('readMore')}</a>
|
||||
);
|
||||
@ -191,13 +193,20 @@ const SegmentList = React.createClass({
|
||||
const unconfirmed = ~~(segment.subscribers_count.unconfirmed || 0);
|
||||
const unsubscribed = ~~(segment.subscribers_count.unsubscribed || 0);
|
||||
|
||||
let segment_name = (
|
||||
<Link to={ `/edit/${segment.id}` }>{ segment.name }</Link>
|
||||
);
|
||||
let segment_name;
|
||||
|
||||
// the WP users segment is not editable so just display its name
|
||||
if (segment.type === 'wp_users') {
|
||||
segment_name = segment.name;
|
||||
// the WP users segment is not editable so just display its name
|
||||
segment_name = (
|
||||
<span className="row-title">{ segment.name }</span>
|
||||
);
|
||||
} else {
|
||||
segment_name = (
|
||||
<Link
|
||||
className="row-title"
|
||||
to={ `/edit/${segment.id}` }
|
||||
>{ segment.name }</Link>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
@ -244,6 +253,8 @@ const SegmentList = React.createClass({
|
||||
columns={ columns }
|
||||
bulk_actions={ bulk_actions }
|
||||
item_actions={ item_actions }
|
||||
sort_by="name"
|
||||
sort_order="asc"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
@ -2,6 +2,7 @@ import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import { Router, Route, IndexRoute, Link, useRouterHistory } from 'react-router'
|
||||
import { createHashHistory } from 'history'
|
||||
|
||||
import SegmentList from 'segments/list.jsx'
|
||||
import SegmentForm from 'segments/form.jsx'
|
||||
|
||||
|
@ -34,16 +34,13 @@ define(
|
||||
// show sending methods
|
||||
jQuery('.mailpoet_sending_methods').fadeIn();
|
||||
} else {
|
||||
// toggle SPF/DKIM (hidden if the sending method is MailPoet)
|
||||
// toggle SPF (hidden if the sending method is MailPoet)
|
||||
jQuery('#mailpoet_mta_spf')[
|
||||
(group === 'mailpoet')
|
||||
? 'hide'
|
||||
: 'show'
|
||||
]();
|
||||
|
||||
// (HIDDEN FOR BETA)
|
||||
jQuery('#mailpoet_mta_dkim').hide();
|
||||
|
||||
// hide sending methods
|
||||
jQuery('.mailpoet_sending_methods').hide();
|
||||
|
||||
|
@ -75,6 +75,9 @@ define(
|
||||
filter: function(segment) {
|
||||
return !!(!segment.deleted_at && segment.type === 'default');
|
||||
},
|
||||
getLabel: function(segment) {
|
||||
return segment.name + ' ('+ segment.subscribers +')';
|
||||
},
|
||||
getSearchLabel: function(segment, subscriber) {
|
||||
let label = '';
|
||||
|
||||
|
@ -95,15 +95,18 @@ define(
|
||||
});
|
||||
};
|
||||
|
||||
// set confirmed subscribers export option to false
|
||||
exportData.exportConfirmedOption = false;
|
||||
|
||||
renderSegmentsAndFields(subscriberFieldsContainerElement, subscriberFieldsSelect2);
|
||||
renderSegmentsAndFields(segmentsContainerElement, segments);
|
||||
|
||||
subscriberFieldsContainerElement.select2('val', [
|
||||
'status',
|
||||
subscriberFieldsContainerElement.val([
|
||||
'email',
|
||||
'first_name',
|
||||
'last_name'
|
||||
]);
|
||||
'last_name',
|
||||
'status'
|
||||
]).trigger("change");
|
||||
|
||||
exportConfirmedOptionElement.change(function () {
|
||||
var selectedSegments = segmentsContainerElement.val();
|
||||
@ -133,8 +136,7 @@ define(
|
||||
return;
|
||||
}
|
||||
MailPoet.Modal.loading(true);
|
||||
MailPoet.Ajax
|
||||
.post({
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'ImportExport',
|
||||
action: 'processExport',
|
||||
data: JSON.stringify({
|
||||
@ -144,25 +146,22 @@ define(
|
||||
'segments': (exportData.segments) ? segmentsContainerElement.val() : false,
|
||||
'subscriber_fields': subscriberFieldsContainerElement.val()
|
||||
})
|
||||
})
|
||||
.done(function (response) {
|
||||
}).always(function(response) {
|
||||
MailPoet.Modal.loading(false);
|
||||
if (response.result === false) {
|
||||
MailPoet.Notice.error(response.errors);
|
||||
} else {
|
||||
resultMessage = MailPoet.I18n.t('exportMessage')
|
||||
.replace('%1$s', '<strong>' + parseInt(response.data.totalExported).toLocaleString() + '</strong>')
|
||||
.replace('[link]', '<a href="' + response.data.exportFileURL + '" target="_blank" >')
|
||||
.replace('[/link]', '</a>');
|
||||
jQuery('#export_result_notice').html('<p>' + resultMessage + '</p>').show();
|
||||
window.location.href = response.data.exportFileURL;
|
||||
}).done(function(response) {
|
||||
resultMessage = MailPoet.I18n.t('exportMessage')
|
||||
.replace('%1$s', '<strong>' + parseInt(response.data.totalExported).toLocaleString() + '</strong>')
|
||||
.replace('[link]', '<a href="' + response.data.exportFileURL + '" target="_blank" >')
|
||||
.replace('[/link]', '</a>');
|
||||
jQuery('#export_result_notice').html('<p>' + resultMessage + '</p>').show();
|
||||
window.location.href = response.data.exportFileURL;
|
||||
}).fail(function(response) {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
})
|
||||
.error(function (error) {
|
||||
MailPoet.Modal.loading(false);
|
||||
MailPoet.Notice.error(
|
||||
MailPoet.I18n.t('serverError') + error.statusText.toLowerCase() + '.'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -7,7 +7,6 @@ define(
|
||||
'handlebars',
|
||||
'papaparse',
|
||||
'asyncqueue',
|
||||
'xss',
|
||||
'moment',
|
||||
'select2'
|
||||
],
|
||||
@ -19,7 +18,6 @@ define(
|
||||
Handlebars,
|
||||
Papa,
|
||||
AsyncQueue,
|
||||
xss,
|
||||
Moment
|
||||
) {
|
||||
if (!jQuery('#mailpoet_subscribers_import').length) {
|
||||
@ -51,6 +49,12 @@ define(
|
||||
* STEP 1 (upload or copy/paste)
|
||||
*/
|
||||
router.on('route:step1', function () {
|
||||
// set or reset temporary validation rule on all columns
|
||||
mailpoetColumns = jQuery.map(mailpoetColumns, function (column, columnIndex) {
|
||||
column.validation_rule = false;
|
||||
return column;
|
||||
});
|
||||
|
||||
if (typeof (importData.step1) !== 'undefined') {
|
||||
showCurrentStep();
|
||||
return;
|
||||
@ -185,68 +189,59 @@ define(
|
||||
mailChimpKeyVerifyButtonElement.click(function () {
|
||||
MailPoet.Modal.loading(true);
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'ImportExport',
|
||||
endpoint: 'importExport',
|
||||
action: 'getMailChimpLists',
|
||||
data: {api_key: mailChimpKeyInputElement.val()}
|
||||
}).done(function (response) {
|
||||
if (response.result === false) {
|
||||
MailPoet.Notice.hide();
|
||||
MailPoet.Notice.error(response.errors);
|
||||
jQuery('.mailpoet_mailchimp-key-status')
|
||||
.removeClass()
|
||||
.addClass('mailpoet_mailchimp-key-status mailpoet_mailchimp-error');
|
||||
data: {
|
||||
api_key: mailChimpKeyInputElement.val()
|
||||
}
|
||||
}).always(function() {
|
||||
MailPoet.Modal.loading(false);
|
||||
}).done(function(response) {
|
||||
jQuery('.mailpoet_mailchimp-key-status')
|
||||
.html('')
|
||||
.removeClass()
|
||||
.addClass('mailpoet_mailchimp-key-status mailpoet_mailchimp-ok');
|
||||
if (response.data.length === 0) {
|
||||
jQuery('.mailpoet_mailchimp-key-status').html(MailPoet.I18n.t('noMailChimpLists'));
|
||||
mailChimpListsContainerElement.hide();
|
||||
toggleNextStepButton(mailChimpProcessButtonElement, 'off');
|
||||
} else {
|
||||
jQuery('.mailpoet_mailchimp-key-status')
|
||||
.html('')
|
||||
.removeClass()
|
||||
.addClass('mailpoet_mailchimp-key-status mailpoet_mailchimp-ok');
|
||||
if (!response.data) {
|
||||
jQuery('.mailpoet_mailchimp-key-status').html(MailPoet.I18n.t('noMailChimpLists'));
|
||||
mailChimpListsContainerElement.hide();
|
||||
toggleNextStepButton(mailChimpProcessButtonElement, 'off');
|
||||
} else {
|
||||
displayMailChimpLists(response.data);
|
||||
}
|
||||
displayMailChimpLists(response.data);
|
||||
}
|
||||
}).fail(function(response) {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
MailPoet.Modal.loading(false);
|
||||
}).error(function (error) {
|
||||
MailPoet.Modal.loading(false);
|
||||
MailPoet.Notice.error(
|
||||
MailPoet.I18n.t('serverError') + error.statusText.toLowerCase() + '.'
|
||||
);
|
||||
});
|
||||
MailPoet.Modal.loading(false);
|
||||
});
|
||||
|
||||
mailChimpProcessButtonElement.click(function () {
|
||||
if (mailChimpProcessButtonElement.closest('table a').hasClass('disabled')) {
|
||||
if (mailChimpProcessButtonElement.closest('table a').hasClass('button-disabled')) {
|
||||
return;
|
||||
}
|
||||
MailPoet.Modal.loading(true);
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'ImportExport',
|
||||
endpoint: 'importExport',
|
||||
action: 'getMailChimpSubscribers',
|
||||
data: {
|
||||
api_key: mailChimpKeyInputElement.val(),
|
||||
lists: mailChimpListsContainerElement.find('select').val()
|
||||
}
|
||||
}).done(function (response) {
|
||||
if (response.result === true) {
|
||||
importData.step1 = response.data;
|
||||
router.navigate('step2', {trigger: true});
|
||||
}
|
||||
else {
|
||||
MailPoet.Notice.hide();
|
||||
MailPoet.Notice.error(response.errors);
|
||||
}
|
||||
}).always(function(response) {
|
||||
MailPoet.Modal.loading(false);
|
||||
}).error(function () {
|
||||
MailPoet.Modal.loading(false);
|
||||
MailPoet.Notice.error(
|
||||
MailPoet.I18n.t('serverError') + result.statusText.toLowerCase() + '.'
|
||||
);
|
||||
}).done(function(response) {
|
||||
importData.step1 = response.data;
|
||||
router.navigate('step2', {trigger: true});
|
||||
}).fail(function(response) {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -340,9 +335,9 @@ define(
|
||||
complete: function (CSV) {
|
||||
for (var rowCount in CSV.data) {
|
||||
var rowData = CSV.data[rowCount].map(function (el) {
|
||||
return filterXSS(el.trim());
|
||||
}),
|
||||
rowColumnCount = rowData.length;
|
||||
return el.trim();
|
||||
});
|
||||
var rowColumnCount = rowData.length;
|
||||
// set the number of row elements based on the first non-empty row
|
||||
if (columnCount === null) {
|
||||
columnCount = rowColumnCount;
|
||||
@ -455,7 +450,7 @@ define(
|
||||
null,
|
||||
new Array(subscribers.subscribers[0].length)
|
||||
).map(String.prototype.valueOf, filler),
|
||||
fillterPosition;
|
||||
fillerPosition;
|
||||
|
||||
showCurrentStep();
|
||||
|
||||
@ -533,15 +528,11 @@ define(
|
||||
width: '20em',
|
||||
templateResult: function (item) {
|
||||
item.subscriberCount = parseInt(item.subscriberCount);
|
||||
return (item.subscriberCount > 0)
|
||||
? item.name + ' (' + item.subscriberCount.toLocaleString() + ')'
|
||||
: item.name;
|
||||
return item.name + ' (' + item.subscriberCount.toLocaleString() + ')';
|
||||
},
|
||||
templateSelection: function (item) {
|
||||
item.subscriberCount = parseInt(item.subscriberCount);
|
||||
return (item.subscriberCount > 0)
|
||||
? item.name + ' (' + item.subscriberCount.toLocaleString() + ')'
|
||||
: item.name;
|
||||
return item.name + ' (' + item.subscriberCount.toLocaleString() + ')';
|
||||
}
|
||||
})
|
||||
.change(function () {
|
||||
@ -565,79 +556,55 @@ define(
|
||||
})
|
||||
}
|
||||
|
||||
jQuery('.mailpoet_create_segment').click(function () {
|
||||
jQuery('.mailpoet_create_segment').click(function() {
|
||||
MailPoet.Modal.popup({
|
||||
title: MailPoet.I18n.t('addNewList'),
|
||||
template: jQuery('#new_segment_template').html()
|
||||
})
|
||||
jQuery('#new_segment_name').keypress(function (e) {
|
||||
jQuery('#new_segment_name').keypress(function(e) {
|
||||
if (e.which == 13) {
|
||||
jQuery('#new_segment_process').click();
|
||||
}
|
||||
});
|
||||
jQuery('#new_segment_process').click(function () {
|
||||
var segmentName = jQuery('#new_segment_name').val().trim(),
|
||||
segmentDescription = jQuery('#new_segment_description').val().trim(),
|
||||
isDuplicateListName = ( jQuery.map(mailpoetSegments, function (el) {
|
||||
if (el.name.toLowerCase() === segmentName.toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
}).length && segmentName) ? true : false;
|
||||
if (segmentName === '') {
|
||||
jQuery('.mailpoet_validation_error[data-error="segment_name_required"]:hidden').show();
|
||||
} else {
|
||||
jQuery('.mailpoet_validation_error[data-error="segment_name_required"]:visible').hide();
|
||||
}
|
||||
if (isDuplicateListName) {
|
||||
jQuery('.mailpoet_validation_error[data-error="segment_name_not_unique"]:hidden').show();
|
||||
} else {
|
||||
jQuery('.mailpoet_validation_error[data-error="segment_name_not_unique"]:visible').hide();
|
||||
}
|
||||
if (segmentName && !isDuplicateListName) {
|
||||
jQuery('.mailpoet_validation_error[data-error="segment_name_required"]:visible').hide();
|
||||
MailPoet.Ajax
|
||||
.post({
|
||||
endpoint: 'ImportExport',
|
||||
action: 'addSegment',
|
||||
data: {
|
||||
name: segmentName,
|
||||
description: segmentDescription
|
||||
}
|
||||
})
|
||||
.done(function (response) {
|
||||
if (response.result === true) {
|
||||
mailpoetSegments.push({
|
||||
'id': response.segment.id,
|
||||
'name': response.segment.name
|
||||
});
|
||||
var segmentName = jQuery('#new_segment_name').val().trim();
|
||||
var segmentDescription = jQuery('#new_segment_description').val().trim();
|
||||
|
||||
var selected_values = segmentSelectElement.val();
|
||||
if (selected_values === null) {
|
||||
selected_values = [response.segment.id]
|
||||
} else {
|
||||
selected_values.push(response.segment.id);
|
||||
}
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'ImportExport',
|
||||
action: 'addSegment',
|
||||
data: {
|
||||
name: segmentName,
|
||||
description: segmentDescription
|
||||
}
|
||||
}).done(function(response) {
|
||||
mailpoetSegments.push({
|
||||
'id': response.data.id,
|
||||
'name': response.data.name,
|
||||
'subscriberCount': 0
|
||||
});
|
||||
|
||||
enableSegmentSelection(mailpoetSegments);
|
||||
segmentSelectElement.val(selected_values).trigger('change');
|
||||
jQuery('.mailpoet_segments:hidden').show();
|
||||
jQuery('.mailpoet_no_segments:visible').hide();
|
||||
MailPoet.Modal.close();
|
||||
}
|
||||
else {
|
||||
MailPoet.Modal.close();
|
||||
MailPoet.Notice.error(
|
||||
MailPoet.I18n.t('segmentCreateError') + response.message + '.'
|
||||
);
|
||||
}
|
||||
})
|
||||
.error(function (error) {
|
||||
MailPoet.Modal.close();
|
||||
MailPoet.Notice.error(
|
||||
MailPoet.I18n.t('serverError') + error.statusText.toLowerCase() + '.'
|
||||
);
|
||||
});
|
||||
}
|
||||
var selected_values = segmentSelectElement.val();
|
||||
if (selected_values === null) {
|
||||
selected_values = [response.data.id]
|
||||
} else {
|
||||
selected_values.push(response.data.id);
|
||||
}
|
||||
|
||||
enableSegmentSelection(mailpoetSegments);
|
||||
segmentSelectElement.val(selected_values).trigger('change');
|
||||
jQuery('.mailpoet_segments:hidden').show();
|
||||
jQuery('.mailpoet_no_segments:visible').hide();
|
||||
MailPoet.Modal.close();
|
||||
}).fail(function(response) {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.hide();
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ positionAfter: '#new_segment_name' }
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
jQuery('#new_segment_cancel').click(function () {
|
||||
MailPoet.Modal.close();
|
||||
@ -701,13 +668,20 @@ define(
|
||||
return options.fn(displayedColumns);
|
||||
});
|
||||
|
||||
// sanitize unsafe data
|
||||
Handlebars.registerHelper('sanitize_data', function(data) {
|
||||
return (data instanceof Handlebars.SafeString) ?
|
||||
data :
|
||||
new Handlebars.SafeString(Handlebars.Utils.escapeExpression(data));
|
||||
});
|
||||
|
||||
// start array index from 1
|
||||
Handlebars.registerHelper('show_real_index', function (index) {
|
||||
Handlebars.registerHelper('calculate_index', function (index) {
|
||||
var index = parseInt(index);
|
||||
// display filler data (e.g., ellipsis) if we've reached the maximum number of rows and
|
||||
// subscribers count is greater than the maximum number of rows we're displaying
|
||||
if (index === maxRowsToShow && subscribers.subscribersCount > (maxRowsToShow + 1)) {
|
||||
fillterPosition = index;
|
||||
fillerPosition = index;
|
||||
return filler;
|
||||
}
|
||||
// if we're on the last line, show the total count of subscribers data
|
||||
@ -745,114 +719,70 @@ define(
|
||||
.on('select2:selecting', function (selectEvent) {
|
||||
var selectElement = this,
|
||||
selectedOptionId = selectEvent.params.args.data.id;
|
||||
// CREATE CUSTOM FIELD
|
||||
if (selectedOptionId === 'create') {
|
||||
selectEvent.preventDefault();
|
||||
jQuery(selectElement).select2('close');
|
||||
MailPoet.Modal.popup({
|
||||
title: MailPoet.I18n.t('addNewColumn'),
|
||||
template: jQuery('#new_column_template').html()
|
||||
title: MailPoet.I18n.t('addNewField'),
|
||||
template: jQuery('#form_template_field_form').html()
|
||||
});
|
||||
jQuery('#new_column_name').keypress(function (e) {
|
||||
if (e.which == 13) {
|
||||
jQuery('#new_column_process').click();
|
||||
}
|
||||
});
|
||||
jQuery('#new_column_process').click(function () {
|
||||
var name = jQuery('#new_column_name').val().trim(),
|
||||
type = jQuery('#new_column_type').val().trim(),
|
||||
columnNames = mailpoetColumns.map(function (el) {
|
||||
return el.name.toLowerCase();
|
||||
jQuery('#form_field_new').parsley().on('form:submit', function(parsley) {
|
||||
// get data
|
||||
var data = jQuery(this.$element).serializeObject();
|
||||
|
||||
// save custom field
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'customFields',
|
||||
action: 'save',
|
||||
data: data
|
||||
}).done(function(response) {
|
||||
var new_column_data = {
|
||||
'id': response.data.id,
|
||||
'name': response.data.name,
|
||||
'type': response.data.type,
|
||||
'params': response.data.params,
|
||||
'custom': true
|
||||
};
|
||||
// if this is the first custom column, create an "optgroup"
|
||||
if (mailpoetColumnsSelect2.length === 2) {
|
||||
mailpoetColumnsSelect2.push({
|
||||
'name': MailPoet.I18n.t('userColumns'),
|
||||
'children': []
|
||||
});
|
||||
isDuplicateColumnName =
|
||||
(name && columnNames.indexOf(name.toLowerCase()) > -1)
|
||||
? true
|
||||
: false;
|
||||
if (name === '') {
|
||||
jQuery('.mailpoet_validation_error[data-error="name_required"]')
|
||||
.show();
|
||||
} else {
|
||||
jQuery('.mailpoet_validation_error[data-error="name_required"]')
|
||||
.hide();
|
||||
}
|
||||
if (type === '') {
|
||||
jQuery('.mailpoet_validation_error[data-error="type_required"]')
|
||||
.show();
|
||||
} else {
|
||||
jQuery('.mailpoet_validation_error[data-error="type_required"]')
|
||||
.hide();
|
||||
}
|
||||
if (isDuplicateColumnName) {
|
||||
jQuery('.mailpoet_validation_error[data-error="name_not_unique"]')
|
||||
.show();
|
||||
} else {
|
||||
jQuery('.mailpoet_validation_error[data-error="name_not_unique"]')
|
||||
.hide();
|
||||
}
|
||||
// create new field
|
||||
if (name && type && !isDuplicateColumnName) {
|
||||
MailPoet.Modal
|
||||
.close()
|
||||
.loading(true);
|
||||
MailPoet.Ajax
|
||||
.post({
|
||||
endpoint: 'ImportExport',
|
||||
action: 'addCustomField',
|
||||
data: {
|
||||
name: name,
|
||||
type: type
|
||||
}
|
||||
})
|
||||
.done(function (response) {
|
||||
if (response.result === true) {
|
||||
var new_column_data = {
|
||||
'id': response.customField.id,
|
||||
'name': name,
|
||||
'type': type,
|
||||
'custom': true,
|
||||
};
|
||||
// if this is the first custom column, create an "optgroup"
|
||||
if (mailpoetColumnsSelect2.length === 2) {
|
||||
mailpoetColumnsSelect2.push({
|
||||
'name': MailPoet.I18n.t('userColumns'),
|
||||
'children': []
|
||||
});
|
||||
}
|
||||
mailpoetColumnsSelect2[2].children.push(new_column_data);
|
||||
mailpoetColumns.push(new_column_data);
|
||||
jQuery('select.mailpoet_subscribers_column_data_match')
|
||||
.each(function () {
|
||||
jQuery(this)
|
||||
.html('')
|
||||
.select2('destroy')
|
||||
.select2({
|
||||
data: mailpoetColumnsSelect2,
|
||||
width: '15em',
|
||||
templateResult: function (item) {
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function (item) {
|
||||
return item.name;
|
||||
}
|
||||
mailpoetColumnsSelect2[2].children.push(new_column_data);
|
||||
mailpoetColumns.push(new_column_data);
|
||||
jQuery('select.mailpoet_subscribers_column_data_match')
|
||||
.each(function () {
|
||||
jQuery(this)
|
||||
.html('')
|
||||
.select2('destroy')
|
||||
.select2({
|
||||
data: mailpoetColumnsSelect2,
|
||||
width: '15em',
|
||||
templateResult: function (item) {
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function (item) {
|
||||
return item.name;
|
||||
}
|
||||
})
|
||||
});
|
||||
jQuery(selectElement).data('column-id', new_column_data.id);
|
||||
filterSubscribers();
|
||||
}
|
||||
else {
|
||||
MailPoet.Notice.error(MailPoet.I18n.t('customFieldCreateError'));
|
||||
}
|
||||
MailPoet.Modal.loading(false);
|
||||
})
|
||||
.error(function (error) {
|
||||
MailPoet.Modal.loading(false);
|
||||
MailPoet.Notice.error(
|
||||
MailPoet.I18n.t('serverError') + error.statusText.toLowerCase() + '.'
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
jQuery('#new_column_cancel').click(function () {
|
||||
MailPoet.Modal.close();
|
||||
})
|
||||
});
|
||||
jQuery(selectElement).data('column-id', new_column_data.id);
|
||||
jQuery(selectElement).data('validation-rule', false);
|
||||
filterSubscribers();
|
||||
// close popup
|
||||
MailPoet.Modal.close();
|
||||
}).fail(function(response) {
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ positionAfter: '#field_name' }
|
||||
);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
// CHANGE COLUMN
|
||||
@ -890,22 +820,22 @@ define(
|
||||
.remove();
|
||||
var subscribersClone = jQuery.extend(true, {}, subscribers),
|
||||
preventNextStep = false,
|
||||
displayedColumnsIds = jQuery.map(
|
||||
jQuery('.mailpoet_subscribers_column_data_match'), function (data) {
|
||||
var columnId = jQuery(data).data('column-id');
|
||||
jQuery(data).val(columnId).trigger('change');
|
||||
return columnId;
|
||||
displayedColumns = jQuery.map(
|
||||
jQuery('.mailpoet_subscribers_column_data_match'), function (element, elementIndex) {
|
||||
var columnId = jQuery(element).data('column-id');
|
||||
var validationRule = jQuery(element).data('validation-rule');
|
||||
jQuery(element).val(columnId).trigger('change');
|
||||
return { id: columnId, index: elementIndex, validationRule: validationRule, element: element };
|
||||
});
|
||||
// iterate through the object of mailpoet columns
|
||||
jQuery.map(mailpoetColumns, function (column) {
|
||||
jQuery.map(mailpoetColumns, function (column, columnIndex) {
|
||||
// check if the column id matches the selected id of one of the
|
||||
// subscriber's data columns
|
||||
var matchedColumn = jQuery.inArray(column.id, displayedColumnsIds);
|
||||
|
||||
// EMAIL filter: if the last value in the column doesn't have a valid
|
||||
var matchedColumn = _.find(displayedColumns, function(data) { return data.id === column.id; });
|
||||
// EMAIL filter: if the first value in the column doesn't have a valid
|
||||
// email, hide the next button
|
||||
if (column.id === "email") {
|
||||
if (!emailRegex.test(subscribersClone.subscribers[0][matchedColumn])) {
|
||||
if (column.id === 'email') {
|
||||
if (!emailRegex.test(subscribersClone.subscribers[0][matchedColumn.index])) {
|
||||
preventNextStep = true;
|
||||
if (!jQuery('[data-id="notice_invalidEmail"]').length) {
|
||||
MailPoet.Notice.error(MailPoet.I18n.t('columnContainsInvalidElement'), {
|
||||
@ -921,35 +851,69 @@ define(
|
||||
}
|
||||
}
|
||||
// DATE filter: if column type is date, check if we can recognize it
|
||||
if (column.type === 'date' && matchedColumn !== -1) {
|
||||
jQuery.map(subscribersClone.subscribers, function (data, position) {
|
||||
var rowData = data[matchedColumn];
|
||||
if (position !== fillterPosition) {
|
||||
// check if date exists
|
||||
if (rowData.trim() === '') {
|
||||
data[matchedColumn] =
|
||||
'<span class="mailpoet_data_match mailpoet_import_error" title="'
|
||||
+ MailPoet.I18n.t('noDateFieldMatch') + '">'
|
||||
+ MailPoet.I18n.t('emptyDate')
|
||||
+ '</span>';
|
||||
preventNextStep = true;
|
||||
return;
|
||||
if (column.type === 'date' && matchedColumn) {
|
||||
var allowedDateFormats = [
|
||||
Moment.ISO_8601,
|
||||
'YYYY/MM/DD',
|
||||
'MM/DD/YYYY',
|
||||
'DD/MM/YYYY',
|
||||
'YYYY/MM/DD',
|
||||
'YYYY/DD/MM',
|
||||
'MM/YYYY',
|
||||
'YYYY/MM',
|
||||
'YYYY'
|
||||
];
|
||||
var firstRowData = subscribersClone.subscribers[0][matchedColumn.index];
|
||||
var validationRule = false;
|
||||
// check if date exists
|
||||
if (firstRowData.trim() === '') {
|
||||
subscribersClone.subscribers[0][matchedColumn.index] =
|
||||
'<span class="mailpoet_data_match mailpoet_import_error" title="'
|
||||
+ MailPoet.I18n.t('noDateFieldMatch') + '">'
|
||||
+ MailPoet.I18n.t('emptyFirstRowDate')
|
||||
+ '</span> ';
|
||||
preventNextStep = true;
|
||||
}
|
||||
else {
|
||||
for (var format in allowedDateFormats) {
|
||||
var testedFormat = allowedDateFormats[format]
|
||||
if (Moment(firstRowData, testedFormat, true).isValid()) {
|
||||
var validationRule = (typeof(testedFormat) === 'function') ?
|
||||
'datetime' :
|
||||
testedFormat
|
||||
// set validation on the column element
|
||||
jQuery(matchedColumn.element).data('validation-rule', validationRule);
|
||||
break;
|
||||
}
|
||||
// check if date is valid and is before today
|
||||
if (Moment(rowData).isValid() && Moment(rowData).isBefore(Moment())) {
|
||||
data[matchedColumn] +=
|
||||
'<span class="mailpoet_data_match" title="'
|
||||
+ MailPoet.I18n.t('verifyDateMatch') + '">'
|
||||
+ MailPoet.Date.format(rowData) + '</span>';
|
||||
}
|
||||
else {
|
||||
data[matchedColumn] +=
|
||||
'<span class="mailpoet_data_match mailpoet_import_error" title="'
|
||||
+ MailPoet.I18n.t('noDateFieldMatch') + '">'
|
||||
+ MailPoet.I18n.t('dateMatchError') + '</span>';
|
||||
preventNextStep = true;
|
||||
if (validationRule === 'datetime') {
|
||||
validationRule = Moment.ISO_8601;
|
||||
}
|
||||
}
|
||||
}
|
||||
jQuery.map(subscribersClone.subscribers, function (data, index) {
|
||||
var rowData = data[matchedColumn.index];
|
||||
if (index === fillerPosition || rowData.trim() === '') return;
|
||||
var date = Moment(rowData, testedFormat, true);
|
||||
// validate date
|
||||
if (date.isValid()) {
|
||||
data[matchedColumn.index] = new Handlebars.SafeString(
|
||||
Handlebars.Utils.escapeExpression(data[matchedColumn.index])
|
||||
+ '<span class="mailpoet_data_match" title="'
|
||||
+ MailPoet.I18n.t('verifyDateMatch') + '">'
|
||||
+ MailPoet.Date.format(date)
|
||||
+ '</span> '
|
||||
);
|
||||
}
|
||||
else {
|
||||
data[matchedColumn.index] = new Handlebars.SafeString(
|
||||
Handlebars.Utils.escapeExpression(data[matchedColumn.index])
|
||||
+ '<span class="mailpoet_data_match mailpoet_import_error" title="'
|
||||
+ MailPoet.I18n.t('noDateFieldMatch') + '">'
|
||||
+ (new Handlebars.SafeString(MailPoet.I18n.t('dateMatchError')))
|
||||
+ '</span> '
|
||||
);
|
||||
preventNextStep = true;
|
||||
};
|
||||
});
|
||||
if (preventNextStep && !jQuery('.mailpoet_invalidDate').length) {
|
||||
MailPoet.Notice.error(MailPoet.I18n.t('columnContainsInvalidDate'), {
|
||||
@ -983,11 +947,11 @@ define(
|
||||
nextStepButton.addClass(disabled);
|
||||
}
|
||||
|
||||
previousStepButton.off().click(function () {
|
||||
router.navigate('step1', {trigger: true});
|
||||
previousStepButton.off().on('click', function () {
|
||||
router.navigate('step1', { trigger: true });
|
||||
});
|
||||
|
||||
nextStepButton.off().click(function () {
|
||||
nextStepButton.off().on('click', function () {
|
||||
if (jQuery(this).hasClass('button-disabled')) {
|
||||
return;
|
||||
}
|
||||
@ -1019,44 +983,41 @@ define(
|
||||
_.each(jQuery('select.mailpoet_subscribers_column_data_match'),
|
||||
function (column, columnIndex) {
|
||||
var columnId = jQuery(column).data('column-id');
|
||||
var validationRule = jQuery(column).data('validation-rule');
|
||||
if (columnId === 'ignore') {
|
||||
return;
|
||||
}
|
||||
columns[columnId] = columnIndex;
|
||||
columns[columnId] = { index: columnIndex, validation_rule: validationRule };
|
||||
});
|
||||
|
||||
_.each(subscribers, function () {
|
||||
queue.add(function (queue) {
|
||||
queue.add(function(queue) {
|
||||
queue.pause();
|
||||
MailPoet.Ajax
|
||||
.post({
|
||||
endpoint: 'ImportExport',
|
||||
action: 'processImport',
|
||||
data: JSON.stringify({
|
||||
columns: columns,
|
||||
subscribers: subscribers[batchNumber],
|
||||
timestamp: timestamp,
|
||||
segments: segmentSelectElement.val(),
|
||||
updateSubscribers: (jQuery(':radio[name="subscriber_update_option"]:checked').val() === 'yes') ? true : false
|
||||
})
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'ImportExport',
|
||||
action: 'processImport',
|
||||
data: JSON.stringify({
|
||||
columns: columns,
|
||||
subscribers: subscribers[batchNumber],
|
||||
timestamp: timestamp,
|
||||
segments: segmentSelectElement.val(),
|
||||
updateSubscribers: (jQuery(':radio[name="subscriber_update_option"]:checked').val() === 'yes') ? true : false
|
||||
})
|
||||
.done(function (response) {
|
||||
if (response.result === false) {
|
||||
importResults.errors.push(response.errors);
|
||||
} else {
|
||||
importResults.created = response.data.created;
|
||||
importResults.updated = response.data.updated;
|
||||
importResults.segments = response.data.segments;
|
||||
importResults.added_to_segment_with_welcome_notification = response.data.added_to_segment_with_welcome_notification;
|
||||
}
|
||||
queue.run();
|
||||
})
|
||||
.error(function (error) {
|
||||
importResults.errors.push(
|
||||
MailPoet.I18n.t('serverError') + error.statusText.toLowerCase() + '.'
|
||||
}).done(function(response) {
|
||||
importResults.created = response.data.created;
|
||||
importResults.updated = response.data.updated;
|
||||
importResults.segments = response.data.segments;
|
||||
importResults.added_to_segment_with_welcome_notification = response.data.added_to_segment_with_welcome_notification;
|
||||
queue.run();
|
||||
}).fail(function(response) {
|
||||
MailPoet.Modal.loading(false);
|
||||
if (response.errors.length > 0) {
|
||||
MailPoet.Notice.error(
|
||||
response.errors.map(function(error) { return error.message; }),
|
||||
{ scroll: true }
|
||||
);
|
||||
queue.run();
|
||||
});
|
||||
}
|
||||
});
|
||||
batchNumber++;
|
||||
})
|
||||
});
|
||||
@ -1146,4 +1107,4 @@ define(
|
||||
Backbone.history.start();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@ -21,8 +21,7 @@ const columns = [
|
||||
},
|
||||
{
|
||||
name: 'segments',
|
||||
label: MailPoet.I18n.t('lists'),
|
||||
sortable: false
|
||||
label: MailPoet.I18n.t('lists')
|
||||
},
|
||||
|
||||
{
|
||||
@ -38,59 +37,50 @@ const columns = [
|
||||
];
|
||||
|
||||
const messages = {
|
||||
onTrash: function(response) {
|
||||
if(response) {
|
||||
var message = null;
|
||||
if(~~response === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSubscriberTrashed')
|
||||
);
|
||||
} else if(~~response > 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSubscribersTrashed')
|
||||
).replace('%$1d', ~~response);
|
||||
}
|
||||
onTrash: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(message !== null) {
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSubscriberTrashed')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSubscribersTrashed')
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onDelete: function(response) {
|
||||
if(response) {
|
||||
var message = null;
|
||||
if(~~response === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSubscriberDeleted')
|
||||
);
|
||||
} else if(~~response > 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSubscribersDeleted')
|
||||
).replace('%$1d', ~~response);
|
||||
}
|
||||
onDelete: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(message !== null) {
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSubscriberDeleted')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSubscribersDeleted')
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
},
|
||||
onRestore: function(response) {
|
||||
if(response) {
|
||||
var message = null;
|
||||
if(~~response === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSubscriberRestored')
|
||||
);
|
||||
} else if(~~response > 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSubscribersRestored')
|
||||
).replace('%$1d', ~~response);
|
||||
}
|
||||
onRestore: (response) => {
|
||||
const count = ~~response.meta.count;
|
||||
let message = null;
|
||||
|
||||
if(message !== null) {
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
if (count === 1) {
|
||||
message = (
|
||||
MailPoet.I18n.t('oneSubscriberRestored')
|
||||
);
|
||||
} else {
|
||||
message = (
|
||||
MailPoet.I18n.t('multipleSubscribersRestored')
|
||||
).replace('%$1d', count.toLocaleString());
|
||||
}
|
||||
MailPoet.Notice.success(message);
|
||||
}
|
||||
};
|
||||
|
||||
@ -121,8 +111,8 @@ const bulk_actions = [
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('multipleSubscribersMovedToList')
|
||||
.replace('%$1d', ~~(response.subscribers))
|
||||
.replace('%$2s', response.segment)
|
||||
.replace('%$1d', (~~(response.meta.count)).toLocaleString())
|
||||
.replace('%$2s', response.meta.segment)
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -152,8 +142,8 @@ const bulk_actions = [
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('multipleSubscribersAddedToList')
|
||||
.replace('%$1d', ~~response.subscribers)
|
||||
.replace('%$2s', response.segment)
|
||||
.replace('%$1d', (~~response.meta.count).toLocaleString())
|
||||
.replace('%$2s', response.meta.segment)
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -183,8 +173,8 @@ const bulk_actions = [
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('multipleSubscribersRemovedFromList')
|
||||
.replace('%$1d', ~~response.subscribers)
|
||||
.replace('%$2s', response.segment)
|
||||
.replace('%$1d', (~~response.meta.count).toLocaleString())
|
||||
.replace('%$2s', response.meta.segment)
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -194,7 +184,7 @@ const bulk_actions = [
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('multipleSubscribersRemovedFromAllLists')
|
||||
.replace('%$1d', ~~response)
|
||||
.replace('%$1d', (~~response.meta.count).toLocaleString())
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -204,7 +194,7 @@ const bulk_actions = [
|
||||
onSuccess: function(response) {
|
||||
MailPoet.Notice.success(
|
||||
MailPoet.I18n.t('multipleConfirmationEmailsSent')
|
||||
.replace('%$1d', ~~response)
|
||||
.replace('%$1d', (~~response.meta.count).toLocaleString())
|
||||
);
|
||||
}
|
||||
},
|
||||
@ -275,7 +265,7 @@ const SubscriberList = React.createClass({
|
||||
|
||||
subscriber.subscriptions.map((subscription) => {
|
||||
const segment = this.getSegmentFromId(subscription.segment_id);
|
||||
if(segment === false) return;
|
||||
if (segment === false) return;
|
||||
if (subscription.status === 'subscribed') {
|
||||
subscribed_segments.push(segment.name);
|
||||
}
|
||||
@ -290,7 +280,7 @@ const SubscriberList = React.createClass({
|
||||
|
||||
|
||||
let avatar = false;
|
||||
if(subscriber.avatar_url) {
|
||||
if (subscriber.avatar_url) {
|
||||
avatar = (
|
||||
<img
|
||||
className="avatar"
|
||||
@ -305,9 +295,12 @@ const SubscriberList = React.createClass({
|
||||
return (
|
||||
<div>
|
||||
<td className={ row_classes }>
|
||||
<strong><Link to={ `/edit/${ subscriber.id }` }>
|
||||
{ subscriber.email }
|
||||
</Link></strong>
|
||||
<strong>
|
||||
<Link
|
||||
className="row-title"
|
||||
to={ `/edit/${ subscriber.id }` }
|
||||
>{ subscriber.email }</Link>
|
||||
</strong>
|
||||
<p style={{margin: 0}}>
|
||||
{ subscriber.first_name } { subscriber.last_name }
|
||||
</p>
|
||||
@ -328,16 +321,23 @@ const SubscriberList = React.createClass({
|
||||
</div>
|
||||
);
|
||||
},
|
||||
onGetItems: function(count) {
|
||||
jQuery('#mailpoet_export_button')[(count > 0) ? 'show' : 'hide']();
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
<div>
|
||||
<h1 className="title">
|
||||
{MailPoet.I18n.t('pageTitle')} <Link className="page-title-action" to="/new">{MailPoet.I18n.t('new')}</Link>
|
||||
<a className="page-title-action" href="?page=mailpoet-import#step1">{MailPoet.I18n.t('import')}</a>
|
||||
<a id="mailpoet_export_button" className="page-title-action" href="?page=mailpoet-export">{MailPoet.I18n.t('export')}</a>
|
||||
{MailPoet.I18n.t('pageTitle')} <Link
|
||||
className="page-title-action"
|
||||
to="/new"
|
||||
>{MailPoet.I18n.t('new')}</Link>
|
||||
<a
|
||||
className="page-title-action"
|
||||
href="?page=mailpoet-import#step1"
|
||||
>{MailPoet.I18n.t('import')}</a>
|
||||
<a
|
||||
id="mailpoet_export_button"
|
||||
className="page-title-action"
|
||||
href="?page=mailpoet-export"
|
||||
>{MailPoet.I18n.t('export')}</a>
|
||||
</h1>
|
||||
|
||||
<Listing
|
||||
@ -350,7 +350,8 @@ const SubscriberList = React.createClass({
|
||||
bulk_actions={ bulk_actions }
|
||||
item_actions={ item_actions }
|
||||
messages={ messages }
|
||||
onGetItems={ this.onGetItems }
|
||||
sort_by={ 'created_at' }
|
||||
sort_order={ 'desc' }
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
45
build.sh
@ -1,22 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Translations (npm install & composer install need to be run before)
|
||||
echo '[BUILD] Generating translations'
|
||||
./do makepot
|
||||
|
||||
plugin_name='mailpoet'
|
||||
|
||||
# Remove previous build.
|
||||
echo '[BUILD] Removing previous build'
|
||||
rm $plugin_name.zip
|
||||
|
||||
# Create temp dir.
|
||||
echo '[BUILD] Creating temporary directory'
|
||||
mkdir $plugin_name
|
||||
|
||||
# Production assets.
|
||||
echo '[BUILD] Generating production CSS and JS assets'
|
||||
rm -rf node_modules
|
||||
npm install
|
||||
./do compile:all
|
||||
|
||||
# Production libraries.
|
||||
./composer.phar install --no-dev
|
||||
echo '[BUILD] Fetching production libraries'
|
||||
rm -rf vendor
|
||||
./composer.phar install --no-dev --prefer-dist --optimize-autoloader --no-scripts
|
||||
|
||||
# Copy release folders.
|
||||
echo '[BUILD] Copying release folders'
|
||||
cp -Rf lang $plugin_name
|
||||
cp -RfL assets $plugin_name
|
||||
cp -Rf lib $plugin_name
|
||||
@ -25,18 +35,49 @@ cp -Rf views $plugin_name
|
||||
rm -Rf $plugin_name/assets/css/src
|
||||
rm -Rf $plugin_name/assets/js/src
|
||||
|
||||
# Remove extra files (docs, examples,...) from 3rd party extensions
|
||||
echo '[BUILD] Removing obsolete files from vendor libraries'
|
||||
find $plugin_name/vendor -type f -regextype posix-egrep -iregex ".*\/*\.(markdown|md|txt)" -print0 | xargs -0 rm -f
|
||||
find $plugin_name/vendor -type f -regextype posix-egrep -iregex ".*\/(readme|license|version|changes|changelog)" -print0 | xargs -0 rm -f
|
||||
find $plugin_name/vendor -type d -regextype posix-egrep -iregex ".*\/(docs?|examples?|\.git)" -print0 | xargs -0 rm -rf
|
||||
|
||||
# Remove unit tests from 3rd party extensions
|
||||
echo '[BUILD] Removing unit tests from vendor libraries'
|
||||
rm -rf $plugin_name/vendor/twig/twig/test
|
||||
rm -rf $plugin_name/vendor/symfony/translation/Tests
|
||||
rm -rf $plugin_name/vendor/phpmailer/phpmailer/test
|
||||
rm -rf $plugin_name/vendor/soundasleep/html2text/tests
|
||||
rm -rf $plugin_name/vendor/mtdowling/cron-expression/tests
|
||||
rm -rf $plugin_name/vendor/swiftmailer/swiftmailer/tests
|
||||
rm -rf $plugin_name/vendor/cerdic/css-tidy/testing
|
||||
|
||||
# Remove risky files from 3rd party extensions
|
||||
echo '[BUILD] Removing risky and demo files from vendor libraries'
|
||||
rm -f $plugin_name/vendor/j4mie/idiorm/demo.php
|
||||
rm -f $plugin_name/vendor/cerdic/css-tidy/css_optimiser.php
|
||||
|
||||
# Copy release files.
|
||||
cp LICENSE $plugin_name
|
||||
echo '[BUILD] Copying release files'
|
||||
cp license.txt $plugin_name
|
||||
cp index.php $plugin_name
|
||||
cp $plugin_name.php $plugin_name
|
||||
cp readme.txt $plugin_name
|
||||
cp uninstall.php $plugin_name
|
||||
|
||||
# Add index files if they don't exist to all folders
|
||||
echo '[BUILD] Adding index files to all project folders'
|
||||
find $plugin_name -type d -exec touch {}/index.php \;
|
||||
|
||||
# Zip final release.
|
||||
echo '[BUILD] Creating final release zip'
|
||||
zip -r $plugin_name.zip $plugin_name
|
||||
|
||||
# Remove temp dir.
|
||||
echo '[BUILD] Removing temp directory'
|
||||
rm -rf $plugin_name
|
||||
|
||||
# Reinstall dev dependencies.
|
||||
echo '[BUILD] Reinstalling dev dependencies'
|
||||
./composer.phar install
|
||||
|
||||
echo '[BUILD] Build finished!'
|
||||
|
66
circle.yml
Normal file
@ -0,0 +1,66 @@
|
||||
machine:
|
||||
timezone:
|
||||
UTC
|
||||
|
||||
hosts:
|
||||
mailpoet.loc: 127.0.0.1
|
||||
|
||||
## Customize dependencies
|
||||
dependencies:
|
||||
pre:
|
||||
# install PHP dependencies for WordPress
|
||||
- sudo apt-get update
|
||||
- sudo apt-get --assume-yes install php5-mysql
|
||||
# configure Apache
|
||||
- sudo cp ./.circle_ci/apache/mailpoet.loc.conf /etc/apache2/sites-available
|
||||
- sudo a2ensite mailpoet.loc
|
||||
- sudo a2enmod rewrite
|
||||
- sudo service apache2 restart
|
||||
# install Phoenix dependencies
|
||||
- curl -sS https://getcomposer.org/installer | php
|
||||
- ./composer.phar install
|
||||
- ./do install
|
||||
# Set up Wordpress
|
||||
# No password is required for the MySQL user `ubuntu`
|
||||
- mysql -u ubuntu -e "create database wordpress"
|
||||
# Use cURL to fetch WP-CLI
|
||||
- curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
|
||||
# Make sure WP-CLI is executable
|
||||
- chmod +x wp-cli.phar
|
||||
# Download WordPress into `wordpress` directory
|
||||
- ./wp-cli.phar core download --allow-root --path=wordpress
|
||||
# Generate `wp-config.php` file
|
||||
- echo "define(\"WP_DEBUG\", true);" | ./wp-cli.phar core config --allow-root --dbname=wordpress --dbuser=ubuntu --dbhost=127.0.0.1:3306 --path=wordpress --extra-php
|
||||
# Install WordPress
|
||||
- ./wp-cli.phar core install --allow-root --admin_name=admin --admin_password=admin --admin_email=admin@mailpoet.loc --url=http://mailpoet.loc:8080 --title=WordPress --path=wordpress
|
||||
# Softlink MailPoet to plugin path
|
||||
- ln -s ../../.. wordpress/wp-content/plugins/mailpoet
|
||||
# Activate MailPoet
|
||||
- ./wp-cli.phar plugin activate mailpoet --path=wordpress
|
||||
# Create .env file with correct path to WP installation
|
||||
- echo "WP_TEST_PATH=\"/home/ubuntu/mailpoet/wordpress\"" > .env
|
||||
|
||||
# Enable XDebug for coverage reports.
|
||||
# Comment out if not running PHP coverage reports, for performance
|
||||
#- sed -i 's/^;//' /opt/circleci/php/$(phpenv global)/etc/conf.d/xdebug.ini
|
||||
|
||||
## tests override
|
||||
test:
|
||||
override:
|
||||
# Add default timezone to PHP's configuration (required for PHP >=5.4)
|
||||
- echo "date.timezone = UTC" > /opt/circleci/php/$(phpenv global)/etc/conf.d/date.ini
|
||||
# Run QA scripts
|
||||
- ./do qa
|
||||
# Run JS tests
|
||||
- mkdir $CIRCLE_TEST_REPORTS/mocha
|
||||
- ./do t:j $CIRCLE_TEST_REPORTS/mocha/junit.xml
|
||||
|
||||
# Run PHP tests
|
||||
- ./do t:u --xml
|
||||
# Uncomment to run coverage tests instead
|
||||
#- ./do t:c --xml
|
||||
# Copy the report
|
||||
- mkdir $CIRCLE_TEST_REPORTS/codeception
|
||||
- cp tests/_output/report.xml $CIRCLE_TEST_REPORTS/codeception/report.xml
|
||||
# Uncomment to copy PHP coverage report
|
||||
#- cp tests/_output/coverage.xml $CIRCLE_TEST_REPORTS/codeception/coverage.xml
|
@ -10,6 +10,7 @@ settings:
|
||||
colors: true
|
||||
memory_limit: 1024M
|
||||
log: true
|
||||
strict_xml: true
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunFailed
|
||||
@ -26,6 +27,7 @@ coverage:
|
||||
include:
|
||||
- lib/*
|
||||
exclude:
|
||||
- lib/Config/PopulatorData/*
|
||||
- lib/Util/Sudzy/*
|
||||
- lib/Util/CSS.php
|
||||
- lib/Util/Helpers.php
|
||||
|
@ -8,13 +8,10 @@
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"twig/twig": "1.*",
|
||||
"phpmailer/phpmailer": "~5.2",
|
||||
"cerdic/css-tidy": "*",
|
||||
"sunra/php-simple-html-dom-parser": "*",
|
||||
"tburry/pquery": "*",
|
||||
"j4mie/paris": "1.5.4",
|
||||
"swiftmailer/swiftmailer": "^5.4",
|
||||
"phpseclib/phpseclib": "*",
|
||||
"mtdowling/cron-expression": "^1.1",
|
||||
"nesbot/carbon": "^1.21",
|
||||
"soundasleep/html2text": "dev-master"
|
||||
@ -25,12 +22,19 @@
|
||||
"codegyre/robo": "*",
|
||||
"vlucas/phpdotenv": "*",
|
||||
"umpirsky/twig-gettext-extractor": "1.1.*",
|
||||
"raveren/kint": "^1.0"
|
||||
"raveren/kint": "^1.0",
|
||||
"squizlabs/php_codesniffer": "*",
|
||||
"wimg/php-compatibility": "*",
|
||||
"simplyadmire/composer-plugins" : "@dev"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"MailPoet\\": "lib/",
|
||||
"Sudzy\\": "lib/Util/Sudzy"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-update-cmd": "rm -rf vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility; cp -rpd vendor/wimg/php-compatibility vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility",
|
||||
"post-install-cmd": "rm -rf vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility; cp -rpd vendor/wimg/php-compatibility vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility"
|
||||
}
|
||||
}
|
||||
}
|
972
composer.lock
generated
@ -1,199 +0,0 @@
|
||||
# Copyright (C) 2015
|
||||
# This file is distributed under the same license as the package.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: http://support.mailpoet.com/\n"
|
||||
"POT-Creation-Date: 2015-07-29 16:59:53+00:00\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"PO-Revision-Date: 2015-07-29 19:00+0100\n"
|
||||
"Last-Translator: MailPoet i18n (https://www.transifex.com/organization/wysija)\n"
|
||||
"Language-Team: MailPoet i18n <https://www.transifex.com/organization/wysija>\n"
|
||||
"X-Generator: Poedit 1.7.4\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-Basepath: ../\n"
|
||||
"X-Textdomain-Support: yes\n"
|
||||
"Language: en\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#: lib/form/renderer.php:91
|
||||
msgid "Year, month, day"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:92
|
||||
msgid "Year, month"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:93
|
||||
msgid "Month (January, February,...)"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:94 lib/form/renderer.php:519
|
||||
msgid "Year"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:108
|
||||
msgid "January"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:109
|
||||
msgid "February"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:110
|
||||
msgid "March"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:111
|
||||
msgid "April"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:112
|
||||
msgid "May"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:113
|
||||
msgid "June"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:114
|
||||
msgid "July"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:115
|
||||
msgid "August"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:116
|
||||
msgid "September"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:117
|
||||
msgid "October"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:118
|
||||
msgid "November"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:119
|
||||
msgid "December"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:509
|
||||
msgid "Day"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/renderer.php:514
|
||||
msgid "Month"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/widget.php:11
|
||||
msgid "MailPoet Subscription Form"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/widget.php:13
|
||||
msgid "Newsletter subscription form"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/widget.php:36
|
||||
msgid "Subscribe to our Newsletter"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/widget.php:56
|
||||
msgid "Title:"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/widget.php:76
|
||||
msgid "Create a new form"
|
||||
msgstr ""
|
||||
|
||||
#: lib/form/widget.php:109
|
||||
msgid "Newsletter"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:4 views/form/editor.html:26
|
||||
msgid "Save"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:5
|
||||
msgid "Translatable string with a link %shere%s"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:6
|
||||
msgid "deleted one message"
|
||||
msgid_plural "deleted %d messages"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
|
||||
#: views/form/editor.html:34
|
||||
msgid "Settings"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:42
|
||||
msgid "This form adds subscribers to these lists:"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:44
|
||||
msgid "Choose a list"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:57
|
||||
msgid "You have to select at least 1 list"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:63
|
||||
msgid "After submit..."
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:65
|
||||
msgid "Show message"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:69
|
||||
msgid "Go to page"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:76
|
||||
msgid "Check your inbox now to confirm your subscription."
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:98
|
||||
msgid "Shortcodes"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:103
|
||||
msgid "You can easily add this form to your theme's in the"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:103
|
||||
msgid "Widgets areas"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:126
|
||||
msgid "[link_html]HTML[/link_html]"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:138
|
||||
msgid "Fields"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:144
|
||||
msgid "Add New Field"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:153
|
||||
msgid "Styles"
|
||||
msgstr ""
|
||||
|
||||
#: views/form/editor.html:157
|
||||
msgid "Preview"
|
||||
msgstr ""
|
||||
|
||||
#: views/index.html:4
|
||||
msgid "monvier"
|
||||
msgstr ""
|