When you edit something in text editor or IDE, you get visual feedback - star next to file name, bolded file name et cetera. That way you easily know what has been edited and what not.

Is there a ready made solution to introduce that to Drupal? Either system-wide or manually using Form API? It would make sense to see if any changes was made or not, especially if one opens dozen of nodes for updates and then sees some of them are already up to date and does not need a save (and associated boost cache clears).

In large setting forms, like permissions or Elysia Cron, it would help too.

The ideal would be to add some class to each field with value not equal it's default value, so the theme could deal with it using only CSS.

Anyone written it already?

up vote 3 down vote accepted

I've only seen Track Field Changes, but that doesn't give immediate visual feedback.

Edit: I know you asked for something that was already out in the wild, but the following might be useful.

I guess you could write something custom relatively easily though using jQuery's .change event.

Something like the following I guess (code will need checking but it should be pretty near).

JavaScript

(function ($) {
    Drupal.behaviors.formFieldTracker = {
      attach: function(){
        $(input).change(function(){
          $(this).addClass('field-edited');
        }));
      }
    }
})(jQuery)

Module

function MYMODULE_preprocess_page(&$vars) {
  // Only add the JavaScript on admin pages as defined by hook_admin_paths()
  if (path_is_admin(current_path())) {
    $path = drupal_get_path('module', 'MYMODULE');
    drupal_add_js($path . '/js/MYSCRIPT.js');
    $vars['scripts'] = drupal_get_js();
  }
}

Then you could add whatever CSS you fancy afterwards:

.field-edited:after {
  content: 'Edited';
  display: inline-block;
  color: #F00;
  font-style: italic;
}
  • I'll try it, thank you. I think... if I'll wrap it into a module, I can post it on Drupal.org so it'll be ready for other users ;) If I will, I'll make sure to give you credit, if you'll do it feel free to make me test or maintain it. – Mołot Jun 11 '13 at 9:17
  • I'm willing to take a look, but I won't be able to get on it today as I am swamped with client work. If you put it up on d.o then I'm more than willing to bugfix/text :-) – Chapabu Jun 11 '13 at 9:19
  • Accepting as from first tests it seems it works. – Mołot Jun 11 '13 at 9:20
  • 1
    It works? I thought there was an error in my JS that I've just noticed :-o. I'll fix the error and if it breaks then just edit it back ;-) – Chapabu Jun 11 '13 at 9:21
  • 2
    +1. Suppose you could match the value to the default-value of the input element to do a slightly more sophisticated approach. By the way there's a :input jquery pseudo selector which covers selects as well: $(':input').not(':button') hopefully should cover it? – Beebee Jun 11 '13 at 9:44

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.