diff --git a/app/assets/v2/js/grants/detail.js b/app/assets/v2/js/grants/detail.js index 5f5dc720ae5..b98d4160e68 100644 --- a/app/assets/v2/js/grants/detail.js +++ b/app/assets/v2/js/grants/detail.js @@ -17,7 +17,7 @@ $(document).ready(function() { $('#grant_contract_owner_address').text(), '#cancel_grant', 'Looks like your grant has been created with ' + - $('#grant_contract_owner_address').text() + '. Switch to take action on your grant.' + $('#grant_contract_owner_address').text() + '. Switch to take action on your grant.' ); if ($('#cancel_grant').attr('disabled')) { @@ -43,6 +43,8 @@ $(document).ready(function() { } }, 1000); + let _text = grant_description.getContents(); + userSearch('#grant-admin', false, undefined, false, false, true); userSearch('#grant-members', false, undefined, false, false, true); $('.select2-selection__rendered').removeAttr('title'); @@ -52,11 +54,10 @@ $(document).ready(function() { $('#edit-details').on('click', (event) => { event.preventDefault(); - if (grant_description !== undefined) { + if (grant_description) { grant_description.enable(true); grant_description.getContents(); } - $('#edit-details').addClass('hidden'); $('#save-details').removeClass('hidden'); $('#cancel-details').removeClass('hidden'); @@ -69,9 +70,14 @@ $(document).ready(function() { editableFields.forEach(field => { makeEditable(field); }); + }); - $('#save-details').on('click', event => { + $('#save-details').on('click', (event) => { + if (grant_description) { + grant_description.enable(false); + } + $('#edit-details').removeClass('hidden'); $('#save-details').addClass('hidden'); $('#cancel-details').addClass('hidden'); @@ -81,32 +87,23 @@ $(document).ready(function() { let edit_title = $('#form--input__title').val(); let edit_reference_url = $('#form--input__reference-url').val(); let edit_admin_profile = $('#grant-admin option').last().text(); + let edit_description = grant_description.getText(); + let edit_description_rich = JSON.stringify(grant_description.getContents()); let edit_amount_goal = $('#amount_goal').val(); let edit_grant_members = $('#grant-members').val(); - let data = { - 'edit-title': edit_title, - 'edit-reference_url': edit_reference_url, - 'edit-admin_profile': edit_admin_profile, - 'edit-amount_goal': edit_amount_goal, - 'edit-grant_members[]': edit_grant_members - }; - - if (grant_description !== undefined) { - const edit_description = grant_description.getText(); - const edit_description_rich = JSON.stringify(grant_description.getContents()); - - grant_description.enable(false); - data = Object.assign({}, data, { - 'edit-description': edit_description, - 'edit-description_rich': edit_description_rich - }); - } - $.ajax({ type: 'post', url: '', - data, + data: { + 'edit-title': edit_title, + 'edit-reference_url': edit_reference_url, + 'edit-admin_profile': edit_admin_profile, + 'edit-description': edit_description, + 'edit-description_rich': edit_description_rich, + 'edit-amount_goal': edit_amount_goal, + 'edit-grant_members[]': edit_grant_members + }, success: function(json) { window.location.reload(false); }, @@ -118,10 +115,10 @@ $(document).ready(function() { editableFields.forEach(field => disableEdit(field)); }); - $('#cancel-details').on('click', event => { - if (grant_description !== undefined) { + $('#cancel-details').on('click', (event) => { + if (grant_description) { grant_description.enable(false); - grant_description.setContents(grant_description.getContents()); + grant_description.setContents(_text); } $('#edit-details').removeClass('hidden'); $('#save-details').addClass('hidden'); @@ -132,6 +129,7 @@ $(document).ready(function() { }); $('#cancel_grant').on('click', function(e) { + $('.modal-cancel-grants').on('click', function(e) { let contract_address = $('#contract_address').val(); let grant_cancel_tx_id; @@ -208,9 +206,6 @@ $(document).ready(function() { }); }); - $('#grant-profile-tabs button').click(function() { - document.location = $(this).attr('href'); - }); }); const makeEditable = (input) => { @@ -254,3 +249,9 @@ const copyDuplicateDetails = () => { }); }); }; + +$(document).ready(() => { + $('#grant-profile-tabs button').click(function() { + document.location = $(this).attr('href'); + }); +}); \ No newline at end of file diff --git a/app/grants/templates/grants/detail/tabs.html b/app/grants/templates/grants/detail/tabs.html index 95fca6e50c3..15d05a68c59 100644 --- a/app/grants/templates/grants/detail/tabs.html +++ b/app/grants/templates/grants/detail/tabs.html @@ -17,7 +17,7 @@ {% load static humanize i18n grants_extra %}
- + @@ -32,12 +32,12 @@ - + - +
@@ -91,30 +91,26 @@

{% trans "No Activity for th

{% endif %} + + let grant_description; + {% if is_admin and not grant_is_inactive %} + grant_description = new Quill('#editor', { + theme: 'snow', + }); + grant_description.enable(false); + {% else %} + grant_description = new Quill('#editor', { + theme: 'bubble', + readOnly: true, + }); + {% endif %} + + let desc = JSON.parse(grant_description.getContents().ops[0].insert); + if (desc.ops) { + grant_description.setContents(desc); + } + \ No newline at end of file diff --git a/app/grants/views.py b/app/grants/views.py index 0a840578624..ca0f58ca63d 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -180,13 +180,12 @@ def grant_details(request, grant_id, grant_slug): grant.reference_url = request.POST.get('edit-reference_url') form_profile = request.POST.get('edit-admin_profile') admin_profile = Profile.objects.get(handle=form_profile) + grant.description = request.POST.get('edit-description') + grant.description_rich = request.POST.get('edit-description_rich') grant.amount_goal = Decimal(request.POST.get('edit-amount_goal')) team_members = request.POST.getlist('edit-grant_members[]') team_members.append(str(admin_profile.id)) grant.team_members.set(team_members) - if 'edit-description' in request.POST: - grant.description = request.POST.get('edit-description') - grant.description_rich = request.POST.get('edit-description_rich') if grant.admin_profile != admin_profile: grant.request_ownership_change = admin_profile change_grant_owner_request(grant, grant.request_ownership_change)