Integrated JMESPath

This commit is contained in:
jos 2018-06-20 12:25:58 +02:00
parent d85a151243
commit a5a43bbc7b
8 changed files with 412 additions and 245 deletions

5
package-lock.json generated
View File

@ -2789,6 +2789,11 @@
"resolved": "https://registry.npmjs.org/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz",
"integrity": "sha1-+eIwPUUH9tdDVac2ZNFED7Wg71k="
},
"jmespath": {
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz",
"integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc="
},
"json-loader": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/json-loader/-/json-loader-0.5.4.tgz",

View File

@ -26,6 +26,7 @@
"ajv": "5.5.2",
"brace": "0.11.0",
"javascript-natural-sort": "0.7.1",
"jmespath": "0.15.0",
"picomodal": "3.0.0"
},
"devDependencies": {

View File

@ -177,6 +177,14 @@ div.jsoneditor-contextmenu button.jsoneditor-sort-desc:focus > div.jsoneditor-ic
background-position: -192px 0;
}
div.jsoneditor-contextmenu button.jsoneditor-transform > div.jsoneditor-icon {
background-position: -216px -24px;
}
div.jsoneditor-contextmenu button.jsoneditor-transform:hover > div.jsoneditor-icon,
div.jsoneditor-contextmenu button.jsoneditor-transform:focus > div.jsoneditor-icon {
background-position: -216px 0;
}
/* ContextMenu - sub menu */
div.jsoneditor-contextmenu ul li button.jsoneditor-selected,
@ -278,6 +286,9 @@ div.jsoneditor-contextmenu button.jsoneditor-type-modes > div.jsoneditor-icon {
border-radius: 2px !important;
padding: 45px 15px 15px 15px !important;
box-shadow: 2px 2px 12px rgba(128, 128, 128, 0.3) !important;
color: #4d4d4d;
line-height: 1.3em;
}
.jsoneditor-modal .pico-modal-header {
@ -305,7 +316,6 @@ div.jsoneditor-contextmenu button.jsoneditor-type-modes > div.jsoneditor-icon {
vertical-align: middle;
font-size: 10pt;
font-family: arial, sans-serif;
color: #4d4d4d;
}
.jsoneditor-modal table td:first-child {
@ -338,6 +348,15 @@ div.jsoneditor-contextmenu button.jsoneditor-type-modes > div.jsoneditor-icon {
cursor: pointer;
}
.jsoneditor-modal input {
padding: 4px 20px;
}
.jsoneditor-modal input[type="text"] {
padding: 4px;
cursor: inherit;
}
.jsoneditor-modal .jsoneditor-select-wrapper {
position: relative;
}
@ -398,7 +417,3 @@ div.jsoneditor-contextmenu button.jsoneditor-type-modes > div.jsoneditor-icon {
border-color: #3883fa;
color: white;
}
.jsoneditor-modal input {
padding: 4px 20px;
}

View File

@ -7,7 +7,7 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="216"
width="240"
height="144"
id="svg4136"
version="1.1"
@ -30,7 +30,7 @@
<defs
id="defs4146" />
<sodipodi:namedview
pagecolor="#ffffff"
pagecolor="#ff63ff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
@ -39,12 +39,12 @@
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1027"
inkscape:window-height="1026"
id="namedview4144"
showgrid="true"
inkscape:zoom="32"
inkscape:cx="101.13921"
inkscape:cy="34.512712"
inkscape:zoom="4"
inkscape:cx="128.30169"
inkscape:cy="93.732883"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
@ -59,224 +59,221 @@
empspacing="24" />
</sodipodi:namedview>
<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
<rect
style="fill:#1aae1c;fill-opacity:1;stroke:none;stroke-width:0"
id="svg_1"
height="16"
width="16"
y="4"
x="4" />
<rect
id="svg_1-7"
height="16"
width="16"
y="3.999995"
x="28.000006"
style="fill:#ec3f29;fill-opacity:0.94117647;stroke:none;stroke-width:0" />
<rect
style="fill:#4c4c4c;fill-opacity:1;stroke:none;stroke-width:0"
x="52.000004"
y="3.999995"
width="16"
height="16"
id="rect4165" />
<rect
id="rect4175"
height="16"
width="16"
y="3.9999852"
x="172.00002"
style="fill:#4c4c4c;fill-opacity:1;stroke:none;stroke-width:0" />
<rect
id="rect4175-3"
height="16"
width="16"
y="3.999995"
x="196"
style="fill:#4c4c4c;fill-opacity:1;stroke:none;stroke-width:0" />
<g
id="g4394">
id="g4299"
style="stroke:none">
<rect
x="4"
y="4"
width="16"
height="16"
id="svg_1"
style="fill:#1aae1c;fill-opacity:1;stroke:none;stroke-width:0" />
x="7.0000048"
y="10.999998"
width="9.9999924"
height="1.9999986"
id="svg_1-1"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0" />
<rect
style="fill:#ec3f29;fill-opacity:0.94117647;stroke:none;stroke-width:0"
x="28.000006"
y="3.999995"
width="16"
height="16"
id="svg_1-7" />
x="11.000005"
y="7.0000114"
width="1.9999955"
height="9.9999838"
id="svg_1-1-1"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0" />
</g>
<g
id="g4299-3"
transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,19.029435,12.000001)"
style="stroke:none">
<rect
id="rect4165"
height="16"
width="16"
y="3.999995"
x="52.000004"
style="fill:#4c4c4c;fill-opacity:1;stroke:none;stroke-width:0" />
x="7.0000048"
y="10.999998"
width="9.9999924"
height="1.9999986"
id="svg_1-1-0"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0" />
<rect
style="fill:#4c4c4c;fill-opacity:1;stroke:none;stroke-width:0"
x="172.00002"
y="3.9999852"
width="16"
height="16"
id="rect4175" />
<rect
style="fill:#4c4c4c;fill-opacity:1;stroke:none;stroke-width:0"
x="196"
y="3.999995"
width="16"
height="16"
id="rect4175-3" />
<g
style="stroke:none"
id="g4299">
<rect
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0"
id="svg_1-1"
height="1.9999986"
width="9.9999924"
y="10.999998"
x="7.0000048" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0"
id="svg_1-1-1"
height="9.9999838"
width="1.9999955"
y="7.0000114"
x="11.000005" />
</g>
<g
style="stroke:none"
transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,19.029435,12.000001)"
id="g4299-3">
<rect
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0"
id="svg_1-1-0"
height="1.9999986"
width="9.9999924"
y="10.999998"
x="7.0000048" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0"
id="svg_1-1-1-9"
height="9.9999838"
width="1.9999955"
y="7.0000114"
x="11.000005" />
</g>
x="11.000005"
y="7.0000114"
width="1.9999955"
height="9.9999838"
id="svg_1-1-1-9"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0" />
</g>
<rect
id="svg_1-7-5"
height="6.9999905"
width="6.9999909"
y="7.0000048"
x="55.000004"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke:#4c4c4c;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
x="58"
y="10.00001"
width="6.9999909"
height="6.9999905"
id="rect4354" />
<rect
id="svg_1-7-5-7"
height="6.9999905"
width="6.9999909"
y="10.000005"
x="58.000004"
style="fill:#ffffff;fill-opacity:1;stroke:#3c80df;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.94117647" />
<g
id="g4378">
<rect
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0"
x="55.000004"
y="7.0000048"
width="6.9999909"
height="6.9999905"
id="svg_1-7-5" />
x="198"
y="10.999999"
width="7.9999909"
height="1.9999965"
id="svg_1-7-5-3" />
<rect
id="rect4354"
height="6.9999905"
width="6.9999909"
y="10.00001"
x="58"
style="fill:#ffffff;fill-opacity:1;stroke:#4c4c4c;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
id="rect4374"
height="1.9999946"
width="11.999995"
y="7.0000005"
x="198"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke:#3c80df;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.94117647"
x="58.000004"
y="10.000005"
width="6.9999909"
height="6.9999905"
id="svg_1-7-5-7" />
<g
id="g4378">
<rect
id="svg_1-7-5-3"
height="1.9999965"
width="7.9999909"
y="10.999999"
x="198"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0"
x="198"
y="7.0000005"
width="11.999995"
height="1.9999946"
id="rect4374" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0"
x="198"
y="14.999996"
width="3.9999928"
height="1.9999995"
id="rect4376" />
</g>
<g
id="g4383"
transform="matrix(1,0,0,-1,-23.999995,23.999995)">
<rect
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0"
x="198"
y="10.999999"
width="7.9999909"
height="1.9999965"
id="rect4385" />
<rect
id="rect4387"
height="1.9999946"
width="11.999995"
y="7.0000005"
x="198"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0" />
<rect
id="rect4389"
height="1.9999995"
width="3.9999928"
y="14.999996"
x="198"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0" />
</g>
<rect
y="3.9999199"
x="76"
height="16"
width="16"
id="rect3754-4"
style="fill:#4c4c4c;fill-opacity:1;stroke:none" />
<path
sodipodi:nodetypes="cccccccc"
inkscape:connector-curvature="0"
id="path4351"
d="m 85.10447,6.0157384 -0.0156,1.4063 c 3.02669,-0.2402 0.33008,3.6507996 2.48438,4.5780996 -2.18694,1.0938 0.49191,4.9069 -2.45313,4.5781 l -0.0156,1.4219 c 5.70828,0.559 1.03264,-5.1005 4.70313,-5.2656 l 0,-1.4063 c -3.61303,-0.027 1.11893,-5.7069996 -4.70313,-5.3124996 z"
style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
sodipodi:nodetypes="cccccccc"
inkscape:connector-curvature="0"
id="path4351-9"
d="m 82.78125,5.9984384 0.0156,1.4063 c -3.02668,-0.2402 -0.33007,3.6506996 -2.48437,4.5780996 2.18694,1.0938 -0.49192,4.9069 2.45312,4.5781 l 0.0156,1.4219 c -5.70827,0.559 -1.03263,-5.1004 -4.70312,-5.2656 l 0,-1.4063 c 3.61303,-0.027 -1.11894,-5.7070996 4.70312,-5.3124996 z"
style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
y="3.9999199"
x="100"
height="16"
width="16"
id="rect3754-25"
style="fill:#4c4c4c;fill-opacity:1;stroke:none" />
<path
inkscape:connector-curvature="0"
id="path2987"
d="m 103.719,5.6719384 0,12.7187996 3.03125,0 0,-1.5313 -1.34375,0 0,-9.6249996 1.375,0 0,-1.5625 z"
style="fill:#ffffff;fill-opacity:1;stroke:none" />
<path
inkscape:connector-curvature="0"
id="path2987-1"
d="m 112.2185,5.6721984 0,12.7187996 -3.03125,0 0,-1.5313 1.34375,0 0,-9.6249996 -1.375,0 0,-1.5625 z"
style="fill:#ffffff;fill-opacity:1;stroke:none" />
<rect
y="3.9999199"
x="124"
height="16"
width="16"
id="rect3754-73"
style="fill:#4c4c4c;fill-opacity:1;stroke:none" />
<path
sodipodi:nodetypes="ccccccccc"
inkscape:connector-curvature="0"
id="path3780"
d="m 126.2824,17.602938 1.78957,0 1.14143,-2.8641 5.65364,0 1.14856,2.8641 1.76565,0 -4.78687,-11.1610996 -1.91903,0 z"
style="fill:#ffffff;fill-opacity:1;stroke:none" />
<path
inkscape:connector-curvature="0"
id="path3782"
d="m 129.72704,13.478838 4.60852,0.01 -2.30426,-5.5497996 z"
style="fill:#4c4c4c;fill-opacity:1;stroke:none" />
<rect
y="3.9999199"
x="148"
height="16"
width="16"
id="rect3754-35"
style="fill:#4c4c4c;fill-opacity:1;stroke:none" />
<path
sodipodi:nodetypes="ccccccc"
inkscape:connector-curvature="0"
id="path5008-2"
d="m 156.47655,5.8917384 0,2.1797 0.46093,2.3983996 1.82813,0 0.39844,-2.3983996 0,-2.1797 z"
style="fill:#ffffff;fill-opacity:1;stroke:none" />
<path
sodipodi:nodetypes="ccccccc"
inkscape:connector-curvature="0"
id="path5008-2-8"
d="m 152.51561,5.8906384 0,2.1797 0.46094,2.3983996 1.82812,0 0.39844,-2.3983996 0,-2.1797 z"
style="fill:#ffffff;fill-opacity:1;stroke:none" />
id="rect4376"
height="1.9999995"
width="3.9999928"
y="14.999996"
x="198"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0" />
</g>
<g
transform="matrix(1,0,0,-1,-23.999995,23.999995)"
id="g4383">
<rect
id="rect4385"
height="1.9999965"
width="7.9999909"
y="10.999999"
x="198"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0"
x="198"
y="7.0000005"
width="11.999995"
height="1.9999946"
id="rect4387" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0"
x="198"
y="14.999996"
width="3.9999928"
height="1.9999995"
id="rect4389" />
</g>
<rect
style="fill:#4c4c4c;fill-opacity:1;stroke:none"
id="rect3754-4"
width="16"
height="16"
x="76"
y="3.9999199" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 85.10447,6.0157384 -0.0156,1.4063 c 3.02669,-0.2402 0.33008,3.6507996 2.48438,4.5780996 -2.18694,1.0938 0.49191,4.9069 -2.45313,4.5781 l -0.0156,1.4219 c 5.70828,0.559 1.03264,-5.1005 4.70313,-5.2656 l 0,-1.4063 c -3.61303,-0.027 1.11893,-5.7069996 -4.70313,-5.3124996 z"
id="path4351"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccc" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:0.2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 82.78125,5.9984384 0.0156,1.4063 c -3.02668,-0.2402 -0.33007,3.6506996 -2.48437,4.5780996 2.18694,1.0938 -0.49192,4.9069 2.45312,4.5781 l 0.0156,1.4219 c -5.70827,0.559 -1.03263,-5.1004 -4.70312,-5.2656 l 0,-1.4063 c 3.61303,-0.027 -1.11894,-5.7070996 4.70312,-5.3124996 z"
id="path4351-9"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccc" />
<rect
style="fill:#4c4c4c;fill-opacity:1;stroke:none"
id="rect3754-25"
width="16"
height="16"
x="100"
y="3.9999199" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:none"
d="m 103.719,5.6719384 0,12.7187996 3.03125,0 0,-1.5313 -1.34375,0 0,-9.6249996 1.375,0 0,-1.5625 z"
id="path2987"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:none"
d="m 112.2185,5.6721984 0,12.7187996 -3.03125,0 0,-1.5313 1.34375,0 0,-9.6249996 -1.375,0 0,-1.5625 z"
id="path2987-1"
inkscape:connector-curvature="0" />
<rect
style="fill:#4c4c4c;fill-opacity:1;stroke:none"
id="rect3754-73"
width="16"
height="16"
x="124"
y="3.9999199" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:none"
d="m 126.2824,17.602938 1.78957,0 1.14143,-2.8641 5.65364,0 1.14856,2.8641 1.76565,0 -4.78687,-11.1610996 -1.91903,0 z"
id="path3780"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccc" />
<path
style="fill:#4c4c4c;fill-opacity:1;stroke:none"
d="m 129.72704,13.478838 4.60852,0.01 -2.30426,-5.5497996 z"
id="path3782"
inkscape:connector-curvature="0" />
<rect
style="fill:#4c4c4c;fill-opacity:1;stroke:none"
id="rect3754-35"
width="16"
height="16"
x="148"
y="3.9999199" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:none"
d="m 156.47655,5.8917384 0,2.1797 0.46093,2.3983996 1.82813,0 0.39844,-2.3983996 0,-2.1797 z"
id="path5008-2"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccc" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:none"
d="m 152.51561,5.8906384 0,2.1797 0.46094,2.3983996 1.82812,0 0.39844,-2.3983996 0,-2.1797 z"
id="path5008-2-8"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccc" />
<rect
x="4"
y="27.999994"
@ -765,17 +762,17 @@
id="path4138-1" />
<path
inkscape:connector-curvature="0"
style="opacity:0.8;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.966;stroke-miterlimit:4;stroke-dasharray:none"
style="opacity:0.8;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.96599996;stroke-miterlimit:4;stroke-dasharray:none"
d="m 10.5,100 0,2 -2.4999996,0 L 12,107 l 4,-5 -2.5,0 0,-2 -3,0 z"
id="path3055-0-77" />
<path
style="opacity:0.8;fill:none;stroke:#ffffff;stroke-width:1.966;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
style="opacity:0.8;fill:none;stroke:#ffffff;stroke-width:1.96599996;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 4.9850574,108.015 14.0298856,-0.03"
id="path5244-5-0-5"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="opacity:0.8;fill:none;stroke:#ffffff;stroke-width:1.966;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
style="opacity:0.8;fill:none;stroke:#ffffff;stroke-width:1.96599996;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 4.9849874,132.015 14.0298866,-0.03"
id="path5244-5-0-5-8"
inkscape:connector-curvature="0"
@ -793,17 +790,17 @@
<path
id="path6191"
d="m 10.5,116 0,-2 -2.4999996,0 L 12,109 l 4,5 -2.5,0 0,2 -3,0 z"
style="opacity:0.8;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.966;stroke-miterlimit:4;stroke-dasharray:none"
style="opacity:0.8;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.96599996;stroke-miterlimit:4;stroke-dasharray:none"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
style="opacity:0.8;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.966;stroke-miterlimit:4;stroke-dasharray:none"
style="opacity:0.8;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.96599996;stroke-miterlimit:4;stroke-dasharray:none"
d="m 10.5,129 0,-2 -2.4999996,0 L 12,122 l 4,5 -2.5,0 0,2 -3,0 z"
id="path6193" />
<path
id="path6195"
d="m 10.5,135 0,2 -2.4999996,0 L 12,142 l 4,-5 -2.5,0 0,-2 -3,0 z"
style="opacity:0.8;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.966;stroke-miterlimit:4;stroke-dasharray:none"
style="opacity:0.8;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.96599996;stroke-miterlimit:4;stroke-dasharray:none"
inkscape:connector-curvature="0" />
<path
sodipodi:type="star"
@ -891,9 +888,35 @@
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc" />
<path
style="fill:#ffffff;fill-opacity:0.8;fill-rule:evenodd;stroke:#ffffff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:0.80000001"
style="fill:#ffffff;fill-opacity:0.8;fill-rule:evenodd;stroke:#ffffff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:0.8"
d="M 99.994369,113.0221 102,114.98353 l 7,-6.9558 3,0.97227 2,-1 1,-2 0,-3 -3,3 -3,-3 3,-3 -3,0 -2,1 -1,2 0.99437,3.0221 z"
id="path4268"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccccccccc" />
<rect
style="fill:#d3d3d3;stroke:#000000;stroke-width:0"
x="220"
y="27.999994"
width="15.99999"
height="16"
id="rect4448-3" />
<rect
id="rect4175-3-5"
height="16"
width="16"
y="4"
x="220"
style="fill:#4c4c4c;fill-opacity:1;stroke:none;stroke-width:0" />
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 234,6 0,2 -5,5 0,5 -2,0 0,-5 -5,-5 0,-2"
id="path3546"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccc" />
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 234,30 0,2 -5,5 0,5 -2,0 0,-5 -5,-5 0,-2"
id="path3546-2"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccc" />
</svg>

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -120,19 +120,19 @@ function History (editor) {
}
},
'sort': {
'transform': {
'undo': function (params) {
var node = params.node;
node.hideChilds();
node.childs = params.oldChilds;
node._updateDomIndexes();
node.updateDom({updateIndexes: true});
node.showChilds();
},
'redo': function (params) {
var node = params.node;
node.hideChilds();
node.childs = params.newChilds;
node._updateDomIndexes();
node.updateDom({updateIndexes: true});
node.showChilds();
}
}

View File

@ -1,10 +1,12 @@
'use strict';
var jmespath = require('jmespath');
var naturalSort = require('javascript-natural-sort');
var ContextMenu = require('./ContextMenu');
var appendNodeFactory = require('./appendNodeFactory');
var showMoreNodeFactory = require('./showMoreNodeFactory');
var showSortModal = require('./showSortModal');
var showTransformModal = require('./showTransformModal');
var util = require('./util');
var translate = require('./i18n').translate;
@ -326,17 +328,16 @@ Node.prototype.getField = function() {
*/
Node.prototype.setValue = function(value, type) {
var childValue, child, visible;
var notUpdateDom = false;
// first clear all current childs (if any)
var childs = this.childs;
if (childs) {
while (childs.length) {
this.removeChild(childs[0]);
this.removeChild(childs[0], notUpdateDom);
}
}
// TODO: remove the DOM of this Node
this.type = this._getType(value);
// check if type corresponds with the provided type
@ -362,7 +363,7 @@ Node.prototype.setValue = function(value, type) {
value: childValue
});
visible = i < this.MAX_VISIBLE_CHILDS;
this.appendChild(child, visible);
this.appendChild(child, visible, notUpdateDom);
}
}
this.value = '';
@ -381,7 +382,7 @@ Node.prototype.setValue = function(value, type) {
value: childValue
});
visible = i < this.MAX_VISIBLE_CHILDS;
this.appendChild(child, visible);
this.appendChild(child, visible, notUpdateDom);
}
i++;
}
@ -398,6 +399,8 @@ Node.prototype.setValue = function(value, type) {
this.childs = undefined;
this.value = value;
}
this.updateDom({'updateIndexes': true});
this.previousValue = this.value;
};
@ -664,9 +667,12 @@ Node.prototype.expandTo = function() {
* Add a new child to the node.
* Only applicable when Node value is of type array or object
* @param {Node} node
* @param {boolean} [visible] If true, the child will be rendered
* @param {boolean} [visible] If true (default), the child will be rendered
* @param {boolean} [updateDom] If true (default), the DOM of both parent
* node and appended node will be updated
* (child count, indexes)
*/
Node.prototype.appendChild = function(node, visible) {
Node.prototype.appendChild = function(node, visible, updateDom) {
if (this._hasChilds()) {
// adjust the link to the parent
node.setParent(this);
@ -690,8 +696,10 @@ Node.prototype.appendChild = function(node, visible) {
this.visibleChilds++;
}
this.updateDom({'updateIndexes': true});
node.updateDom({'recurse': true});
if (updateDom !== false) {
this.updateDom({'updateIndexes': true});
node.updateDom({'recurse': true});
}
}
};
@ -1105,15 +1113,19 @@ Node.prototype._move = function(node, beforeNode) {
* Remove a child from the node.
* Only applicable when Node value is of type array or object
* @param {Node} node The child node to be removed;
* @param {boolean} [updateDom] If true (default), the DOM of the parent
* node will be updated (like child count)
* @return {Node | undefined} node The removed node on success,
* else undefined
*/
Node.prototype.removeChild = function(node) {
Node.prototype.removeChild = function(node, updateDom) {
if (this.childs) {
var index = this.childs.indexOf(node);
if (index !== -1) {
this.visibleChilds--;
if (index < this.visibleChilds && this.expanded) {
this.visibleChilds--;
}
node.hide();
@ -1124,7 +1136,9 @@ Node.prototype.removeChild = function(node) {
var removedNode = this.childs.splice(index, 1)[0];
removedNode.parent = null;
this.updateDom({'updateIndexes': true});
if (updateDom !== false) {
this.updateDom({'updateIndexes': true});
}
return removedNode;
}
@ -3147,7 +3161,37 @@ Node.prototype.sort = function (path, direction) {
// update the index numbering
this._updateDomIndexes();
this.editor._onAction('sort', {
this.editor._onAction('transform', {
node: this,
oldChilds: oldChilds,
newChilds: this.childs
});
this.showChilds();
};
/**
* Transform the node given a JMESPath query.
* @param {String} query JMESPath query to apply
* @private
*/
Node.prototype.transform = function (query) {
if (!this._hasChilds()) {
return;
}
this.hideChilds(); // sorting is faster when the childs are not attached to the dom
// copy the childs array (the old one will be kept for an undo action
var oldChilds = this.childs;
this.childs = this.childs.concat();
// apply the JMESPath query
var transformed = jmespath.search(this.getValue(), query);
this.setValue(transformed);
this.editor._onAction('transform', {
node: this,
oldChilds: oldChilds,
newChilds: this.childs
@ -3583,12 +3627,21 @@ Node.prototype.showContextMenu = function (anchor, onClose) {
if (this._hasChilds()) {
items.push({
text: translate('sort'),
title: translate('sortTitle') + this.type,
title: translate('sortTitle', {type: this.type}),
className: 'jsoneditor-sort-asc',
click: function () {
showSortModal(node, node.editor.frame)
}
});
items.push({
text: translate('transform'),
title: translate('transformTitle', {type: this.type}),
className: 'jsoneditor-transform',
click: function () {
showTransformModal(node, node.editor.frame)
}
});
}
if (this.parent && this.parent._hasChilds()) {

View File

@ -38,7 +38,7 @@ var _defs = {
'showMore': 'show more',
'showMoreStatus': 'displaying ${visibleChilds} of ${totalChilds} items.',
'sort': 'Sort',
'sortTitle': 'Sort the childs of this ',
'sortTitle': 'Sort the childs of this ${type}',
'sortFieldLabel': 'Field:',
'sortDirectionLabel': 'Direction:',
'sortFieldTitle': 'Select the nested field by which to sort the array or object',
@ -47,6 +47,10 @@ var _defs = {
'sortDescending': 'Descending',
'sortDescendingTitle': 'Sort the selected field in descending order',
'string': 'String',
'transform': 'Transform',
'transformTitle': 'Filter, sort, or transform the childs of this ${type}',
'transformQueryTitle': 'Enter a JMESPath query',
'transformQueryLabel': 'Query',
'type': 'Type',
'typeTitle': 'Change the type of this field',
'openUrl': 'Ctrl+Click or Ctrl+Enter to open url in new window',
@ -103,7 +107,7 @@ var _defs = {
// TODO: correctly translate showMoreStatus
'showMoreStatus': 'exibindo ${visibleChilds} de ${totalChilds} itens.',
'sort': 'Organizar',
'sortTitle': 'Organizar os filhos deste ',
'sortTitle': 'Organizar os filhos deste ${type}',
// TODO: correctly translate sortFieldLabel
'sortFieldLabel': 'Field:',
// TODO: correctly translate sortDirectionLabel

View File

@ -0,0 +1,66 @@
var picoModal = require('picomodal');
var translate = require('./i18n').translate;
/**
* Show advanced filter and transform modal using JMESPath
* @param {Node} node the node to be transformed
* @param {HTMLElement} container The container where to center
* the modal and create an overlay
*/
function showTransformModal (node, container) {
var content = '<div class="pico-modal-contents jsoneditor-transform-modal">' +
'<div class="pico-modal-header">' + translate('transform') + '</div>' +
'<form>' +
'<p>' +
'Enter a JMESPath query to filter, sort, or transform the JSON data. ' +
'To learn JMESPath, go to <a href="http://jmespath.org/tutorial.html" target="_blank">the interactive tutorial</a>.' +
'</p>' +
'<table>' +
'<tbody>' +
'<tr>' +
' <td>' + translate('transformQueryLabel') + ' </td>' +
' <td class="jsoneditor-modal-input">' +
' <input id="query" type="text" title="' + translate('transformQueryTitle') + '" value="[*]"/>' +
' </td>' +
'</tr>' +
'<tr>' +
'<td colspan="2" class="jsoneditor-modal-input jsoneditor-modal-actions">' +
' <input type="submit" id="ok" value="' + translate('ok') + '" />' +
'</td>' +
'</tr>' +
'</tbody>' +
'</table>' +
'</form>' +
'</div>';
picoModal({
parent: container,
content: content,
overlayClass: 'jsoneditor-modal-overlay',
modalClass: 'jsoneditor-modal'
})
.afterCreate(function (modal) {
var form = modal.modalElem().querySelector('form');
var ok = modal.modalElem().querySelector('#ok');
var query = modal.modalElem().querySelector('#query');
ok.onclick = function (event) {
event.preventDefault();
event.stopPropagation();
modal.close();
node.transform(query.value)
};
if (form) { // form is not available when JSONEditor is created inside a form
form.onsubmit = ok.onclick;
}
})
.afterClose(function (modal) {
modal.destroy();
})
.show();
}
module.exports = showTransformModal;