Add country select to customer in admin

master
Mark Moffat 2019-12-28 17:01:28 +10:30
parent 3092726cd5
commit 77c9cecaeb
4 changed files with 15 additions and 6 deletions

View File

@ -14,6 +14,12 @@ const mkdirp = require('mkdirp');
const ObjectId = require('mongodb').ObjectID; const ObjectId = require('mongodb').ObjectID;
const countryList = require('countries-list'); const countryList = require('countries-list');
// Parse country list once
const countryArray = [];
Object.keys(countryList.countries).forEach((country) => {
countryArray.push(countryList.countries[country].name);
});
// Allowed mime types for product images // Allowed mime types for product images
const allowedMimeType = [ const allowedMimeType = [
'image/jpeg', 'image/jpeg',
@ -564,10 +570,6 @@ const hooker = (order) => {
}; };
const getCountryList = () => { const getCountryList = () => {
const countryArray = [];
Object.keys(countryList.countries).forEach((country) => {
countryArray.push(countryList.countries[country].name);
});
return countryArray; return countryArray;
}; };

View File

@ -170,5 +170,6 @@
"Information": "Information", "Information": "Information",
"Shipping options": "Shipping options", "Shipping options": "Shipping options",
"Proceed to payment": "Proceed to payment", "Proceed to payment": "Proceed to payment",
"Return to information": "Return to information" "Return to information": "Return to information",
"Search shop": "Search shop"
} }

View File

@ -221,6 +221,7 @@ router.get('/admin/customer/view/:id?', restrict, async (req, res) => {
session: req.session, session: req.session,
message: common.clearSessionValue(req.session, 'message'), message: common.clearSessionValue(req.session, 'message'),
messageType: common.clearSessionValue(req.session, 'messageType'), messageType: common.clearSessionValue(req.session, 'messageType'),
countryList: common.getCountryList(),
config: req.app.config, config: req.app.config,
editor: true, editor: true,
helpers: req.handlebars.helpers helpers: req.handlebars.helpers

View File

@ -44,7 +44,12 @@
<div class="col-sm-10"> <div class="col-sm-10">
<div class="form-group"> <div class="form-group">
<label class="control-label">{{ @root.__ "Country" }} *</label> <label class="control-label">{{ @root.__ "Country" }} *</label>
<input type="text" class="form-control" name="country" id="country" value={{result.country}} required> <select class="form-control" id="country" name="country" required>
<option value="" disabled selected>Select Country</option>
{{#each countryList}}
<option {{selectState this @root.result.country}} value="{{this}}">{{this}}</option>
{{/each}}
</select>
</div> </div>
</div> </div>
<div class="col-sm-5"> <div class="col-sm-5">