From 9f017f8524b9ef687aaaa57a2775f86e5391a7cf Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 10 Jul 2020 15:52:08 +0200 Subject: link form --- frontend/views/page/components/tile.form.js | 57 ++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 5 deletions(-) (limited to 'frontend/views/page/components') diff --git a/frontend/views/page/components/tile.form.js b/frontend/views/page/components/tile.form.js index dd8da96..eca895f 100644 --- a/frontend/views/page/components/tile.form.js +++ b/frontend/views/page/components/tile.form.js @@ -15,7 +15,7 @@ import { preloadImage } from '../../../util' import * as tileActions from '../../tile/tile.actions' const SELECT_TYPES = [ - "image", "text" + "image", "text", "link" ].map(s => ({ name: s, label: s })) const ALIGNMENTS = [ @@ -32,6 +32,7 @@ const ALIGNMENTS = [ const REQUIRED_KEYS = { image: ['url'], text: ['content'], + link: [], } const IMAGE_TILE_STYLES = [ @@ -66,6 +67,7 @@ const newImage = (data) => ({ }, type: 'image', target_page_id: null, + external_link_url: "", ...data, }) @@ -83,20 +85,33 @@ const newText = (data) => ({ }, type: 'text', target_page_id: null, + external_link_url: "", ...data, }) -const newPosition = () => ({ +const newLink = (data) => ({ + settings: { + ...newPosition({ width: 100, height: 100, }), + }, + type: 'link', + target_page_id: null, + external_link_url: "", + ...data, +}) + +const newPosition = (data) => ({ x: 0, y: 0, width: 0, height: 0, rotation: 0, scale: 1, opacity: 1, align: "center_center", + ...data, }) const TYPE_CONSTRUCTORS = { image: newImage, text: newText, + link: newLink, } class TileForm extends Component { @@ -329,9 +344,11 @@ class TileForm extends Component { ? this.renderImageForm() : temporaryTile.type === 'text' ? this.renderTextForm() + : temporaryTile.type === 'link' + ? this.renderLinkForm() : ""} - {this.renderLinkForm()} + {this.renderHyperlinkForm()} {this.renderMiscForm()}
@@ -372,7 +389,7 @@ class TileForm extends Component { ) } - renderLinkForm() { + renderHyperlinkForm() { const { temporaryTile } = this.props const { pageList } = this.state const isExternalLink = temporaryTile.target_page_id === EXTERNAL_LINK @@ -439,7 +456,6 @@ class TileForm extends Component {
) - } renderTextForm() { @@ -525,6 +541,37 @@ class TileForm extends Component { ) } + renderLinkForm() { + const { temporaryTile } = this.props + const { errorFields } = this.state + return ( +
+
+ + +
+
+ ) + } + renderMiscForm() { const { temporaryTile } = this.props return ( -- cgit v1.2.3-70-g09d2