Skip to content

Commit

Permalink
[wizard] Add container and scripts for redirects app.
Browse files Browse the repository at this point in the history
  • Loading branch information
mayakokits authored and torotil committed Jan 11, 2018
1 parent b228071 commit 4826a99
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
1 change: 1 addition & 0 deletions campaignion_wizard/css/redirects_app/redirects_app.css
@@ -0,0 +1 @@
h1 {color: red; font-size: 4rem;}
7 changes: 7 additions & 0 deletions campaignion_wizard/js/redirects_app/redirects_app.vue.min.js
@@ -0,0 +1,7 @@
$('.personalized-redirects-widget').each(function() {
console.log('redirects script running');
var id = $(this).attr('id');
$(this)
.append('<h1>' + id + '</h1>')
.append('Default url: ' + Drupal.settings.campaignion_wizard[id].default_redirect_url)
})
42 changes: 37 additions & 5 deletions campaignion_wizard/src/ThankyouStep.php
Expand Up @@ -77,12 +77,33 @@ protected function pageForm(&$form_state, $index, $title, $prefix) {
'#default_value' => $type == 'redirect' ? 'redirect' : NULL,
'#parents' => array($prefix, 'type'),
);
$form['redirect_url'] = array(
'#type' => 'textfield',
'#title' => t('Redirect URL'),
'#states' => array('visible' => array(":input[name=\"${prefix}[type]\"]" => array('value' => 'redirect'))),
'#default_value' => $old['redirect_url'],
// $form['redirect_url'] = array(
// '#type' => 'textfield',
// '#title' => t('Redirect URL'),
// '#states' => array('visible' => array(":input[name=\"${prefix}[type]\"]" => array('value' => 'redirect'))),
// '#default_value' => $old['redirect_url'],
// );

// Personalized redirects widget
$redirect_container_id = drupal_html_id('personalized-redirects-widget');
$form['redirects'] = array(
'#type' => 'container',
'#title' => t('Manage redirects'),
'#states' => array('visible' => array(":input[name=\"${prefix}[type]\"]" => array('value' => 'redirect'))),
'#id' => $redirect_container_id,
'#attributes' => ['class' => ['personalized-redirects-widget']],
);
$settings = array(
'default_redirect_url' => $old['redirect_url'],
// ...
);
$settings = array(
'campaignion_wizard' => array(
$redirect_container_id => $settings,
),
);
$form['#attached']['js'][] = ['data' => $settings, 'type' => 'setting'];

$form['or2'] = array(
'#type' => 'markup',
'#markup' => '<div class="thank-you-outer-or"><span class="thank-you-line-or"><span class="thank-you-text-or">' . t('or') . '</span></span></div>',
Expand Down Expand Up @@ -139,6 +160,17 @@ public function stepForm($form, &$form_state) {
$form['thank_you_node'] = $this->pageForm($form_state, 1, t('Thank you page'), 'thank_you_node');
$form['thank_you_node']['#attributes']['class'][] = $thank_you_class;

$dir = drupal_get_path('module', 'campaignion_wizard');
$form['#attached']['js'][] = [
'data' => $dir . '/js/redirects_app/redirects_app.vue.min.js',
'scope' => 'footer',
'preprocess' => FALSE,
];
$form['#attached']['css'][] = [
'data' => $dir . '/css/redirects_app/redirects_app.css',
'group' => 'CSS_DEFAULT',
];

$form['#tree'] = TRUE;
$form['wizard_head']['#tree'] = FALSE;
return $form;
Expand Down

0 comments on commit 4826a99

Please sign in to comment.