Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/113/do-not-ad…
Browse files Browse the repository at this point in the history
…d-spp-suffix-to-hybrids
  • Loading branch information
lucacug committed Oct 6, 2023
2 parents 503fe1c + 1c31f5d commit 8f1e6d0
Show file tree
Hide file tree
Showing 24 changed files with 576 additions and 39 deletions.
3 changes: 3 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
= Species+

NOTE: There is a separate {public API application}[https://github.com/unepwcmc/species-api] for Species+

{<img src="https://secure.travis-ci.org/unepwcmc/SAPI.png" />}[http://travis-ci.org/unepwcmc/SAPI]
{<img src="https://codeclimate.com/github/unepwcmc/SAPI.png" />}[https://codeclimate.com/github/unepwcmc/SAPI]
{<img src="https://coveralls.io/repos/unepwcmc/SAPI/badge.png?branch=master" alt="Coverage Status" />}[https://coveralls.io/r/unepwcmc/SAPI?branch=master]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Species.DownloadsController = Ember.Controller.extend Species.Spinner,
needs: [
'downloadsForCmsListings',
'downloadsForCitesListings', 'downloadsForCitesRestrictions',
'downloadsForCitesListings', 'downloadsForCitesRestrictions', 'downloadsForCitesProcesses',
'downloadsForEuListings', 'downloadsForEuDecisions'
]
downloadsPopupVisible: false
Expand All @@ -23,6 +23,9 @@ Species.DownloadsController = Ember.Controller.extend Species.Spinner,
legislationIsCitesRestrictions: ( ->
@get('citesLegislation') == 'restrictions'
).property('citesLegislation')
legislationIsCitesProcesses: ( ->
@get('citesLegislation') == 'processes'
).property('citesLegislation')
legislationIsEuListings: ( ->
@get('euLegislation') == 'listings'
).property('euLegislation')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Species.DownloadsForCitesListingsController = Ember.Controller.extend
}
).filter((e) ->
e.taxonConcepts.length > 0
)
)
else
@get('higherTaxaController.contentByRank')
).property('higherTaxaController.contentByRank.@each', 'taxonConceptQuery')
Expand Down Expand Up @@ -103,4 +103,4 @@ Species.DownloadsForCitesListingsController = Ember.Controller.extend
@set('selectedTaxonConcepts', [])

deleteGeoEntitySelection: (context) ->
@get('selectedGeoEntities').removeObject(context)
@get('selectedGeoEntities').removeObject(context)
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
Species.DownloadsForCitesProcessesController = Ember.Controller.extend
designation: 'cites'

needs: ['geoEntities','higherTaxaCitesEu', 'downloads']

higherTaxaController: ( ->
@get('controllers.higherTaxaCitesEu')
).property()

geoEntityQuery: null
taxonConceptQuery: null
selectedGeoEntities: []
selectedTaxonConcepts: []
timeScope: 'current'
timeScopeIsCurrent: ( ->
@get('timeScope') == 'current'
).property('timeScope')
years: [1975..new Date().getFullYear()]
selectedYears: []
processType: 'Both'
documentTypeIsCitesSuspensions: ( ->
@get('documentType') == 'CitesSuspensions'
).property('documentType')

autoCompleteTaxonConcepts: ( ->
if @get('taxonConceptQuery') && @get('taxonConceptQuery').length > 0
re = new RegExp("^"+@get('taxonConceptQuery'),"i")
@get('higherTaxaController.contentByRank')
.map((e) =>
{
rankName: e.rankName
taxonConcepts: e.taxonConcepts.filter((item) =>
re.test item.get('fullName')
)
}
).filter((e) ->
e.taxonConcepts.length > 0
)
else
@get('higherTaxaController.contentByRank')
).property('higherTaxaController.contentByRank.@each', 'taxonConceptQuery')

autoCompleteRegions: ( ->
if @get('geoEntityQuery') && @get('geoEntityQuery').length > 0
re = new RegExp("(^|\\(| )"+@get('geoEntityQuery'),"i")
@get('controllers.geoEntities.regions')
.filter (item, index, enumerable) =>
re.test item.get('name')
else
@get('controllers.geoEntities.regions')
).property('controllers.geoEntities.regions.@each', 'geoEntityQuery')

autoCompleteCountries: ( ->
if @get('geoEntityQuery') && @get('geoEntityQuery').length > 0
re = new RegExp("(^|\\(| )"+@get('geoEntityQuery'),"i")
@get('controllers.geoEntities.countries')
.filter (item, index, enumerable) =>
re.test item.get('name')
else
@get('controllers.geoEntities.countries')
).property('controllers.geoEntities.countries.@each', 'geoEntityQuery')

