From c066ced7ab180a43799f024c3e92dc13ee60947a Mon Sep 17 00:00:00 2001 From: libremente Date: Thu, 17 Jan 2019 17:07:48 +0100 Subject: [PATCH 1/5] fix: removed editor from this repo The publiccode.yml editor has been moved to another repo. The `editor` folder has been removed from this repo accordingly. --- editor/.babelrc | 4 - editor/.eslintrc | 29 - editor/.gitignore | 14 - editor/CNAME | 1 - editor/LICENSE | 116 - editor/README.md | 23 - editor/package.json | 85 - editor/postcss.config.js | 5 - editor/src/app/app.js | 26 - editor/src/app/components/Info.js | 65 - editor/src/app/components/InfoBox.js | 57 - editor/src/app/components/_layout.js | 50 - editor/src/app/components/countrySwitcher.js | 38 - editor/src/app/components/display.js | 62 - editor/src/app/components/editor.js | 409 - editor/src/app/components/editorForm.js | 137 - editor/src/app/components/foot.js | 56 - editor/src/app/components/head.js | 73 - editor/src/app/components/index.js | 263 - editor/src/app/components/languageSwitcher.js | 72 - editor/src/app/components/sidebar.js | 263 - editor/src/app/contents/constants.js | 5 - editor/src/app/contents/data.js | 112 - editor/src/app/contents/fields/generic.js | 602 - editor/src/app/contents/fields/index.js | 120 - editor/src/app/contents/fields/it.js | 160 - editor/src/app/contents/fields/uk.js | 26 - editor/src/app/contents/fields/us.js | 13 - editor/src/app/contents/langs.js | 511 - editor/src/app/contents/sample.js | 219 - editor/src/app/contents/tags.js | 96 - editor/src/app/editor_generator_schema.json | 587 - editor/src/app/form/buildSyncValidation.js | 86 - editor/src/app/form/compileSchema.js | 44 - editor/src/app/form/index.js | 53 - editor/src/app/form/processSubmitErrors.js | 40 - editor/src/app/form/renderField.js | 63 - editor/src/app/form/renderFields.js | 49 - editor/src/app/form/widgets/ArrayWidget.js | 137 - .../src/app/form/widgets/BaseInputWidget.js | 74 - editor/src/app/form/widgets/CheckboxWidget.js | 63 - .../app/form/widgets/ChoiceExpandedWidget.js | 71 - .../widgets/ChoiceMultipleExpandedWidget.js | 90 - editor/src/app/form/widgets/ChoiceWidget.js | 88 - editor/src/app/form/widgets/ColorWidget.js | 10 - .../form/widgets/CompatibleDateTimeWidget.js | 191 - .../app/form/widgets/CompatibleDateWidget.js | 143 - editor/src/app/form/widgets/DateSelector.js | 29 - editor/src/app/form/widgets/DateTimeWidget.js | 8 - editor/src/app/form/widgets/DateWidget.js | 8 - editor/src/app/form/widgets/EditorWidget.js | 120 - editor/src/app/form/widgets/EmailWidget.js | 8 - editor/src/app/form/widgets/FileWidget.js | 62 - editor/src/app/form/widgets/MoneyWidget.js | 61 - editor/src/app/form/widgets/NumberWidget.js | 8 - editor/src/app/form/widgets/ObjectWidget.js | 39 - .../app/form/widgets/OriginalArrayWidget.js | 147 - editor/src/app/form/widgets/PasswordWidget.js | 8 - editor/src/app/form/widgets/PercentWidget.js | 61 - editor/src/app/form/widgets/SearchWidget.js | 8 - editor/src/app/form/widgets/StringWidget.js | 8 - editor/src/app/form/widgets/TagWidget.js | 60 - editor/src/app/form/widgets/TextareaWidget.js | 56 - editor/src/app/form/widgets/TimeWidget.js | 8 - editor/src/app/form/widgets/UrlWidget.js | 8 - editor/src/app/form/widgets/index.js | 54 - .../src/app/form/widgets/oneOfChoiceWidget.js | 82 - editor/src/app/store/cache.js | 39 - editor/src/app/store/data.js | 43 - editor/src/app/store/index.js | 21 - editor/src/app/store/infobox.js | 30 - editor/src/app/store/notifications.js | 26 - editor/src/app/utils/calls.js | 14 - editor/src/app/utils/transform.js | 223 - editor/src/app/utils/validate.js | 187 - editor/src/app/yaml_validation_schema.json | 5650 ------- editor/src/asset/accordion.scss | 108 - editor/src/asset/block.scss | 89 - editor/src/asset/bs_override.scss | 100 - editor/src/asset/bsi.scss | 13604 ---------------- editor/src/asset/content.scss | 100 - editor/src/asset/editor_buttons.scss | 136 - editor/src/asset/editor_widget.scss | 24 - .../glyphicons-halflings-regular.eot | Bin 20127 -> 0 bytes .../glyphicons-halflings-regular.svg | 288 - .../glyphicons-halflings-regular.ttf | Bin 45404 -> 0 bytes .../glyphicons-halflings-regular.woff | Bin 23424 -> 0 bytes .../glyphicons-halflings-regular.woff2 | Bin 18028 -> 0 bytes editor/src/asset/glyphicons/glyphicons.css | 809 - editor/src/asset/img/_copy.svg | 1 - editor/src/asset/img/_download.svg | 1 - editor/src/asset/img/_load.svg | 22 - editor/src/asset/img/accordion-closed.svg | 12 - editor/src/asset/img/accordion-open.svg | 14 - editor/src/asset/img/checkbox-nonselected.svg | 25 - editor/src/asset/img/checkbox-selected.svg | 28 - editor/src/asset/img/checkbox.svg | 14 - editor/src/asset/img/close.svg | 7 - editor/src/asset/img/copy.svg | 1 - editor/src/asset/img/dots.svg | 32 - editor/src/asset/img/download.svg | 1 - editor/src/asset/img/load.svg | 1 - editor/src/asset/img/option-nonselected.svg | 25 - editor/src/asset/img/option-selected.svg | 25 - editor/src/asset/img/upload.svg | 1 - editor/src/asset/img/x.svg | 6 - editor/src/asset/img/xx.svg | 1 - editor/src/asset/info_box.scss | 55 - editor/src/asset/language_switcher.scss | 91 - editor/src/asset/notify.scss | 48 - editor/src/asset/sidebar.scss | 170 - editor/src/asset/snackbar.scss | 22 - editor/src/asset/style.scss | 32 - editor/src/asset/system_font.scss | 22 - editor/src/asset/toolbar.scss | 12 - editor/src/asset/transitions.scss | 22 - editor/src/asset/wrapper.scss | 17 - editor/src/index.html | 11 - editor/webpack.config.js | 78 - editor/yarn.lock | 8052 --------- 120 files changed, 36684 deletions(-) delete mode 100755 editor/.babelrc delete mode 100644 editor/.eslintrc delete mode 100644 editor/.gitignore delete mode 100644 editor/CNAME delete mode 100644 editor/LICENSE delete mode 100644 editor/README.md delete mode 100644 editor/package.json delete mode 100644 editor/postcss.config.js delete mode 100644 editor/src/app/app.js delete mode 100644 editor/src/app/components/Info.js delete mode 100644 editor/src/app/components/InfoBox.js delete mode 100644 editor/src/app/components/_layout.js delete mode 100644 editor/src/app/components/countrySwitcher.js delete mode 100644 editor/src/app/components/display.js delete mode 100644 editor/src/app/components/editor.js delete mode 100644 editor/src/app/components/editorForm.js delete mode 100644 editor/src/app/components/foot.js delete mode 100644 editor/src/app/components/head.js delete mode 100644 editor/src/app/components/index.js delete mode 100644 editor/src/app/components/languageSwitcher.js delete mode 100644 editor/src/app/components/sidebar.js delete mode 100644 editor/src/app/contents/constants.js delete mode 100644 editor/src/app/contents/data.js delete mode 100644 editor/src/app/contents/fields/generic.js delete mode 100644 editor/src/app/contents/fields/index.js delete mode 100644 editor/src/app/contents/fields/it.js delete mode 100644 editor/src/app/contents/fields/uk.js delete mode 100644 editor/src/app/contents/fields/us.js delete mode 100644 editor/src/app/contents/langs.js delete mode 100644 editor/src/app/contents/sample.js delete mode 100644 editor/src/app/contents/tags.js delete mode 100644 editor/src/app/editor_generator_schema.json delete mode 100644 editor/src/app/form/buildSyncValidation.js delete mode 100644 editor/src/app/form/compileSchema.js delete mode 100644 editor/src/app/form/index.js delete mode 100644 editor/src/app/form/processSubmitErrors.js delete mode 100644 editor/src/app/form/renderField.js delete mode 100644 editor/src/app/form/renderFields.js delete mode 100644 editor/src/app/form/widgets/ArrayWidget.js delete mode 100644 editor/src/app/form/widgets/BaseInputWidget.js delete mode 100644 editor/src/app/form/widgets/CheckboxWidget.js delete mode 100644 editor/src/app/form/widgets/ChoiceExpandedWidget.js delete mode 100644 editor/src/app/form/widgets/ChoiceMultipleExpandedWidget.js delete mode 100644 editor/src/app/form/widgets/ChoiceWidget.js delete mode 100644 editor/src/app/form/widgets/ColorWidget.js delete mode 100644 editor/src/app/form/widgets/CompatibleDateTimeWidget.js delete mode 100644 editor/src/app/form/widgets/CompatibleDateWidget.js delete mode 100644 editor/src/app/form/widgets/DateSelector.js delete mode 100644 editor/src/app/form/widgets/DateTimeWidget.js delete mode 100644 editor/src/app/form/widgets/DateWidget.js delete mode 100644 editor/src/app/form/widgets/EditorWidget.js delete mode 100644 editor/src/app/form/widgets/EmailWidget.js delete mode 100644 editor/src/app/form/widgets/FileWidget.js delete mode 100644 editor/src/app/form/widgets/MoneyWidget.js delete mode 100644 editor/src/app/form/widgets/NumberWidget.js delete mode 100644 editor/src/app/form/widgets/ObjectWidget.js delete mode 100644 editor/src/app/form/widgets/OriginalArrayWidget.js delete mode 100644 editor/src/app/form/widgets/PasswordWidget.js delete mode 100644 editor/src/app/form/widgets/PercentWidget.js delete mode 100644 editor/src/app/form/widgets/SearchWidget.js delete mode 100644 editor/src/app/form/widgets/StringWidget.js delete mode 100644 editor/src/app/form/widgets/TagWidget.js delete mode 100644 editor/src/app/form/widgets/TextareaWidget.js delete mode 100644 editor/src/app/form/widgets/TimeWidget.js delete mode 100644 editor/src/app/form/widgets/UrlWidget.js delete mode 100644 editor/src/app/form/widgets/index.js delete mode 100644 editor/src/app/form/widgets/oneOfChoiceWidget.js delete mode 100644 editor/src/app/store/cache.js delete mode 100644 editor/src/app/store/data.js delete mode 100644 editor/src/app/store/index.js delete mode 100644 editor/src/app/store/infobox.js delete mode 100644 editor/src/app/store/notifications.js delete mode 100644 editor/src/app/utils/calls.js delete mode 100644 editor/src/app/utils/transform.js delete mode 100644 editor/src/app/utils/validate.js delete mode 100644 editor/src/app/yaml_validation_schema.json delete mode 100644 editor/src/asset/accordion.scss delete mode 100644 editor/src/asset/block.scss delete mode 100644 editor/src/asset/bs_override.scss delete mode 100644 editor/src/asset/bsi.scss delete mode 100644 editor/src/asset/content.scss delete mode 100644 editor/src/asset/editor_buttons.scss delete mode 100644 editor/src/asset/editor_widget.scss delete mode 100644 editor/src/asset/glyphicons/glyphicons-halflings-regular.eot delete mode 100644 editor/src/asset/glyphicons/glyphicons-halflings-regular.svg delete mode 100644 editor/src/asset/glyphicons/glyphicons-halflings-regular.ttf delete mode 100644 editor/src/asset/glyphicons/glyphicons-halflings-regular.woff delete mode 100644 editor/src/asset/glyphicons/glyphicons-halflings-regular.woff2 delete mode 100644 editor/src/asset/glyphicons/glyphicons.css delete mode 100644 editor/src/asset/img/_copy.svg delete mode 100644 editor/src/asset/img/_download.svg delete mode 100644 editor/src/asset/img/_load.svg delete mode 100644 editor/src/asset/img/accordion-closed.svg delete mode 100644 editor/src/asset/img/accordion-open.svg delete mode 100644 editor/src/asset/img/checkbox-nonselected.svg delete mode 100644 editor/src/asset/img/checkbox-selected.svg delete mode 100644 editor/src/asset/img/checkbox.svg delete mode 100644 editor/src/asset/img/close.svg delete mode 100644 editor/src/asset/img/copy.svg delete mode 100644 editor/src/asset/img/dots.svg delete mode 100644 editor/src/asset/img/download.svg delete mode 100644 editor/src/asset/img/load.svg delete mode 100644 editor/src/asset/img/option-nonselected.svg delete mode 100644 editor/src/asset/img/option-selected.svg delete mode 100644 editor/src/asset/img/upload.svg delete mode 100644 editor/src/asset/img/x.svg delete mode 100644 editor/src/asset/img/xx.svg delete mode 100644 editor/src/asset/info_box.scss delete mode 100644 editor/src/asset/language_switcher.scss delete mode 100644 editor/src/asset/notify.scss delete mode 100644 editor/src/asset/sidebar.scss delete mode 100644 editor/src/asset/snackbar.scss delete mode 100644 editor/src/asset/style.scss delete mode 100644 editor/src/asset/system_font.scss delete mode 100644 editor/src/asset/toolbar.scss delete mode 100644 editor/src/asset/transitions.scss delete mode 100644 editor/src/asset/wrapper.scss delete mode 100644 editor/src/index.html delete mode 100644 editor/webpack.config.js delete mode 100644 editor/yarn.lock diff --git a/editor/.babelrc b/editor/.babelrc deleted file mode 100755 index 16b5a89c..00000000 --- a/editor/.babelrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "presets": ["env", "react", "stage-3"], - "plugins": ["transform-async-to-generator", "transform-runtime", "transform-decorators-legacy"] -} diff --git a/editor/.eslintrc b/editor/.eslintrc deleted file mode 100644 index 9df3578c..00000000 --- a/editor/.eslintrc +++ /dev/null @@ -1,29 +0,0 @@ -{ - "root": true, - "extends": ["eslint:recommended", "plugin:react/recommended"], - "plugins": ["react"], - "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module", - "ecmaFeatures": { - "jsx": true - } - }, - "env": { - "es6": true, - "browser": true, - "commonjs": true, - "node": true - }, - "parser": "babel-eslint", - "rules": { - "react/jsx-uses-react": "error", - "react/jsx-uses-vars": "error", - "react/prop-types": "off", - "react/no-find-dom-node": "off", - "react/no-string-refs": "off", - "strict": 0, - "no-console": "off", - "no-unused-vars":1 - } -} diff --git a/editor/.gitignore b/editor/.gitignore deleted file mode 100644 index f4b69a16..00000000 --- a/editor/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -.DS_Store -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -node_modules - -build -dist - -.env -.serverless -.eslintcache diff --git a/editor/CNAME b/editor/CNAME deleted file mode 100644 index 13b0ecb5..00000000 --- a/editor/CNAME +++ /dev/null @@ -1 +0,0 @@ -http://publiccode.surge.sh/ diff --git a/editor/LICENSE b/editor/LICENSE deleted file mode 100644 index 670154e3..00000000 --- a/editor/LICENSE +++ /dev/null @@ -1,116 +0,0 @@ -CC0 1.0 Universal - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator and -subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for the -purpose of contributing to a commons of creative, cultural and scientific -works ("Commons") that the public can reliably and without fear of later -claims of infringement build upon, modify, incorporate in other works, reuse -and redistribute as freely as possible in any form whatsoever and for any -purposes, including without limitation commercial purposes. These owners may -contribute to the Commons to promote the ideal of a free culture and the -further production of creative, cultural and scientific works, or to gain -reputation or greater distribution for their Work in part through the use and -efforts of others. - -For these and/or other purposes and motivations, and without any expectation -of additional consideration or compensation, the person associating CC0 with a -Work (the "Affirmer"), to the extent that he or she is an owner of Copyright -and Related Rights in the Work, voluntarily elects to apply CC0 to the Work -and publicly distribute the Work under its terms, with knowledge of his or her -Copyright and Related Rights in the Work and the meaning and intended legal -effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not limited -to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, communicate, - and translate a Work; - - ii. moral rights retained by the original author(s) and/or performer(s); - - iii. publicity and privacy rights pertaining to a person's image or likeness - depicted in a Work; - - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - - v. rights protecting the extraction, dissemination, use and reuse of data in - a Work; - - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation thereof, - including any amended or successor version of such directive); and - - vii. other similar, equivalent or corresponding rights throughout the world - based on applicable law or treaty, and any national implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention of, -applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and -unconditionally waives, abandons, and surrenders all of Affirmer's Copyright -and Related Rights and associated claims and causes of action, whether now -known or unknown (including existing as well as future claims and causes of -action), in the Work (i) in all territories worldwide, (ii) for the maximum -duration provided by applicable law or treaty (including future time -extensions), (iii) in any current or future medium and for any number of -copies, and (iv) for any purpose whatsoever, including without limitation -commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes -the Waiver for the benefit of each member of the public at large and to the -detriment of Affirmer's heirs and successors, fully intending that such Waiver -shall not be subject to revocation, rescission, cancellation, termination, or -any other legal or equitable action to disrupt the quiet enjoyment of the Work -by the public as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason be -judged legally invalid or ineffective under applicable law, then the Waiver -shall be preserved to the maximum extent permitted taking into account -Affirmer's express Statement of Purpose. In addition, to the extent the Waiver -is so judged Affirmer hereby grants to each affected person a royalty-free, -non transferable, non sublicensable, non exclusive, irrevocable and -unconditional license to exercise Affirmer's Copyright and Related Rights in -the Work (i) in all territories worldwide, (ii) for the maximum duration -provided by applicable law or treaty (including future time extensions), (iii) -in any current or future medium and for any number of copies, and (iv) for any -purpose whatsoever, including without limitation commercial, advertising or -promotional purposes (the "License"). The License shall be deemed effective as -of the date CC0 was applied by Affirmer to the Work. Should any part of the -License for any reason be judged legally invalid or ineffective under -applicable law, such partial invalidity or ineffectiveness shall not -invalidate the remainder of the License, and in such case Affirmer hereby -affirms that he or she will not (i) exercise any of his or her remaining -Copyright and Related Rights in the Work or (ii) assert any associated claims -and causes of action with respect to the Work, in either case contrary to -Affirmer's express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - - b. Affirmer offers the Work as-is and makes no representations or warranties - of any kind concerning the Work, express, implied, statutory or otherwise, - including without limitation warranties of title, merchantability, fitness - for a particular purpose, non infringement, or the absence of latent or - other defects, accuracy, or the present or absence of errors, whether or not - discoverable, all to the greatest extent permissible under applicable law. - - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without limitation - any person's Copyright and Related Rights in the Work. Further, Affirmer - disclaims responsibility for obtaining any necessary consents, permissions - or other rights required for any use of the Work. - - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to this - CC0 or use of the Work. - -For more information, please see - diff --git a/editor/README.md b/editor/README.md deleted file mode 100644 index 96ce52e2..00000000 --- a/editor/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# PUBLICCODE.YML EDITOR - -Scope of this project is to provide an interface to easily generate a well-done (formatted and validated) file publiccode.yml - -#### SETUP - -You will need [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/lang/en/) command installed to setup this web app. - -First clone or download the repository, - -then from a shell run - -``` -cd editor -yarn install //or npm install -yarn dev //or npm run dev -``` - -Last command is to run the app locally . - -#### PREVIEW - -You can preview this app on [https://publiccode.surge.sh](https://publiccode.surge.sh) diff --git a/editor/package.json b/editor/package.json deleted file mode 100644 index f2afe958..00000000 --- a/editor/package.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "name": "publiccode-editor", - "version": "0.0.1", - "license": "CC0 1.0 Universal", - "description": "[License](./LICENSE)", - "scripts": { - "dev": "webpack-dev-server --port 3000", - "build": "webpack", - "test": "jest --watch" - }, - "keywords": [ - "publiccode", - "editor" - ], - "author": "Lorenzo Ponticelli ", - "devDependencies": { - "autoprefixer": "^7.1.6", - "babel-core": "^6.26.0", - "babel-eslint": "^8.0.3", - "babel-jest": "^23.0.1", - "babel-loader": "^7.1.2", - "babel-plugin-transform-async-to-generator": "^6.24.1", - "babel-plugin-transform-decorators": "^6.24.1", - "babel-plugin-transform-decorators-legacy": "^1.3.4", - "babel-plugin-transform-runtime": "^6.23.0", - "babel-preset-env": "^1.6.0", - "babel-preset-react": "^6.24.1", - "babel-preset-stage-3": "^6.24.1", - "babel-runtime": "^6.26.0", - "css-loader": "^0.28.7", - "enzyme": "^3.3.0", - "eslint": "^4.13.1", - "eslint-loader": "^1.9.0", - "eslint-plugin-react": "^7.5.1", - "extract-text-webpack-plugin": "^3.0.1", - "file-loader": "^1.1.5", - "html-webpack-plugin": "^2.30.1", - "import-glob-loader": "^1.1.0", - "jest": "^23.1.0", - "node-sass": "^4.8.3", - "nodemon": "^1.17.5", - "postcss-loader": "^2.0.8", - "react-addons-test-utils": "^15.6.2", - "react-test-renderer": "^16.4.0", - "sass-loader": "^7.0.1", - "style-loader": "^0.21.0", - "url-loader": "^1.0.1", - "webpack": "^3.6.0", - "webpack-dev-server": "^2.9.1", - "yaml-validator": "^1.3.0" - }, - "dependencies": { - "ajv": "^6.5.2", - "bootstrap": "^4.1.1", - "classnames": "^2.2.6", - "clean-deep": "^3.0.2", - "copy-to-clipboard": "^3.0.8", - "deepmerge": "^2.1.1", - "dotenv": "^6.0.0", - "draft-js": "^0.10.5", - "immutable": "^3.8.2", - "isomorphic-fetch": "^2.2.1", - "jquery": "^3.3.1", - "js-yaml": "^3.11.0", - "lodash": "^4.17.10", - "moment": "^2.22.1", - "popper.js": "^1.14.3", - "prop-type": "^0.0.1", - "rc-collapse": "^1.9.3", - "react": "^16.4.0", - "react-collapsible": "^2.2.0", - "react-dom": "^16.4.0", - "react-draft-wysiwyg": "^1.12.13", - "react-notify": "^3.0.0", - "react-redux": "^5.0.7", - "react-rte": "^0.16.1", - "react-widgets": "^4.2.6", - "redux": "^4.0.0", - "redux-actions": "^2.4.0", - "redux-form": "^7.4.2", - "slugify": "^1.3.0", - "updeep": "^1.0.0", - "validator": "^10.4.0" - } -} diff --git a/editor/postcss.config.js b/editor/postcss.config.js deleted file mode 100644 index 88752c6c..00000000 --- a/editor/postcss.config.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - plugins: [ - require('autoprefixer') - ] -} diff --git a/editor/src/app/app.js b/editor/src/app/app.js deleted file mode 100644 index fa14a925..00000000 --- a/editor/src/app/app.js +++ /dev/null @@ -1,26 +0,0 @@ -import React, { Component } from "react"; -import { render } from "react-dom"; -import store from "./store/index"; -import { Provider } from "react-redux"; -import Layout from "./components/_layout"; -// import Index from "./components/index"; -import Index from "./components/editor"; - -import "bootstrap"; -import $ from "jquery"; -window.jQuery = $; -window.$ = $; - -export default class App extends Component { - render() { - return ( - - - - - - ); - } -} - -render(, document.getElementById("app")); diff --git a/editor/src/app/components/Info.js b/editor/src/app/components/Info.js deleted file mode 100644 index afff133b..00000000 --- a/editor/src/app/components/Info.js +++ /dev/null @@ -1,65 +0,0 @@ -import React, { Component } from "react"; -import { connect } from "react-redux"; -import { show } from "../store/infobox"; - -const ReadMore = props => { - if (!props.description) return null; - let partial = ellipsis(props.description); - return {partial}; -}; - -const ellipsis = descr => { - let partial = descr; - if (descr.length > MAX_LEN) { - partial = descr.substring(0, MAX_LEN - 1) + "..."; - } - return partial; -}; - -const MAX_LEN = 100; - -const mapStateToProps = state => { - return {}; -}; - -const mapDispatchToProps = dispatch => { - return { - show: data => dispatch(show(data)) - }; -}; - -@connect( - mapStateToProps, - mapDispatchToProps -) -export default class InfoBox extends Component { - constructor(props) { - super(props); - } - render() { - if (!(this.props.title || this.props.description)) return null; - let { title, description } = this.props; - let partial = ellipsis(description); - return ( -
- - {partial} - {description.length > MAX_LEN && ( - - { - console.log("CLICK", description); - this.props.show({ title, description }); - }} - > - Read more - - - )} - -
- ); - } -} diff --git a/editor/src/app/components/InfoBox.js b/editor/src/app/components/InfoBox.js deleted file mode 100644 index 853990c3..00000000 --- a/editor/src/app/components/InfoBox.js +++ /dev/null @@ -1,57 +0,0 @@ -import React, { Component } from "react"; -import { connect } from "react-redux"; -import { show, hide } from "../store/infobox"; -import classNames from "classnames"; -import img_close from "../../asset/img/close.svg"; - -const mapStateToProps = state => { - return { - infobox: state.infobox - }; -}; - -const mapDispatchToProps = dispatch => { - return { - show: data => dispatch(show(data)), - hide: () => dispatch(hide()) - }; -}; - -@connect( - mapStateToProps, - mapDispatchToProps -) -export default class InfoBox extends Component { - constructor(props) { - super(props); - } - render() { - const { title, description, visible } = this.props.infobox; - const className = classNames([ - "info__box", - { info__box__visible: visible } - ]); - - console.log("CLASSNAME", className); - return ( -
-
- - -
-

{title}

-

{description}

-
-
-
- ); - } -} diff --git a/editor/src/app/components/_layout.js b/editor/src/app/components/_layout.js deleted file mode 100644 index a5d5f45c..00000000 --- a/editor/src/app/components/_layout.js +++ /dev/null @@ -1,50 +0,0 @@ -import React, { Component } from "react"; -import "../../asset/style.scss"; -import 'react-widgets/dist/css/react-widgets.css'; -import ReactNotify from "react-notify"; -import { connect } from "react-redux"; - -@connect(state => { - return { - notifications: state.notifications - }; -}) -export default class Layout extends Component { - componentWillReceiveProps(nextProps) { - if ( - nextProps.notifications && - nextProps.notifications != this.props.notifications && - nextProps.notifications.item - ) { - let n = nextProps.notifications.item; - let { type, title, msg, millis } = n; - if (type == "success") { - this.refs.notificator.success( - title ? title : "", - msg, - millis ? millis : 2000 - ); - } else if (type == "info") { - this.refs.notificator.info( - title ? title : "", - msg, - millis ? millis : 2000 - ); - } else { - this.refs.notificator.error( - title ? title : "", - msg, - millis ? millis : 3000 - ); - } - } - } - render() { - return ( -
- - {this.props.children} -
- ); - } -} diff --git a/editor/src/app/components/countrySwitcher.js b/editor/src/app/components/countrySwitcher.js deleted file mode 100644 index 7b43ef44..00000000 --- a/editor/src/app/components/countrySwitcher.js +++ /dev/null @@ -1,38 +0,0 @@ -import React, { Component } from "react"; -import { AVAILABLE_COUNTRIES } from "../contents/data"; - -const countrySwitcher = props => { - let { country } = props; - return ( -
-
- -
-
- {AVAILABLE_COUNTRIES && - AVAILABLE_COUNTRIES.map(c => ( - props.switchCountry(c)} - > - {c} - - ))} -
-
-
-
- ); -}; - -export default countrySwitcher; diff --git a/editor/src/app/components/display.js b/editor/src/app/components/display.js deleted file mode 100644 index 733ad2f0..00000000 --- a/editor/src/app/components/display.js +++ /dev/null @@ -1,62 +0,0 @@ -import React, { Component } from "react"; -import { connect } from "react-redux"; -import _ from "lodash"; -function mapStateToProps(state) { - return { - form: state.form - }; -} - -function mapDispatchToProps(dispatch) { - return {}; -} - -@connect( - mapStateToProps, - mapDispatchToProps -) -export default class Display extends Component { - constructor(props) { - super(props); - } - - render() { - if (!(this.props.form && this.props.form.appForm)) return null; - try { - let { appForm } = this.props.form; - let anyTouched = appForm.anyTouched ? appForm.anyTouched : false; - let errorsObj = appForm.syncErrors ? appForm.syncErrors : null; - let errors = null; - console.log(errorsObj); - if (anyTouched && errorsObj) { - errors = Object.keys(errorsObj).map((k, i) => { - try { - let val = errorsObj[k]; - // console.log(k, val); - let msg = val; - if (_.isArray(val)) { - // console.log("ARRAY"); - msg = "multiple errors"; - } else if (_.isObject(val)) { - // console.log("OBJ"); - if (val._error) msg = val._error; - else msg = "multiple errors"; - } - return ( -
- {k} : {msg} -
- ); - } catch (e) { - console.log("skipped error", e); - return null; - } - }); - } - return
{errors}
; - } catch (e) { - console.log(" error", e); - return null; - } - } -} diff --git a/editor/src/app/components/editor.js b/editor/src/app/components/editor.js deleted file mode 100644 index 9fda1987..00000000 --- a/editor/src/app/components/editor.js +++ /dev/null @@ -1,409 +0,0 @@ -import React, { Component, Fragment } from "react"; -import { connect } from "react-redux"; -import { reduxForm } from "redux-form"; -import { initialize, submit } from "redux-form"; -import { notify, clearNotifications } from "../store/notifications"; -import { saveYaml, setVersions } from "../store/cache"; -import { APP_FORM, yamlData, versionsUrl } from "../contents/constants"; -import { - getData, - SUMMARY, - GROUPS, - AVAILABLE_COUNTRIES -} from "../contents/data"; -import jsyaml from "../../../node_modules/js-yaml/dist/js-yaml.js"; - -import _ from "lodash"; -import u from "updeep"; -import moment from "moment"; - -import cleanDeep from "clean-deep"; - -import Head from "./head"; -import Foot from "./foot"; -import EditorForm from "./editorForm"; -import InfoBox from "./InfoBox"; - -import LanguageSwitcher from "./languageSwitcher"; -import Sidebar from "./sidebar"; - -import * as ft from "../utils/transform"; -import * as fv from "../utils/validate"; - -const mapStateToProps = state => { - return { - notifications: state.notifications, - cache: state.cache, - form: state.form - }; -}; - -const mapDispatchToProps = dispatch => { - return { - initialize: (name, data) => dispatch(initialize(name, data)), - submit: name => dispatch(submit(name)), - notify: data => dispatch(notify(data)), - setVersions: data => dispatch(setVersions(data)) - }; -}; - -@connect( - mapStateToProps, - mapDispatchToProps -) -export default class Index extends Component { - constructor(props) { - super(props); - this.state = { - search: null, - yaml: null, - loading: false, - languages: [], - values: {}, - currentValues: {}, - currentLanguage: null, - country: null, - blocks: null, - elements: null, - activeSection: 0, - allFields: null, - lastGen: null - }; - } - - initBootstrap() { - // $('[data-toggle="tooltip"]').tooltip(); - // $('[data-toggle="popover"]').popover(); - // $('[data-toggle="collapse"]').collapse(); - $('[data-toggle="dropdown"]').dropdown(); - } - - async componentDidMount() { - await this.initData(); - this.switchLang("eng"); - this.switchCountry("it"); - } - - async initData(country = null) { - //has state - console.log("initData"); - let { elements, blocks, allFields } = await getData(country); - this.setState({ elements, blocks, country, allFields }); - this.initBootstrap(); - } - - parseYml(yaml) { - //HAS STATE - this.setState({ loading: true }); - let obj = null; - try { - obj = jsyaml.load(yaml); - // let errors = fv.validatePubliccodeYml(obj); - // if (errors) alert(errors); - } catch (e) { - alert("Error loading yaml"); - return; - } - if (!obj) { - alert("Error loading yaml"); - return; - } - //TODO VALIDATE WITH SCHEMA - let { languages, values, country } = ft.transformBack(obj); - - let currentValues = null; - let currentLanguage = languages ? languages[0] : null; - if (currentLanguage) currentValues = values[currentLanguage]; - - //UPDATE STATE - this.setState({ - yaml, - languages, - values, - country, - loading: false - }); - - //RESET FORM - this.switchLang(currentLanguage); - if (country) this.switchCountry(country); - } - - generate(formValues) { - let lastGen = moment(); - this.setState({ loading: true, lastGen }); - //has state - let { values, currentLanguage, country } = this.state; - //values[currentLanguage] = formValues; - let obj = ft.transform(values, country); - - // let errors = await fv.validatePubliccodeYml(obj); - // if (errors) alert(errors); - - //SET TIMESTAMP - this.showResults(obj); - //this.showResults(obj); - } - - showResults(values) { - //has state - try { - let yaml = jsyaml.dump(values); - this.setState({ yaml, loading: false }); - } catch (e) { - console.error(e); - } - } - - submitFeedback() { - //has state - const title = ""; - const millis = 3000; - const { form } = this.props; - let { yaml } = this.state; - let type = "success"; - let msg = "Success"; - if (form[APP_FORM].syncErrors) { - type = "error"; - msg = "There are some errors"; - yaml = null; - } - - this.props.notify({ type, title, msg, millis }); - //this.scrollToError(errors) - this.setState({ yaml }); - } - - fakeLoading() { - //has state - setTimeout(() => { - this.setState({ loading: false }); - }, 1000); - } - - validate(contents) { - //has state - let errors = {}; - let { values, currentLanguage, elements } = this.state; - - //CHECK REQUIRED FIELDS - let required = fv.validateRequired(contents, elements); - //VALIDATE TYPES AND SUBOBJECT - let objs_n_arrays = fv.validateSubTypes(contents, elements); - errors = Object.assign(required, objs_n_arrays); - // console.log(errors); - - //UPDATE STATE - values[currentLanguage] = contents; - this.setState({ - currentValues: contents, - values, - loading: true, - error: null - }); - this.fakeLoading(); - return errors; - } - - async reset() { - //has state - this.props.initialize(APP_FORM, null); - this.setState({ - search: null, - yaml: null, - loading: false, - languages: [], - values: {}, - currentValues: {}, - currentLanguage: null, - country: null, - error: null, - blocks: null, - elements: null, - collapse: false, - activeSection: null - }); - this.props.notify({ type: "info", msg: "Reset" }); - await this.initData(); - } - - renderFoot() { - //c - let props = { - reset: this.reset.bind(this), - submitFeedback: this.submitFeedback.bind(this) - }; - return ; - } - - renderSidebar() { - //c with state - let { yaml, loading, values, allFields } = this.state; - let props = { - yaml, - loading, - values, - allFields, - onLoad: this.parseYml.bind(this), - onReset: this.reset.bind(this) - }; - return ; - } - - langSwitcher() { - //c with state - let { languages, currentLanguage, search } = this.state; - let props = { - languages, - currentLanguage, - search, - switchLang: this.switchLang.bind(this), - removeLang: this.removeLang.bind(this), - onSearch: this.onSearch.bind(this) - }; - return ; - } - - removeLang(lng) { - //has state - let { values, languages, currentValues, currentLanguage } = this.state; - //remove contents of lang - delete values[lng]; - //remove lang from list - languages.splice(languages.indexOf(lng), 1); - //manage state to move on other key - let k0 = Object.keys(values) ? Object.keys(values)[0] : null; - currentLanguage = k0 ? k0 : null; - if (!currentLanguage) { - currentLanguage = languages ? languages[0] : null; - } - currentValues = currentLanguage - ? Object.assign({}, values[currentLanguage]) - : null; - this.setState({ values, languages, currentValues, currentLanguage }); - this.props.initialize(APP_FORM, currentValues ? currentValues : {}); - } - - onSearch(search) { - this.setState({ - search - }); - } - - switchLang(lng) { - //has state - let { values, languages, currentValues, currentLanguage } = this.state; - if (!lng || lng === currentLanguage) return; - - //save current language data - if (currentLanguage) - values[currentLanguage] = Object.assign({}, currentValues); - - if (languages.indexOf(lng) > -1) { - // load previous lang data - currentValues = Object.assign({}, values[lng]); - } else { - //clone current data and then add language - languages.push(lng); - currentValues = {}; - if (currentLanguage && values[currentLanguage]) { - let clonedValues = _.omitBy(values[currentLanguage], (value, key) => { - return _.startsWith(key, SUMMARY + "_"); - }); - currentValues = Object.assign({}, clonedValues); - } - } - //move to current lang - currentLanguage = lng; - - let search = null; - let activeSection = -1; - if (languages && languages.length == 1) { - activeSection = 0; - } - //update state - this.setState({ - values, - languages, - currentValues, - currentLanguage, - search, - activeSection - }); - - this.props.initialize(APP_FORM, currentValues); - } - - async switchCountry(country) { - //has state - let { currentValues } = this.state; - await this.initData(country); - this.props.initialize(APP_FORM, currentValues); - } - - onAccordion(activeSection) { - //has state - - let offset = activeSection * 56; - let currentScroll = document.getElementById(`content__main`).scrollTop; - let diff = currentScroll - offset; - - if (diff > 0) { - console.info("diff", diff); - document.getElementById(`content__main`).scrollTop = offset; - } else { - console.warn("inviewport"); - } - this.setState({ activeSection: activeSection }); - } - - render() { - let { - currentLanguage, - blocks, - activeSection, - country, - allFields, - lastGen - } = this.state; - - let errors = null; - let submitFailed = false; - let { form } = this.props; - - if (form && form[APP_FORM]) { - errors = - form[APP_FORM] && form[APP_FORM].syncErrors - ? form[APP_FORM].syncErrors - : null; - } - - return ( - -
- - {this.langSwitcher()} -
- {currentLanguage && - blocks && ( - - )} -
- {currentLanguage && this.renderFoot()} - -
- {this.renderSidebar()} -
- ); - } -} diff --git a/editor/src/app/components/editorForm.js b/editor/src/app/components/editorForm.js deleted file mode 100644 index 7bbb7e78..00000000 --- a/editor/src/app/components/editorForm.js +++ /dev/null @@ -1,137 +0,0 @@ -import React, { Component, Fragment } from "react"; -import { Field, reduxForm } from "redux-form"; -import { DefaultTheme as Widgets } from "../form"; -import { APP_FORM } from "../contents/constants"; -import renderField from "../form/renderField"; -import CountrySwitcher from "./countrySwitcher"; -import Collapse, { Panel } from "rc-collapse"; -import img_x from "../../asset/img/x.svg"; -import img_accordion_open from "../../asset/img/accordion-open.svg"; -import img_accordion_closed from "../../asset/img/accordion-closed.svg"; -import { getFieldByTitle } from "../contents/data"; - -const renderBlocksSimple = blocks => { - return blocks.map((block, i) => ( -
-
-
{block.index}
-
{block.title}
-
-
{renderBlockItems(block.items, i)}
-
- )); -}; - -const renderBlockItems = (items, id) => { - return items.map((item, i) => { - // getField(item); - let cn = item.cn ? item.cn : "block__item"; - if (item.type === "object") cn = "block__object"; - return ( -
- {renderField(item, item.title, Widgets, "", {}, item.required === true)} -
- ); - }); -}; - -const renderHeader = props => { - let img_arrow = img_accordion_closed; - if (props.activeSection == props.block.index - 1) { - img_arrow = img_accordion_open; - } - return ( - - {props.block.index}. {props.block.title} - {props.hasError && ( - - - - )} - - ); -}; - -const renderBlocks = ( - blocks, - activeSection, - countryProps, - sectionsWithErrors -) => { - return blocks.map((block, i) => { - let last = blocks.length === i + 1; - //let cn = activeSection == i ? "block_heading--active" : ''; - let hasError = sectionsWithErrors.indexOf(i) >= 0; - let c = { - showArrow: false - }; - if (hasError) { - c.headerClass = "rc-collapse-header-error"; - } - return ( - - {last && } -
{renderBlockItems(block.items, i)}
-
- ); - }); -}; - -const EditForm = props => { - const { - handleSubmit, - pristine, - reset, - submitting, - data, - errors, - activeSection, - country, - switchCountry, - allFields, - submitFailed - } = props; - - let countryProps = { country, switchCountry }; - - let params = { - accordion: true, - defaultActiveKey: "0" - }; - - if (activeSection) { - params.activeKey = activeSection == -1 ? "0" : activeSection; - } - - let sectionsWithErrors = []; - //submitFailed && - if (submitFailed && errors) { - sectionsWithErrors = Object.keys(errors).reduce((s, e) => { - let field = getFieldByTitle(allFields, e); - if (s.indexOf(field.section) < 0) { - s.push(field.section); - } - return s; - }, []); - } - - return ( -
-
- - {renderBlocks(data, activeSection, countryProps, sectionsWithErrors)} - -
-
- ); -}; - -export default reduxForm({ - form: APP_FORM -})(EditForm); diff --git a/editor/src/app/components/foot.js b/editor/src/app/components/foot.js deleted file mode 100644 index 860d6966..00000000 --- a/editor/src/app/components/foot.js +++ /dev/null @@ -1,56 +0,0 @@ -import React, { Component } from "react"; -import { connect } from "react-redux"; -import { submit } from "redux-form"; -import { APP_FORM } from "../contents/constants"; - -function mapStateToProps(state) { - return { form: state.form }; -} - -const mapDispatchToProps = dispatch => { - return { - submit: name => dispatch(submit(name)) - }; -}; - -@connect( - mapStateToProps, - mapDispatchToProps -) -export default class foot extends Component { - constructor(props) { - super(props); - } - - render() { - let { yaml, error, loading, values, form } = this.props; - return ( -
-
- -
-
- -
-
- ); - } -} -//disabled={form[APP_FORM].submitFailed && form[APP_FORM].syncErrors} diff --git a/editor/src/app/components/head.js b/editor/src/app/components/head.js deleted file mode 100644 index c597992b..00000000 --- a/editor/src/app/components/head.js +++ /dev/null @@ -1,73 +0,0 @@ -import React, { Component } from "react"; -import { repositoryUrl } from "../contents/constants"; -import moment from "moment"; - -let timer = null; -class head extends Component { - constructor(props) { - super(props); - this.state = { - info: null - }; - } - - updateGen(lastGen) { - console.log("UPDATE GEN"); - let info = null; - if (lastGen) { - info = moment(lastGen).fromNow(); - timer = setTimeout( - function() { - this.updateGen(lastGen); - }.bind(this), - 30000 - ); - } - this.setState({ info }); - } - - componentWillReceiveProps(next) { - if (next.lastGen != this.props.lastGen) { - if (timer) { - clearTimeout(timer); - } - this.updateGen(next.lastGen); - } - } - - componentWillUnmount() { - if (timer) { - clearTimeout(timer); - } - } - - componentDidMount() { - const { lastGen } = this.props; - this.updateGen(lastGen); - } - - render() { - let { info } = this.state; - return ( -
-
Public Code
-
- -
- {info && ( - - Last generation: {info} - - )} -
-
-
- ); - } -} - -export default head; diff --git a/editor/src/app/components/index.js b/editor/src/app/components/index.js deleted file mode 100644 index 0a58407f..00000000 --- a/editor/src/app/components/index.js +++ /dev/null @@ -1,263 +0,0 @@ -import React, { Component } from "react"; -import Schema from "../contents/schema"; -import cleanDeep from "clean-deep"; -import jsyaml from "../../../node_modules/js-yaml/dist/js-yaml.js"; -import renderField from "../form/renderField"; -import buildSyncValidation from "../form/buildSyncValidation"; - -import { - APP_FORM, - yamlData, - versionsUrl, - repositoryUrl -} from "../contents/constants"; - -import { initialize, submit } from "redux-form"; -import { notify, clearNotifications } from "../store/notifications"; -import { saveYaml, setVersions } from "../store/cache"; -import { DefaultTheme } from "../form"; -import { reduxForm } from "redux-form"; -import { connect } from "react-redux"; - -import myTheme from "../form/widgets/"; -import compileSchema from "../form/compileSchema"; -import langs from "../contents/langs"; -import tags from "../contents/tags"; -import validator from "validator"; -import Toolbar from "./toolbar"; -import _ from "lodash"; -import u from "updeep"; -import Ajv from "ajv"; - -const jsonData = require("../schema.json"); -const APP_FORM = "appForm"; -const ajv = new Ajv({ - errorDataPath: "property", - allErrors: true, - jsonPointers: false -}); - -let schema = {}; -let tag_names = tags.map(t => t.tag); -let tag_descrs = tags.map(t => t.descr); - -const mapStateToProps = state => { - return { - notifications: state.notifications, - cache: state.cache - }; -}; -const mapDispatchToProps = dispatch => { - return { - saveYaml: data => dispatch(saveYaml(data)), - setVersions: data => dispatch(setVersions(data)), - notify: (type, data) => dispatch(notify(type, data)), - clearNotifications: (type, data) => - dispatch(clearNotifications(type, data)), - initialize: (name, data) => dispatch(initialize(name, data)), - submit: name => dispatch(submit(name)) - }; -}; -const getReleases = () => { - - return fetch(versionsUrl) - .then(res => res.json()) - .then(data => data.map(d => d.name)); -}; - -@connect( - mapStateToProps, - mapDispatchToProps -) -export default class Index extends Component { - constructor(props) { - super(props); - this.state = { - yaml: null, - formData: null, - loading: true - }; - this.submit = this.submit.bind(this); - } - - async componentDidMount() { - let versions = await getReleases(); - console.log("VERSIONS", versions); - this.getSchema(versions); - } - - getSchema(versions) { - console.log(versions); - let customMeta = { - definitions: { - publiccodeYamlVersion: { - widget: "choice-multiple-expanded" - }, - descriptionPerLang: { - properties: { - longDescription: { - widget: "editor" - } - } - }, - landingURL: { - widget: "url" - }, - releaseDate: { - widget: "date" - }, - developmentStatus: { - widget: "choice-multiple-expanded" - }, - softwareType: { - widget: "choice-multiple-expanded" - } - } - }; - - let custom_props = { - publiccodeYamlVersion: { - type: "array", - uniqueItems: true, - items: { - type: "string", - title: "Version", - enum: versions - } - }, - softwareDescription: { - type: "array", - uniqueItems: true, - items: { - type: "object", - properties: { - language: { - type: "string", - title: "Language", - enum: langs - }, - description: { $ref: "#/definitions/descriptionPerLang" } - }, - required: ["language", "description"] - } - } - }; - delete jsonData.$schema; - delete jsonData.id; - - let data = jsonData; - //data = Object.assign({}, custom_props, data); - let custom_field_keys = _.keys(custom_props); - custom_field_keys.map(k => { - data.properties[k] = custom_props[k]; - }); - data = u(customMeta, data); - - console.log("DATA", data); - let obj = jsyaml.load(JSON.stringify(data)); - - schema = compileSchema(obj); - console.log("COMPILED SCHEMA", obj); - this.setState({ loading: false }); - } - - submit(data) { - this.notify(); - console.log("SUBMIT"); - - data = cleanDeep(data); - console.log(data); - //REFORMAT CUSTOM FIELDS DATA - try { - let yaml = jsyaml.dump(data); - this.setState({ yaml, error: null }); - } catch (e) { - console.error(e); - } - } - - onLoad(formData, yaml) { - console.log("loaded", yaml, formData); - this.setState({ formData, yaml }); - } - - notify(title = "hey", msg = "ciao", millis = 3000) { - this.props.notify({ title, msg, millis }); - } - - BaseForm(props) { - const { - schema, - handleSubmit, - theme, - error, - submitting, - context, - load, - pristine - } = props; - - return ( -
-
{error && {error}}
- {renderField(schema, null, theme || DefaultTheme, "", context)} -
- ); - } - - renderForm() { - const { loading } = this.state; - if (loading) return
Loading...
; - console.log("COMPILED SCHEMA", schema); - const initialValues = Schema.initialValues; - const MyForm = reduxForm({ - form: APP_FORM, - validate: buildSyncValidation(schema), - initialValues: initialValues - })(this.BaseForm); - - return ( - - ); - } - - reset(data) { - if (!data) { - data = Schema.initialValues; - } - console.log("RESET", data); - this.props.initialize(APP_FORM, data); - } - - render() { - let { yaml } = this.state; - return ( -
-
-
{this.renderForm()}
- -
- - -
-
-
- ); - } -} diff --git a/editor/src/app/components/languageSwitcher.js b/editor/src/app/components/languageSwitcher.js deleted file mode 100644 index 70b80ba6..00000000 --- a/editor/src/app/components/languageSwitcher.js +++ /dev/null @@ -1,72 +0,0 @@ -import React, { Component } from "react"; -import available_languages from "../contents/langs"; -//const available_languages = ["ita", "eng", "fra", "zho"]; -import img_close from "../../asset/img/close.svg"; - -export default class languageSwitcher extends Component { - constructor(props) { - super(props); - } - - render() { - let { languages, currentLanguage, search } = this.props; - //console.log(error); - let results = available_languages; - if (search) - results = available_languages.filter(name => name.indexOf(search) > -1); - - return ( -
- {languages.map(lng => { - let cn = "language-switcher__item"; - if (lng == currentLanguage) { - cn += " language-switcher__item--selected"; - } - return ( -
- this.props.switchLang(lng)}>{lng} - this.props.removeLang(lng)} /> -
- ); - })} -
- -
-
- this.props.onSearch(e.target.value)} - /> -
- -
- {results.map(lng => ( - this.props.switchLang(lng)} - > - {lng} - - ))} -
-
-
-
- ); - } -} diff --git a/editor/src/app/components/sidebar.js b/editor/src/app/components/sidebar.js deleted file mode 100644 index b403514f..00000000 --- a/editor/src/app/components/sidebar.js +++ /dev/null @@ -1,263 +0,0 @@ -import React, { Component } from "react"; -import { connect } from "react-redux"; -import copy from "copy-to-clipboard"; -import validator from "validator"; -import { notify } from "../store/notifications"; -import { APP_FORM } from "../contents/constants"; -import img_x from "../../asset/img/x.svg"; -import img_copy from "../../asset/img/copy.svg"; -import img_upload from "../../asset/img/load.svg"; -import img_download from "../../asset/img/download.svg"; -import img_dots from "../../asset/img/dots.svg"; -import img_xx from "../../asset/img/xx.svg"; - -import { getRemoteYml } from "../utils/calls"; -import { getLabel } from "../contents/data"; - -function mapStateToProps(state) { - return { form: state.form }; -} - -const mapDispatchToProps = dispatch => { - return { - notify: data => dispatch(notify(data)) - }; -}; - -const sampleUrl = `https://api.github.com/repos/italia/publiccode.yml/contents/version/0.1/example/publiccode.minimal.yml`; - -@connect( - mapStateToProps, - mapDispatchToProps -) -export default class sidebar extends Component { - constructor(props) { - super(props); - this.state = { - dialog: false, - remoteYml: sampleUrl - }; - } - - showDialog(dialog) { - this.setState({ dialog }); - } - - handleChange(e) { - this.setState({ remoteYml: e.target.value }); - } - - async loadRemoteYaml(e) { - e.preventDefault(); - const { onLoad, onReset } = this.props; - let { remoteYml } = this.state; - this.showDialog(false); - - if (!remoteYml || !validator.isURL(remoteYml)) { - this.props.notify({ type: 1, msg: "Not a valid url" }); - } - - let ext = remoteYml.split(/[. ]+/).pop(); - if (ext != "yml" && ext != "yaml") { - this.props.notify({ type: 1, msg: "File type not supported" }); - return; - } - - onReset(); - - let yaml = null; - try { - yaml = await getRemoteYml(remoteYml); - onLoad(yaml); - } catch (error) { - console.error(error); - alert("error parsing remote yaml"); - } - } - - load(files) { - const { onLoad, onReset } = this.props; - //has dom - if (!files || !files[0]) { - this.props.notify({ type: 1, msg: "File not found" }); - return; - } - // let ext = files[0].name.split(".")[1]; - let ext = files[0].name.split(/[. ]+/).pop(); - if (ext != "yml" && ext != "yaml") { - this.props.notify({ type: 1, msg: "File type not supported" }); - return; - } - - const reader = new FileReader(); - const that = this; - - onReset(); - - reader.onload = function() { - let yaml = reader.result; - onLoad(yaml); - document.getElementById("load_yaml").value = ""; - that.showDialog(false); - }; - reader.readAsText(files[0]); - } - - download(data) { - //has dom - const blob = new Blob([data], { - type: "text/yaml;charset=utf-8;" - }); - let blobURL = window.URL.createObjectURL(blob); - let tempLink = document.createElement("a"); - tempLink.style = "display:none"; - tempLink.download = "pubbliccode.yml"; - tempLink.href = blobURL; - tempLink.setAttribute("download", "pubbliccode.yml"); - document.body.appendChild(tempLink); - tempLink.click(); - setTimeout(function() { - document.body.removeChild(tempLink); - window.URL.revokeObjectURL(blobURL); - }, 1000); - } - - render() { - let { dialog } = this.state; - let { yaml, loading, values, allFields, form } = this.props; - let errors = null; - let fail = false; - - if (form && form[APP_FORM]) { - errors = - form[APP_FORM] && form[APP_FORM].syncErrors - ? form[APP_FORM].syncErrors - : null; - fail = form[APP_FORM].submitFailed ? form[APP_FORM].submitFailed : false; - } - - return ( -
-
- {fail == true ? "Errors" : "File YAML"} - {loading && } -
- -
- {!fail && - !yaml &&
No code generated.
} - {fail && - errors && ( -
- {Object.keys(errors).map((e, i) => ( -
- - {getLabel(allFields, e)} -
- ))} -
- )} - {!(fail && errors) && ( -
-
-                
-                  {"\n"}
-                  {yaml}
-                
-              
-
- )} -
- - {dialog && ( -
-
this.showDialog(false)} - > - close -
- this.load(e.target.files)} - /> -
-
-
Browse file from disk
-
- -
-
-
-
Paste remote yaml url
-
-
this.loadRemoteYaml(e)} - className="sidebar__prefooter__content__form" - > - this.handleChange(e)} - /> - -
-
-
-
-
- )} - - -
- ); - } -} diff --git a/editor/src/app/contents/constants.js b/editor/src/app/contents/constants.js deleted file mode 100644 index 3d2e1f4b..00000000 --- a/editor/src/app/contents/constants.js +++ /dev/null @@ -1,5 +0,0 @@ - let {REPOSITORY} = process.env; -export const repositoryUrl = `https://github.com/${REPOSITORY}`; -export const versionsUrl = `https://api.github.com/repos/${REPOSITORY}/contents/version`; - -export const APP_FORM = "appForm"; diff --git a/editor/src/app/contents/data.js b/editor/src/app/contents/data.js deleted file mode 100644 index d9dcb7ea..00000000 --- a/editor/src/app/contents/data.js +++ /dev/null @@ -1,112 +0,0 @@ -import data, { fieldsAsync } from "./fields"; - -const { sections, groups, available_countries, countrySpec } = data; - -//export groups; -export const SUMMARY = "description"; -export const DEPENDSON = "dependsOn"; - -export const GROUPS = groups; -export const SECTIONS = sections; -export const AVAILABLE_COUNTRIES = available_countries; - -export const getData = async (countryCode = null) => { - const fields = await fieldsAsync(); - const countryFields = getCountryElements(countryCode); - const allFields = getAllFields(fields, countryFields); - const blocks = generateBlocks(allFields); - const elements = generateElements(blocks); - const obj = { blocks, elements, allFields }; - return obj; -}; - -export const getFieldByTitle = (allFields, title) => { - return allFields.find(field => field.title === title); -}; - -export const getLabel = (allFields, title) => { - let field = allFields.find(field => field.title === title); - if (field) { - return field.label ? field.label : field.title; - } - return null; -}; - -const generateBlocks = allFields => { - return sections.map((s, i) => { - let fields = allFields.filter(obj => obj.section === i); - let items = fields.map(i => { - let prefix = i.group ? `${i.group}_` : ""; - if (!i.title.includes(prefix)) i.title = `${prefix}${i.title}`; - return i; - }); - return { - title: s, - index: i + 1, - items - }; - }); -}; - -export const removeAdditional = (allFields, obj) => { - validKeys = allFields.map(f => f.title); - Object.keys(obj).forEach(key => validKeys.includes(key) || delete obj[key]); - return obj; -}; - -const generateElements = blocks => { - return blocks.reduce((merge, block) => { - merge = [...merge, ...block.items]; - return merge; - }, []); -}; - -const getCountryElements = (countryCode = null) => { - let country = countrySpec.find(c => c.code == countryCode); - if (country) return country.fields; - return null; -}; - -const getAllFields = (generic, countryFields = null) => { - if (countryFields) return [...generic, ...countryFields]; - return generic; -}; - -// - -const flatAll = allFields => { - console.log("flatAll", allFields); - return allFields.reduce((list, f) => { - let items = flatField(f); - return [...list, ...items]; - }, []); -}; - -const flatField = field => { - console.log("flatField", field.title, field.type); - let items = []; - if (field.type === "object") { - items = flatObject(field); - } else if (field.type === "array") { - items = flatArray(field); - } else { - items.push(field); - } - return items; -}; - -const flatArray = field => { - console.log("flatArray", field.title, field.type); - return field.items.reduce((list, f) => { - let items = flatField(f); - return [...list, ...items]; - }, []); -}; - -const flatObject = field => { - console.log("flatObject", field.title, field.type); - return field.properties.reduce((list, f) => { - let items = flatField(f); - return [...list, ...items]; - }, []); -}; diff --git a/editor/src/app/contents/fields/generic.js b/editor/src/app/contents/fields/generic.js deleted file mode 100644 index e82223b1..00000000 --- a/editor/src/app/contents/fields/generic.js +++ /dev/null @@ -1,602 +0,0 @@ -import { getReleases } from "../../utils/calls"; -import { versionsUrl } from "../constants"; -import tags from "../tags"; - -const tag_names = tags.map(t => t.tag); -const tag_descrs = tags.map(t => t.descr); -const developmentStatus_list = [ - "concept", - "development", - "beta", - "stable", - "obsolete" -]; -const softwareType_list = [ - "standalone", - "addon", - "library", - "configurationFiles" -]; - -let versions = null; - -const fields = async () => { - if (!versions) { - console.log("get versions"); - try { - versions = await getReleases(versionsUrl); - } catch (e) { - versions = ["development", "0.1"]; - } - } else { - versions = await Promise.resolve(versions); - } - - return [ - { - title: "publiccode-yaml-version", - label: "Publiccode Yaml Version", - type: "string", - description: "This key contains the version of the publicode definition.", - items: { - type: "string" - }, - section: 0, - required: true, - enum: versions, - widget: "choice-expanded" - }, - { - title: "name", - label: "Name of the software", - type: "string", - description: - "This key contains the name of the software. It contains the (short) public name of the product, which can be localised in the specific localisation section. It should be the name most people usually refer to the software. In case the software has both an internal 'code' name and a commercial name, use the commercial name.", - section: 0, - required: true - }, - { - title: "releaseDate", - label: "Release Date", - type: "string", - description: - "This key contains the date at which the latest version was released. This date is mandatory if the software has been released at least once and thus the version number is present.", - - section: 0, - required: true, - widget: "date" - }, - { - title: "url", - label: "Repository URL", - type: "string", - description: - "A unique identifier for this software. This string must be a URL to the source code repository (git, svn, ...) in which the software is published. If the repository is available under multiple protocols, prefer HTTP/HTTPS URLs which don't require user authentication.", - widget: "url", - section: 0, - required: true - }, - { - title: "applicationSuite", - label: "Application Suite", - type: "string", - description: - "This key contains the name of the 'suite' to which the software belongs.", - section: 0 - }, - { - type: "string", - title: "landingURL", - label: "Landing Page URL", - description: - "If the url parameter does not serve a human readable or browsable page, but only serves source code to a source control client, with this key you have an option to specify a landing page. This page, ideally, is where your users will land when they will click a button labeled something like 'Go to the application source code'. In case the product provides an automated graphical installer, this URL can point to a page which contains a reference to the source code but also offers the download of such an installer.", - section: 1, - widget: "url" - }, - { - title: "localisedName", - label: "Localised Name", - type: "string", - description: "localisedName", - section: 2, - group: "description" - }, - { - title: "shortDescription", - label: "Short Description", - type: "string", - description: "A short description is isRequired", - section: 0, - group: "description", - required: true - }, - { - title: "longDescription", - label: "Long Description", - type: "string", - description: "A long description is isRequired", - section: 3, - group: "description", - widget: "editor", - required: true, - cn: "block__item--full" - }, - { - title: "documentation", - label: "Documentation", - type: "string", - description: "link to documentation", - section: 1, - group: "description" - }, - { - title: "apiDocumentation", - label: "API Documentation", - section: 3, - group: "description", - type: "string", - description: "link to the api documentation" - }, - { - title: "freeTags", - label: "Free Tags", - section: 1, - group: "description", - type: "array", - description: "a list of tags", - items: { - title: "tag", - type: "string" - } - }, - { - title: "featureList", - label: "Feature List", - type: "array", - description: "a list of feature that the sw has", - items: { - type: "string", - title: "feature" - }, - section: 1, - group: "description" - }, - { - title: "screenshots", - label: "Screenshots", - type: "array", - description: "array of image url", - items: { - type: "string", - title: "screenshot" - }, - section: 2, - group: "description" - }, - { - title: "videos", - label: "Videos", - type: "array", - description: "link to videos", - items: { - type: "string", - title: "video" - }, - section: 2, - group: "description" - }, - { - title: "awards", - label: "Awards", - type: "array", - description: "awards won", - items: { - type: "string", - title: "award" - }, - section: 2, - group: "description" - }, - { - title: "isBasedOn", - label: "Is Based On", - type: "string", - description: - "In case this software is a variant or a fork of another software, which might or might not contain a publiccode.yml file, this key will contain the url of the original project(s). The existence of this key identifies the fork as a software variant, descending from the specified repositories.", - section: 0, - widget: "url" - }, - - { - type: "string", - title: "softwareVersion", - label: "Software Version", - description: - "This key contains the latest stable version number of the software. The version number is a string that is not meant to be interpreted and parsed but just displayed; parsers should not assume semantic versioning or any other specific version format.", - section: 1 - }, - { - title: "roadmap", - label: "Roadmap", - type: "string", - description: "A link to a public roadmap of the software.", - section: 1, - widget: "url" - }, - { - type: "string", - title: "logo", - label: "Logo", - description: - "This key contains the logo of the software. Logos should be in vector format; raster formats are only allowed as a fallback. In this case, they should be transparent PNGs, minimum 1000px of width. Acceptable formats: SVG, SVGZ, PNG", - section: 2 - }, - { - type: "string", - title: "monochromeLogo", - label: "Logo Monochrome", - description: - "A monochromatic (black) logo. The logo should be in vector format; raster formats are only allowed as a fallback. In this case, they should be transparent PNGs, minimum 1000px of width. Acceptable formats: SVG, SVGZ, PNG", - section: 2 - }, - - { - title: "developmentStatus", - label: "Development Status", - - type: "string", - description: - "Allowed values: concept, development, beta, stable, obsolete", - enum: developmentStatus_list, - section: 1, - required: true, - widget: "choice-expanded" - }, - { - title: "softwareType", - label: "Software Type", - type: "string", - description: - "Allowed values: standalone, addon, library, configurationFiles", - enum: softwareType_list, - section: 1, - required: true, - widget: "choice-expanded" - }, - - { - type: "array", - title: "platforms", - label: "Platforms", - description: - "Values: web, windows, mac, linux, ios, android. Human readable values outside this list are allowed", - examples: ["android", "ios"], - items: { - type: "string", - enum: ["web", "windows", "mac", "linux", "ios", "android"] - }, - section: 1, - widget: "tags" - }, - { - type: "string", - title: "license", - label: "License", - description: - "This string describes the license under which the software is distributed. The string must contain a valid SPDX expression, referring to one (or multiple) open-source license. Please refer to the SPDX documentation for further information.", - section: 4, - group: "legal", - required: true - }, - { - type: "string", - title: "mainCopyrightOwner", - label: "Main Copyright Owner", - description: - "This string describes the entity that owns the copyright on 'most' of the code in the repository. Normally, this is the line that is reported with the copyright symbol at the top of most files in the repo.", - section: 4, - group: "legal" - }, - { - type: "string", - title: "repoOwner", - label: "Repository Owner", - description: - "This string describes the entity that owns this repository; this might or might not be the same entity who owns the copyright on the code itself. For instance, in case of a fork of the original software, the repoOwner is probably different from the mainCopyrightOwner.", - section: 0, - group: "legal", - required: true - }, - { - title: "authorsFile", - label: "Authors File", - type: "string", - description: - "Some open-source softwares adopt a convention of identify the copyright holders through a file that lists all the entities that own the copyright. This is common in projects strongly backed by a community where there are many external contributors and no clear single/main copyright owner. In such cases, this key can be used to refer to the authors file, using a path relative to the root of the repository.", - section: 4, - group: "legal" - }, - { - title: "tags", - label: "Tags", - description: - "A list of words that can be used to describe the software and can help building catalogs of open software. Each tag must be in Unicode lowercase, and should not contain any Unicode whitespace character. The suggested character to separate multiple words is - (single dash). See also: description/[lang]/freeTags/", - type: "array", - items: { - type: "string", - title: "tag", - enum: tag_names, - enum_titles: tag_descrs - }, - section: 3, - required: true, - widget: "tags" - }, - { - title: "onlyFor", - label: "Only For", - type: "array", - description: - "Public software could be very specific in scope because there is a large set of tasks that are specific to each type of administration. For instance, many softwares that are used in schools are probably not useful in hospitals. If you want to explicitly mark some software as only useful to certain types of administrations, you should add them to this key.The list of allowed values is defined in pa-types.md, and can be country-specific. This list can evolve at any time, separately from the version of this specification.", - - items: { - type: "string" - }, - section: 3, - group: "intendedAudience" - }, - { - title: "countries", - label: "Countries", - type: "array", - description: - "This key explicitly includes certain countries in the intended audience, i.e. the software explicitly claims compliance with specific processes, technologies or laws. All countries are specified using lowercase ISO 3166-1 alpha-2 two-letter country codes.", - items: { - title: "item", - type: "string" - }, - section: 3, - group: "intendedAudience" - }, - { - title: "unsupportedCountries", - label: "Unsupported Countries", - type: "array", - description: - "This key explicitly marks countries as NOT supported. This might be the case if there is a conflict between how software is working and a specific law, process or technology. All countries are specified using lowercase ISO 3166-1 alpha-2 two-letter country codes.", - items: { - title: "item", - type: "string" - }, - section: 3, - group: "intendedAudience" - }, - { - title: "usedBy", - label: "Used By", - description: - "A list of the names of prominent public administrations (that will serve as testimonials) that are currently known to the software maintainer to be using this software. Parsers are encouraged to enhance this list also with other information that can obtain independently; for instance, a fork of a software, owned by an administration, could be used as a signal of usage of the software.", - - type: "array", - items: { - type: "string" - }, - section: 1 - }, - - { - title: "inputTypes", - label: "Input Types", - description: - "A list of Media Types (MIME Types) as mandated in RFC 6838 which the application can handle as output. In case the software does not support any input, you can skip this field or use application/x.empty.", - type: "array", - items: { - type: "string" - }, - section: 1 - }, - { - title: "outputTypes", - label: "Output Types", - description: - "A list of Media Types (MIME Types) as mandated in RFC 6838 which the application can handle as output. In case the software does not support any output, you can skip this field or use application/x.empty.", - type: "array", - items: { - type: "string" - }, - section: 1 - }, - { - title: "localisationReady", - label: "Localisation Ready", - type: "boolean", - description: - "If yes, the software has infrastructure in place or is otherwise designed to be multilingual. It does not need to be available in more than one language.", - section: 3, - group: "localisation" - }, - { - title: "availableLanguages", - label: "Available Languages", - type: "array", - description: - "If present, this is the list of languages in which the software is available. Of course, this list will contain at least one language. See also: https://en.wikipedia.org/wiki/ISO_639-2", - items: { - type: "string" - }, - section: 3, - group: "localisation" - }, - { - title: "type", - label: "Maintenance Type", - type: "array", - description: - "This key describes how the software is currently maintained. 'internal' means that the software is internally maintained by the repository owner. 'contract' means that there is a commercial contract that binds an entity to the maintenance of the software; 'community' means that the software is currently maintained by one or more people that donate their time to the project; 'none' means that the software is not actively maintained.", - items: { - type: "string" - }, - uniqueItems: true, - enum: ["internal", "contract", "community", "none"], - widget: "choice-expanded", - section: 5, - group: "maintenance" - }, - { - title: "contacts", - label: "Contacts", - type: "array", - description: - "One or more contacts maintaining this software. This key describes the technical people currently responsible for maintaining the software. All contacts need to be a physical person, not a company or an organisation. if somebody is acting as a representative of an institution, it must be listed within the affiliation of the contact. In case of a commercial agreement (or a chain of such agreements), specify the final entities actually contracted to deliver the maintenance. Do not specify the software owner unless it is technically involved with the maintenance of the product as well.", - items: { - title: "contact", - label: "Contact", - description: - "This key contains an explicit affiliation information for the technical contact. In case of multiple maintainers, this can be used to create a relation between each technical contact and each maintainer entity. It can contain for instance a company name, an association name, etc.", - type: "object", - properties: { - name: { - type: "string", - title: "name", - label: "Name", - description: - " mandatory - This key contains the full name of one of the technical contacts. It must be a real person; do NOT populate this key with generic contact information, company departments, associations, etc." - }, - email: { - type: "string", - title: "Email", - label: "Email", - widget: "email", - description: - "This key contains the e-mail address of the technical contact. It must be an email address of where the technical contact can be directly reached; do NOT populate this key with mailing-lists or generic contact points like info@acme.inc. " - }, - phone: { - type: "string", - title: "phone", - label: "Phone", - description: " phone number (with international prefix)" - }, - affiliation: { - type: "string", - title: "affiliation", - label: "Affiliation", - description: - "This key contains an explicit affiliation information for the technical contact. In case of multiple maintainers, this can be used to create a relation between each technical contact and each maintainer entity. It can contain for instance a company name, an association name, etc." - } - }, - required: ["name"] - }, - section: 5, - group: "maintenance", - cn: "block__item--full", - required: true - }, - { - title: "contractors", - label: "Contractors", - type: "array", - description: - "This key describes the entity or entities, if any, that are currently contracted for maintaining the software. They can be companies, organizations, or other collective names.", - items: { - title: "contractor", - label: "Contractor", - description: - "This key contains an explicit affiliation information for the technical contact. In case of multiple maintainers, this can be used to create a relation between each technical contact and each maintainer entity. It can contain for instance a company name, an association name, etc.", - type: "object", - properties: { - name: { - type: "string", - title: "name", - label: "Name", - description: - "mandatory - The name of the contractor, whether it's a company or a physical person." - }, - until: { - type: "string", - title: "until", - label: "Until", - description: - " mandatory - This is a date (YYYY-MM-DD). This key must contain the date at which the maintenance is going to end. In case of community maintenance, the value should not be more than 2 years in the future, and thus will need to be regularly updated as the community continues working on the project.", - widget: "date" - }, - website: { - type: "string", - title: "website", - label: "website", - description: - "This key points to the maintainer website. It can either point to the main institutional website, or to a more project-specific page or website.", - widget: "url" - } - }, - required: ["name", "until"] - }, - section: 5, - group: "maintenance", - cn: "block__item--full" - }, - - { - title: "dependsOn", - label: "Depends On", - description: - "This section provides an overview on the system-level dependencies required to install and use this software.", - type: "array", - items: { - title: "dependency", - label: "Dependency", - description: - "A dependency is a complex object. The properties are the following:", - type: "object", - properties: { - type: { - title: "type", - label: "Type", - type: "array", - items: { - type: "string" - }, - enum: ["open", "proprietary", "hardware"], - uniqueItems: true, - widget: "choice-expanded" - }, - name: { - title: "name", - label: "Name", - type: "string", - description: - "mandatory - The name of the dependency (e.g. MySQL, NFC Reader)" - }, - versionMin: { - type: "string", - title: "versionMin", - label: "Version Range Min", - description: "the first compatible version" - }, - versionMax: { - type: "string", - title: "versionMax", - label: "Version Range Max", - description: "the latest compatible version" - }, - version: { - type: "string", - title: "version", - label: "Exact Version", - description: - "the only major version for which the software is compatible. It assumes compatibility with all patches and bugfixes later applied to this version." - }, - optional: { - title: "optional", - label: "Optional", - type: "boolean", - description: "whether the dependency is optional or mandatory" - } - }, - required: ["name", "type"] - }, - section: 4, - cn: "block__item--full" - } - ]; -}; -export default fields; diff --git a/editor/src/app/contents/fields/index.js b/editor/src/app/contents/fields/index.js deleted file mode 100644 index 1499315f..00000000 --- a/editor/src/app/contents/fields/index.js +++ /dev/null @@ -1,120 +0,0 @@ -import uk from "./uk"; -import us from "./us"; -import it from "./it"; -import getFields from "./generic"; - -const sections = [ - "Main information", - "Specification", - "Multimedia", - "Description", - "Legal", - "Maintenance", - "Country Specific" -]; - -const groups = [ - "summary", - "maintenance", - "legal", - "intendedAudience", - "localisation" -]; - -const countrySpec = [ - { - code: "uk", - name: "United Kingdom", - fields: uk - }, - { - code: "us", - name: "United States", - fields: us - }, - { - code: "it", - name: "italia", - fields: it - } -]; -const available_countries = countrySpec.map(country => country.code); -const data = { - countrySpec, - sections, - groups, - available_countries -}; - -export const fieldsAsync = async () => { - return await getFields(); -}; -export default data; - -/* ------------------------------------- -# MAIN INFORMATION 0 ------------------------------------- -name -applicationSuite -summary_shortDescription -publiccodeYamlVersion -releaseDate -legal_repoOwner -landingURL -isBasedOn -tags - ------------------------------------- -# SPECIFICATION 1 ------------------------------------- -roadmap -summary_documentation -url -softwareVersion -developmentStatus -softwareType -inputTypes -outputTypes -platforms -usedBy -summary_featureList -summary_freeTags - ------------------------------------- -# MULTIMEDIA 2 ------------------------------------- -summary_screenshots -summary_videos -logo -monochromeLogo -summary_localisedName -summary_awards - ------------------------------------- -# SUMMARY 3 ------------------------------------- -summary_longDescription -summary_apiDocumentation -intendedAudience_onlyFor -intendedAudience_countries -intendedAudience_unsupportedCountries -localisation_localisationReady -localisation_availableLanguages -dependsOn - ------------------------------------- -# LEGAL 4 ------------------------------------- -legal_license -legal_mainCopyrightOwner -legal_authorsFile - ------------------------------------- -# MAINTENANCE 5 ------------------------------------- -maintenance_type -maintenance_contractors -maintenance_contacts - -*/ diff --git a/editor/src/app/contents/fields/it.js b/editor/src/app/contents/fields/it.js deleted file mode 100644 index f930d8ee..00000000 --- a/editor/src/app/contents/fields/it.js +++ /dev/null @@ -1,160 +0,0 @@ -const ecosistemi_list = [ - "sanita", - "welfare", - "finanza-pubblica", - "scuola", - "istruzione-superiore-ricerca", - "difesa-sicurezza-soccorso-legalita", - "giustizia", - "infrastruttura-logistica", - "sviluppo-sostenibilita", - "beni-culturali-turismo", - "agricoltura", - "italia-europa-mondo" -]; - -const it = [ - { - section: 6, - group: "it", - title: "spid", - label: "SPID", - type: "boolean", - description: - "Se presente e impostato a yes, il software si interfaccia con SPID - il Sistema Pubblico di Identità Digitale." - }, - { - section: 6, - group: "it", - title: "cie", - label: "CIE", - type: "boolean", - description: - "Se presente e impostato a yes, il software si interfaccia con la Carta di Identità Elettronica." - }, - { - section: 6, - group: "it", - title: "anpr", - label: "ANPR", - type: "boolean", - description: - "Se presente e impostato a yes, il software si interfaccia con ANPR." - }, - { - section: 6, - group: "it", - title: "pagopa", - label: "PagoPA", - type: "boolean", - description: - "Se presente e impostato a yes, il software si interfaccia con PagoPA." - }, - { - section: 6, - group: "it", - title: "conforme", - label: "Conforme", - type: "object", - properties: { - accessibile: { - title: "accessibile", - label: "Accessibile", - type: "boolean", - description: - "Se presente e impostato a yes, il software è conforme alle leggi in materia di accessibilità (L. 4/2004), come descritto ulteriormente nelle linee guida di design." - }, - interoperabile: { - title: "interoperabile", - label: "Interoperabile", - type: "boolean", - description: - "Se presente e impostato a yes, il software è conforme alle linee guida sull'interoperabilità.Riferimento normativo: Art. 73 del CAD." - }, - sicuro: { - title: "sicuro", - label: "Sicuro", - type: "boolean", - description: - "Se presente e impostato a yes, il software è conforme alle Misure minime di sicurezza ICT per le Pubbliche amministrazioni." - }, - privacy: { - title: "privacy", - label: "Privacy", - type: "boolean", - description: - "Se presente e impostato a yes, il software rispetta le linee guida del Garante per la protezione dei dati personali." - } - } - }, - - { - section: 6, - group: "it", - title: "riuso", - label: "Riuso", - type: "object", - properties: { - codiceIPA: { - title: "codiceIPA", - label: "Codice IPA", - type: "string", - description: - "Questa chiave rappresenta il codice dell'amministrazione all'interno dell'Indice delle Pubbliche Amministrazioni (codice IPA) Il parser applicherà il corretto prefisso al valore dato a questa chiave per creare un'URI identificativa, una volta che questo sarà definito. L'URI sarà riconducibile a http://w3id.org/italia/data secondo la politica degli URI adottata in ambito DAF." - }, - ecosistemi: { - type: "array", - title: "ecosistemi", - label: "Ecosistemi", - description: - "Values: web, windows, mac, linux, ios, android. Human readable values outside this list are allowed", - examples: ["android", "ios"], - items: { - title: "ecosistema", - label: "Ecosistema", - type: "string", - enum: ecosistemi_list - }, - section: 6 - } - } - }, - { - section: 6, - group: "it", - title: "designKit", - label: "Design Kit", - type: "object", - properties: { - seo: { - title: "seo", - label: "SEO", - type: "boolean", - description: - "Se presente e impostato a yes, il software ha utilizzato, in fase di progettazione, il kit di SEO di Designers Italia." - }, - ui: { - title: "ui", - label: "UI", - type: "boolean", - description: - "Se presente e impostato a yes, il software ha utilizzato, in fase di progettazione, il kit UI di Designers Italia." - }, - web: { - title: "web", - label: "Web", - type: "boolean", - description: - "Se presente e impostato a yes, il software utilizza il kit per lo sviluppo web di Designers Italia." - }, - content: { - title: "content", - label: "Content", - type: "boolean", - description: - "Se presente e impostato a yes, il software ha utilizzato, in fase di progettazione, il kit per la scrittura del contenuto di Designers Italia." - } - } - } -]; -export default it; diff --git a/editor/src/app/contents/fields/uk.js b/editor/src/app/contents/fields/uk.js deleted file mode 100644 index 19de1df2..00000000 --- a/editor/src/app/contents/fields/uk.js +++ /dev/null @@ -1,26 +0,0 @@ -const uk = [ - { - type: "array", - title: "platforms", - label: "Platforms", - description: - "Values: web, windows, mac, linux, ios, android. Human readable values outside this list are allowed", - examples: ["android", "ios"], - items: { - type: "string", - enum: ["web", "windows", "mac", "linux", "ios", "android"] - }, - section: 1 - }, - { - title: "sample", - label: "sample UK", - type: "string", - description: - "This key contains the sample version of the country specific subschema.", - section: 6, - required: true, - group: "uk" - } -]; -export default uk; diff --git a/editor/src/app/contents/fields/us.js b/editor/src/app/contents/fields/us.js deleted file mode 100644 index 05fc3aaf..00000000 --- a/editor/src/app/contents/fields/us.js +++ /dev/null @@ -1,13 +0,0 @@ -const us = [ - { - title: "sample", - label: "sample USA", - type: "string", - description: - "This key contains the sample version of the country specific subschema.", - section: 6, - required: true, - group: "us" - } -]; -export default us; diff --git a/editor/src/app/contents/langs.js b/editor/src/app/contents/langs.js deleted file mode 100644 index d73da0e5..00000000 --- a/editor/src/app/contents/langs.js +++ /dev/null @@ -1,511 +0,0 @@ -const langs = [ - "aar", - "abk", - "ace", - "ach", - "ada", - "ady", - "afa", - "afh", - "afr", - "ain", - "aka", - "akk", - "alb", - "ale", - "alg", - "alt", - "amh", - "ang", - "anp", - "apa", - "ara", - "arc", - "arg", - "arm", - "arn", - "arp", - "art", - "arw", - "asm", - "ast", - "ath", - "aus", - "ava", - "ave", - "awa", - "aym", - "aze", - "bad", - "bai", - "bak", - "bal", - "bam", - "ban", - "baq", - "bas", - "bat", - "bej", - "bel", - "bem", - "ben", - "ber", - "bho", - "bih", - "bik", - "bin", - "bis", - "bla", - "bnt", - "bod", - "bos", - "bra", - "bre", - "btk", - "bua", - "bug", - "bul", - "bur", - "byn", - "cad", - "cai", - "car", - "cat", - "cau", - "ceb", - "cel", - "ces", - "cha", - "chb", - "che", - "chg", - "chi", - "chk", - "chm", - "chn", - "cho", - "chp", - "chr", - "chu", - "chv", - "chy", - "cmc", - "cnr", - "cop", - "cor", - "cos", - "cpe", - "cpf", - "cpp", - "cre", - "crh", - "crp", - "csb", - "cus", - "cym", - "cze", - "dak", - "dan", - "dar", - "day", - "del", - "den", - "deu", - "dgr", - "din", - "div", - "doi", - "dra", - "dsb", - "dua", - "dum", - "dut", - "dyu", - "dzo", - "efi", - "egy", - "eka", - "ell", - "elx", - "eng", - "enm", - "epo", - "est", - "eus", - "ewe", - "ewo", - "fan", - "fao", - "fas", - "fat", - "fij", - "fil", - "fin", - "fiu", - "fon", - "fra", - "fre", - "frm", - "fro", - "frr", - "frs", - "fry", - "ful", - "fur", - "gaa", - "gay", - "gba", - "gem", - "geo", - "ger", - "gez", - "gil", - "gla", - "gle", - "glg", - "glv", - "gmh", - "goh", - "gon", - "gor", - "got", - "grb", - "grc", - "gre", - "grn", - "gsw", - "guj", - "gwi", - "hai", - "hat", - "hau", - "haw", - "heb", - "her", - "hil", - "him", - "hin", - "hit", - "hmn", - "hmo", - "hrv", - "hsb", - "hun", - "hup", - "hye", - "iba", - "ibo", - "ice", - "ido", - "iii", - "ijo", - "iku", - "ile", - "ilo", - "ina", - "inc", - "ind", - "ine", - "inh", - "ipk", - "ira", - "iro", - "isl", - "ita", - "jav", - "jbo", - "jpn", - "jpr", - "jrb", - "kaa", - "kab", - "kac", - "kal", - "kam", - "kan", - "kar", - "kas", - "kat", - "kau", - "kaw", - "kaz", - "kbd", - "kha", - "khi", - "khm", - "kho", - "kik", - "kin", - "kir", - "kmb", - "kok", - "kom", - "kon", - "kor", - "kos", - "kpe", - "krc", - "krl", - "kro", - "kru", - "kua", - "kum", - "kur", - "kut", - "lad", - "lah", - "lam", - "lao", - "lat", - "lav", - "lez", - "lim", - "lin", - "lit", - "lol", - "loz", - "ltz", - "lua", - "lub", - "lug", - "lui", - "lun", - "luo", - "lus", - "mac", - "mad", - "mag", - "mah", - "mai", - "mak", - "mal", - "man", - "mao", - "map", - "mar", - "mas", - "may", - "mdf", - "mdr", - "men", - "mga", - "mic", - "min", - "mis", - "mkd", - "mkh", - "mlg", - "mlt", - "mnc", - "mni", - "mno", - "moh", - "mon", - "mos", - "mri", - "msa", - "mul", - "mun", - "mus", - "mwl", - "mwr", - "mya", - "myn", - "myv", - "nah", - "nai", - "nap", - "nau", - "nav", - "nbl", - "nde", - "ndo", - "nds", - "nep", - "new", - "nia", - "nic", - "niu", - "nld", - "nno", - "nob", - "nog", - "non", - "nor", - "nqo", - "nso", - "nub", - "nwc", - "nya", - "nym", - "nyn", - "nyo", - "nzi", - "oci", - "oji", - "ori", - "orm", - "osa", - "oss", - "ota", - "oto", - "paa", - "pag", - "pal", - "pam", - "pan", - "pap", - "pau", - "peo", - "per", - "phi", - "phn", - "pli", - "pol", - "pon", - "por", - "pra", - "pro", - "pus", - "qaa-", - "que", - "raj", - "rap", - "rar", - "roa", - "roh", - "rom", - "ron", - "rum", - "run", - "rup", - "rus", - "sad", - "sag", - "sah", - "sai", - "sal", - "sam", - "san", - "sas", - "sat", - "scn", - "sco", - "sel", - "sem", - "sga", - "sgn", - "shn", - "sid", - "sin", - "sio", - "sit", - "sla", - "slo", - "slk", - "slv", - "sma", - "sme", - "smi", - "smj", - "smn", - "smo", - "sms", - "sna", - "snd", - "snk", - "sog", - "som", - "son", - "sot", - "spa", - "sqi", - "srd", - "srn", - "srp", - "srr", - "ssa", - "ssw", - "suk", - "sun", - "sus", - "sux", - "swa", - "swe", - "syc", - "syr", - "tah", - "tai", - "tam", - "tat", - "tel", - "tem", - "ter", - "tet", - "tgk", - "tgl", - "tha", - "tib", - "tig", - "tir", - "tiv", - "tkl", - "tlh", - "tli", - "tmh", - "tog", - "ton", - "tpi", - "tsi", - "tsn", - "tso", - "tuk", - "tum", - "tup", - "tur", - "tut", - "tvl", - "twi", - "tyv", - "udm", - "uga", - "uig", - "ukr", - "umb", - "und", - "urd", - "uzb", - "vai", - "ven", - "vie", - "vol", - "vot", - "wak", - "wal", - "war", - "was", - "wel", - "wen", - "wln", - "wol", - "xal", - "xho", - "yao", - "yap", - "yid", - "yor", - "ypk", - "zap", - "zbl", - "zen", - "zgh", - "zha", - "zho", - "znd", - "zul", - "zun", - "zxx", - "zza" -]; - -export default langs; diff --git a/editor/src/app/contents/sample.js b/editor/src/app/contents/sample.js deleted file mode 100644 index 0e34ec83..00000000 --- a/editor/src/app/contents/sample.js +++ /dev/null @@ -1,219 +0,0 @@ -import compileSchema from "../form/compileSchema"; -import _ from "lodash"; - -// export const gen = () => { -// let items = []; -// Object.keys(obj).map(k => { -// if (obj[k].type != "object") items.push(obj[k]); -// }); -// console.log(items); -// return items; -// }; - -export const data = [ - { - title: "Main Infos", - index: 1, - items: [ - { - title: "Summary", - descr: "informazioni varie", - type: "string", - cn: "block__item--full", - widget: "editor" - }, - { - type: "array", - cn: "block__item--full", - title: "contacts", - description: - "One or more contacts maintaining this software. This key describes the technical people currently responsible for maintaining the software. All contacts need to be a physical person, not a company or an organisation. if somebody is acting as a representative of an institution, it must be listed within the affiliation of the contact. In case of a commercial agreement (or a chain of such agreements), specify the final entities actually contracted to deliver the maintenance. Do not specify the software owner unless it is technically involved with the maintenance of the product as well.", - items: { - title: "contact", - description: - "This key contains an explicit affiliation information for the technical contact. In case of multiple maintainers, this can be used to create a relation between each technical contact and each maintainer entity. It can contain for instance a company name, an association name, etc.", - type: "object", - properties: { - name: { - type: "string", - title: "name", - description: - " mandatory - This key contains the full name of one of the technical contacts. It must be a real person; do NOT populate this key with generic contact information, company departments, associations, etc." - }, - email: { - type: "string", - title: "Email", - description: - "This key contains the e-mail address of the technical contact. It must be an email address of where the technical contact can be directly reached; do NOT populate this key with mailing-lists or generic contact points like info@acme.inc. ", - examples: ["lou.reed@acme.inc"] - }, - phone: { - type: "string", - title: "phone", - description: " phone number (with international prefix)" - }, - affiliation: { - type: "string", - title: "affiliation", - description: - "This key contains an explicit affiliation information for the technical contact. In case of multiple maintainers, this can be used to create a relation between each technical contact and each maintainer entity. It can contain for instance a company name, an association name, etc." - } - }, - required: ["email"] - } - }, - { - title: "softwareVersion", - label: "Software Version", - description: "This key contains...", - type: "string", - widget: "textarea" - } - ] - }, - { - title: "Multimedia", - index: 2, - items: [ - { - title: "firstName", - label: "First Name", - descr: "", - type: "string" - }, - { - title: "lastName", - label: "Last Name", - descr: "", - type: "string" - }, - { - title: "email", - label: "Email", - descr: "", - type: "string", - required: true - } - ] - }, - { - title: "Block 3", - index: 3, - items: [ - { - title: "developmentStatus", - label: "developmentStatus", - type: "array", - description: - "Allowed values: concept, development, beta, stable, obsolete", - examples: [""], - items: { - type: "string" - } - }, - { - title: "softwareType", - label: "softwareType", - type: "array", - uniqueItems: true, - description: - "Allowed values: standalone, addon, library, configurationFiles", - examples: ["standalone"], - items: { - type: "string", - enum: ["standalone", "addon", "library", "configurationFiles"] - }, - widget: "choice-multiple-expanded" - }, - { - title: "releaseDate", - label: "Release Date", - type: "string", - description: - "This key contains the date at which the latest version was released. This date is mandatory if the software has been released at least once and thus the version number is present.", - widget: "date" - } - ] - }, - { - title: "Blok 4", - index: "4", - items: [ - { - title: "intendedAudience", - label: "Intended Audience", - type: "object", - properties: { - onlyFor: { - title: "only for", - type: "array", - description: - "Public software could be very specific in scope because there is a large set of tasks that are specific to each type of administration. For instance, many softwares that are used in schools are probably not useful in hospitals. If you want to explicitly mark some software as only useful to certain types of administrations, you should add them to this key.The list of allowed values is defined in pa-types.md, and can be country-specific. This list can evolve at any time, separately from the version of this specification.", - examples: ["city"], - items: { - type: "string" - } - }, - countries: { - title: "countries", - type: "array", - description: - "This key explicitly includes certain countries in the intended audience, i.e. the software explicitly claims compliance with specific processes, technologies or laws. All countries are specified using lowercase ISO 3166-1 alpha-2 two-letter country codes.", - items: { - title: "item", - type: "string" - } - }, - unsupportedCountries: { - title: "unsupportedCountries", - type: "array", - description: - "This key explicitly marks countries as NOT supported. This might be the case if there is a conflict between how software is working and a specific law, process or technology. All countries are specified using lowercase ISO 3166-1 alpha-2 two-letter country codes.", - items: { - title: "item", - type: "string" - } - } - } - }, - { - title: "legal", - label: "Legal", - type: "object", - description: - "This section provides an overview of the legal info of the software.", - properties: { - license: { - type: "string", - title: "license", - examples: ["AGPL-3.0-or-later"], - description: - "This string describes the license under which the software is distributed. The string must contain a valid SPDX expression, referring to one (or multiple) open-source license. Please refer to the SPDX documentation for further information." - }, - mainCopyrightOwner: { - type: "string", - title: "mainCopyrightOwner", - examples: ["City of Amsterdam"], - description: - "This string describes the entity that owns the copyright on 'most' of the code in the repository. Normally, this is the line that is reported with the copyright symbol at the top of most files in the repo." - }, - repoOwner: { - type: "string", - title: "repoOwner", - examples: ["City of Amsterdam"], - description: - "This string describes the entity that owns this repository; this might or might not be the same entity who owns the copyright on the code itself. For instance, in case of a fork of the original software, the repoOwner is probably different from the mainCopyrightOwner." - }, - authorsFile: { - type: "string", - title: "authorsFile", - examples: ["authorsFile"], - description: - "Some open-source softwares adopt a convention of identify the copyright holders through a file that lists all the entities that own the copyright. This is common in projects strongly backed by a community where there are many external contributors and no clear single/main copyright owner. In such cases, this key can be used to refer to the authors file, using a path relative to the root of the repository." - } - }, - required: ["license", "repoOwner"] - } - ] - } -]; diff --git a/editor/src/app/contents/tags.js b/editor/src/app/contents/tags.js deleted file mode 100644 index 2b823cb8..00000000 --- a/editor/src/app/contents/tags.js +++ /dev/null @@ -1,96 +0,0 @@ -const tags = [ - { - tag: "3dgraphics", - descr: "application for viewing, creating, or processing 3-d graphics" - }, - { tag: "accessibility", descr: "accessibility" }, - { tag: "accounting", descr: "accounting software" }, - { tag: "amusement", descr: "a simple amusement" }, - { tag: "archiving", descr: "a tool to archive/backup data" }, - { tag: "art", descr: "software to teach arts" }, - { tag: "artificial-intelligence", descr: "artificial intelligence software" }, - { tag: "backend", descr: "software not meant for end users" }, - { tag: "calculator", descr: "a calculator" }, - { tag: "calendar", descr: "calendar application" }, - { tag: "chat", descr: "a chat client" }, - { tag: "classroom-management", descr: "classroom management software" }, - { tag: "clock", descr: "a clock application/applet" }, - { tag: "content-management", descr: "a content management system (CMS)" }, - { tag: "compression", descr: "a tool to manage compressed data/archives" }, - { tag: "construction", descr: "" }, - { tag: "contact-management", descr: "e.g. an address book" }, - { tag: "database", descr: "application to manage a database" }, - { tag: "debugger", descr: "a tool to debug applications" }, - { tag: "dictionary", descr: "a dictionary" }, - { tag: "documentation", descr: "help or documentation" }, - { - tag: "electronics", - descr: "electronics software, e.g. a circuit designer" - }, - { tag: "email", descr: "email application" }, - { - tag: "emulator", - descr: "emulator of another platform, such as a dos emulator" - }, - { tag: "engineering", descr: "engineering software, e.g. cad programs" }, - { tag: "file-manager", descr: "a file manager" }, - { tag: "file-transfer", descr: "tools like ftp or p2p programs" }, - { tag: "finance", descr: "application to manage your finance" }, - { tag: "flowchart", descr: "a flowchart application" }, - { tag: "gui-designer", descr: "a gui designer application" }, - { tag: "identity", descr: "identity management" }, - { tag: "instant-messaging", descr: "an instant messaging client" }, - { tag: "library", descr: "a library software" }, - { tag: "medical-software", descr: "medical software" }, - { - tag: "monitor", - descr: "monitor application/applet that monitors some resource or activity" - }, - { tag: "museum", descr: "museum software" }, - { tag: "music", descr: "musical software" }, - { tag: "news", descr: "software to manage and publish news" }, - { tag: "ocr", descr: "optical character recognition application" }, - { tag: "parallel-computing", descr: "parallel computing software" }, - { tag: "photography", descr: "camera tools, etc." }, - { tag: "presentation", descr: "presentation software" }, - { tag: "printing", descr: "a tool to manage printers" }, - { tag: "procurement", descr: "software for managing procurement" }, - { tag: "project-management", descr: "project management application" }, - { - tag: "publishing", - descr: "desktop publishing applications and color management tools" - }, - { - tag: "raster-graphics", - descr: - "application for viewing, creating, or processing raster (bitmap) graphics" - }, - { tag: "remote-access", descr: "a tool to remotely manage your pc" }, - { tag: "revision-control", descr: "applications like git or subversion" }, - { tag: "robotics", descr: "robotics software" }, - { tag: "scanning", descr: "tool to scan a file/text" }, - { tag: "security", descr: "a security tool" }, - { tag: "sports", descr: "sports software" }, - { tag: "spreadsheet", descr: "a spreadsheet" }, - { tag: "telephony", descr: "telephony via pc" }, - { tag: "terminal-emulator", descr: "a terminal emulator application" }, - { tag: "texteditor", descr: "a text editor" }, - { tag: "texttools", descr: "a text tool utility" }, - { tag: "translation", descr: "a translation tool" }, - { - tag: "vector-graphics", - descr: "application for viewing, creating, or processing vector graphics" - }, - { tag: "video-conference", descr: "video conference software" }, - { tag: "viewer", descr: "tool to view e.g. a graphic or pdf file" }, - { tag: "web-browser", descr: "a web browser" }, - { - tag: "whistleblowing", - descr: "software for whistleblowing / anticorruption" - }, - { tag: "word-processor", descr: "a word processor" } -]; - -export default tags; -export const tag_names = tags.map(t => t.tag); -export const tag_descrs = tags.map(t => t.descr); diff --git a/editor/src/app/editor_generator_schema.json b/editor/src/app/editor_generator_schema.json deleted file mode 100644 index fb9add1f..00000000 --- a/editor/src/app/editor_generator_schema.json +++ /dev/null @@ -1,587 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/hyper-schema", - "title": "Publiccode definition schema", - "description": "", - "type": "object", - "id": "publiccode", - "properties": { - "publiccode-yaml-version": { - "$ref": "#/definitions/publiccode-yaml-version" - }, - "name": { - "$ref": "#/definitions/name" - }, - "applicationSuite": { - "$ref": "#/definitions/applicationSuite" - }, - "url": { - "$ref": "#/definitions/url" - }, - "landingURL": { - "$ref": "#/definitions/landingURL" - }, - "isBasedOn": { - "$ref": "#/definitions/isBasedOn" - }, - "softwareVersion": { - "$ref": "#/definitions/softwareVersion" - }, - "releaseDate": { - "$ref": "#/definitions/releaseDate" - }, - "logo": { - "$ref": "#/definitions/logo" - }, - "monochromeLogo": { - "$ref": "#/definitions/monochromeLogo" - }, - "inputTypes": { - "$ref": "#/definitions/inputTypes" - }, - "outputTypes": { - "$ref": "#/definitions/outputTypes" - }, - "platforms": { - "$ref": "#/definitions/platforms" - }, - "tags": { - "$ref": "#/definitions/tags" - }, - "usedBy": { - "$ref": "#/definitions/usedBy" - }, - "roadmap": { - "$ref": "#/definitions/roadmap" - }, - "developmentStatus": { - "$ref": "#/definitions/developmentStatus" - }, - "softwareType": { - "$ref": "#/definitions/softwareType" - }, - "intendedAudience": { - "$ref": "#/definitions/intendedAudience" - }, - "description": { - "$ref": "#/definitions/description" - }, - "legal": { - "$ref": "#/definitions/legal" - }, - "maintenance": { - "$ref": "#/definitions/maintenance" - }, - "localisation": { - "$ref": "#/definitions/localisation" - }, - "dependsOn": { - "$ref": "#/definitions/dependsOn" - } - }, - "required": [ - "publiccode-yaml-version", - "name", - "url", - "releaseDate", - "tags", - "developmentStatus", - "softwareType", - "description", - "legal" - ], - "definitions": { - "publiccode-yaml-version": { - "title": "publiccode-yaml-version", - "label": "publiccode-yaml-version", - "type": "string", - "enum": ["developmnet", "0.1"], - "description": - "This key contains the version of the publicode definition.", - "widget": "choice-multiple-expanded" - }, - "name": { - "type": "string", - "title": "Name", - "label": "Name", - "description": - "This key contains the name of the software. It contains the (short) public name of the product, which can be localised in the specific localisation section. It should be the name most people usually refer to the software. In case the software has both an internal 'code' name and a commercial name, use the commercial name.", - "examples": ["Medusa"] - }, - "applicationSuite": { - "type": "string", - "title": "applicationSuite", - "description": - "This key contains the name of the 'suite' to which the software belongs.", - "examples": ["MegaProductivitySuite"] - }, - "url": { - "type": "string", - "title": "url", - "description": - "A unique identifier for this software. This string must be a URL to the source code repository (git, svn, ...) in which the software is published. If the repository is available under multiple protocols, prefer HTTP/HTTPS URLs which don't require user authentication.", - "examples": ["https://example.com/italia/medusa.git"] - }, - "landingURL": { - "type": "string", - "title": "landingURL", - "description": - "If the url parameter does not serve a human readable or browsable page, but only serves source code to a source control client, with this key you have an option to specify a landing page. This page, ideally, is where your users will land when they will click a button labeled something like 'Go to the application source code'. In case the product provides an automated graphical installer, this URL can point to a page which contains a reference to the source code but also offers the download of such an installer.", - "examples": ["https://example.com/italia/medusa"] - }, - "isBasedOn": { - "type": "string", - "title": "isBasedOn", - "description": - "In case this software is a variant or a fork of another software, which might or might not contain a publiccode.yml file, this key will contain the url of the original project(s). The existence of this key identifies the fork as a software variant, descending from the specified repositories.", - "examples": ["https://github.com/italia/otello.git"] - }, - "softwareVersion": { - "type": "string", - "title": "softwareVersion", - "description": - "This key contains the latest stable version number of the software. The version number is a string that is not meant to be interpreted and parsed but just displayed; parsers should not assume semantic versioning or any other specific version format.", - "examples": ["1.0", "dev"] - }, - "releaseDate": { - "type": "string", - "title": "releaseDate", - "description": - "This key contains the date at which the latest version was released. This date is mandatory if the software has been released at least once and thus the version number is present.", - "examples": ["2017-04-15"], - "widget": "date" - }, - "logo": { - "type": "string", - "title": "logo", - "description": - "This key contains the logo of the software. Logos should be in vector format; raster formats are only allowed as a fallback. In this case, they should be transparent PNGs, minimum 1000px of width. Acceptable formats: SVG, SVGZ, PNG", - "examples": ["img/logo.jpg"] - }, - "monochromeLogo": { - "type": "string", - "title": "monochromeLogo", - "description": - "A monochromatic (black) logo. The logo should be in vector format; raster formats are only allowed as a fallback. In this case, they should be transparent PNGs, minimum 1000px of width. Acceptable formats: SVG, SVGZ, PNG", - "examples": ["img/logo.jpg"] - }, - "inputTypes": { - "title": "inputTypes", - "description": - "A list of Media Types (MIME Types) as mandated in RFC 6838 which the application can handle as output. In case the software does not support any input, you can skip this field or use application/x.empty.", - "type": "array", - "items": { - "type": "string" - } - }, - "outputTypes": { - "title": "outputTypes", - "description": - "A list of Media Types (MIME Types) as mandated in RFC 6838 which the application can handle as output. In case the software does not support any output, you can skip this field or use application/x.empty.", - "type": "array", - "items": { - "type": "string" - } - }, - "platforms": { - "type": "array", - "title": "platforms", - "description": - "Values: web, windows, mac, linux, ios, android. Human readable values outside this list are allowed", - "examples": ["android", "ios"], - "items": { - "type": "string", - "enum": ["web", "windows", "mac", "linux", "ios", "android"] - } - }, - "tags": { - "title": "tags", - "description": - "A list of words that can be used to describe the software and can help building catalogs of open software. Each tag must be in Unicode lowercase, and should not contain any Unicode whitespace character. The suggested character to separate multiple words is - (single dash). See also: description/[lang]/freeTags/", - "type": "array", - "items": { - "type": "string", - "enum": ["art", "backend"] - } - }, - "usedBy": { - "title": "usedBy", - "description": - "A list of the names of prominent public administrations (that will serve as testimonials) that are currently known to the software maintainer to be using this software. Parsers are encouraged to enhance this list also with other information that can obtain independently; for instance, a fork of a software, owned by an administration, could be used as a signal of usage of the software.", - "examples": ["stripe"], - "type": "array", - "items": { - "type": "string" - } - }, - "roadmap": { - "type": "string", - "title": "roadmap", - "description": "A link to a public roadmap of the software." - }, - "developmentStatus": { - "type": "string", - "title": "developmentStatus", - "description": - "Allowed values: concept, development, beta, stable, obsolete", - "enum": ["concept", "development", "beta", "stable", "obsolete"], - "widget": "choice-expanded" - }, - "softwareType": { - "type": "string", - "title": "softwareType", - "description": - "Allowed values: standalone, addon, library, configurationFiles", - "examples": ["standalone"], - "enum": ["standalone", "addon", "library", "configurationFiles"], - "widget": "choice-expanded" - }, - "intendedAudience": { - "title": "intended audience", - "type": "object", - "properties": { - "onlyFor": { - "title": "only for", - "type": "array", - "description": - "Public software could be very specific in scope because there is a large set of tasks that are specific to each type of administration. For instance, many softwares that are used in schools are probably not useful in hospitals. If you want to explicitly mark some software as only useful to certain types of administrations, you should add them to this key.The list of allowed values is defined in pa-types.md, and can be country-specific. This list can evolve at any time, separately from the version of this specification.", - "examples": ["city"], - "items": { - "type": "string" - } - }, - "countries": { - "title": "countries", - "type": "array", - "description": - "This key explicitly includes certain countries in the intended audience, i.e. the software explicitly claims compliance with specific processes, technologies or laws. All countries are specified using lowercase ISO 3166-1 alpha-2 two-letter country codes.", - "items": { - "title": "item", - "type": "string" - } - }, - "unsupportedCountries": { - "title": "unsupportedCountries", - "type": "array", - "description": - "This key explicitly marks countries as NOT supported. This might be the case if there is a conflict between how software is working and a specific law, process or technology. All countries are specified using lowercase ISO 3166-1 alpha-2 two-letter country codes.", - "items": { - "title": "item", - "type": "string" - } - } - } - }, - "legal": { - "title": "legal", - "type": "object", - "description": - "This section provides an overview of the legal info of the software.", - "properties": { - "license": { - "type": "string", - "title": "license", - "examples": ["AGPL-3.0-or-later"], - "description": - "This string describes the license under which the software is distributed. The string must contain a valid SPDX expression, referring to one (or multiple) open-source license. Please refer to the SPDX documentation for further information." - }, - "mainCopyrightOwner": { - "type": "string", - "title": "mainCopyrightOwner", - "examples": ["City of Amsterdam"], - "description": - "This string describes the entity that owns the copyright on 'most' of the code in the repository. Normally, this is the line that is reported with the copyright symbol at the top of most files in the repo." - }, - "repoOwner": { - "type": "string", - "title": "repoOwner", - "examples": ["City of Amsterdam"], - "description": - "This string describes the entity that owns this repository; this might or might not be the same entity who owns the copyright on the code itself. For instance, in case of a fork of the original software, the repoOwner is probably different from the mainCopyrightOwner." - }, - "authorsFile": { - "type": "string", - "title": "authorsFile", - "examples": ["authorsFile"], - "description": - "Some open-source softwares adopt a convention of identify the copyright holders through a file that lists all the entities that own the copyright. This is common in projects strongly backed by a community where there are many external contributors and no clear single/main copyright owner. In such cases, this key can be used to refer to the authors file, using a path relative to the root of the repository." - } - }, - "required": ["license", "repoOwner"] - }, - "contact": { - "title": "contact", - "description": - "This key contains an explicit affiliation information for the technical contact. In case of multiple maintainers, this can be used to create a relation between each technical contact and each maintainer entity. It can contain for instance a company name, an association name, etc.", - "type": "object", - "properties": { - "name": { - "type": "string", - "title": "name", - "description": - " mandatory - This key contains the full name of one of the technical contacts. It must be a real person; do NOT populate this key with generic contact information, company departments, associations, etc." - }, - "email": { - "type": "string", - "title": "Email", - "description": - "This key contains the e-mail address of the technical contact. It must be an email address of where the technical contact can be directly reached; do NOT populate this key with mailing-lists or generic contact points like info@acme.inc. ", - "examples": ["lou.reed@acme.inc"], - "widget": "email" - }, - "phone": { - "type": "string", - "title": "phone", - "description": " phone number (with international prefix)" - }, - "affiliation": { - "type": "string", - "title": "affiliation", - "description": - "This key contains an explicit affiliation information for the technical contact. In case of multiple maintainers, this can be used to create a relation between each technical contact and each maintainer entity. It can contain for instance a company name, an association name, etc." - } - }, - "required": ["email"] - }, - "contractor": { - "title": "contractor", - "description": - "This key contains an explicit affiliation information for the technical contact. In case of multiple maintainers, this can be used to create a relation between each technical contact and each maintainer entity. It can contain for instance a company name, an association name, etc.", - "type": "object", - "properties": { - "name": { - "type": "string", - "title": "name", - "description": - "mandatory - The name of the contractor, whether it's a company or a physical person." - }, - "until": { - "type": "string", - "title": "until", - "description": - " mandatory - This is a date (YYYY-MM-DD). This key must contain the date at which the maintenance is going to end. In case of community maintenance, the value should not be more than 2 years in the future, and thus will need to be regularly updated as the community continues working on the project." - }, - "website": { - "type": "string", - "title": "website", - "description": - "This key points to the maintainer website. It can either point to the main institutional website, or to a more project-specific page or website.", - "widget": "url" - } - } - }, - "maintenance": { - "title": "maintenance", - "type": "object", - "properties": { - "type": { - "type": "array", - "title": "type", - "description": - "This key describes how the software is currently maintained. 'internal' means that the software is internally maintained by the repository owner. 'contract' means that there is a commercial contract that binds an entity to the maintenance of the software; 'community' means that the software is currently maintained by one or more people that donate their time to the project; 'none' means that the software is not actively maintained.", - "items": { - "type": "string", - "enum": ["internal", "contract", "community", "none"] - } - }, - "contractors": { - "type": "array", - "title": "contractors", - "description": - "This key describes the entity or entities, if any, that are currently contracted for maintaining the software. They can be companies, organizations, or other collective names.", - "items": { - "$ref": "#/definitions/contractor" - } - }, - "contacts": { - "type": "array", - "title": "contacts", - "description": - "One or more contacts maintaining this software. This key describes the technical people currently responsible for maintaining the software. All contacts need to be a physical person, not a company or an organisation. if somebody is acting as a representative of an institution, it must be listed within the affiliation of the contact. In case of a commercial agreement (or a chain of such agreements), specify the final entities actually contracted to deliver the maintenance. Do not specify the software owner unless it is technically involved with the maintenance of the product as well.", - "items": { - "$ref": "#/definitions/contact" - } - } - }, - "required": ["contacts"] - }, - "localisation": { - "title": "localisation", - "type": "object", - "description": - "This section provides an overview of the localization features of the software.", - "properties": { - "localisationReady": { - "type": "boolean", - "title": "localisationReady", - "description": - "If yes, the software has infrastructure in place or is otherwise designed to be multilingual. It does not need to be available in more than one language." - }, - "availableLanguages": { - "type": "array", - "title": "availableLanguages", - "description": - "If present, this is the list of languages in which the software is available. Of course, this list will contain at least one language. See also: https://en.wikipedia.org/wiki/ISO_639-2", - "items": { - "type": "string" - } - } - } - }, - "dependency": { - "title": "dependency", - "description": - "A dependency is a complex object. The properties are the following:", - "type": "object", - "properties": { - "name": { - "type": "string", - "title": "name", - "description": - "mandatory - The name of the dependency (e.g. MySQL, NFC Reader)", - "examples": ["MySQL", "NFC Reader"] - }, - "versionMin": { - "type": "string", - "title": "versionMin", - "description": "the first compatible version", - "examples": ["1.0"] - }, - "versionMax": { - "type": "string", - "title": "versionMax", - "description": "the latest compatible version", - "examples": ["1.0"] - }, - "version": { - "type": "string", - "title": "version", - "description": - "the only major version for which the software is compatible. It assumes compatibility with all patches and bugfixes later applied to this version.", - "examples": ["1.0"] - }, - "optional": { - "type": "boolean", - "title": "optional", - "description": "whether the dependency is optional or mandatory", - "examples": [""] - } - } - }, - "dependsOn": { - "title": "dependsOn", - "description": - "This section provides an overview on the system-level dependencies required to install and use this software.", - "type": "object", - "properties": { - "open": { - "title": "open", - "description": - "This key contains a list of runtime dependencies that are distributed under an open-source license.", - "type": "array", - "items": { - "$ref": "#/definitions/dependency" - } - }, - "proprietary": { - "title": "propietary", - "description": - "TThis key contains a list of runtime dependencies that are distributed under a proprietary license.", - "type": "array", - "items": { - "$ref": "#/definitions/dependency" - } - }, - "hardware": { - "title": "hardware", - "description": - "This key contains a list of hardware dependencies that must be owned to use the software.", - "type": "array", - "items": { - "$ref": "#/definitions/dependency" - } - } - } - }, - "description": { - "title": "Description per Language", - "description": - "A set of fields to describe in language the current software", - "type": "object", - "properties": { - "localisedName": { - "type": "string", - "title": "localisedName", - "description": "localisedName" - }, - "shortDescription": { - "type": "string", - "title": "shortDescription", - "description": "A short description is required" - }, - "longDescription": { - "type": "string", - "title": "longDescription", - "description": "A long description is required", - "widget": "editor" - }, - "documentation": { - "type": "string", - "title": "documentation", - "description": "link to documentation" - }, - "apiDocumentation": { - "type": "string", - "title": "apiDocumentation", - "description": "link to the api documentation" - }, - "freeTags": { - "type": "array", - "title": "freeTags", - "description": "a list of tags", - "examples": ["webapp"], - "items": { - "title": "tag", - "type": "string" - } - }, - "featureList": { - "type": "array", - "title": "featureList", - "description": "a list of feature that the sw has", - "items": { - "type": "string", - "title": "feature" - } - }, - "screenshots": { - "type": "array", - "title": "screenshots", - "description": "array of image url", - "items": { - "type": "string", - "title": "screenshot" - } - }, - "videos": { - "type": "array", - "title": "videos", - "description": "link to videos", - "items": { - "type": "string", - "title": "video" - } - }, - "awards": { - "type": "array", - "title": "awards", - "description": "awards won", - "items": { - "type": "string", - "title": "award" - } - } - }, - "required": ["longDescription", "shortDescription"] - } - } -} diff --git a/editor/src/app/form/buildSyncValidation.js b/editor/src/app/form/buildSyncValidation.js deleted file mode 100644 index 119b9be0..00000000 --- a/editor/src/app/form/buildSyncValidation.js +++ /dev/null @@ -1,86 +0,0 @@ -import Ajv from "ajv"; -import merge from "deepmerge"; -import { set as _set } from "lodash"; - -const setError = (error, schema) => { - // convert property accessor (.xxx[].xxx) notation to jsonPointers notation - if (error.dataPath.charAt(0) === ".") { - error.dataPath = error.dataPath.replace(/[.[]/gi, "/"); - error.dataPath = error.dataPath.replace(/[\]]/gi, ""); - } - const dataPathParts = error.dataPath.split("/").slice(1); - let dataPath = error.dataPath.slice(1).replace(/\//g, "."); - const type = findTypeInSchema(schema, dataPathParts); - - let errorToSet; - if (type === "array" || type === "allOf" || type === "oneOf") { - errorToSet = { _error: error.message }; - } else { - errorToSet = error.message; - } - - let errors = {}; - _set(errors, dataPath, errorToSet); - return errors; -}; - -const findTypeInSchema = (schema, dataPath) => { - if (!schema) { - return; - } else if (dataPath.length === 0 && schema.hasOwnProperty("type")) { - return schema.type; - } else { - if (schema.type === "array") { - return findTypeInSchema(schema.items, dataPath.slice(1)); - } else if (schema.hasOwnProperty("allOf")) { - if (dataPath.length === 0) return "allOf"; - schema = { ...schema, ...merge.all(schema.allOf) }; - delete schema.allOf; - return findTypeInSchema(schema, dataPath); - } else if (schema.hasOwnProperty("oneOf")) { - if (dataPath.length === 0) return "oneOf"; - schema.oneOf.forEach(item => { - let type = findTypeInSchema(item, dataPath); - if (type) { - return type; - } - }); - } else { - return findTypeInSchema( - schema.properties[dataPath[0]], - dataPath.slice(1) - ); - } - } -}; - -const buildSyncValidation = (schema, ajvParam = null) => { - console.log("SYNC VALIDATION"); - let ajv = ajvParam; - if (ajv === null) { - ajv = new Ajv({ - errorDataPath: "property", - allErrors: true, - jsonPointers: false - }); - } - return values => { - const valid = ajv.validate(schema, values); - if (valid) { - return {}; - } - const ajvErrors = ajv.errors; - - let errors = ajvErrors.map(error => { - return setError(error, schema); - }); - // We need at least two elements - errors.push({}); - errors.push({}); - return merge.all(errors); - }; -}; - -export default buildSyncValidation; - -export { setError }; diff --git a/editor/src/app/form/compileSchema.js b/editor/src/app/form/compileSchema.js deleted file mode 100644 index 89becd4d..00000000 --- a/editor/src/app/form/compileSchema.js +++ /dev/null @@ -1,44 +0,0 @@ -function isObject(thing) { - return typeof thing === "object" && thing !== null && !Array.isArray(thing); -} - -function compileSchema(schema, root) { - if (!root) { - root = schema; - } - let newSchema; - - if (isObject(schema)) { - newSchema = {}; - for (let i in schema) { - if (schema.hasOwnProperty(i)) { - if (i === "$ref") { - newSchema = compileSchema(resolveRef(schema[i], root), root); - } else { - newSchema[i] = compileSchema(schema[i], root); - } - } - } - return newSchema; - } - - if (Array.isArray(schema)) { - newSchema = []; - for (let i = 0; i < schema.length; i += 1) { - newSchema[i] = compileSchema(schema[i], root); - } - return newSchema; - } - - return schema; -} - -function resolveRef(uri, schema) { - uri = uri.replace("#/", ""); - const tokens = uri.split("/"); - const tip = tokens.reduce((obj, token) => obj[token], schema); - - return tip; -} - -export default compileSchema; diff --git a/editor/src/app/form/index.js b/editor/src/app/form/index.js deleted file mode 100644 index 811f24d5..00000000 --- a/editor/src/app/form/index.js +++ /dev/null @@ -1,53 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import DefaultTheme from "./widgets/"; -import { reduxForm } from "redux-form"; -import renderFields from "./renderFields"; -import renderField from "./renderField"; -import processSubmitErrors from "./processSubmitErrors"; -import buildSyncValidation from "./buildSyncValidation"; -import { setError } from "./buildSyncValidation"; -import compileSchema from "./compileSchema"; - -const BaseForm = props => { - const { schema, handleSubmit, theme, error, submitting, context } = props; - return ( -
- {renderField(schema, null, theme || DefaultTheme, "", context)} -
{error && {error}}
- -
- ); -}; - -const Liform = props => { - props.schema.showLabel = false; - const schema = compileSchema(props.schema); - const formName = props.formKey ? props.formKey : "appForm"; - const FinalForm = reduxForm({ - form: formName, - validate: props.syncValidation || buildSyncValidation(schema, props.ajv), - initialValues: props.initialValues, - context: { ...props.context, formName } - })(BaseForm); - - return ( - - ); -}; - -export default Liform; - -export { - renderFields, - renderField, - processSubmitErrors, - DefaultTheme, - setError -}; diff --git a/editor/src/app/form/processSubmitErrors.js b/editor/src/app/form/processSubmitErrors.js deleted file mode 100644 index 74f0ab95..00000000 --- a/editor/src/app/form/processSubmitErrors.js +++ /dev/null @@ -1,40 +0,0 @@ -import { SubmissionError } from "redux-form"; -import { isEmpty as _isEmpty } from "lodash"; // added for empty check - -const convertToReduxFormErrors = obj => { - let objectWithoutChildrenAndFalseErrors = {}; - Object.keys(obj).map(name => { - if (name === "children") { - objectWithoutChildrenAndFalseErrors = { - ...objectWithoutChildrenAndFalseErrors, - ...convertToReduxFormErrors(obj[name]) - }; - } else { - if (obj[name].hasOwnProperty("children")) { - // if children, take field from it and set them directly as own field - objectWithoutChildrenAndFalseErrors[name] = convertToReduxFormErrors( - obj[name] - ); - } else { - if ( - obj[name].hasOwnProperty("errors") && - !_isEmpty(obj[name]["errors"]) - ) { - // using lodash for empty error check, dont add them if empty - objectWithoutChildrenAndFalseErrors[name] = obj[name]["errors"]; - } - } - } - return null; - }); - return objectWithoutChildrenAndFalseErrors; -}; - -const processSubmitErrors = errors => { - if (errors.hasOwnProperty("errors")) { - errors = convertToReduxFormErrors(errors.errors); - throw new SubmissionError(errors); - } -}; - -export default processSubmitErrors; diff --git a/editor/src/app/form/renderField.js b/editor/src/app/form/renderField.js deleted file mode 100644 index c8a174a3..00000000 --- a/editor/src/app/form/renderField.js +++ /dev/null @@ -1,63 +0,0 @@ -import React from "react"; -import deepmerge from "deepmerge"; - -const guessWidget = (schema, theme) => { - if (schema.widget) { - return schema.widget; - } else if (schema.hasOwnProperty("enum")) { - return "choice"; - } else if (schema.hasOwnProperty("oneOf")) { - return "oneOf"; - } else if (theme[schema.format]) { - return schema.format; - } - return schema.type || "object"; -}; - -export const isRequired = (schema, fieldName) => { - if (!schema.required) { - return false; - } - return schema.required === true || schema.required.indexOf(fieldName) !== -1; -}; - -const renderField = ( - schema, - fieldName, - theme, - prefix = "", - context = {}, - required = false -) => { - if (schema.hasOwnProperty("allOf")) { - schema = { ...schema, ...deepmerge.all(schema.allOf) }; - delete schema.allOf; - } - - const widget = guessWidget(schema, theme); - if (!theme[widget]) { - throw new Error(widget + " is not defined in the theme"); - } - - const newFieldName = prefix ? prefix + fieldName : fieldName; - - let showLabel = schema.showLabel == false ? false : true; - let lbl = schema.label || schema.title || fieldName; - let obj = React.createElement(theme[widget], { - key: fieldName, - fieldName: widget === "oneOf" ? fieldName : newFieldName, - label: lbl, - required: required, - schema: schema, - theme, - context, - prefix, - id: schema.id, - group: schema.group, - showLabel - }); - - return obj; -}; - -export default renderField; diff --git a/editor/src/app/form/renderFields.js b/editor/src/app/form/renderFields.js deleted file mode 100644 index ae569f0d..00000000 --- a/editor/src/app/form/renderFields.js +++ /dev/null @@ -1,49 +0,0 @@ -import React from "react"; -import renderField from "./renderField"; - -export const isRequired = (schema, fieldName) => { - if (!schema.required) { - return false; - } - return schema.required === true || schema.required.indexOf(fieldName) !== -1; -}; - -const renderFields = (schema, theme, prefix = null, context = {}) => { - let props = []; - for (let i in schema.properties) { - props.push({ prop: i, propertyOrder: schema.properties[i].propertyOrder }); - } - props = props.sort((a, b) => { - if (a.propertyOrder > b.propertyOrder) { - return 1; - } else if (a.propertyOrder < b.propertyOrder) { - return -1; - } else { - return 0; - } - }); - return props.map((item, i) => { - const name = item.prop; - const field = schema.properties[name]; - if (schema.isSummary) { - field.isSummary = schema.isSummary; - } - - return ( -
-
- {renderField( - field, - name, - theme, - prefix, - context, - isRequired(schema, name) - )} -
-
- ); - }); -}; - -export default renderFields; diff --git a/editor/src/app/form/widgets/ArrayWidget.js b/editor/src/app/form/widgets/ArrayWidget.js deleted file mode 100644 index 75198c7e..00000000 --- a/editor/src/app/form/widgets/ArrayWidget.js +++ /dev/null @@ -1,137 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import renderField from "../renderField"; -import { FieldArray, Field } from "redux-form"; -import { times as _times } from "lodash"; -import ChoiceWidget from "./ChoiceWidget"; -import classNames from "classnames"; -import Info from "../../components/Info"; -import img_close from "../../../asset/img/close.svg"; - -const renderArrayFields = ( - count, - schema, - theme, - fieldName, - remove, - context, - swap -) => { - const prefix = fieldName + "."; - - if (count) { - return _times(count, idx => { - let isSummary = false; - if (idx != count - 1) { - isSummary = true; - } - schema.isSummary = isSummary; - return ( -
- - {renderField( - { ...schema, showLabel: false }, - idx.toString(), - theme, - prefix, - context - )} -
- ); - }); - } else { - return null; - } -}; - -const renderInput = field => { - const className = classNames([ - "block__array", - { "has-error": field.meta.submitFailed && field.meta.error } - ]); - - return ( -
- {field.showLabel && ( - - )} - {field.meta.error &&
{field.meta.error}
} - {renderArrayFields( - field.fields.length, - field.schema.items, - field.theme, - field.fieldName, - idx => field.fields.remove(idx), - field.context, - (a, b) => { - field.fields.swap(a, b); - } - )} - - {field.description && ( - - )} -
- ); -}; - -const CollectionWidget = props => { - return ( - - ); -}; - -const ArrayWidget = props => { - // Arrays are tricky because they can be multiselects or collections - if ( - props.schema.items.hasOwnProperty("enum") && - props.schema.hasOwnProperty("uniqueItems") && - props.schema.uniqueItems - ) { - return ChoiceWidget({ - ...props, - schema: props.schema.items, - multiple: true - }); - } else { - return CollectionWidget(props); - } -}; - -ArrayWidget.propTypes = { - schema: PropTypes.object.isRequired, - fieldName: PropTypes.string, - label: PropTypes.string, - theme: PropTypes.object, - context: PropTypes.object -}; - -export default ArrayWidget; diff --git a/editor/src/app/form/widgets/BaseInputWidget.js b/editor/src/app/form/widgets/BaseInputWidget.js deleted file mode 100644 index cc75298c..00000000 --- a/editor/src/app/form/widgets/BaseInputWidget.js +++ /dev/null @@ -1,74 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import classNames from "classnames"; -import { Field } from "redux-form"; -import Info from "../../components/Info"; - -const renderInput = field => { - const className = classNames([ - "form-group", - { "has-error": field.meta.touched && field.meta.error } - ]); - - // let type = field.type; - // if (field.schema.widget) { - // console.log("WIDGET", field.schema.widget); - // } - - return ( -
- {field.showLabel && ( - - )} - - - {field.meta.touched && - field.meta.error && ( - {field.meta.error} - )} - {field.description && ( - - )} -
- ); -}; - -const BaseInputWidget = props => { - return ( - - ); -}; - -BaseInputWidget.propTypes = { - schema: PropTypes.object.isRequired, - type: PropTypes.string.isRequired, - required: PropTypes.bool, - fieldName: PropTypes.string, - label: PropTypes.string, - normalizer: PropTypes.func, - description: PropTypes.string -}; - -export default BaseInputWidget; diff --git a/editor/src/app/form/widgets/CheckboxWidget.js b/editor/src/app/form/widgets/CheckboxWidget.js deleted file mode 100644 index 7422bdc0..00000000 --- a/editor/src/app/form/widgets/CheckboxWidget.js +++ /dev/null @@ -1,63 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import classNames from "classnames"; -import { Field } from "redux-form"; -import Info from "../../components/Info"; - -const renderInput = field => { - const className = classNames([ - "form-group", - { "has-error": field.meta.touched && field.meta.error } - ]); - return ( -
-
- - -
- {field.meta.touched && - field.meta.error && ( - {field.meta.error} - )} - - {field.description && ( - - )} -
- ); -}; - -const CheckboxWidget = props => { - return ( - - ); -}; - -CheckboxWidget.propTypes = { - schema: PropTypes.object.isRequired, - fieldName: PropTypes.string, - label: PropTypes.string, - theme: PropTypes.object -}; - -export default CheckboxWidget; diff --git a/editor/src/app/form/widgets/ChoiceExpandedWidget.js b/editor/src/app/form/widgets/ChoiceExpandedWidget.js deleted file mode 100644 index 21f12201..00000000 --- a/editor/src/app/form/widgets/ChoiceExpandedWidget.js +++ /dev/null @@ -1,71 +0,0 @@ -import React from "react"; -import classNames from "classnames"; -import { Field } from "redux-form"; -import Info from "../../components/Info"; - -const zipObject = (props, values) => - props.reduce( - (prev, prop, i) => Object.assign(prev, { [prop]: values[i] }), - {} - ); - -const renderChoice = field => { - const className = classNames([ - "form-group", - { "has-error": field.meta.touched && field.meta.error } - ]); - const options = field.schema.enum; - const optionNames = field.schema.enum_titles || options; - - const selectOptions = zipObject(options, optionNames); - return ( -
- - {Object.entries(selectOptions).map(([value, name]) => ( -
- field.input.onChange(value)} - /> - -
- ))} - - {field.meta.touched && - field.meta.error && ( - {field.meta.error} - )} - - {field.description && ( - - )} -
- ); -}; - -const ChoiceExpandedWidget = props => { - return ( - - ); -}; - -export default ChoiceExpandedWidget; diff --git a/editor/src/app/form/widgets/ChoiceMultipleExpandedWidget.js b/editor/src/app/form/widgets/ChoiceMultipleExpandedWidget.js deleted file mode 100644 index 43d34f10..00000000 --- a/editor/src/app/form/widgets/ChoiceMultipleExpandedWidget.js +++ /dev/null @@ -1,90 +0,0 @@ -import React from "react"; -import classNames from "classnames"; -import { Field } from "redux-form"; -import Info from "../../components/Info"; - -const zipObject = (props, values) => - props.reduce( - (prev, prop, i) => Object.assign(prev, { [prop]: values[i] }), - {} - ); - -const changeValue = (checked, item, onChange, currentValue = []) => { - console.log("CURRENT ITEM", item, "CURRENT VALUE", currentValue); - if (checked) { - if (currentValue.indexOf(checked) === -1) { - return onChange([...currentValue, item]); - } - } else { - return onChange(currentValue.filter(it => it != item)); - } - return onChange(currentValue); -}; - -const renderChoice = field => { - const className = classNames([ - "form-group", - { "has-error": field.meta.touched && field.meta.error } - ]); - const options = field.schema.items.enum; - const optionNames = field.schema.items.enum_titles || options; - - const selectOptions = zipObject(options, optionNames); - return ( -
- - {Object.entries(selectOptions).map(([value, name]) => { - return ( -
- - changeValue( - e.target.checked, - value, - field.input.onChange, - field.input.value - ) - } - /> - -
- ); - })} - - {field.meta.touched && - field.meta.error && ( - {field.meta.error} - )} - {field.description && ( - - )} -
- ); -}; - -const ChoiceMultipleExpandedWidget = props => { - return ( - - ); -}; - -export default ChoiceMultipleExpandedWidget; diff --git a/editor/src/app/form/widgets/ChoiceWidget.js b/editor/src/app/form/widgets/ChoiceWidget.js deleted file mode 100644 index 51f6b77b..00000000 --- a/editor/src/app/form/widgets/ChoiceWidget.js +++ /dev/null @@ -1,88 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import classNames from "classnames"; -import { Field } from "redux-form"; -import { zipObject as _zipObject, map as _map } from "lodash"; -import Info from "../../components/Info"; - -const renderSelect = field => { - const className = classNames([ - "form-group", - { "has-error": field.meta.touched && field.meta.error } - ]); - const options = field.schema.enum; - const optionNames = field.schema.enum_titles || options; - - const selectOptions = _zipObject(options, optionNames); - return ( -
- {field.showLabel && ( - - )} - - - - {field.meta.touched && - field.meta.error && ( -
{field.meta.error}
- )} - - {field.description && ( - - )} -
- ); -}; - -const ChoiceWidget = props => { - return ( - - ); -}; - -ChoiceWidget.propTypes = { - schema: PropTypes.object.isRequired, - fieldName: PropTypes.string, - label: PropTypes.string, - theme: PropTypes.object, - multiple: PropTypes.bool, - required: PropTypes.bool -}; - -export default ChoiceWidget; diff --git a/editor/src/app/form/widgets/ColorWidget.js b/editor/src/app/form/widgets/ColorWidget.js deleted file mode 100644 index 202c4cbe..00000000 --- a/editor/src/app/form/widgets/ColorWidget.js +++ /dev/null @@ -1,10 +0,0 @@ -import React from "react"; -import BaseInputWidget from "./BaseInputWidget"; - -const ColorWidget = props => { - return ; -}; - - - -export default ColorWidget; diff --git a/editor/src/app/form/widgets/CompatibleDateTimeWidget.js b/editor/src/app/form/widgets/CompatibleDateTimeWidget.js deleted file mode 100644 index 942e8244..00000000 --- a/editor/src/app/form/widgets/CompatibleDateTimeWidget.js +++ /dev/null @@ -1,191 +0,0 @@ -import React from "react"; -import classNames from "classnames"; -import { Field } from "redux-form"; -import DateSelector from "./DateSelector"; -import Info from "../../components/Info"; - -// produces an array [start..end-1] -const range = (start, end) => - Array.from({ length: end - start }, (v, k) => k + start); - -// produces an array [start..end-1] padded with zeros, (two digits) -const rangeZeroPad = (start, end) => - Array.from({ length: end - start }, (v, k) => ("0" + (k + start)).slice(-2)); - -const extractYear = value => { - return extractDateTimeToken(value, 0); -}; -const extractMonth = value => { - return extractDateTimeToken(value, 1); -}; -const extractDay = value => { - return extractDateTimeToken(value, 2); -}; -const extractHour = value => { - return extractDateTimeToken(value, 3); -}; -const extractMinute = value => { - return extractDateTimeToken(value, 4); -}; -const extractSecond = value => { - return extractDateTimeToken(value, 5); -}; - -const extractDateTimeToken = (value, index) => { - if (!value) { - return ""; - } - // Remove timezone Z - value = value.substring(0, value.length - 1); - const tokens = value.split(/[-T:]/); - if (tokens.length !== 6) { - return ""; - } - return tokens[index]; -}; - -class CompatibleDateTime extends React.Component { - constructor(props, context) { - super(props, context); - this.state = { - year: null, - month: null, - day: null, - hour: null, - minute: null, - second: null - }; - this.onBlur = this.onBlur.bind(this); - } - - // Produces a RFC 3339 full-date from the state - buildRfc3339Date() { - const year = this.state.year || ""; - const month = this.state.month || ""; - const day = this.state.day || ""; - return year + "-" + month + "-" + day; - } - - // Produces a RFC 3339 datetime from the state - buildRfc3339DateTime() { - const date = this.buildRfc3339Date(); - const hour = this.state.hour || ""; - const minute = this.state.minute || ""; - const second = this.state.second || ""; - return date + "T" + hour + ":" + minute + ":" + second + "Z"; - } - - onChangeField(field, e) { - const value = e.target.value; - let changeset = {}; - changeset[field] = value; - this.setState(changeset, () => { - this.props.input.onChange(this.buildRfc3339DateTime()); - }); - } - onBlur() { - this.props.input.onBlur(this.buildRfc3339DateTime()); - } - render() { - const field = this.props; - const className = classNames([ - "form-group", - { "has-error": field.meta.touched && field.meta.error } - ]); - return ( -
- -
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
  • - -
  • -
