Commit db818a7b authored by Miguel Guerreiro's avatar Miguel Guerreiro Committed by Miguel Guerreiro
Browse files

Issue #2926429 by guilherme-lima-almeida, gueguerreiro, heymo: Separate...

Issue #2926429 by guilherme-lima-almeida, gueguerreiro, heymo: Separate required comment option for "Yes" and "No" answers
parent 37f06527
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
helpfulness_yes_allow_comment: 1
helpfulness_yes_title: 'Thanks. Any other comments?'
helpfulness_yes_description: 'We appreciate the feedback.'
helpfulness_yes_comment_required: 0
helpfulness_yes_comment_required_message: 'Comment is required.'
helpfulness_no_allow_comment: 1
helpfulness_no_title: 'Sorry to hear that. Please tell me more!'
helpfulness_no_description: 'Please include your email if you want us to follow up with you.'
helpfulness_comment_required: 0
helpfulness_comment_required_message: 'Comment is required.'
helpfulness_no_comment_required: 1
helpfulness_no_comment_required_message: 'Comment is required.'
helpfulness_notification_email: ''
helpfulness_notification_subject: 'Helpfulness feedback message'
helpfulness_notification_message_prefix: 'You have received new helpfulness feedback.'
+12 −0
Original line number Diff line number Diff line
@@ -6,10 +6,22 @@ helpfulness.settings:
      type: string
    helpfulness_no_title:
      type: string
    helpfulness_yes_allow_comment:
      type: boolean
    helpfulness_no_allow_comment:
      type: boolean
    helpfulness_yes_description:
      type: string
    helpfulness_no_description:
      type: string
    helpfulness_yes_comment_required:
      type: boolean
    helpfulness_no_comment_required:
      type: boolean
    helpfulness_yes_comment_required_message:
      type: string
    helpfulness_no_comment_required_message:
       type: string
    helpfulness_report_option_display_username:
      type: integer
    helpfulness_report_option_display_helpfulness:
+5 −1
Original line number Diff line number Diff line
@@ -18,7 +18,11 @@
  display: none;
}

.form-item-helpfulness-comments {
.form-item-helpfulness-comments-no  {
  display: none;
}

.form-item-helpfulness-comments-yes  {
  display: none;
}

+19 −0
Original line number Diff line number Diff line
@@ -78,3 +78,22 @@ function helpfulness_schema() {

  return $schema;
}

/**
 * Update schema config to separate required options for Yes and No.
 */
function helpfulness_update_9201() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory->getEditable('helpfulness.settings');
  $comment_required = $config->get('helpfulness_comment_required');
  $comment_required_message = $config->get('helpfulness_comment_required_message');
  $config->set('helpfulness_yes_comment_required', $comment_required)
    ->set('helpfulness_no_comment_required', $comment_required)
    ->set('helpfulness_yes_allow_comment', TRUE)
    ->set('helpfulness_no_allow_comment', TRUE)
    ->set('helpfulness_yes_comment_required_message', $comment_required_message)
    ->set('helpfulness_no_comment_required_message', $comment_required_message)
    ->clear('helpfulness_comment_required')
    ->clear('helpfulness_comment_required_message')
    ->save(TRUE);
}
+8 −2
Original line number Diff line number Diff line
@@ -8,15 +8,18 @@
    $(document).ready(function () {
      var selected = $("input[type='radio'][name='helpfulness_rating']:checked");
      if (selected.length > 0) {
        $('.form-item-helpfulness-comments').css('display', 'block');
        $('.helpfulness_submit_button').css('display', 'block');
        if (selected.val() === '1') {
          $('.form-item-helpfulness-comments-yes').show();
          $('.form-item-helpfulness-comments-no').hide();
          $('.helpfulness_no_title').css('display', 'none');
          $('.helpfulness_yes_title').css('display', 'block');
          $('.helpfulness_no_description').css('display', 'none');
          $('.helpfulness_yes_description').css('display', 'block');
        }
        else {
          $('.form-item-helpfulness-comments-no').show();
          $('.form-item-helpfulness-comments-yes').hide();
          $('.helpfulness_yes_title').css('display', 'none');
          $('.helpfulness_no_title').css('display', 'block');
          $('.helpfulness_yes_description').css('display', 'none');
@@ -26,15 +29,18 @@

      $('input:radio[name=helpfulness_rating]').change(function () {
        var value = $(this).val();
        $('.form-item-helpfulness-comments').show();
        $('.helpfulness_submit_button').show();
        if (value === '1') {
          $('.form-item-helpfulness-comments-yes').show();
          $('.form-item-helpfulness-comments-no').hide();
          $('.helpfulness_no_title').hide();
          $('.helpfulness_no_description').hide();
          $('.helpfulness_yes_title').show();
          $('.helpfulness_yes_description').show();
        }
        else {
          $('.form-item-helpfulness-comments-no').show();
          $('.form-item-helpfulness-comments-yes').hide();
          $('.helpfulness_yes_title').hide();
          $('.helpfulness_yes_description').hide();
          $('.helpfulness_no_title').show();
Loading