- Codice internazionale numero + Country

This commit is contained in:
paoloar77
2021-12-21 01:27:45 +01:00
parent 3f8a2abd66
commit d6e571edbf
13 changed files with 237 additions and 179 deletions

58
src/server/models/pickup.js Executable file
View File

@@ -0,0 +1,58 @@
const shared_consts = require('../tools/shared_nodejs');
const tools = require('../tools/general');
const countryCodes = require('country-codes-list');
module.exports = {
async executeQueryTable(idapp, params) {
const table = params.table;
const strfind = params.search;
if (strfind === '') {
return [];
}
let myCountryArr = [];
let out = {};
if (table === shared_consts.TAB_COUNTRY) {
// '[{countryCode}] {countryNameLocal}: +{countryCallingCode}'
out = {
id: '{countryCode}',
value: '{countryNameLocal}',
flag: '{flag}',
};
} else if (table === shared_consts.TAB_PHONES) {
out = {
id: '{countryCode}',
value: '{countryNameLocal} +{countryCallingCode}',
code: '+{countryCallingCode}',
flag: '{flag}',
};
}
try {
// const myCountryArr = countryCodes.filter('countryNameLocal', strfind);
// const myCountryArr = countryCodes.customList.filter()
// myCountryArr = countryCodes.customList('countryCode', lavueout, { filter: ((countryData) => { return countryData['countryNameLocal'].toLocaleLowerCase().indexOf(strfind) >= 0 })} );
myCountryArr = countryCodes.customArray(out, {
filter: ((countryData) => {
return countryData['countryNameLocal'].toLocaleLowerCase().
startsWith(strfind) || countryData['countryNameEn'].toLocaleLowerCase().
startsWith(strfind);
}),
});
} catch (e) {
console.log('err', e);
}
return myCountryArr;
},
};