Skip to content

Commit

Permalink
Fix issue with overriding the phrases for fields, v3.0.0-rc.1
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Mar 15, 2023
1 parent 0d20f71 commit 5fefbb9
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ implemented as a single page application (SPA) for ease of development and to
limit the overall number of catalog reads necessary when browsing (as catalogs
may be nested and do not necessarily contain references to their parents).

Version: **3.0.0-beta.9** (supports all STAC versions between 0.6.0 and 1.0.0)
Version: **3.0.0-rc.1** (supports all STAC versions between 0.6.0 and 1.0.0)

This package has also been published to npm as [`@radiantearth/stac-browser`](https://www.npmjs.com/package/@radiantearth/stac-browser).

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@radiantearth/stac-browser",
"version": "3.0.0-beta.9",
"version": "3.0.0-rc.1",
"description": "A full-fledged UI in Vue for browsing and searching static STAC catalogs and STAC APIs.",
"main": "src/main.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/locales/de-CH/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default Object.assign(
import Utils from '../../utils';
export default Utils.mergeDeep(
{
fields: require('../de/fields.json'),
},
Expand Down
3 changes: 2 additions & 1 deletion src/locales/de/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default Object.assign(
import Utils from '../../utils';
export default Utils.mergeDeep(
{
fields: require('./fields.json'),
},
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default Object.assign(
import Utils from '../../utils';
export default Utils.mergeDeep(
// Don't import the fields as it's a 1:1 mapping anyway
// { fields: require('./fields.json') },
require('./texts.json'),
Expand Down
3 changes: 2 additions & 1 deletion src/locales/es/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default Object.assign(
import Utils from '../../utils';
export default Utils.mergeDeep(
{
fields: require('./fields.json'),
},
Expand Down
3 changes: 2 additions & 1 deletion src/locales/fr-CA/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default Object.assign(
import Utils from '../../utils';
export default Utils.mergeDeep(
{
fields: require('../fr/fields.json'),
},
Expand Down
3 changes: 2 additions & 1 deletion src/locales/fr-CH/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default Object.assign(
import Utils from '../../utils';
export default Utils.mergeDeep(
{
fields: require('../fr/fields.json'),
},
Expand Down
3 changes: 2 additions & 1 deletion src/locales/fr/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default Object.assign(
import Utils from '../../utils';
export default Utils.mergeDeep(
{
fields: require('./fields.json'),
},
Expand Down
3 changes: 2 additions & 1 deletion src/locales/it-CH/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default Object.assign(
import Utils from '../../utils';
export default Utils.mergeDeep(
{
fields: require('../it/fields.json'),
},
Expand Down
3 changes: 2 additions & 1 deletion src/locales/it/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default Object.assign(
import Utils from '../../utils';
export default Utils.mergeDeep(
{
fields: require('./fields.json'),
},
Expand Down
3 changes: 2 additions & 1 deletion src/locales/ro/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default Object.assign(
import Utils from '../../utils';
export default Utils.mergeDeep(
{
fields: require('./fields.json'),
},
Expand Down
27 changes: 27 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,31 @@ export default class Utils {
return Boolean(data['stac_extensions'].find(uri => regexp.test(uri)));
}

/**
* Deep merge two objects.
* @param target
* @param ...sources
*/
static mergeDeep(target, ...sources) {
if (!sources.length) {
return target;
}
const source = sources.shift();

if (Utils.isObject(target) && Utils.isObject(source)) {
for (const key in source) {
if (Utils.isObject(source[key])) {
if (!target[key]) {
Object.assign(target, { [key]: {} });
}
Utils.mergeDeep(target[key], source[key]);
} else {
Object.assign(target, { [key]: source[key] });
}
}
}

return Utils.mergeDeep(target, ...sources);
}

}

0 comments on commit 5fefbb9

Please sign in to comment.