Skip to content

Commit

Permalink
#464 Touch ups
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman committed Jun 11, 2024
1 parent 9f0c798 commit 7f2fa74
Show file tree
Hide file tree
Showing 13 changed files with 181 additions and 129 deletions.
11 changes: 10 additions & 1 deletion configure/src/core/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { saveAs } from "file-saver";

// Positive ints only
export const isNumeric = (value) => {
return /^\d+$/.test(value);
};
/**
* Traverses an object with an array of keys
* @param {*} obj
Expand All @@ -19,11 +23,15 @@ export const getIn = (obj, keyArray, notSetValue) => {
return object;
};
export const setIn = (obj, keyArray, value, force) => {
console.log("setIn", obj, keyArray, value, force);
if (keyArray == null || keyArray.length === 0) return null;
let object = obj;
for (let i = 0; i < keyArray.length - 1; i++) {
console.log(obj, keyArray, keyArray[i], value, force);
if (force) {
if (!object.hasOwnProperty(keyArray[i])) object[keyArray[i]] = {};
if (!object.hasOwnProperty(keyArray[i]))
object[keyArray[i]] =
i === keyArray.length - 2 && isNumeric(keyArray[i + 1]) ? [] : {};
object = object[keyArray[i]];
} else {
if (object.hasOwnProperty(keyArray[i])) object = object[keyArray[i]];
Expand All @@ -32,6 +40,7 @@ export const setIn = (obj, keyArray, value, force) => {
}
object[keyArray[keyArray.length - 1]] = value;
};

export const traverseLayers = (layers, onLayer) => {
depthTraversal(layers, 0, []);
function depthTraversal(node, depth, path) {
Expand Down
27 changes: 13 additions & 14 deletions configure/src/metaconfigs/layer-data-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -384,46 +384,45 @@
{
"name": "Information",
"subname": "Layer Tags",
"subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool.",
"subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool. A category may be specified with the following pattern: 'category:tag'",
"components": [
{
"new": true,
"field": "variables.tags.0",
"field": "tags.0",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.1",
"field": "tags.1",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.2",
"field": "tags.2",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.3",
"field": "tags.3",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.4",
"field": "tags.4",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.5",
"field": "tags.5",
"name": "Tag",
"description": "",
"type": "text",
Expand All @@ -434,42 +433,42 @@
{
"components": [
{
"field": "variables.tags.6",
"field": "tags.6",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.7",
"field": "tags.7",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.8",
"field": "tags.8",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.9",
"field": "tags.9",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.10",
"field": "tags.10",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.11",
"field": "tags.11",
"name": "Tag",
"description": "",
"type": "text",
Expand Down
27 changes: 13 additions & 14 deletions configure/src/metaconfigs/layer-header-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,46 +39,45 @@
{
"name": "Information",
"subname": "Layer Tags",
"subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool.",
"subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool. A category may be specified with the following pattern: 'category:tag'",
"components": [
{
"new": true,
"field": "variables.tags.0",
"field": "tags.0",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.1",
"field": "tags.1",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.2",
"field": "tags.2",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.3",
"field": "tags.3",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.4",
"field": "tags.4",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.5",
"field": "tags.5",
"name": "Tag",
"description": "",
"type": "text",
Expand All @@ -89,42 +88,42 @@
{
"components": [
{
"field": "variables.tags.6",
"field": "tags.6",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.7",
"field": "tags.7",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.8",
"field": "tags.8",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.9",
"field": "tags.9",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.10",
"field": "tags.10",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.11",
"field": "tags.11",
"name": "Tag",
"description": "",
"type": "text",
Expand Down
27 changes: 13 additions & 14 deletions configure/src/metaconfigs/layer-model-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -686,46 +686,45 @@
{
"name": "Information",
"subname": "Layer Tags",
"subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool.",
"subdescription": "Assign tags to this layer so that they may be searched upon through the LayersTool. A category may be specified with the following pattern: 'category:tag'",
"components": [
{
"new": true,
"field": "variables.tags.0",
"field": "tags.0",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.1",
"field": "tags.1",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.2",
"field": "tags.2",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.3",
"field": "tags.3",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.4",
"field": "tags.4",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.5",
"field": "tags.5",
"name": "Tag",
"description": "",
"type": "text",
Expand All @@ -736,42 +735,42 @@
{
"components": [
{
"field": "variables.tags.6",
"field": "tags.6",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.7",
"field": "tags.7",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.8",
"field": "tags.8",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.9",
"field": "tags.9",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.10",
"field": "tags.10",
"name": "Tag",
"description": "",
"type": "text",
"width": 2
},
{
"field": "variables.tags.11",
"field": "tags.11",
"name": "Tag",
"description": "",
"type": "text",
Expand Down
Loading

0 comments on commit 7f2fa74

Please sign in to comment.