diff --git a/assets/js/src/listing/listing.jsx b/assets/js/src/listing/listing.jsx index addeaab843..eab7749572 100644 --- a/assets/js/src/listing/listing.jsx +++ b/assets/js/src/listing/listing.jsx @@ -69,13 +69,33 @@ define( ); } - var item_actions = ( + var custom_actions = this.props.item_actions; + var item_actions = false; + + if(custom_actions.length > 0) { + item_actions = custom_actions.map(function(action, index) { + return ( + + + { action.label } + + {(index < (custom_actions.length - 1)) ? ' | ' : ''} + + ); + }.bind(this)); + } else { + item_actions = ( + + Edit + + ); + } + + var actions = (
- - Edit - -  |  + { item_actions } + { ' | ' } { checkbox } - { this.props.onRenderItem(this.props.item, item_actions) } + { this.props.onRenderItem(this.props.item, actions) } ); } @@ -166,6 +186,7 @@ define( onDeleteItem={ this.props.onDeleteItem } selection={ this.props.selection } is_selectable={ this.props.is_selectable } + item_actions={ this.props.item_actions } key={ 'item-' + item.id } item={ item } /> ); @@ -367,6 +388,9 @@ define( // bulk actions var bulk_actions = this.props.bulk_actions || []; + // item actions + var item_actions = this.props.item_actions || []; + var tableClasses = classNames( 'wp-list-table', 'widefat', @@ -420,6 +444,7 @@ define( loading={ this.state.loading } count={ this.state.count } limit={ this.state.limit } + item_actions={ item_actions } items={ items } /> diff --git a/assets/js/src/newsletters/list.jsx b/assets/js/src/newsletters/list.jsx index f15dd7c48e..c17a1c3971 100644 --- a/assets/js/src/newsletters/list.jsx +++ b/assets/js/src/newsletters/list.jsx @@ -34,8 +34,19 @@ define( } ]; + var item_actions = [ + { + name: 'edit', + label: 'Edit', + link: function(id) { + return '?page=mailpoet-newsletter-editor&id='+parseInt(id, 10); + } + } + ]; + var NewsletterList = React.createClass({ renderItem: function(newsletter, actions) { + var rowClasses = classNames( 'manage-column', 'column-primary', @@ -65,7 +76,8 @@ define( endpoint="newsletters" onRenderItem={this.renderItem} columns={columns} - bulk_actions={ bulk_actions } /> + bulk_actions={ bulk_actions } + item_actions={ item_actions } /> ); } }); diff --git a/lib/Config/Menu.php b/lib/Config/Menu.php index cd680ffc7e..a5830b4a71 100644 --- a/lib/Config/Menu.php +++ b/lib/Config/Menu.php @@ -59,14 +59,30 @@ class Menu { 'mailpoet-settings', array($this, 'settings') ); - add_submenu_page( - 'mailpoet', - __('Newsletter editor'), - __('Newsletter editor'), - 'manage_options', - 'mailpoet-newsletter-editor', - array($this, 'newsletterEditor') + // add_submenu_page( + // 'mailpoet', + // __('Newsletter editor'), + // __('Newsletter editor'), + // 'manage_options', + // 'mailpoet-newsletter-editor', + // array($this, 'newletterEditor') + // ); + $this->registered_pages(); + } + + function registered_pages() { + global $_registered_pages; + $pages = array( + //'mailpoet-form-editor' => 'formEditor', + 'mailpoet-newsletter-editor' => array($this, 'newletterForm') ); + foreach($pages as $menu_slug => $callback) { + $hookname = get_plugin_page_hookname($menu_slug, null); + if(!empty($hookname)) { + add_action($hookname, $callback); + } + $_registered_pages[$hookname] = true; + } } function home() { @@ -97,11 +113,11 @@ class Menu { echo $this->renderer->render('newsletters.html', $data); } - function newsletterEditor() { + function newletterForm() { $data = array(); wp_enqueue_media(); wp_enqueue_script('tinymce-wplink', includes_url('js/tinymce/plugins/wplink/plugin.js')); wp_enqueue_style('editor', includes_url('css/editor.css')); - echo $this->renderer->render('newsletter/editor.html', $data); + echo $this->renderer->render('newsletter/form.html', $data); } } diff --git a/lib/Twig/Functions.php b/lib/Twig/Functions.php index aaa55c8231..0ee443d045 100644 --- a/lib/Twig/Functions.php +++ b/lib/Twig/Functions.php @@ -3,14 +3,14 @@ namespace MailPoet\Twig; class Functions extends \Twig_Extension { - public function __construct() { + function __construct() { } - public function getName() { + function getName() { return 'functions'; } - public function getFunctions() { + function getFunctions() { return array( new \Twig_SimpleFunction( 'json_encode', @@ -21,7 +21,25 @@ class Functions extends \Twig_Extension { 'json_decode', 'json_decode', array('is_safe' => array('all')) + ), + new \Twig_SimpleFunction( + 'wp_nonce_field', + 'wp_nonce_field', + array('is_safe' => array('all')) + ), + new \Twig_SimpleFunction( + 'params', + array($this, 'params'), + array('is_safe' => array('all')) ) ); } + + function params($key = null) { + $args = stripslashes_deep($_GET); + if(array_key_exists($key, $args)) { + return $args[$key]; + } + return null; + } } diff --git a/views/newsletter/form.html b/views/newsletter/form.html new file mode 100644 index 0000000000..f4d5153838 --- /dev/null +++ b/views/newsletter/form.html @@ -0,0 +1,1274 @@ +<% extends 'layout.html' %> + +<% block content %> +
+
+
+ <%= __('Select type') %> > <%= __('Template') %> > <%= __('Designer') %> > <%= __('Send') %> +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + +
+ +<% endblock %> + +<% block templates %> + <%= partial( + 'newsletter_editor_template_tools_generic', + 'newsletter/templates/blocks/base/toolsGeneric.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_automated_latest_content_block', + 'newsletter/templates/blocks/automatedLatestContent/block.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_automated_latest_content_widget', + 'newsletter/templates/blocks/automatedLatestContent/widget.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_automated_latest_content_settings', + 'newsletter/templates/blocks/automatedLatestContent/settings.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_button_block', + 'newsletter/templates/blocks/button/block.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_button_widget', + 'newsletter/templates/blocks/button/widget.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_button_settings', + 'newsletter/templates/blocks/button/settings.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_container_block', + 'newsletter/templates/blocks/container/block.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_container_block_empty', + 'newsletter/templates/blocks/container/emptyBlock.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_container_one_column_widget', + 'newsletter/templates/blocks/container/oneColumnLayoutWidget.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_container_two_column_widget', + 'newsletter/templates/blocks/container/twoColumnLayoutWidget.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_container_three_column_widget', + 'newsletter/templates/blocks/container/threeColumnLayoutWidget.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_container_settings', + 'newsletter/templates/blocks/container/settings.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_divider_block', + 'newsletter/templates/blocks/divider/block.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_divider_widget', + 'newsletter/templates/blocks/divider/widget.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_divider_settings', + 'newsletter/templates/blocks/divider/settings.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_footer_block', + 'newsletter/templates/blocks/footer/block.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_footer_widget', + 'newsletter/templates/blocks/footer/widget.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_footer_settings', + 'newsletter/templates/blocks/footer/settings.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_header_block', + 'newsletter/templates/blocks/header/block.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_header_widget', + 'newsletter/templates/blocks/header/widget.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_header_settings', + 'newsletter/templates/blocks/header/settings.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_image_block', + 'newsletter/templates/blocks/image/block.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_image_widget', + 'newsletter/templates/blocks/image/widget.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_image_settings', + 'newsletter/templates/blocks/image/settings.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_posts_block', + 'newsletter/templates/blocks/posts/block.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_posts_widget', + 'newsletter/templates/blocks/posts/widget.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_posts_settings', + 'newsletter/templates/blocks/posts/settings.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_posts_settings_display_options', + 'newsletter/templates/blocks/posts/settingsDisplayOptions.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_posts_settings_selection', + 'newsletter/templates/blocks/posts/settingsSelection.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_posts_settings_selection_empty', + 'newsletter/templates/blocks/posts/settingsSelectionEmpty.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_posts_settings_single_post', + 'newsletter/templates/blocks/posts/settingsSinglePost.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_social_block', + 'newsletter/templates/blocks/social/block.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_social_block_icon', + 'newsletter/templates/blocks/social/blockIcon.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_social_widget', + 'newsletter/templates/blocks/social/widget.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_social_settings', + 'newsletter/templates/blocks/social/settings.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_social_settings_icon', + 'newsletter/templates/blocks/social/settingsIcon.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_social_settings_icon_selector', + 'newsletter/templates/blocks/social/settingsIconSelector.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_social_settings_styles', + 'newsletter/templates/blocks/social/settingsStyles.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_spacer_block', + 'newsletter/templates/blocks/spacer/block.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_spacer_widget', + 'newsletter/templates/blocks/spacer/widget.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_spacer_settings', + 'newsletter/templates/blocks/spacer/settings.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_text_block', + 'newsletter/templates/blocks/text/block.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_text_widget', + 'newsletter/templates/blocks/text/widget.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_text_settings', + 'newsletter/templates/blocks/text/settings.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_heading', + 'newsletter/templates/components/heading.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_save', + 'newsletter/templates/components/save.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_styles', + 'newsletter/templates/components/styles.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_sidebar', + 'newsletter/templates/components/sidebar/sidebar.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_sidebar_content', + 'newsletter/templates/components/sidebar/content.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_sidebar_layout', + 'newsletter/templates/components/sidebar/layout.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_sidebar_preview', + 'newsletter/templates/components/sidebar/preview.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_sidebar_styles', + 'newsletter/templates/components/sidebar/styles.hbs' + ) %> + + <%= javascript( + 'vendor.js', + 'lib/tinymce/tinymce.jquery.min.js', + 'lib/tinymce/jquery.tinymce.min.js', + 'lib/mailpoet_custom_fields/plugin.js', + 'lib/wplink/plugin.js', + 'newsletter_editor.js' + ) %> + + <%= stylesheet( + 'newsletter_editor.css' + ) %> + + + + +<% endblock %> diff --git a/views/newsletter/templates/components/heading.hbs b/views/newsletter/templates/components/heading.hbs index 30fee47c29..a1eaf668b5 100644 --- a/views/newsletter/templates/components/heading.hbs +++ b/views/newsletter/templates/components/heading.hbs @@ -1,6 +1,15 @@
- +
- +
diff --git a/views/templates/test.hbs b/views/templates/test.hbs deleted file mode 100644 index d0662f1919..0000000000 --- a/views/templates/test.hbs +++ /dev/null @@ -1,2 +0,0 @@ -

<%= __('Settings') %>

-{{ user.name }} ({{ user.age }}) - extra value: {{ extra_value }}