From 041b268ca28212fde7ff515d46b20510c859623e Mon Sep 17 00:00:00 2001 From: Forrest Li Date: Fri, 25 May 2018 12:05:55 -0400 Subject: [PATCH] fix(widgets): Move EditableList to paraviewweb library Import the paraviewweb library to use an updated version of the EditableList widget. --- package-lock.json | 106 +++++++++++++++++++++--------------- package.json | 1 + rules/paraviewweb.js | 21 +++++++ src/assets/vera.mcss | 19 ------- src/simput/CellEditor.js | 13 +++-- src/simput/RodEditor.js | 21 ++++++- src/widgets/EditableList.js | 94 -------------------------------- webpack.simput.config.js | 7 ++- 8 files changed, 116 insertions(+), 166 deletions(-) create mode 100644 rules/paraviewweb.js delete mode 100644 src/widgets/EditableList.js diff --git a/package-lock.json b/package-lock.json index 2b07a31..ea60c04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2284,8 +2284,7 @@ "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "base": { "version": "0.11.2", @@ -2508,7 +2507,6 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, "requires": { "balanced-match": "1.0.0", "concat-map": "0.0.1" @@ -3623,8 +3621,7 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, "concat-stream": { "version": "1.6.2", @@ -3809,14 +3806,12 @@ "core-js": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.3.0.tgz", - "integrity": "sha1-+rg/uwstjchfpjbEudNMdUIMbWU=", - "dev": true + "integrity": "sha1-+rg/uwstjchfpjbEudNMdUIMbWU=" }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "cosmiconfig": { "version": "2.2.2", @@ -4973,8 +4968,7 @@ "es6-promise": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.0.2.tgz", - "integrity": "sha1-AQ1YWEI6XxGJeWZfRkhqlcbuK7Y=", - "dev": true + "integrity": "sha1-AQ1YWEI6XxGJeWZfRkhqlcbuK7Y=" }, "es6-promisify": { "version": "5.0.0", @@ -6411,8 +6405,7 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, "fsevents": { "version": "1.1.3", @@ -7511,7 +7504,6 @@ "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, "requires": { "fs.realpath": "1.0.0", "inflight": "1.0.6", @@ -8627,8 +8619,7 @@ "immediate": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", - "integrity": "sha1-nbHb0Pr43m++D13V5Wu2BigN5ps=", - "dev": true + "integrity": "sha1-nbHb0Pr43m++D13V5Wu2BigN5ps=" }, "immutable": { "version": "3.7.6", @@ -8691,7 +8682,6 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, "requires": { "once": "1.4.0", "wrappy": "1.0.2" @@ -8700,8 +8690,7 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" }, "ini": { "version": "1.3.5", @@ -8989,8 +8978,7 @@ "interpret": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", - "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=", - "dev": true + "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=" }, "into-stream": { "version": "3.1.0", @@ -9424,8 +9412,7 @@ "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" }, "isexe": { "version": "2.0.0", @@ -9911,7 +9898,6 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", "integrity": "sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=", - "dev": true, "requires": { "immediate": "3.0.6" } @@ -10760,7 +10746,6 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, "requires": { "brace-expansion": "1.1.11" } @@ -11331,7 +11316,6 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, "requires": { "wrappy": "1.0.2" } @@ -11590,8 +11574,7 @@ "pako": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", - "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==", - "dev": true + "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==" }, "parallel-transform": { "version": "1.1.0", @@ -11645,6 +11628,52 @@ "no-case": "2.3.2" } }, + "paraviewweb": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/paraviewweb/-/paraviewweb-3.2.0.tgz", + "integrity": "sha512-97sAqYsDjEbdfwEyoh5sfrartJMThKPNzJH6WVQDDCs//BrUdSZNFPtvjgzBlRuT0V893kPTNyOjKAi912JHkw==", + "requires": { + "base64-js": "1.3.0", + "commander": "2.15.1", + "jszip": "3.1.5", + "pako": "1.0.6", + "shelljs": "0.8.2" + }, + "dependencies": { + "base64-js": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", + "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" + }, + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==" + }, + "jszip": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.1.5.tgz", + "integrity": "sha512-5W8NUaFRFRqTOL7ZDDrx5qWHJyBXy6velVudIzQUSoqAAYqzSh2Z7/m0Rf1QbmQJccegD0r+YZxBjzqoBiEeJQ==", + "requires": { + "core-js": "2.3.0", + "es6-promise": "3.0.2", + "lie": "3.1.1", + "pako": "1.0.6", + "readable-stream": "2.0.6" + } + }, + "shelljs": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.2.tgz", + "integrity": "sha512-pRXeNrCA2Wd9itwhvLp5LZQvPJ0wU6bcjaTMywHHGX5XWhVN2nzSu7WV0q+oUY7mGK3mgSkDDzP3MgjqdyIgbQ==", + "requires": { + "glob": "7.1.2", + "interpret": "1.1.0", + "rechoir": "0.6.2" + } + } + } + }, "parse-asn1": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", @@ -11740,8 +11769,7 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, "path-is-inside": { "version": "1.0.2", @@ -11758,8 +11786,7 @@ "path-parse": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", - "dev": true + "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=" }, "path-to-regexp": { "version": "0.1.7", @@ -14049,8 +14076,7 @@ "process-nextick-args": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" }, "progress": { "version": "2.0.0", @@ -14913,7 +14939,6 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "dev": true, "requires": { "core-util-is": "1.0.2", "inherits": "2.0.3", @@ -14965,7 +14990,6 @@ "version": "0.6.2", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true, "requires": { "resolve": "1.7.1" } @@ -15299,7 +15323,6 @@ "version": "1.7.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", - "dev": true, "requires": { "path-parse": "1.0.5" } @@ -16856,8 +16879,7 @@ "string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" }, "stringstream": { "version": "0.0.5", @@ -18043,8 +18065,7 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "util.promisify": { "version": "1.0.0", @@ -19318,8 +19339,7 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "write": { "version": "0.2.1", diff --git a/package.json b/package.json index 3477d33..ae040e5 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "markdown-pdf": "8.1.1", "@doe-casl/verain-view": "1.0.1", "antd": "2.13.11", + "paraviewweb": "^3.2.0", "react": "16.1.1", "react-dom": "16.1.1", "react-cursor-position": "2.4.1", diff --git a/rules/paraviewweb.js b/rules/paraviewweb.js new file mode 100644 index 0000000..c7b9780 --- /dev/null +++ b/rules/paraviewweb.js @@ -0,0 +1,21 @@ +module.exports = [ + { + test: /\.js$/, + include: /node_modules(\/|\\)paraviewweb(\/|\\)/, + use: [{ loader: 'babel-loader', options: { presets: ['env', 'react'] } }], + }, + { + test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, + use: [ + { + loader: 'url-loader', + options: { limit: 600000, mimetype: 'application/font-woff' }, + }, + ], + }, + { + test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, + use: [{ loader: 'url-loader', options: { limit: 600000 } }], + include: /fonts/, + }, +]; diff --git a/src/assets/vera.mcss b/src/assets/vera.mcss index ef72b05..6f94a8e 100644 --- a/src/assets/vera.mcss +++ b/src/assets/vera.mcss @@ -371,22 +371,3 @@ top: 10px; color: black; } - -.editableListTable { - width: 100%; -} - -.editableListAddBtn { - position: relative; - top: 15px; - height: 25px; - width: 25px; - border-radius: 50%; -} - -.editableListDelBtn { - margin-left: 5px; - height: 25px; - width: 25px; - border-radius: 50%; -} diff --git a/src/simput/CellEditor.js b/src/simput/CellEditor.js index f910d9b..26ebe2f 100644 --- a/src/simput/CellEditor.js +++ b/src/simput/CellEditor.js @@ -1,8 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; +import EditableList from 'paraviewweb/src/React/Widgets/EditableListWidget'; + import ViewerWidget from '../widgets/ViewerWidget'; -import EditableList from '../widgets/EditableList'; import ThreeDToolbar from '../widgets/ThreeDToolbar'; import VisibilityToolbar from '../widgets/VisibilityToolbar'; @@ -85,13 +86,12 @@ export default class CellEditor extends React.Component { } } - addRadius(afterIdx) { + addRadius(idx) { const { data } = this.props; const viz = this.props.ui.domain; const materialIds = Object.keys(viz.colors || {}); if (data.value && data.value.length && materialIds.length) { const cell = data.value[0]; - const idx = afterIdx + 1; const length = cell.mats.length; const pitch = this.props.viewData.cell.pitch.value[0]; @@ -111,13 +111,14 @@ export default class CellEditor extends React.Component { } } - deleteEntry(idx) { + deleteEntry(key) { const { data } = this.props; if (data.value && data.value.length) { const cell = data.value[0]; - cell.mats.splice(idx, 1); - cell.radii.splice(idx, 1); + // key is index (from the render() method) + cell.mats.splice(key, 1); + cell.radii.splice(key, 1); this.props.onChange(data); } diff --git a/src/simput/RodEditor.js b/src/simput/RodEditor.js index 2d78ce4..8751a8d 100644 --- a/src/simput/RodEditor.js +++ b/src/simput/RodEditor.js @@ -1,8 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; +import EditableList from 'paraviewweb/src/React/Widgets/EditableListWidget'; + import Rod2DPreview from '../widgets/Rod2DPreview'; -import EditableList from '../widgets/EditableList'; import ViewerWidget from '../widgets/ViewerWidget'; import ThreeDToolbar from '../widgets/ThreeDToolbar'; @@ -24,6 +25,7 @@ export default class RodEditor extends React.Component { this.onLengthChange = this.onLengthChange.bind(this); this.addLayer = this.addLayer.bind(this); this.delLayer = this.delLayer.bind(this); + this.moveLayer = this.moveLayer.bind(this); this.rodViewer = vtkRodVTKViewer.newInstance(); } @@ -66,11 +68,22 @@ export default class RodEditor extends React.Component { } } - delLayer(idx) { + delLayer(key) { + const data = this.props.data; + if (data.value && data.value.length) { + const stack = data.value[0].stack; + // key is index (from the render() method) + stack.splice(key, 1); + + this.props.onChange(data); + } + } + + moveLayer(srcIdx, dstIdx) { const data = this.props.data; if (data.value && data.value.length) { const stack = data.value[0].stack; - stack.splice(idx, 1); + stack.splice(dstIdx, 0, ...stack.splice(srcIdx, 1)); this.props.onChange(data); } @@ -203,10 +216,12 @@ export default class RodEditor extends React.Component { ); diff --git a/src/widgets/EditableList.js b/src/widgets/EditableList.js deleted file mode 100644 index eea61d4..0000000 --- a/src/widgets/EditableList.js +++ /dev/null @@ -1,94 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import style from '../assets/vera.mcss'; - -function EditableList(props) { - const { columns, data, onAdd, onDelete } = props; - - const header = columns.map((col) => {col.label}); - - const rows = data.map((datum, idx) => { - const cells = columns.map((col) => { - const value = datum[col.dataKey]; - const content = col.render ? col.render(value, datum) : value; - - const cellKey = `${col.dataKey}::${datum.key}`; - - return ( - - {content} - - ); - }); - - return ( - - - - - {cells} - - - - - ); - }); - - return ( - - - - - - - {rows.length ? ( - rows - ) : ( - - - - - )} - -
- {header} - -
- - {props.addFirstRowText}
- ); -} - -EditableList.propTypes = { - columns: PropTypes.array, - data: PropTypes.array, - onAdd: PropTypes.func, - onDelete: PropTypes.func, - addFirstRowText: PropTypes.string, -}; - -EditableList.defaultProps = { - columns: [], - data: [], - onAdd: () => {}, - onDelete: () => {}, - addFirstRowText: 'Add new item', -}; - -export default EditableList; diff --git a/webpack.simput.config.js b/webpack.simput.config.js index cd23c24..6ec6f58 100644 --- a/webpack.simput.config.js +++ b/webpack.simput.config.js @@ -3,6 +3,7 @@ const path = require('path'); const linterRules = require('./rules/linter.js'); const veraRules = require('./rules/vera.js'); const vtkRules = require('./rules/vtkjs.js'); +const pvwRules = require('./rules/paraviewweb.js'); const plugins = []; const simput = path.join(__dirname, './src/simput/index.js'); @@ -22,10 +23,14 @@ module.exports = { rules: [].concat( linterRules, veraRules, - vtkRules + vtkRules, + pvwRules ), }, resolve: { + alias: { + PVWStyle: path.resolve('./node_modules/paraviewweb/style'), + }, modules: [path.resolve(__dirname, 'node_modules'), sourcePath], }, externals: {