selectedGeoEntitiesIds: ( ->
@get('selectedGeoEntities').mapProperty('id')
).property('selectedGeoEntities.@each')

selectedTaxonConceptsIds: ( ->
@get('selectedTaxonConcepts').mapProperty('id')
).property('selectedTaxonConcepts.@each')

toParams: ( ->
{
data_type: 'Processes'
filters:
process_type: @get('processType')
designation: @get('designation')
geo_entities_ids: @get('selectedGeoEntitiesIds')
taxon_concepts_ids: @get('selectedTaxonConceptsIds')
set: @get('timeScope')
years: @get('selectedYears')
csv_separator: @get('controllers.downloads.csvSeparator')
}
).property(
'selectedGeoEntitiesIds.@each', 'selectedTaxonConceptsIds.@each',
'timeScope', 'selectedYears.@each', 'processType', 'controllers.downloads.csvSeparator'
)

downloadUrl: ( ->
'/species/exports/download?' + $.param(@get('toParams'))
).property('toParams')

actions:
startDownload: () ->
@set('downloadInProgress', true)
@set('downloadMessage', 'Downloading...')
$.ajax({
type: 'GET'
dataType: 'json'
url: @get('downloadUrl')
}).done((data) =>
@set('downloadInProgress', false)
if data.total > 0
@set('downloadMessage', null)
ga('send', {
hitType: 'event',
eventCategory: 'Downloads: ' + @get('processType'),
eventAction: 'Format: CSV',
eventLabel: @get('controllers.downloads.csvSeparator')
})
window.location = @get('downloadUrl')
return
else
@set('downloadMessage', 'No results')
)

deleteTaxonConceptSelection: (context) ->
@set('selectedTaxonConcepts', [])

deleteGeoEntitySelection: (context) ->
@get('selectedGeoEntities').removeObject(context)

deleteYearSelection: (context) ->
@get('selectedYears').removeObject(Number(context))
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Species.ElibrarySearchController = Ember.Controller.extend Species.Spinner,
allDocumentTypes = @get('controllers.events.documentTypes')
.concat @get('controllers.events.interSessionalDocumentTypes')
.concat @get('controllers.events.identificationDocumentTypes')

if @get('isSignedIn')
allDocumentTypes = allDocumentTypes.concat(@get('controllers.events.interSessionalNonPublicDocumentTypes'))
@set('selectedDocumentType', allDocumentTypes.findBy('id', filtersHash.document_type))

general_subtype_type = @get_general_subtype_type(filtersHash)
Expand Down Expand Up @@ -71,10 +72,10 @@ Species.ElibrarySearchController = Ember.Controller.extend Species.Spinner,
general_subtype: isGeneralSubType
}

getDocTypeParam: ->
getDocTypeParam: ->
id = @get('selectedDocumentType.id')

if id != '__all__' then id else null
if id != '__all__' then id else null

