From c1b3f09836223c6865a2d09c6b77496730127fc3 Mon Sep 17 00:00:00 2001
From: megachriz <megachriz@654114.no-reply.drupal.org>
Date: Thu, 4 Sep 2014 10:54:26 -0700
Subject: [PATCH] Issue #2305929 by twistor, MegaChriz: Show message that
 mapping settings must be saved after changes.

---
 feeds_ui/feeds_ui.admin.inc    | 21 ++++++++++++++++++++-
 tests/feeds_mapper_config.test |  2 ++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/feeds_ui/feeds_ui.admin.inc b/feeds_ui/feeds_ui.admin.inc
index ce8f1ed7..6224c7d3 100644
--- a/feeds_ui/feeds_ui.admin.inc
+++ b/feeds_ui/feeds_ui.admin.inc
@@ -493,6 +493,16 @@ function feeds_ui_mapping_form($form, &$form_state, $importer) {
   $form['#prefix'] = '<div id="feeds-ui-mapping-form-wrapper">';
   $form['#suffix'] = '</div>';
 
+  // Show message when target configuration gets changed.
+  if (!empty($form_state['mapping_settings'])) {
+    $form['#mapping_settings'] = $form_state['mapping_settings'];
+    $form['changed'] = array(
+      '#theme_wrappers' => array('container'),
+      '#attributes' => array('class' => array('messages', 'warning')),
+      '#markup' => t('* Changes made to target configuration are stored temporarily. Click Save to make your changes permanent.'),
+    );
+  }
+
   // Get mapping sources from parsers and targets from processor, format them
   // for output.
   // Some parsers do not define mapping sources but let them define on the fly.
@@ -1016,6 +1026,10 @@ function theme_feeds_ui_mapping_form($variables) {
       // Some parsers do not define source options.
       $source = isset($form['source']['#options'][$mapping['source']]) ? $form['source']['#options'][$mapping['source']] : $mapping['source'];
       $target = isset($form['target']['#options'][$mapping['target']]) ? check_plain($form['target']['#options'][$mapping['target']]) : '<em>' . t('Missing') . '</em>';
+      // Add indicator to target if target configuration changed.
+      if (isset($form['#mapping_settings'][$i])) {
+        $target .= '<span class="warning">*</span>';
+      }
       $rows[] = array(
         'data' => array(
           check_plain($source),
@@ -1043,7 +1057,12 @@ function theme_feeds_ui_mapping_form($variables) {
     drupal_render($form['add']),
     '',
   );
-  $output = '<div class="help feeds-admin-ui">' . drupal_render($form['help']) . '</div>';
+  $output = '';
+  if (!empty($form['changed'])) {
+    // This form element is only available if target configuration changed.
+    $output .= drupal_render($form['changed']);
+  }
+  $output .= '<div class="help feeds-admin-ui">' . drupal_render($form['help']) . '</div>';
   $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'feeds-ui-mapping-overview')));
 
   // Build the help table that explains available sources.
diff --git a/tests/feeds_mapper_config.test b/tests/feeds_mapper_config.test
index b5fd92dd..58dd11e5 100644
--- a/tests/feeds_mapper_config.test
+++ b/tests/feeds_mapper_config.test
@@ -46,6 +46,7 @@ class FeedsMapperConfigTestCase extends FeedsMapperTestCase {
       'config[0][settings][select]' => 'option4',
     );
     $this->drupalPostAJAX(NULL, $edit, 'mapping_settings_update_0');
+    $this->assertText(t('* Changes made to target configuration are stored temporarily. Click Save to make your changes permanent.'));
 
     // Click Save.
     $this->drupalPost(NULL, array(), t('Save'));
@@ -112,4 +113,5 @@ class FeedsMapperConfigTestCase extends FeedsMapperTestCase {
     $this->assertText('Checkbox inactive.');
     $this->assertText('Second mapping text');
   }
+
 }
-- 
GitLab