Skip to content

Commit

Permalink
style: Format project with prettier for json, yaml and markdown.
Browse files Browse the repository at this point in the history
Apply the prettier pre-commit hook for all json, yaml and markdown files. More file formats are available and can be used as needed.
  • Loading branch information
MichaelsJP authored and TheGreatRefrigerator committed Dec 9, 2022
1 parent f3aa047 commit 456db08
Show file tree
Hide file tree
Showing 13 changed files with 9,440 additions and 8,005 deletions.
33 changes: 21 additions & 12 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
{
"presets": [
["@babel/preset-env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
[
"@babel/preset-env",
{
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
},
"stage-2"
]
],
"plugins": [
[
"transform-imports",
{
"vuetify": {
"transform": "vuetify/es5/components/${member}",
"preventFullImport": true
}
}
}, "stage-2"]
],
["@babel/plugin-proposal-class-properties"]
],
"plugins": [["transform-imports", {
"vuetify": {
"transform": "vuetify/es5/components/${member}",
"preventFullImport": true
}
}],
["@babel/plugin-proposal-class-properties"]],
"env": {
"test": {
"presets": ["@babel/preset-env"],
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ on:
- master
- main
pull_request:
branches: [ "**" ]
branches: ["**"]
jobs:
Run-lint:
strategy:
fail-fast: true # Good to fail all fast if one of the matrix runs fails.
matrix:
node-version: [ 16 ]
python-version: [ "3.10" ]
os: [ ubuntu-20.04 ]
node-version: [16]
python-version: ["3.10"]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- name: checkout
Expand Down
744 changes: 269 additions & 475 deletions CHANGELOG.md

Large diffs are not rendered by default.

176 changes: 91 additions & 85 deletions README.md

Large diffs are not rendered by default.

170 changes: 90 additions & 80 deletions docs/dynamic-inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The supported field types are the ones listed under `constants.filterTypes`. The
- `wrapper` - renders a visual element that wrappers other child fields
- `array` - renders a select or multi-select field
- `string` - used in combination with `isEnum` (boolean) and/or `items` (array) and renders a select or multi-select field
- `steps` - renders a slider field
- `steps` - renders a slider field
- `random` - renders a custom field that allow users to set a random value to a filter/parameter
- `text` - renders a text input (type text or number)
- `boolean` - renders a checkbox
Expand Down Expand Up @@ -50,84 +50,94 @@ The code below shows all the possible properties of a field, but they are not al
Some are only for certain types of fields.

```js
field = {
name: String,
internalName: String, // as `name` must be unique in the scope of the file and the API has support for some parameters that expect different data types depending on the value of another parameter, different types of fields must be rendered depending on the filters' value. In this case, multiple fields declared would have the same name, but with distinct rules. Therefore, `internalName` will contain the name of the parameter expected by the API. For example: `interval` accepts a time or a distance interval and fields with different UIs must be rendered for time or distance fields. But, both of them (that will never be rendered at the same time) will end up by generating a API parameter named `interval` and containing the value of `distance_interval` or `time_interval`.
useInServices: List[String], // each item must be a constant present in `constants.services.*`
hidden: Boolean, // If the field must not be automatically rendered, but instead rendered with a custom code using a type of element not supported by the engine. One example is the `profile` or avoid_polygons filters/parameters.
required: Boolean,
type: String, // the type must be a constant present in `constants.filterTypes.*` and determines the type of HTML element displayed
enum: Array, // list of options of a field
mapping: { // Object // with the following structure:
'map-key': // String, usually the same of the slug, like 'cycling-regular'
{
slug: String, // semantic unique identifier,
icon: String, // a valid material design icon string,
nestedProfiles: List[String], // possibilities: 'cycling-regular', 'cycling-road', 'cycling-electric' and 'cycling-mountain'
supportsTrailDifficulty: Boolean
}
field = {
name: String,
internalName: String, // as `name` must be unique in the scope of the file and the API has support for some parameters that expect different data types depending on the value of another parameter, different types of fields must be rendered depending on the filters' value. In this case, multiple fields declared would have the same name, but with distinct rules. Therefore, `internalName` will contain the name of the parameter expected by the API. For example: `interval` accepts a time or a distance interval and fields with different UIs must be rendered for time or distance fields. But, both of them (that will never be rendered at the same time) will end up by generating a API parameter named `interval` and containing the value of `distance_interval` or `time_interval`.
useInServices: List[String], // each item must be a constant present in `constants.services.*`
hidden: Boolean, // If the field must not be automatically rendered, but instead rendered with a custom code using a type of element not supported by the engine. One example is the `profile` or avoid_polygons filters/parameters.
required: Boolean,
type: String, // the type must be a constant present in `constants.filterTypes.*` and determines the type of HTML element displayed
enum: Array, // list of options of a field
mapping: {
// Object // with the following structure:
// String, usually the same of the slug, like 'cycling-regular'
"map-key": {
slug: String, // semantic unique identifier,
icon: String, // a valid material design icon string,
nestedProfiles: List[String], // possibilities: 'cycling-regular', 'cycling-road', 'cycling-electric' and 'cycling-mountain'
supportsTrailDifficulty: Boolean,
},
availableOnModes: List[String], // each item must be a constant present in `constants.modes.*`
isEnum: Boolean, // determines if the field is a list of values that should be presented as a select-like input,
separator: String, // determines how the options selected must be concatenated when the expected API parameter expects a single value (a string with a separator)
default: Any, // the default value of the field - it can be a string, a boolean, a Number, array or object. The default value will be added to the request even if the field value is empty.
value: "*", // the value of the field - it can be a string, a boolean, a Number, array or object.
unit: String, // the unit label that must be presented on the side of a field, like 'kmh', 'min', 'km',
min: Number, // min value of number field
max: Number, // max value of number field
multiplyValueBy: Number, // some fields expect a value that when expressed in the expected unit are too big to be displayed/inputted. Like `meters`. So, in this case, for example, km can be used as unit and the value inputted, like 1 will be multiplied by `multiplyValueBy` before added to the request.
valueAsArray: Boolean, // if the the value of a multiple options field must be sent to the API as an array.
step: Number, // the increasing step for a number input,
visibleWhen: [ // Array of objects containing each an object with the following structure:
{
ref: 'range_type',
value: 'distance'
}
],
validWhen: [ // Array of objects containing conditions to determine if the filter/field is valid. If the field is considered not valid, its value will not be part of the request.
{
ref: String, // the path to another filter/field in the ors-map-filters.js structure. For example 'range_type' (the filter is at the root level) or 'alternative_routes.props.target_count' in an example where the navigation to the filter is informed, `self` can also be used so that the condition will look for the filter itself and evaluate it value, min or max
value: String | List[String], // like 'distance' or ['driving-hgv', 'wheelchair', 'foot-*']. The mask * is accepted.
min: Number // the min value of a filter/field
}
],
visibleWhen: [ // Array of objects containing conditions to determine if the filter/field is visible.
{
ref: String, // the path to another filter/field in the ors-map-filters.js structure. For example 'range_type' (the filter is at the root level) or 'alternative_routes.props.target_count' in an example where the navigation to the filter is informed, `self` can also be used so that the condition will look for the filter itself and evaluate it value, min or max
value: String | List[String], // like 'distance' or ['driving-hgv', 'wheelchair', 'foot-*']. The mask * is accepted.
min: Number // the min value of a filter/field
}
],
valuesRestrictions: [ // Array of objects containing conditions that might determine the value of some of the field properties, like value, min and max
{
ref: 'profile', // the filter/field that should be watched
valuesWhen: { // when the target field has one of the values (or part of it), like 'driving-*'
'driving-*': {
max: [{ref: 'time_range'}, 60], // the `max` value must be set as the value of the 'time_range' field or, if it is not set, as 60.
min: [{ref: 'time_range', calc: {dividedBy: 9}, min: 1}], // the `min` must be set as the result of value of the 'time_range' divided by 9 field, and it must be at least 1.
value: "*" // the value of the field mut be set as the define value (it can be anything, Sting, Object, Number etc)
},
}
}
],
valueAsObject: Boolean, // if the field value must be stringified or sent as an object.
props: List, // list of child filters/fields that might contain the same properties and even other props and children. To be correctly rendered, the field which has props must be of the type `wrapper`. When the API parameters are built, the values of all children will be aggregated and set as the wrapper parent as its value, having the prop.name/prop.internalName as the key.
apiDefault: "*", // the value that must be sent to the API if no value is defined using the UI.
multiSelect: Boolean, // if more then one value can be selected in this field/filter
itemRestrictions: // Array of Objects containing the definitions that will determine the options that are available depending the value of other filter/field.
[
{
ref: String, // the name of the filter/field to be watched.
itemsWhen: { // the options that should be listed depending on the value of the watched field
'driving-*': [ // in this case, if the watched field has as its value something starting with `driving-` then the options available are the one listed
'highways', 'tollways', 'ferries'
],
}
}
],
items: List[Object], // containing the options that will be present in the field. This mostly used to outsource the items, when it is a big list.
itemValue: String, // like 'value' - used in combination with items and to determine which property in each item from items should be used as the option value.
translation_key: String, // an specific key in the translation resource that should be used to generate the UI text, like 'round_trip_length',
multiplyValueBy: Number // the multiplier that must be used to multiply the value for before the API request is built. It is used to avoid big numbers in the UI, like meters/kilometers
}
},
availableOnModes: List[String], // each item must be a constant present in `constants.modes.*`
isEnum: Boolean, // determines if the field is a list of values that should be presented as a select-like input,
separator: String, // determines how the options selected must be concatenated when the expected API parameter expects a single value (a string with a separator)
default: Any, // the default value of the field - it can be a string, a boolean, a Number, array or object. The default value will be added to the request even if the field value is empty.
value: "*", // the value of the field - it can be a string, a boolean, a Number, array or object.
unit: String, // the unit label that must be presented on the side of a field, like 'kmh', 'min', 'km',
min: Number, // min value of number field
max: Number, // max value of number field
multiplyValueBy: Number, // some fields expect a value that when expressed in the expected unit are too big to be displayed/inputted. Like `meters`. So, in this case, for example, km can be used as unit and the value inputted, like 1 will be multiplied by `multiplyValueBy` before added to the request.
valueAsArray: Boolean, // if the the value of a multiple options field must be sent to the API as an array.
step: Number, // the increasing step for a number input,
visibleWhen: [
// Array of objects containing each an object with the following structure:
{
ref: "range_type",
value: "distance",
},
],
validWhen: [
// Array of objects containing conditions to determine if the filter/field is valid. If the field is considered not valid, its value will not be part of the request.
{
ref: String, // the path to another filter/field in the ors-map-filters.js structure. For example 'range_type' (the filter is at the root level) or 'alternative_routes.props.target_count' in an example where the navigation to the filter is informed, `self` can also be used so that the condition will look for the filter itself and evaluate it value, min or max
value: String | List[String], // like 'distance' or ['driving-hgv', 'wheelchair', 'foot-*']. The mask * is accepted.
min: Number, // the min value of a filter/field
},
],
visibleWhen: [
// Array of objects containing conditions to determine if the filter/field is visible.
{
ref: String, // the path to another filter/field in the ors-map-filters.js structure. For example 'range_type' (the filter is at the root level) or 'alternative_routes.props.target_count' in an example where the navigation to the filter is informed, `self` can also be used so that the condition will look for the filter itself and evaluate it value, min or max
value: String | List[String], // like 'distance' or ['driving-hgv', 'wheelchair', 'foot-*']. The mask * is accepted.
min: Number, // the min value of a filter/field
},
],
valuesRestrictions: [
// Array of objects containing conditions that might determine the value of some of the field properties, like value, min and max
{
ref: "profile", // the filter/field that should be watched
valuesWhen: {
// when the target field has one of the values (or part of it), like 'driving-*'
"driving-*": {
max: [{ ref: "time_range" }, 60], // the `max` value must be set as the value of the 'time_range' field or, if it is not set, as 60.
min: [{ ref: "time_range", calc: { dividedBy: 9 }, min: 1 }], // the `min` must be set as the result of value of the 'time_range' divided by 9 field, and it must be at least 1.
value: "*", // the value of the field mut be set as the define value (it can be anything, Sting, Object, Number etc)
},
},
},
],
valueAsObject: Boolean, // if the field value must be stringified or sent as an object.
props: List, // list of child filters/fields that might contain the same properties and even other props and children. To be correctly rendered, the field which has props must be of the type `wrapper`. When the API parameters are built, the values of all children will be aggregated and set as the wrapper parent as its value, having the prop.name/prop.internalName as the key.
apiDefault: "*", // the value that must be sent to the API if no value is defined using the UI.
multiSelect: Boolean, // if more then one value can be selected in this field/filter
// Array of Objects containing the definitions that will determine the options that are available depending the value of other filter/field.
itemRestrictions: [
{
ref: String, // the name of the filter/field to be watched.
itemsWhen: {
// the options that should be listed depending on the value of the watched field
"driving-*": [
// in this case, if the watched field has as its value something starting with `driving-` then the options available are the one listed
"highways",
"tollways",
"ferries",
],
},
},
],
items: List[Object], // containing the options that will be present in the field. This mostly used to outsource the items, when it is a big list.
itemValue: String, // like 'value' - used in combination with items and to determine which property in each item from items should be used as the option value.
translation_key: String, // an specific key in the translation resource that should be used to generate the UI text, like 'round_trip_length',
multiplyValueBy: Number, // the multiplier that must be used to multiply the value for before the API request is built. It is used to avoid big numbers in the UI, like meters/kilometers
};
```
6 changes: 3 additions & 3 deletions docs/en-translation-source-merged.json
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@
"gestureHandling": {
"touch": "Use two fingers to move the map",
"scroll": "Use ctrl + scroll to zoom the map",
"scrollMac": "Use + scroll to zoom the map"
"scrollMac": "Use \u2318 + scroll to zoom the map"
}
},
"placesCarousel": {
Expand Down Expand Up @@ -568,9 +568,9 @@
"miles": "Miles"
},
"areUnits": {
"sqKms": "km²",
"sqKms": "km\u00b2",
"hectare": "Hectare",
"sqMeters": "m²"
"sqMeters": "m\u00b2"
}
},
"orsDictionary": {
Expand Down
33 changes: 15 additions & 18 deletions docs/learned-lessons.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Add longer timeouts:

```js
module.exports = {
//how long does Karma wait for a browser to reconnect, 2000 is default
browserDisconnectTimeout: 60000,
//how long will Karma wait for a message from a browser before disconnecting from it, 10000 is default
browserNoActivityTimeout: 60000,
}
//how long does Karma wait for a browser to reconnect, 2000 is default
browserDisconnectTimeout: 60000,
//how long will Karma wait for a message from a browser before disconnecting from it, 10000 is default
browserNoActivityTimeout: 60000,
};
```

http://alexeyhorn.com/javascript/karma/2017/05/31/fix-karma-disconnected-error.html
Expand All @@ -26,17 +26,14 @@ module.exports = {
test_settings: {
chrome: {
desiredCapabilities: {
browserName: 'chrome',
'chromeOptions': {
'args': [
'--disable-dev-shm-usage',
]
}
}
}
}
}

browserName: "chrome",
chromeOptions: {
args: ["--disable-dev-shm-usage"],
},
},
},
},
};
```

https://svdoscience.com/2021-03-17/fix-session-deleted-page-crash-selenium-grid-chrome-docker
Expand All @@ -60,7 +57,7 @@ Install the @babel/register package - https://www.npmjs.com/package/@babel/regis
Add to the file where you want to use import, before any import statement:

```js
require('@babel/register')
require("@babel/register");
```

## Use babel.config.js to support dynamic compiling rules
Expand All @@ -74,6 +71,6 @@ While chromedriver gives back `rgba`, geckodriver returns `rgb` which is both va
for browsers.
When checking for specific colors, currently a regex should be used to match both returned values, e.g.

/rgba?\(255, 0, 0(, 1)?\)/
/rgba?\(255, 0, 0(, 1)?\)/

to match both `rgb(255, 0, 0)` and `rgba(255, 0, 0, 1)`.

0 comments on commit 456db08

Please sign in to comment.