Skip to content

Commit

Permalink
Merge pull request #37 from sphereio/ISSUE-36-support-input-tip
Browse files Browse the repository at this point in the history
feat(attributes-definition): add support for input tips
  • Loading branch information
PhilippSpo committed Sep 13, 2016
2 parents c5a04cb + 65c2351 commit 8c974dc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
26 changes: 15 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@ language: node_js
node_js:
- '4'
before_script:
- npm install -g grunt-cli
- gem install cucumber aruba
- ./create_config.sh
- npm install -g grunt-cli
- gem install cucumber aruba
- ./create_config.sh
script:
- npm test
- cucumber -t ~@wip
- 'mkdir -p tmp && ./bin/product-type-generator --types data/sample-product-types.csv --attributes data/sample-product-types-attributes.csv --target ./tmp --zip'
- 'mkdir -p tmp && ./bin/product-type-generator --types data/marketplace-types.csv --attributes data/marketplace-attributes.csv --target ./tmp --withRetailer --zip'
- './bin/product-type-update --projectKey ${SPHERE_PROJECT_KEY} --clientId ${SPHERE_CLIENT_ID} --clientSecret ${SPHERE_CLIENT_SECRET} --source ./tmp'
- npm test
- cucumber -t ~@wip
- mkdir -p tmp && ./bin/product-type-generator --types data/sample-product-types.csv
--attributes data/sample-product-types-attributes.csv --target ./tmp --zip
- mkdir -p tmp && ./bin/product-type-generator --types data/marketplace-types.csv
--attributes data/marketplace-attributes.csv --target ./tmp --withRetailer --zip
- ./bin/product-type-update --projectKey ${SPHERE_PROJECT_KEY} --clientId ${SPHERE_CLIENT_ID}
--clientSecret ${SPHERE_CLIENT_SECRET} --source ./tmp
notifications:
hipchat:
rooms:
- secure: BbMUlILTPGhOX0ZBNqyCq0LpqwRNTOmuqv8gsg83LiDPy4SI/YsjAOQLlrbnoXLECAQMfRBwnED1XVJnskgJbj/VFL+q0hAa0GWfp8gLj7PAv40TYM7+pj6KDxJMWh3ZMWrQ2ixNRAjbuGnP2AfL0Gn6hj6NaxFwyIGQrb7sHKo=
- secure: BbMUlILTPGhOX0ZBNqyCq0LpqwRNTOmuqv8gsg83LiDPy4SI/YsjAOQLlrbnoXLECAQMfRBwnED1XVJnskgJbj/VFL+q0hAa0GWfp8gLj7PAv40TYM7+pj6KDxJMWh3ZMWrQ2ixNRAjbuGnP2AfL0Gn6hj6NaxFwyIGQrb7sHKo=
template:
- '%{repository}#%{build_number} (%{author}): %{message} (<a href="%{build_url}">Details</a>/<a href="%{compare_url}">Compare</a>)'
- '%{repository}#%{build_number} (%{author}): %{message} (<a href="%{build_url}">Details</a>/<a
href="%{compare_url}">Compare</a>)'
format: html
on_success: change
on_failure: change
env:
global:
- secure: iytO3AZ1pOvuZ8Mb6F6WqNjFnbxWw5yfadrnN5z43jK+23/YKS04bvcExJJ095L7t9IX9Jes2YfH1nbUm/f0oys3l1K40MDTDP7JvG39AfTHxLezUTrNKLryCI/FbuvIcA3BX1x2KH9FuRO1kmz5zaDQ0paNnn8z1MHU2PqizR0=
- secure: 04u05uQP06WQX0BvFY2RISY/9/Z63c+Tjono6Z4habOvLYtYsfE0rmxEcQkp3PGgRnWlDtYek/2S5XMKAG1Vlhlmv/kRpmp4h9t+SsPwLuYlUu8VI0/ADcOn9nLurFVc95jAtLjXSWTtwq5A92Lqj8Ujzpucr8m3pF9XWRnhLg0=
- secure: dF44muD7/0sSF6D0JV1KaVcgjPp/P/q8Yd2CzC/okP+xYNo5DcZhJGjNoPEtdOleE5/Osj+XWPQZfhQaWfoe1tptdXppEYJlkHvkHgJh7k3OIBKxCWr+1onssxkUIYuWZEKtwF4koxtoUNw1EFsHkfSOEWGpb644wL6aeddDv+k=
- secure: dF44muD7/0sSF6D0JV1KaVcgjPp/P/q8Yd2CzC/okP+xYNo5DcZhJGjNoPEtdOleE5/Osj+XWPQZfhQaWfoe1tptdXppEYJlkHvkHgJh7k3OIBKxCWr+1onssxkUIYuWZEKtwF4koxtoUNw1EFsHkfSOEWGpb644wL6aeddDv+k=
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"jszip": "2.5.x",
"optimist": "0.6.x",
"sphere-node-sdk": "1.3.x",
"sphere-node-utils": "0.7.0",
"sphere-node-utils": "0.8.1",
"sphere-product-type-import": "^1.1.0",
"underscore": "1.8.3",
"underscore.string": "3.1.x"
Expand Down
7 changes: 6 additions & 1 deletion src/coffee/product-type-generator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class ProductTypeGenerator
isRequired: row['isRequired'] is 'true'
isSearchable: row['isSearchable'] is 'true'

inputTip = @_i18n row, 'inputTip'
if _.keys(inputTip).length > 0
attributeDefinition.inputTip = inputTip

# store attribute definition using name as key for easy access
attributeDefinitions[attrName] = attributeDefinition
# store last processed attribute for further usage (reading next rows)
Expand Down Expand Up @@ -192,7 +196,8 @@ class ProductTypeGenerator
i18n = {}
languages = @_languages header, _.keys row
for language in languages
i18n[language] = row["#{header}.#{language}"].trim()
if row["#{header}.#{language}"].trim() isnt ''
i18n[language] = row["#{header}.#{language}"].trim()
i18n

###*
Expand Down
18 changes: 18 additions & 0 deletions src/spec/unit/product-type-generator.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ describe 'ProductTypeGenerator', ->

expect(@generator._i18n(attributeRow, 'label')).to.deep.equal {de: 'Geschlecht', en: 'gender'}

it 'should return an object with localized inputTip values', ->

attributeRow =
name: 'gender'
type: 'lenum'
attributeConstraint: 'None'
isRequired: 'false'
isSearchable: 'false'
'label.de': 'Geschlecht'
'label.en': 'gender'
'inputTip.de': 'tip de'
'inputTip.en': 'tip en'
enumKey: 'M'
'enumLabel.en': 'male'
'enumLabel.de': 'männlich'

expect(@generator._i18n(attributeRow, 'inputTip')).to.deep.equal {de: 'tip de', en: 'tip en'}


it 'should return an object with localized values using full locales and languages', ->

Expand Down

0 comments on commit 8c974dc

Please sign in to comment.