Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

Commit

Permalink
django-fy opportunity loading and simplify list.js
Browse files Browse the repository at this point in the history
  • Loading branch information
stvnrlly committed Jan 23, 2016
1 parent bdb0e71 commit e1cf22f
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 262 deletions.
125 changes: 0 additions & 125 deletions forecast-admin/forecast/opportunities/static/assets/js/main.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@

<div class="form-group-dropdown">
<label for="award_amount-dropdown">Award Amount</label>
<select name="award-amount-dropdown" id="award-amount-dropdown" ></select>
<select name="award_amount-dropdown" id="award_amount-dropdown" >
<option default value="all">All</option>
</select>
</div>

<div class="form-group-dropdown">
<label for="estimated_fiscal_year_quarter-dropdown">Projected Solicitation Quarter</label>
<select name="estimated_fiscal_year_quarter-dropdown" id="estimated_fiscal_year_quarter-dropdown" ></select>
<select name="estimated_fiscal_year_quarter-dropdown" id="estimated_fiscal_year_quarter-dropdown" >
<option default value="all">All</option>
</select>
</div>

<!-- The following link allows for showing additional filters -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{% for o in o %}
<li class="opportunity-row" id="opportunity-row">
<div>{{ o.fields.office.0 }}, {{ o.fields.office.1 }}</div>
<div>{{ o.fields.description }}</div>
<div class="office">{{ o.fields.office.0 }}, {{ o.fields.office.1 }}</div>
<div class="description">{{ o.fields.description }}</div>
<div class="details">
<div class="row">
<div class="usa-width-one-half">
<p><span class="detail-label">Award Status: </span>{{ o.fields.award_status }}</p>
<p><span class="detail-label">Place of Performance: </span>{{ o.fields.place_of_performance_city }}, {{ o.fields.place_of_performance_state }}</p>
<p><span class="detail-label">NAICS Code: </span>{{ o.fields.naics }}</p>
<p><span class="detail-label">Award Status: </span><span class="award_status">{{ o.fields.award_status }}</span></p>
<p><span class="detail-label">Place of Performance: </span>{{ o.fields.place_of_performance_city }}, <span class="place_of_performance_state">{{ o.fields.place_of_performance_state }}</span></p>
<p><span class="detail-label">NAICS Code: </span><span class="naics">{{ o.fields.naics }}</span></p>
</div>
<div class="usa-width-one-half">
<p><span class="detail-label">Estimated Award Date: </span>FY {{ o.fields.estimated_fiscal_year }} - Quarter {{ o.fields.estimated_fiscal_year_quarter }} </p>
<p><span class="detail-label">Category: </span> {{ o.fields.socioeconomic }} </p>
<p><span class="detail-label">Estimated Award Date: </span>FY {{ o.fields.estimated_fiscal_year }} - Quarter <span class="estimated_fiscal_year_quarter">{{ o.fields.estimated_fiscal_year_quarter }}</span></p>
<p><span class="detail-label">Category: </span> <span class="award_amount">{{ o.fields.socioeconomic }}</span></p>
<p><a href="/details/{{ o.pk }}" target="_blank">View Details </a></p>
</div>
</div>
Expand Down
57 changes: 54 additions & 3 deletions forecast-admin/forecast/opportunities/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,60 @@
<script src="{% static 'assets/js/vendor/underscore-min.js' %}"></script>
<script src="{% static 'assets/js/vendor/list.min.js' %}"></script>
<script type="text/javascript">


/**
*Initializes list.js
**/
var listOptions = {
valueNames: ['award_status', 'place_of_performance_state', 'naics', 'award_amount', 'estimated_fiscal_year_quarter']
};
var opportunitiesList = new List('opportunities', listOptions)
var data = {}

/**
*Initializes the More/Fewer Filters
**/
$("#award_amount-dropdown").parent().toggle();
$("#estimated_fiscal_year_quarter-dropdown").parent().toggle();
$("#more-filters").on('click', function(e){
$("#more-filters").text("Fewer Filters");
$("#award_amount-dropdown").parent().toggle();
$("#estimated_fiscal_year_quarter-dropdown").parent().toggle();
});

/**
* Load the Data into the Filters
**/
_.each(listOptions.valueNames, function (name) {

// Create an array for each filterable element
data[name] = [];
$('.'+name).each( function (index) {
data[name].push($(this).text());
})

// Find unique values and add them as options in dropdowns
var opt = _.uniq(data[name]);
$.each(opt, function(key, value) {
$('#' + name + '-dropdown')
.append($("<option></option>")
.attr("value",value)
.text(value));
});

// Add the filtering action to each dropdown
var dropdown = "#" + name + "-dropdown";
$(dropdown).change(function (){
opportunitiesList.filter(function(item) {
var value = $(dropdown).val();
if (value === "all") {
return true;
}
else {
return (item.values()[name] === value ? true : false);
}
})
})
})
</script>
<!-- <script src="{% static 'assets/js/main.js' %}"></script> -->

{% endblock %}
125 changes: 0 additions & 125 deletions forecast-admin/forecast/static/assets/js/main.js

This file was deleted.

0 comments on commit e1cf22f

Please sign in to comment.