diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-06-02 20:41:58 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-06-02 20:41:58 +0200 |
| commit | 7eab18f839616140fe3dbc4b51e29ec903c48077 (patch) | |
| tree | c6f4160b7567904726f8036d2f5a2ef4d7846093 /frontend/views/graph/components/page.form.js | |
| parent | 402dd17858076b6a0fac618de85614114dfe94fe (diff) | |
adding les pages
Diffstat (limited to 'frontend/views/graph/components/page.form.js')
| -rw-r--r-- | frontend/views/graph/components/page.form.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/frontend/views/graph/components/page.form.js b/frontend/views/graph/components/page.form.js index ce14e2e..54a96a1 100644 --- a/frontend/views/graph/components/page.form.js +++ b/frontend/views/graph/components/page.form.js @@ -10,6 +10,9 @@ const newPage = (data) => ({ title: '', username: session('username'), description: '', + settings: { + x: 10, y: 10, + }, ...data, }) @@ -42,11 +45,15 @@ export default class PageForm extends Component { if (errorFields.has(name)) { errorFields.delete(name) } + let sanitizedValue = value + if (name === 'path') { + sanitizedValue = sanitizedValue.toLowerCase().replace(/ /, '-').replace(/[!@#$%^&*()[\]{}]/, '-').replace(/-+/, '-') + } this.setState({ errorFields, data: { ...this.state.data, - [name]: value, + [name]: sanitizedValue, } }) } @@ -69,8 +76,8 @@ export default class PageForm extends Component { e.preventDefault() const { isNew, onSubmit } = this.props const { data } = this.state - const requiredKeys = "title username path description".split(" ") - const validKeys = "title username path description".split(" ") + const requiredKeys = "path title".split(" ") + const validKeys = "graph_id path title username description settings".split(" ") const validData = validKeys.reduce((a,b) => { a[b] = data[b]; return a }, {}) const errorFields = requiredKeys.filter(key => !validData[key]) if (errorFields.length) { |
