Skip to content

Commit

Permalink
feat: add EU option to importer/exporter WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
WillKocur committed Oct 13, 2022
1 parent 8db896e commit 795a144
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/assets/javascripts/cites_trade/application.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//TODO: align with backend
const EU_OPTION = {
geo_entity_type: 'REGION',
id: 1001,
iso_code2: 'EU',
name: 'European Union'
}

$(document).ready(function(){

var ajaxFail, initExpctyImpcty, initTerms, initSources, initPurposes,
Expand Down Expand Up @@ -104,6 +112,14 @@ $(document).ready(function(){

function getParamsFromInputs(){
var values = parseInputs($('#form_expert :input'));

// TODO: add required logic here
['exporters_ids', 'importers_ids'].forEach(function (key) {
if (values[key].indexOf(EU_OPTION.id.toString()) > 0) {
console.log('Getting params: ' + key + ' contains EU.')
}
})

return $.param({'filters': values});
}

Expand Down Expand Up @@ -257,6 +273,8 @@ $(document).ready(function(){
}

initExpctyImpcty = function (data) {
data.geo_entities.push(EU_OPTION)
// TODO: Sort if required
var args = {
data: data.geo_entities,
condition: function (item) {return item.iso_code2},
Expand Down

0 comments on commit 795a144

Please sign in to comment.