Skip to content

Commit

Permalink
Merge pull request #5518 from thelostone-mc/explorer
Browse files Browse the repository at this point in the history
bug: fix bounty details update
  • Loading branch information
thelostone-mc authored Nov 20, 2019
2 parents fb0c23c + b256c82 commit d283816
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 163 deletions.
64 changes: 44 additions & 20 deletions app/assets/v2/js/pages/change_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
function trigger_form_hooks() {
}

$(document).ready(function() {
const oldBounty = document.result;
const keys = Object.keys(oldBounty);
const form = $('#submitBounty');

if (oldBounty.is_featured === true) {
$('#featuredBounty').prop('checked', true);
const populateFromAPI = bounty => {
bounty.is_featured ?
$('#featuredBounty').prop('checked', true) :
$('#featuredBounty').prop('disabled', true);
}

$.each(oldBounty, function(key, value) {
let ctrl = $('[name=' + key + ']', form);
$.each(bounty, function(key, value) {
let ctrl = $('[name=' + key + ']', $('#submitBounty'));

switch (ctrl.prop('type')) {
case 'radio':
$(`.${value}`).button('toggle');
break;

case 'checkbox':
ctrl.each(function() {
if (value.length) {
Expand All @@ -31,13 +27,41 @@ $(document).ready(function() {
}
});
break;

case 'select-one':
$('#' + key).val(value).trigger('change');
break;

default:
if (value > 0) {
ctrl.val(value);
}
}
});

if (bounty.keywords) {

let keywords = bounty['keywords'].split(',');

$('#keywords').select2({
placeholder: 'Select tags',
data: keywords,
tags: true,
allowClear: true,
tokenSeparators: [ ',', ' ' ]
}).trigger('change');

$('#keywords').val(keywords).trigger('change');
$('#keyword-suggestion-container').hide();
}
};

$(document).ready(function() {
const bounty = document.result;
const form = $('#submitBounty');

populateFromAPI(bounty);

$('.js-select2').each(function() {
$(this).select2({
minimumResultsForSearch: Infinity
Expand Down Expand Up @@ -67,17 +91,13 @@ $(document).ready(function() {
}
}).triggerHandler('change');

const reservedForHandle = oldBounty['reserved_for_user_handle'];
const reservedForHandle = bounty.reserved_for_user_handle;

userSearch(
'#reservedFor',
// show address
false,
// theme
'',
// initial data
reservedForHandle ? [reservedForHandle] : [],
// allowClear
'#reservedFor', // show address
false, // theme
'', // initial data
reservedForHandle ? [reservedForHandle] : [], // allowClear
true
);

Expand Down Expand Up @@ -192,7 +212,7 @@ $(document).ready(function() {
);
};

if (formData['is_featured'] && !oldBounty.is_featured) {
if (formData['is_featured'] && !bounty.is_featured) {
payFeaturedBounty();
} else {
saveBountyChanges();
Expand All @@ -214,6 +234,10 @@ $(document).ready(function() {
$('#invite-contributors.js-select2').data('select2').dataAdapter.select(processedData[0].children[$(this).data('id')]);
});

$('#keywords').select2({
tags: true
}).trigger('change');

const getSuggestions = () => {

const settings = {
Expand Down
4 changes: 2 additions & 2 deletions app/assets/v2/js/pages/new_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ $('#neverExpires').on('click', () => {

$('#submitBounty').validate({
errorPlacement: function(error, element) {
if (element.attr('name') == 'bounty_category') {
if (element.attr('name') == 'bounty_categories') {
error.appendTo($(element).parents('.btn-group-toggle').next('.cat-error'));
} else {
error.insertAfter(element);
Expand Down Expand Up @@ -618,7 +618,7 @@ $('#submitBounty').validate({
releaseAfter: releaseAfter !== 'Release To Public After' ? releaseAfter : '',
tokenName,
invite: inviteContributors,
bounty_categories: data.bounty_category
bounty_categories: data.bounty_categories
};

var privacy_preferences = {
Expand Down
80 changes: 15 additions & 65 deletions app/dashboard/templates/bounty/change.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,86 +36,35 @@
<div id="primary_form" class="col-lg-8 col-sm-12 my-5">
<form id="submitBounty" class="submit_bounty_form px-5 pt-5">
<h1 class="text-center title">{% trans "Change Bounty Details" %}</h1>

<div id="details-section" class="pt-2">
{% include 'shared/issue_details.html' %}
</div>

<div class="mt-4">
<label class="font-caption letter-spacing text-black-60 text-uppercase">{% trans "Details" %}</label>
<div class="d-flex row mb-2">
<div class="col-12 col-md-4">
<label class="form__label" for="experience_level">{% trans "Experience Level" %}</label>
<div class="form__select2">
<select class="js-select2" name="experience_level" id="experience_level">
<option disabled selected>{% trans "Experience Level" %}</option>
<option>{% trans "Beginner" %}</option>
<option>{% trans "Intermediate" %}</option>
<option>{% trans "Advanced" %}</option>
</select>
</div>
</div>
<div class="col-12 col-md-4">
<label class="form__label" for="project_length">{% trans "Time Commitment" %}</label>
<div class="form__select2">
<select class="js-select2" name="project_length" id="project_length">
<option disabled selected>{% trans "Time Commitment" %}</option>
<option>{% trans "Hours" %}</option>
<option>{% trans "Days" %}</option>
<option>{% trans "Weeks" %}</option>
<option>{% trans "Months" %}</option>
</select>
</div>
</div>
<div class="col-12 col-md-4">
<label class="form__label" for="bounty_type">{% trans "Bounty Type" %}</label>
<div class="form__select2">
<select class="js-select2" name="bounty_type" id="bounty_type">
<option disabled selected>{% trans "Bounty Type" %}</option>
<option>{% trans "Bug" %}</option>
<option>{% trans "Feature" %}</option>
<option>{% trans "Improvement" %}</option>
<option>{% trans "Security" %}</option>
<option>{% trans "Documentation" %}</option>
<option>{% trans "Design" %}</option>
<option>{% trans "Code Review" %}</option>
<option>{% trans "Other" %}</option>
</select>
</div>
</div>
</div>
{% include 'shared/bounty_details.html' %}
</div>
<div class="mt-4">
<label class="font-caption letter-spacing text-black-60 text-uppercase" for=issueURL>{% trans "Bounty category" %} <span class="badge badge-greylight text-capitalize">Required</span></label>
<p class="font-body">Pick the most accurate categories for this bounty to get the right contributors</p>

<div class="btn-group-toggle" data-toggle="buttons">
<label class="btn btn-radio frontend mr-2 font-weight-bold py-2 px-4" for="frontend_cat">
<input type="checkbox" name="bounty_categories" id="frontend_cat" value="frontend" autocomplete="off" required><i class="fas fa-laptop-code mr-2"></i> {% trans "Front End" %}
</label>
<label class="btn btn-radio backend mr-2 font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_categories" id="backend_cat" value="backend" autocomplete="off" required><i class="fas fa-code mr-2"></i> {% trans "Back End" %}
</label>
<label class="btn btn-radio design mr-2 font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_categories" id="design_cat" value="design" autocomplete="off" required><i class="fas fa-pencil-ruler mr-2"></i> {% trans "Design" %}
</label>
<label class="btn btn-radio doc mr-2 font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_categories" id="doc_cat" value="doc" autocomplete="off" required><i class="fas fa-file-alt mr-2"></i> {% trans "Documentation" %}
</label>
<label class="btn btn-radio other font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_categories" id="other_cat" value="other" autocomplete="off" required><i class="fas fa-briefcase mr-2"></i> {% trans "Other" %}
</label>
</div>
<div class="cat-error"></div>
<div class="mt-4">
{% include 'shared/bounty_categories.html' %}
</div>

<div class="mt-4">
{% include 'shared/bounty_keywords.html' %}
</div>

<div class="mt-4">
{% include 'shared/reserved.html' %}
</div>

<div class="m-4 pt-4">
{% include 'shared/featured.html' %}
</div>

<div class="row justify-content-center p-3">
<button class="btn btn-gc-blue btn-lg disabled js-submit mb-3 btn-lg-padding" type="submit">{% trans 'Update Issue Details' %}</button>
<button class="button button--primary btn-lg font-weight-semibold js-submit mb-3 btn-lg-padding" type="submit">{% trans 'Update Issue Details' %}</button>
</div>

</form>
</div>
</div>
Expand All @@ -127,7 +76,7 @@ <h1 class="text-center title">{% trans "Change Bounty Details" %}</h1>
{% include 'shared/analytics.html' %}
{% include 'shared/footer_scripts_lite.html' %}
{% include 'shared/footer.html' %}

{% include 'shared/current_profile.html' %}
</body>
<script>
Expand All @@ -138,5 +87,6 @@ <h1 class="text-center title">{% trans "Change Bounty Details" %}</h1>
<script src="{% static "v2/js/shared.js" %}"></script>
<script src="{% static "v2/js/amounts.js" %}"></script>
<script src="{% static "v2/js/user-search.js" %}"></script>
<script src="{% static "v2/js/lib/purify.min.js" %}"></script>
<script src="{% static "v2/js/pages/change_bounty.js" %}"></script>
</html>
82 changes: 8 additions & 74 deletions app/dashboard/templates/bounty/fund.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,87 +116,21 @@ <h5 class="font-smaller-3 font-weight-bold mb-2">Important Notes on Private Repo
<input name='issueNDA' id="issueNDA" class="form__input" type="file" accept="application/pdf,application/msword, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.presentationml.presentation" required/>
</div>
</div>

{% include 'shared/pricing.html' %}

<div class="mt-4">
<label class="font-caption letter-spacing text-black-60 text-uppercase">{% trans "Details" %}</label>
<div class="d-flex row mb-2">
<div class="col-12 col-md-4">
<label class="form__label" for="experience_level">{% trans "Experience Level" %}</label>
<div class="form__select2">
<select class="js-select2" name="experience_level">
<option disabled selected>{% trans "Experience Level" %}</option>
<option>{% trans "Beginner" %}</option>
<option>{% trans "Intermediate" %}</option>
<option>{% trans "Advanced" %}</option>
</select>
</div>
</div>
<div class="col-12 col-md-4">
<label class="form__label" for="project_length">{% trans "Time Commitment" %}</label>
<div class="form__select2">
<select class="js-select2" name="project_length">
<option disabled selected>{% trans "Time Commitment" %}</option>
<option>{% trans "Hours" %}</option>
<option>{% trans "Days" %}</option>
<option>{% trans "Weeks" %}</option>
<option>{% trans "Months" %}</option>
</select>
</div>
</div>
<div class="col-12 col-md-4">
<label class="form__label" for="bounty_type">{% trans "Bounty Type" %}</label>
<div class="form__select2">
<select class="js-select2" name="bounty_type">
<option disabled selected>{% trans "Bounty Type" %}</option>
<option>{% trans "Bug" %}</option>
<option>{% trans "Feature" %}</option>
<option>{% trans "Improvement" %}</option>
<option>{% trans "Security" %}</option>
<option>{% trans "Documentation" %}</option>
<option>{% trans "Design" %}</option>
<option>{% trans "Code Review" %}</option>
<option>{% trans "Other" %}</option>
</select>
</div>
</div>
</div>
{% include 'shared/bounty_details.html' %}
</div>
<div class="mt-4">
<label class="font-caption letter-spacing text-black-60 text-uppercase" for=issueURL>{% trans "Bounty category" %} <span class="badge badge-greylight text-capitalize">Required</span></label>
<p class="font-body">Pick the most accurate categories for this bounty to get the right contributors</p>

<div class="btn-group-toggle" data-toggle="buttons">
<label class="btn btn-radio frontend mr-2 font-weight-bold py-2 px-4" for="frontend_cat">
<input type="checkbox" name="bounty_category" id="frontend_cat" value="frontend" autocomplete="off" required><i class="fas fa-laptop-code mr-2"></i> {% trans "Front End" %}
</label>
<label class="btn btn-radio backend mr-2 font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_category" id="backend_cat" value="backend" autocomplete="off" required><i class="fas fa-code mr-2"></i> {% trans "Back End" %}
</label>
<label class="btn btn-radio design mr-2 font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_category" id="design_cat" value="design" autocomplete="off" required><i class="fas fa-pencil-ruler mr-2"></i> {% trans "Design" %}
</label>
<label class="btn btn-radio doc mr-2 font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_category" id="doc_cat" value="doc" autocomplete="off" required><i class="fas fa-file-alt mr-2"></i> {% trans "Documentation" %}
</label>
<label class="btn btn-radio other font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_category" id="other_cat" value="other" autocomplete="off" required><i class="fas fa-briefcase mr-2"></i> {% trans "Other" %}
</label>
</div>
<div class="cat-error"></div>

<div class="mt-4">
{% include 'shared/bounty_categories.html' %}
</div>

<div class="mt-4">
<label class="font-caption letter-spacing text-black-60 text-uppercase" for="keywords">{% trans "Keywords" %} <span class="badge badge-greylight text-capitalize">Required</span></label>
<p class="font-body">Insert keywords relevant to your issue to make it easily discoverable by contributors </p>
<div class="form__select2 g-multiselect flex-column">
<select class="js-select2" id="keywords" name="keywords" multiple required>
</select>
</div>
<div id="keyword-suggestion-container" class="font-caption font-weight-semibold mt-1">
<span>Add tags from your repo: </span>
<div id="keyword-suggestions"></div>
</div>
{% include 'shared/bounty_keywords.html' %}
</div>

</div>

<div class="bg-white my-3 px-5 rounded">
Expand Down
39 changes: 39 additions & 0 deletions app/dashboard/templates/shared/bounty_categories.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% comment %}
Copyright (C) 2018 Gitcoin Core

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}
{% load i18n static %}

<label class="font-caption letter-spacing text-black-60 text-uppercase" for=issueURL>{% trans "Bounty category" %} <span class="badge badge-greylight text-capitalize">Required</span></label>
<p class="font-body">Pick the most accurate categories for this bounty to get the right contributors</p>

<div class="btn-group-toggle" data-toggle="buttons">
<label class="btn btn-radio frontend mr-2 font-weight-bold py-2 px-4" for="frontend_cat">
<input type="checkbox" name="bounty_categories" id="frontend_cat" value="frontend" autocomplete="off" required><i class="fas fa-laptop-code mr-2"></i> {% trans "Front End" %}
</label>
<label class="btn btn-radio backend mr-2 font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_categories" id="backend_cat" value="backend" autocomplete="off" required><i class="fas fa-code mr-2"></i> {% trans "Back End" %}
</label>
<label class="btn btn-radio design mr-2 font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_categories" id="design_cat" value="design" autocomplete="off" required><i class="fas fa-pencil-ruler mr-2"></i> {% trans "Design" %}
</label>
<label class="btn btn-radio doc mr-2 font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_categories" id="doc_cat" value="documentation" autocomplete="off" required><i class="fas fa-file-alt mr-2"></i> {% trans "Documentation" %}
</label>
<label class="btn btn-radio other font-weight-bold py-2 px-4 ">
<input type="checkbox" name="bounty_categories" id="other_cat" value="other" autocomplete="off" required><i class="fas fa-briefcase mr-2"></i> {% trans "Other" %}
</label>
</div>
<div class="cat-error"></div>
Loading

0 comments on commit d283816

Please sign in to comment.