filteredDocumentTypes: ( ->
if @get('selectedEventType')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
LISTINGS
{{/view}}
</li>
<li class="last-child">
<li>
{{#view Species.ToggleButton option="restrictions" valueBinding="controller.citesLegislation"}}
QUOTAS/SUSPENSIONS
{{/view}}
</li>
<li class="last-child">
{{#view Species.ToggleButton option="processes" valueBinding="controller.citesLegislation"}}
Processes
{{/view}}
</li>
</ul>
{{#view Species.DownloadsForLegislation
isVisibleBinding="controller.legislationIsCitesListings"
Expand Down Expand Up @@ -136,3 +141,84 @@
</div>
</div>
{{/view}}
{{#view Species.DownloadsForLegislation
isVisibleBinding="controller.legislationIsCitesProcesses"
controllerBinding="controllers.downloadsForCitesProcesses"
}}
<div class="process-type">
<div class="typy-columns">
<div class="col">
<label>
{{view Ember.RadioButton name="process_type" selectionBinding="processType" value="Rst"}}
RST
</label>
</div>
<div class="col-wide">
<label>
{{view Ember.RadioButton name="process_type" selectionBinding="processType" value="CaptiveBreeding"}}
Captive Breeding
</label>
</div>
<div class="col">
<label>
{{view Ember.RadioButton name="process_type" selectionBinding="processType" value="Both"}}
Both
</label>
</div>
</div>
</div>
<div class="info-columns more">
<div class="col">
<ul class="tab-link">
<li>
{{#view Species.ToggleButton option="current" valueBinding="controller.timeScope"}}
CURRENT
{{/view}}
</li>
<li class="last-child">
{{#view Species.ToggleButton option="all" valueBinding="controller.timeScope"}}
ALL
{{/view}}
</li>
</ul>
</div>
<div class="col">
{{#if timeScopeIsCurrent}}
Only current data has<br />been selected.
{{else}}
{{#unless documentTypeIsCitesSuspensions}}
<div class="popup-area">
{{view Species.YearSearchButton selectedYearsBinding="controller.selectedYears"}}
{{view Species.YearSearchDropdown controllerBinding="controller"}}
</div>
{{/unless}}
{{/if}}
</div>
</div>
<div class="bottom-columns">
<div class="col">
<div class="popup-area">
{{view Species.HigherTaxaSearchButton controllerBinding="controller"}}
{{view Species.HigherTaxaSearchDropdown controllerBinding="controller"}}
</div>
</div>
<div class="col">
<div class="popup-area">
{{view Species.GeoEntitiesSearchButton
selectedGeoEntitiesBinding="controller.selectedGeoEntities"
loadedBinding="controller.loaded"
}}
{{view Species.GeoEntitiesSearchDropdown controllerBinding="controller"}}
</div>
</div>
</div>
<div class="btn-holder">
{{view Species.StartDownloadButton controllerBinding="controller"}}
<div class="message-area">
{{#if controller.downloadInProgress}}
<img src="/loading.gif">
{{/if}}
{{controller.downloadMessage}}
</div>
</div>
{{/view}}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{/if}}
<div class="heading-holder">
<h1>{{fullName}}</h1>
<h2>{{authorYear}}</h2>
<h2 class="authors">{{authorYear}}</h2>
<ul class="list">
<li>
<a {{action 'openSearchPage' phylumName}} class="hover-pointer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
<a class="legal-links" href="https://speciesplus.net/api/v1/documents/{{unbound decision.intersessional_decision_id}}">
Intersessional decision
</a>
{{else}}
{{#unless decision.start_event.name }}
Intersessional decision
{{/unless}}
{{/if}}
{{#if decision.private_url}}
<a class="legal-links" href="{{unbound decision.private_url}}">
Expand Down Expand Up @@ -164,6 +168,10 @@
<a class="legal-links" href="https://speciesplus.net/api/v1/documents/{{unbound decision.intersessional_decision_id}}">
Intersessional decision
</a>
{{else}}
{{#unless decision.start_event.name }}
Intersessional decision
{{/unless}}
{{/if}}
{{#if decision.private_url}}
<a class="legal-links" href="{{unbound decision.private_url}}">
Expand Down
27 changes: 27 additions & 0 deletions app/assets/stylesheets/species/all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,30 @@ body.inner #footer .holder{
width: 140px;
}
.doc-type .typy-columns .col .row { margin: 0 0 5px }

//
.process-type {
overflow: hidden;
padding: 16px 0 13px 20px;
}
.process-type .heading {
color: $color-navy-dark;
font-weight: bold;
display: block;
margin: 0 0 4px;
text-transform: uppercase;
}
.process-type .heading.more { margin: 0 0 4px 11px; }
.process-type .typy-columns { overflow: hidden; }
.process-type .typy-columns .col {
float: left;
width: 25%;
}
.process-type .typy-columns .col-wide {
float: left;
width: 50%;
}

.info-columns {
width: 100%;
padding: 20px 0 16px;
Expand Down Expand Up @@ -809,6 +833,9 @@ body.inner #footer .holder{
word-spacing: -3px;
text-align: left;
}
.heading-holder .authors {
line-height: 30px;
}
.heading-holder .species-name {
word-spacing: 0;
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/taxon_listing_changes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def load_change_types
find_by_name(ChangeType::EXCEPTION)
@species_listings = @designation.species_listings.order(:abbreviation)
@geo_entities = GeoEntity.order(:name_en).joins(:geo_entity_type).
where(:is_current => true, :geo_entity_types => { :name => 'COUNTRY' })
where(:is_current => true, :geo_entity_types => { :name => ['COUNTRY', 'REGION'] })
@hash_annotations =
if @designation.is_eu?
Annotation.for_eu
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/species/exports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def download
result = Species::ListingsExportFactory.new(@filters).export
when 'EuDecisions'
result = Species::EuDecisionsExport.new(@filters).export
when 'Processes'
result = Species::CitesProcessesExport.new(@filters).export
end
respond_to do |format|
format.html {
Expand Down
Loading

0 comments on commit 8f1e6d0

Please sign in to comment.