- {field.meta.touched && - field.meta.error && ( - {field.meta.error} - )} - {field.description && } -
- ); - } -} -const CompatibleDateTimeWidget = props => { - return ( - - ); -}; - -export default CompatibleDateTimeWidget; - -// Only for testing purposes -export { extractDateTimeToken }; diff --git a/editor/src/app/form/widgets/CompatibleDateWidget.js b/editor/src/app/form/widgets/CompatibleDateWidget.js deleted file mode 100644 index 4fa1fd3a..00000000 --- a/editor/src/app/form/widgets/CompatibleDateWidget.js +++ /dev/null @@ -1,143 +0,0 @@ -import React from "react"; -import classNames from "classnames"; -import { Field } from "redux-form"; -import DateSelector from "./DateSelector"; -import Info from "../../components/Info"; - -// produces an array [start..end-1] -const range = (start, end) => - Array.from({ length: end - start }, (v, k) => k + start); - -// produces an array [start..end-1] padded with zeros, (two digits) -const rangeZeroPad = (start, end) => - Array.from({ length: end - start }, (v, k) => ("0" + (k + start)).slice(-2)); - -const extractYear = value => { - return extractDateToken(value, 0); -}; -const extractMonth = value => { - return extractDateToken(value, 1); -}; -const extractDay = value => { - return extractDateToken(value, 2); -}; - -const extractDateToken = (value, index) => { - if (!value) { - return ""; - } - const tokens = value.split(/-/); - if (tokens.length !== 3) { - return ""; - } - return tokens[index]; -}; - -class CompatibleDate extends React.Component { - constructor(props, context) { - super(props, context); - this.state = { - year: null, - month: null, - day: null, - hour: null, - minute: null, - second: null - }; - this.onBlur = this.onBlur.bind(this); - } - - // Produces a RFC 3339 full-date from the state - buildRfc3339Date() { - const year = this.state.year || ""; - const month = this.state.month || ""; - const day = this.state.day || ""; - return year + "-" + month + "-" + day; - } - - onChangeField(field, e) { - const value = e.target.value; - let changeset = {}; - changeset[field] = value; - this.setState(changeset, () => { - this.props.input.onChange(this.buildRfc3339Date()); - }); - } - - onBlur() { - this.props.input.onBlur(this.buildRfc3339Date()); - } - - render() { - const field = this.props; - const className = classNames([ - "form-group", - { "has-error": field.meta.touched && field.meta.error } - ]); - return ( -
- -
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
- {field.meta.touched && - field.meta.error && ( - {field.meta.error} - )} - {field.description && } -
- ); - } -} -const CompatibleDateWidget = props => { - return ( - - ); -}; - -export default CompatibleDateWidget; - -// Only for testing purposes -export { extractDateToken }; diff --git a/editor/src/app/form/widgets/DateSelector.js b/editor/src/app/form/widgets/DateSelector.js deleted file mode 100644 index 97528c8c..00000000 --- a/editor/src/app/form/widgets/DateSelector.js +++ /dev/null @@ -1,29 +0,0 @@ -import React from "react"; - -const DateSelector = props => { - return ( - - ); -}; - -export default DateSelector; diff --git a/editor/src/app/form/widgets/DateTimeWidget.js b/editor/src/app/form/widgets/DateTimeWidget.js deleted file mode 100644 index 1833f880..00000000 --- a/editor/src/app/form/widgets/DateTimeWidget.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import BaseInputWidget from "./BaseInputWidget"; - -const DateTimeWidget = props => { - return ; -}; - -export default DateTimeWidget; diff --git a/editor/src/app/form/widgets/DateWidget.js b/editor/src/app/form/widgets/DateWidget.js deleted file mode 100644 index bbc8bc69..00000000 --- a/editor/src/app/form/widgets/DateWidget.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import BaseInputWidget from "./BaseInputWidget"; - -const DateWidget = props => { - return ; -}; - -export default DateWidget; diff --git a/editor/src/app/form/widgets/EditorWidget.js b/editor/src/app/form/widgets/EditorWidget.js deleted file mode 100644 index 8c00b78c..00000000 --- a/editor/src/app/form/widgets/EditorWidget.js +++ /dev/null @@ -1,120 +0,0 @@ -import React, { Component } from "react"; -import PropTypes from "prop-types"; -import classNames from "classnames"; -import { Field } from "redux-form"; -import RichTextEditor from "react-rte"; -import Info from "../../components/Info"; - -const emptyVal = RichTextEditor.createEmptyValue(); - -class MyEditor extends Component { - constructor(props) { - super(props); - //let value = this.props.value ? RichTextEditor.createValueFromString(this.props.value, "html") : emptyVal; - let text = emptyVal; - if (this.props.value) { - text = RichTextEditor.createValueFromString(this.props.value, "html"); - } - this.state = { - text, - reset: false - }; - this.onChange = this.onChange.bind(this); - } - - onChange(val) { - let { text } = this.state; - console.log("onChange"); - if (this.props.onChange) { - if (val == null) this.props.onChange(""); - else this.props.onChange(val.toString("html")); - } - - this.setState({ text: val }); - } - - componentWillReceiveProps(next) { - if (!next.value) { - console.log("RESET "); - this.setState({ text: emptyVal, reset: true }); - } else { - if (next.pristine && next.initial) { - console.log("INITIAL "); - - let next_html = RichTextEditor.createValueFromString( - next.initial, - "html" - ); - this.setState({ text: next_html }); - } - } - } - - render() { - return ( - - ); - } -} - -const renderInput = field => { - const className = classNames([ - "form-group editor__widget", - { "has-error": field.meta.touched && field.meta.error } - ]); - - return ( -
- -
- -
- {field.meta.touched && - field.meta.error && ( - {field.meta.error} - )} - {field.description && } -
- ); -}; - -const editorWidget = props => { - return ( - - ); -}; - -editorWidget.propTypes = { - schema: PropTypes.object.isRequired, - fieldName: PropTypes.string, - label: PropTypes.string, - theme: PropTypes.object, - multiple: PropTypes.bool, - required: PropTypes.bool -}; - -export default editorWidget; diff --git a/editor/src/app/form/widgets/EmailWidget.js b/editor/src/app/form/widgets/EmailWidget.js deleted file mode 100644 index 7ef56852..00000000 --- a/editor/src/app/form/widgets/EmailWidget.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import BaseInputWidget from "./BaseInputWidget"; - -const EmailWidget = props => { - return ; -}; - -export default EmailWidget; diff --git a/editor/src/app/form/widgets/FileWidget.js b/editor/src/app/form/widgets/FileWidget.js deleted file mode 100644 index 28a4dd70..00000000 --- a/editor/src/app/form/widgets/FileWidget.js +++ /dev/null @@ -1,62 +0,0 @@ -import React from "react"; -import { Field } from "redux-form"; -import classNames from "classnames"; - -const processFile = (onChange, e) => { - const files = e.target.files; - return new Promise(() => { - let reader = new FileReader(); - reader.addEventListener( - "load", - () => { - onChange(reader.result); - }, - false - ); - reader.readAsDataURL(files[0]); - }); -}; - -const File = field => { - const className = classNames([ - "form-group", - { "has-error": field.meta.touched && field.meta.error } - ]); - return ( -
- - - {field.meta.touched && - field.meta.error && ( - {field.meta.error} - )} - {field.description && {field.description}} -
- ); -}; - -const FileWidget = props => { - return ( - - ); -}; - -export default FileWidget; diff --git a/editor/src/app/form/widgets/MoneyWidget.js b/editor/src/app/form/widgets/MoneyWidget.js deleted file mode 100644 index 722c866f..00000000 --- a/editor/src/app/form/widgets/MoneyWidget.js +++ /dev/null @@ -1,61 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import classNames from "classnames"; -import { Field } from "redux-form"; - -const renderInput = field => { - const className = classNames([ - "form-group", - { "has-error": field.meta.touched && field.meta.error } - ]); - return ( -
- -
- - -
- {field.meta.touched && - field.meta.error && ( - {field.meta.error} - )} - {field.description && ( - {field.description} - )} -
- ); -}; - -const MoneyWidget = props => { - return ( - - ); -}; - -MoneyWidget.propTypes = { - schema: PropTypes.object.isRequired, - fieldName: PropTypes.string, - label: PropTypes.string, - theme: PropTypes.object, - multiple: PropTypes.bool, - required: PropTypes.bool -}; - -export default MoneyWidget; diff --git a/editor/src/app/form/widgets/NumberWidget.js b/editor/src/app/form/widgets/NumberWidget.js deleted file mode 100644 index 00e02be9..00000000 --- a/editor/src/app/form/widgets/NumberWidget.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import BaseInputWidget from "./BaseInputWidget"; - -const NumberWidget = props => { - return ; -}; - -export default NumberWidget; diff --git a/editor/src/app/form/widgets/ObjectWidget.js b/editor/src/app/form/widgets/ObjectWidget.js deleted file mode 100644 index d1d6ac19..00000000 --- a/editor/src/app/form/widgets/ObjectWidget.js +++ /dev/null @@ -1,39 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import renderFields from "../renderFields"; - -const Widget = props => { - let isSummary = false; - if (props && props.schema && props.schema.isSummary) { - isSummary = props.schema.isSummary; - } - // console.log(props); - return ( -
- {props.showLabel && - props.label && ( - - {props.label} {props.schema.required ? "*" : ""} - - )} - - {renderFields( - props.schema, - props.theme, - props.fieldName && props.fieldName + ".", - props.context - )} - -
- ); -}; - -Widget.propTypes = { - schema: PropTypes.object.isRequired, - fieldName: PropTypes.string, - label: PropTypes.string, - theme: PropTypes.object, - context: PropTypes.object -}; - -export default Widget; diff --git a/editor/src/app/form/widgets/OriginalArrayWidget.js b/editor/src/app/form/widgets/OriginalArrayWidget.js deleted file mode 100644 index 50bc232c..00000000 --- a/editor/src/app/form/widgets/OriginalArrayWidget.js +++ /dev/null @@ -1,147 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import renderField from "../renderField"; -import { FieldArray } from "redux-form"; -import { times as _times } from "lodash"; -import ChoiceWidget from "./ChoiceWidget"; -import classNames from "classnames"; - -const renderArrayFields = ( - count, - schema, - theme, - fieldName, - remove, - context, - swap -) => { - const prefix = fieldName + "."; - if (count) { - return _times(count, idx => { - return ( -
-
- {idx !== count - 1 && count > 1 ? ( - - ) : ( - "" - )} - {idx !== 0 && count > 1 ? ( - - ) : ( - "" - )} - - -
- {renderField( - { ...schema, showLabel: false }, - idx.toString(), - theme, - prefix, - context - )} -
- ); - }); - } else { - return null; - } -}; - -const renderInput = field => { - const className = classNames([ - "arrayType", - { "has-error": field.meta.submitFailed && field.meta.error } - ]); - - return ( -
- {field.label} - {field.meta.submitFailed && - field.meta.error && ( - {field.meta.error} - )} - {renderArrayFields( - field.fields.length, - field.schema.items, - field.theme, - field.fieldName, - idx => field.fields.remove(idx), - field.context, - (a, b) => { - field.fields.swap(a, b); - } - )} - field.fields.push()}> - Add new - -
- ); -}; - -const CollectionWidget = props => { - return ( - - ); -}; - -const ArrayWidget = props => { - // Arrays are tricky because they can be multiselects or collections - if ( - props.schema.items.hasOwnProperty("enum") && - props.schema.hasOwnProperty("uniqueItems") && - props.schema.uniqueItems - ) { - return ChoiceWidget({ - ...props, - schema: props.schema.items, - multiple: true - }); - } else { - return CollectionWidget(props); - } -}; - -ArrayWidget.propTypes = { - schema: PropTypes.object.isRequired, - fieldName: PropTypes.string, - label: PropTypes.string, - theme: PropTypes.object, - context: PropTypes.object -}; - -export default ArrayWidget; diff --git a/editor/src/app/form/widgets/PasswordWidget.js b/editor/src/app/form/widgets/PasswordWidget.js deleted file mode 100644 index 456f2793..00000000 --- a/editor/src/app/form/widgets/PasswordWidget.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import BaseInputWidget from "./BaseInputWidget"; - -const PasswordWidget = props => { - return ; -}; - -export default PasswordWidget; diff --git a/editor/src/app/form/widgets/PercentWidget.js b/editor/src/app/form/widgets/PercentWidget.js deleted file mode 100644 index 89707dd2..00000000 --- a/editor/src/app/form/widgets/PercentWidget.js +++ /dev/null @@ -1,61 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import classNames from "classnames"; -import { Field } from "redux-form"; - -const renderInput = field => { - const className = classNames([ - "form-group", - { "has-error": field.meta.touched && field.meta.error } - ]); - return ( -
- -
- - % -
- {field.meta.touched && - field.meta.error && ( - {field.meta.error} - )} - {field.description && ( - {field.description} - )} -
- ); -}; - -const Widget = props => { - return ( - - ); -}; - -Widget.propTypes = { - schema: PropTypes.object.isRequired, - fieldName: PropTypes.string, - label: PropTypes.string, - theme: PropTypes.object, - multiple: PropTypes.bool, - required: PropTypes.bool -}; - -export default Widget; diff --git a/editor/src/app/form/widgets/SearchWidget.js b/editor/src/app/form/widgets/SearchWidget.js deleted file mode 100644 index 8a93e3ef..00000000 --- a/editor/src/app/form/widgets/SearchWidget.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import BaseInputWidget from "./BaseInputWidget"; - -const SearchWidget = props => { - return ; -}; - -export default SearchWidget; diff --git a/editor/src/app/form/widgets/StringWidget.js b/editor/src/app/form/widgets/StringWidget.js deleted file mode 100644 index ad84d401..00000000 --- a/editor/src/app/form/widgets/StringWidget.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import BaseInputWidget from "./BaseInputWidget"; - -const StringWidget = props => { - return ; -}; - -export default StringWidget; diff --git a/editor/src/app/form/widgets/TagWidget.js b/editor/src/app/form/widgets/TagWidget.js deleted file mode 100644 index 223c0687..00000000 --- a/editor/src/app/form/widgets/TagWidget.js +++ /dev/null @@ -1,60 +0,0 @@ -import React, { Component } from "react"; -import PropTypes from "prop-types"; -import classNames from "classnames"; -import { Field } from "redux-form"; -import { Multiselect } from "react-widgets"; -import Info from "../../components/Info"; - -const renderInput = field => { - const className = classNames([ - "form-group", - { "has-error": field.meta.touched && field.meta.error } - ]); - - return ( -
- - - field.input.onBlur()} - value={field.input.value || []} - data={field.schema.items.enum} - /> - - {field.meta.touched && - field.meta.error && ( - {field.meta.error} - )} - {field.description && } -
- ); -}; - -const editorWidget = props => { - return ( - - ); -}; - -editorWidget.propTypes = { - schema: PropTypes.object.isRequired, - fieldName: PropTypes.string, - label: PropTypes.string, - theme: PropTypes.object, - multiple: PropTypes.bool, - required: PropTypes.bool -}; - -export default editorWidget; diff --git a/editor/src/app/form/widgets/TextareaWidget.js b/editor/src/app/form/widgets/TextareaWidget.js deleted file mode 100644 index adef579d..00000000 --- a/editor/src/app/form/widgets/TextareaWidget.js +++ /dev/null @@ -1,56 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import classNames from "classnames"; -import { Field } from "redux-form"; -import Info from "../../components/Info"; - -const renderInput = field => { - const className = classNames([ - "form-group", - { "has-error": field.meta.touched && field.meta.error } - ]); - return ( -
- -