Skip to content

Commit

Permalink
Add autofill replies in tickets (#359)
Browse files Browse the repository at this point in the history
* add autofill replies in tickets

* change to select, add more replies

---------

Co-authored-by: winprn <[email protected]>
  • Loading branch information
winprn and winprn authored Dec 5, 2023
1 parent 938cbdf commit 5567fac
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
9 changes: 9 additions & 0 deletions resources/ticket.scss
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,12 @@ div.ticket-title {
.new-message .button, #edit-notes .submit {
margin: 10px 0 0 auto;
}

.auto-reply {
margin: 10px 0;
padding: 10px;
border: 1px $color_primary50 solid;
border-radius: 5px;
background: $color_primary10;
cursor: pointer;
}
42 changes: 42 additions & 0 deletions templates/ticket/ticket.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,42 @@
}
);
}

window.add_autofill_reply = function (message) {
$('#id_body').val(message);
}

$('.autofill-options').select2({
theme: '{{ DMOJ_SELECT2_THEME }}',
multiple: false,
closeOnSelect: true,
placeholder: '{{ _('Select reply') }}',
});

const selection = $('.autofill-options').data().select2.selection;
const results = $('.autofill-options').data().select2.results;

$('.autofill-options').on('select2:selecting', function(e) {
console.log(e);
});

window.get_options = function() {
const options = ["No coments", "Read the problem statement", "Yes", "No", "Question is unclear", "Read the global announcement"];
let reply_options = $('.autofill-options');
reply_options.empty();
options.forEach(function(option) {
reply_options.append($('<option>', {
value: option,
text: option
}));
});
}
window.get_options();

window.add_reply = function() {
const reply = $('.autofill-options').val();
add_autofill_reply(reply);
}
});
</script>

Expand Down Expand Up @@ -259,6 +295,12 @@
<button data-ajax="{{ url('ticket_open', ticket.id) }}" data-open="1" class="open-ticket"
{% if ticket.is_open %}style="display: none"{% endif %}>{{ _('Reopen ticket') }}</button>
</div>
<div>
<h4 style="margin-top: 1.2em;">Autofill</h4>
<select class="autofill-options" style="width: 100%;">
</select>
<button onclick="add_reply()">Add</button>
</div>
</aside>
</div>
{% endblock %}
Expand Down

0 comments on commit 5567fac

Please sign in to comment.