migrate_ui.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. (function ($) {
  2. /**
  3. * Provide the summary information for the migration detail vertical tabs.
  4. */
  5. Drupal.behaviors.migrateUISummary = {
  6. attach: function (context) {
  7. // The drupalSetSummary method required for this behavior is not available
  8. // on the Blocks administration page, so we need to make sure this
  9. // behavior is processed only if setSummary is defined.
  10. if (typeof jQuery.fn.drupalSetSummary == 'undefined') {
  11. return;
  12. }
  13. $('fieldset#edit-overview', context).drupalSetSummary(function (context) {
  14. if (!$('#owner', context).children()) {
  15. return '<span class="error">' + Drupal.t('Missing client owner.') + '</span>';
  16. }
  17. });
  18. $('fieldset#edit-destination', context).drupalSetSummary(function (context) {
  19. total = $('tr', context).length - 2;
  20. unmapped = $('td.migrate-error', context).length / 2;
  21. mapped = total - unmapped;
  22. msg = Drupal.formatPlural(mapped, '1 mapping.', '@count mapped.');
  23. if (unmapped) {
  24. msg = '<span class="error">' + Drupal.formatPlural(unmapped, '1 unmapped', '@count unmapped') + '</span>' + '. ' + msg;
  25. }
  26. return msg;
  27. });
  28. $('fieldset#edit-source', context).drupalSetSummary(function (context) {
  29. total = $('tr', context).length - 2;
  30. unmapped = $('td.migrate-error', context).length / 2;
  31. mapped = total - unmapped;
  32. msg = Drupal.formatPlural(mapped, '1 mapping.', '@count mapped.');
  33. if (unmapped) {
  34. msg = '<span class="error">' + Drupal.formatPlural(unmapped, '1 unmapped', '@count unmapped') + '</span>' + '. ' + msg;
  35. }
  36. return msg;
  37. });
  38. $('fieldset.migrate-mapping').each(function ($context) {
  39. msg = Drupal.t('By priority: ');
  40. var levels= {1:'OK',2:'Low',3:'Medium',4:'Blocker'};
  41. for (level in levels) {
  42. txt = '';
  43. if (count = $(this).find('td.migrate-priority-' + level).length / 5) {
  44. txt = count + ' ' + levels[level];
  45. if (level > 1) {
  46. txt = '<span class="error">' + txt + '</span>';
  47. }
  48. msg = msg + txt + '. ';
  49. }
  50. }
  51. $(this).drupalSetSummary(msg);
  52. }
  53. )}
  54. }
  55. })(jQuery);