mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-04-04 21:25:24 +00:00
Merge branch '2257-add-an-option-to-enter-markdown-for-the-paragraph-element-1' into 'develop'
Rename ParagraphElement to TextElement Closes #2257 See merge request baserow/baserow!2052
This commit is contained in:
commit
59192c94f3
31 changed files with 153 additions and 145 deletions
backend
src/baserow
contrib/builder
test_utils/fixtures
tests/baserow/contrib/builder
web-frontend/modules
builder
core/assets/scss/components/builder/elements
|
@ -167,13 +167,13 @@ class BuilderConfig(AppConfig):
|
|||
ImageElementType,
|
||||
InputTextElementType,
|
||||
LinkElementType,
|
||||
ParagraphElementType,
|
||||
TableElementType,
|
||||
TextElementType,
|
||||
)
|
||||
from .elements.registries import element_type_registry
|
||||
|
||||
element_type_registry.register(HeadingElementType())
|
||||
element_type_registry.register(ParagraphElementType())
|
||||
element_type_registry.register(TextElementType())
|
||||
element_type_registry.register(LinkElementType())
|
||||
element_type_registry.register(ImageElementType())
|
||||
element_type_registry.register(InputTextElementType())
|
||||
|
|
|
@ -104,7 +104,7 @@ class BuilderApplicationTypeInitApplication:
|
|||
value="'Welcome to the Application Builder!'",
|
||||
)
|
||||
ElementHandler().create_element(
|
||||
element_type_registry.get("paragraph"),
|
||||
element_type_registry.get("text"),
|
||||
page=page,
|
||||
value="\"Baserow's application builder allows you to create dynamic and "
|
||||
"complex interface applications with no code. Pages can optionally "
|
||||
|
@ -140,7 +140,7 @@ class BuilderApplicationTypeInitApplication:
|
|||
value="'Tables'",
|
||||
)
|
||||
ElementHandler().create_element(
|
||||
element_type_registry.get("paragraph"),
|
||||
element_type_registry.get("text"),
|
||||
page=page,
|
||||
value="'Here is an example table sourcing data from the "
|
||||
f"{table.name} table.'",
|
||||
|
@ -284,7 +284,7 @@ class BuilderApplicationTypeInitApplication:
|
|||
value="'Containers'",
|
||||
)
|
||||
ElementHandler().create_element(
|
||||
element_type_registry.get("paragraph"),
|
||||
element_type_registry.get("text"),
|
||||
page=page,
|
||||
place_in_container=0,
|
||||
style_padding_left=0,
|
||||
|
@ -293,7 +293,7 @@ class BuilderApplicationTypeInitApplication:
|
|||
value="'Elements can be placed in containers...'",
|
||||
)
|
||||
ElementHandler().create_element(
|
||||
element_type_registry.get("paragraph"),
|
||||
element_type_registry.get("text"),
|
||||
page=page,
|
||||
place_in_container=1,
|
||||
style_padding_left=0,
|
||||
|
@ -302,7 +302,7 @@ class BuilderApplicationTypeInitApplication:
|
|||
value="'which you can configure with more, or fewer columns.'",
|
||||
)
|
||||
ElementHandler().create_element(
|
||||
element_type_registry.get("paragraph"),
|
||||
element_type_registry.get("text"),
|
||||
page=page,
|
||||
place_in_container=2,
|
||||
style_padding_left=0,
|
||||
|
|
|
@ -29,8 +29,8 @@ from baserow.contrib.builder.elements.models import (
|
|||
ImageElement,
|
||||
InputTextElement,
|
||||
LinkElement,
|
||||
ParagraphElement,
|
||||
TableElement,
|
||||
TextElement,
|
||||
VerticalAlignments,
|
||||
)
|
||||
from baserow.contrib.builder.elements.registries import (
|
||||
|
@ -446,13 +446,13 @@ class HeadingElementType(ElementType):
|
|||
return super().import_serialized(page, serialized_copy, id_mapping)
|
||||
|
||||
|
||||
class ParagraphElementType(ElementType):
|
||||
class TextElementType(ElementType):
|
||||
"""
|
||||
A simple paragraph element that can be used to display a paragraph of text.
|
||||
A text element that allows plain or markdown content.
|
||||
"""
|
||||
|
||||
type = "paragraph"
|
||||
model_class = ParagraphElement
|
||||
type = "text"
|
||||
model_class = TextElement
|
||||
serializer_field_names = ["value"]
|
||||
allowed_fields = ["value"]
|
||||
|
||||
|
|
|
@ -345,9 +345,9 @@ class HeadingElement(Element):
|
|||
)
|
||||
|
||||
|
||||
class ParagraphElement(Element):
|
||||
class TextElement(Element):
|
||||
"""
|
||||
A simple paragraph.
|
||||
A simple blob of text.
|
||||
"""
|
||||
|
||||
value = FormulaField(default="")
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
# Generated by Django 4.0.10 on 2024-01-17 13:53
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("builder", "0001_squashed_0038_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name="ParagraphElement",
|
||||
new_name="TextElement",
|
||||
),
|
||||
]
|
|
@ -65,7 +65,7 @@ def load_test_data():
|
|||
)
|
||||
|
||||
heading_element_type = element_type_registry.get("heading")
|
||||
paragraph_element_type = element_type_registry.get("paragraph")
|
||||
text_element_type = element_type_registry.get("text")
|
||||
table_element_type = element_type_registry.get("table")
|
||||
link_element_type = element_type_registry.get("link")
|
||||
|
||||
|
@ -82,7 +82,7 @@ def load_test_data():
|
|||
)
|
||||
content = "\n".join(fake.paragraphs(nb=2))
|
||||
ElementHandler().create_element(
|
||||
paragraph_element_type,
|
||||
text_element_type,
|
||||
homepage,
|
||||
value=f'"{content}"',
|
||||
)
|
||||
|
@ -94,7 +94,7 @@ def load_test_data():
|
|||
)
|
||||
content = "\n".join(fake.paragraphs(nb=2))
|
||||
ElementHandler().create_element(
|
||||
paragraph_element_type,
|
||||
text_element_type,
|
||||
homepage,
|
||||
value=f'"{content}"',
|
||||
)
|
||||
|
@ -112,7 +112,7 @@ def load_test_data():
|
|||
)
|
||||
content = "\n".join(fake.paragraphs(nb=3))
|
||||
ElementHandler().create_element(
|
||||
paragraph_element_type,
|
||||
text_element_type,
|
||||
terms,
|
||||
value=f'"{content}"',
|
||||
)
|
||||
|
@ -124,7 +124,7 @@ def load_test_data():
|
|||
)
|
||||
content = "\n".join(fake.paragraphs(nb=3))
|
||||
ElementHandler().create_element(
|
||||
paragraph_element_type,
|
||||
text_element_type,
|
||||
terms,
|
||||
value=(f'"{content}"'),
|
||||
)
|
||||
|
@ -136,7 +136,7 @@ def load_test_data():
|
|||
)
|
||||
content = "\n".join(fake.paragraphs(nb=3))
|
||||
ElementHandler().create_element(
|
||||
paragraph_element_type,
|
||||
text_element_type,
|
||||
terms,
|
||||
value=(f'"{content}"'),
|
||||
)
|
||||
|
@ -222,7 +222,7 @@ def load_test_data():
|
|||
)
|
||||
|
||||
ElementHandler().create_element(
|
||||
paragraph_element_type,
|
||||
text_element_type,
|
||||
product_detail,
|
||||
value=(
|
||||
f'get("data_source.{product_detail_data_source.id}.{field_notes.db_column}")'
|
||||
|
|
|
@ -10,8 +10,8 @@ from baserow.contrib.builder.elements.models import (
|
|||
ImageElement,
|
||||
InputTextElement,
|
||||
LinkElement,
|
||||
ParagraphElement,
|
||||
TableElement,
|
||||
TextElement,
|
||||
)
|
||||
|
||||
|
||||
|
@ -20,8 +20,8 @@ class ElementFixtures:
|
|||
element = self.create_builder_element(HeadingElement, user, page, **kwargs)
|
||||
return element
|
||||
|
||||
def create_builder_paragraph_element(self, user=None, page=None, **kwargs):
|
||||
element = self.create_builder_element(ParagraphElement, user, page, **kwargs)
|
||||
def create_builder_text_element(self, user=None, page=None, **kwargs):
|
||||
element = self.create_builder_element(TextElement, user, page, **kwargs)
|
||||
return element
|
||||
|
||||
def create_builder_image_element(self, user=None, page=None, **kwargs):
|
||||
|
|
|
@ -215,7 +215,7 @@ def test_get_elements_of_public_builder(api_client, data_fixture):
|
|||
page = data_fixture.create_builder_page(builder=builder_to, user=user)
|
||||
element1 = data_fixture.create_builder_heading_element(page=page)
|
||||
element2 = data_fixture.create_builder_heading_element(page=page)
|
||||
element3 = data_fixture.create_builder_paragraph_element(page=page)
|
||||
element3 = data_fixture.create_builder_text_element(page=page)
|
||||
|
||||
domain = data_fixture.create_builder_custom_domain(
|
||||
domain_name="test.getbaserow.io",
|
||||
|
|
|
@ -120,28 +120,28 @@ def test_elements_moved_when_column_is_removed(api_client, data_fixture):
|
|||
column = data_fixture.create_builder_column_element(
|
||||
user=user, page=page, column_amount=3
|
||||
)
|
||||
column_element_column_0 = data_fixture.create_builder_paragraph_element(
|
||||
column_element_column_0 = data_fixture.create_builder_text_element(
|
||||
user=user,
|
||||
page=page,
|
||||
parent_element_id=column.id,
|
||||
place_in_container="0",
|
||||
order=22,
|
||||
)
|
||||
column_element_column_1 = data_fixture.create_builder_paragraph_element(
|
||||
column_element_column_1 = data_fixture.create_builder_text_element(
|
||||
user=user,
|
||||
page=page,
|
||||
parent_element_id=column.id,
|
||||
place_in_container="1",
|
||||
order=4,
|
||||
)
|
||||
column_element_column_1_1 = data_fixture.create_builder_paragraph_element(
|
||||
column_element_column_1_1 = data_fixture.create_builder_text_element(
|
||||
user=user,
|
||||
page=page,
|
||||
parent_element_id=column.id,
|
||||
place_in_container="1",
|
||||
order=5,
|
||||
)
|
||||
column_element_column_2 = data_fixture.create_builder_paragraph_element(
|
||||
column_element_column_2 = data_fixture.create_builder_text_element(
|
||||
user=user,
|
||||
page=page,
|
||||
parent_element_id=column.id,
|
||||
|
@ -185,7 +185,7 @@ def test_moving_an_element_to_new_column_appends_element(api_client, data_fixtur
|
|||
user=user, page=page, column_amount=2
|
||||
)
|
||||
|
||||
element_in_column_0 = data_fixture.create_builder_paragraph_element(
|
||||
element_in_column_0 = data_fixture.create_builder_text_element(
|
||||
user=user,
|
||||
page=page,
|
||||
parent_element_id=column_element.id,
|
||||
|
@ -193,7 +193,7 @@ def test_moving_an_element_to_new_column_appends_element(api_client, data_fixtur
|
|||
order=1,
|
||||
)
|
||||
|
||||
element_in_column_1 = data_fixture.create_builder_paragraph_element(
|
||||
element_in_column_1 = data_fixture.create_builder_text_element(
|
||||
user=user,
|
||||
page=page,
|
||||
parent_element_id=column_element.id,
|
||||
|
@ -232,7 +232,7 @@ def test_column_element_invalid_child_in_container_on_move(api_client, data_fixt
|
|||
column_element = data_fixture.create_builder_column_element(
|
||||
user=user, column_amount=2
|
||||
)
|
||||
child = data_fixture.create_builder_paragraph_element(page=column_element.page)
|
||||
child = data_fixture.create_builder_text_element(page=column_element.page)
|
||||
|
||||
url = reverse("api:builder:element:move", kwargs={"element_id": child.id})
|
||||
response = api_client.patch(
|
||||
|
@ -262,7 +262,7 @@ def test_column_element_invalid_child_in_container_on_create(api_client, data_fi
|
|||
response = api_client.post(
|
||||
url,
|
||||
{
|
||||
"type": "paragraph",
|
||||
"type": "text",
|
||||
"parent_element_id": column_element.id,
|
||||
"place_in_container": "9999",
|
||||
},
|
||||
|
|
|
@ -22,7 +22,7 @@ def test_get_elements(api_client, data_fixture):
|
|||
page = data_fixture.create_builder_page(user=user)
|
||||
element1 = data_fixture.create_builder_heading_element(page=page)
|
||||
element2 = data_fixture.create_builder_heading_element(page=page)
|
||||
element3 = data_fixture.create_builder_paragraph_element(page=page)
|
||||
element3 = data_fixture.create_builder_text_element(page=page)
|
||||
|
||||
url = reverse("api:builder:element:list", kwargs={"page_id": page.id})
|
||||
response = api_client.get(
|
||||
|
@ -40,7 +40,7 @@ def test_get_elements(api_client, data_fixture):
|
|||
assert response_json[1]["id"] == element2.id
|
||||
assert response_json[1]["type"] == "heading"
|
||||
assert response_json[2]["id"] == element3.id
|
||||
assert response_json[2]["type"] == "paragraph"
|
||||
assert response_json[2]["type"] == "text"
|
||||
assert "level" not in response_json[2]
|
||||
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ def test_domain_publishing(data_fixture):
|
|||
element1 = data_fixture.create_builder_heading_element(
|
||||
page=page1, level=2, value="'foo'"
|
||||
)
|
||||
element2 = data_fixture.create_builder_paragraph_element(page=page1)
|
||||
element2 = data_fixture.create_builder_text_element(page=page1)
|
||||
element3 = data_fixture.create_builder_heading_element(page=page2)
|
||||
|
||||
progress = Progress(100)
|
||||
|
|
|
@ -43,10 +43,10 @@ def test_apply_order_by_children(data_fixture):
|
|||
first_element = data_fixture.create_builder_heading_element(
|
||||
parent_element=column_element, place_in_container="0"
|
||||
)
|
||||
last_element = data_fixture.create_builder_paragraph_element(
|
||||
last_element = data_fixture.create_builder_text_element(
|
||||
parent_element=column_element, place_in_container="11"
|
||||
)
|
||||
middle_element = data_fixture.create_builder_paragraph_element(
|
||||
middle_element = data_fixture.create_builder_text_element(
|
||||
parent_element=column_element, place_in_container="5"
|
||||
)
|
||||
|
||||
|
|
|
@ -4,18 +4,14 @@ import pytest
|
|||
|
||||
from baserow.contrib.builder.elements.element_types import (
|
||||
ColumnElementType,
|
||||
ParagraphElementType,
|
||||
TextElementType,
|
||||
)
|
||||
from baserow.contrib.builder.elements.exceptions import (
|
||||
ElementDoesNotExist,
|
||||
ElementNotInSamePage,
|
||||
)
|
||||
from baserow.contrib.builder.elements.handler import ElementHandler
|
||||
from baserow.contrib.builder.elements.models import (
|
||||
Element,
|
||||
HeadingElement,
|
||||
ParagraphElement,
|
||||
)
|
||||
from baserow.contrib.builder.elements.models import Element, HeadingElement, TextElement
|
||||
from baserow.contrib.builder.elements.registries import element_type_registry
|
||||
from baserow.core.exceptions import CannotCalculateIntermediateOrder
|
||||
|
||||
|
@ -62,7 +58,7 @@ def test_get_elements(data_fixture):
|
|||
page = data_fixture.create_builder_page()
|
||||
element1 = data_fixture.create_builder_heading_element(page=page)
|
||||
element2 = data_fixture.create_builder_heading_element(page=page)
|
||||
element3 = data_fixture.create_builder_paragraph_element(page=page)
|
||||
element3 = data_fixture.create_builder_text_element(page=page)
|
||||
|
||||
elements = ElementHandler().get_elements(page)
|
||||
|
||||
|
@ -73,7 +69,7 @@ def test_get_elements(data_fixture):
|
|||
]
|
||||
|
||||
assert isinstance(elements[0], HeadingElement)
|
||||
assert isinstance(elements[2], ParagraphElement)
|
||||
assert isinstance(elements[2], TextElement)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
@ -160,15 +156,15 @@ def test_move_element_before_fails(data_fixture):
|
|||
def test_creating_element_in_container_starts_its_own_order_sequence(data_fixture):
|
||||
page = data_fixture.create_builder_page()
|
||||
container = ElementHandler().create_element(ColumnElementType(), page=page)
|
||||
root_element = ElementHandler().create_element(ParagraphElementType(), page=page)
|
||||
root_element = ElementHandler().create_element(TextElementType(), page=page)
|
||||
element_inside_container_one = ElementHandler().create_element(
|
||||
ParagraphElementType(),
|
||||
TextElementType(),
|
||||
page=page,
|
||||
parent_element_id=container.id,
|
||||
place_in_container="1",
|
||||
)
|
||||
element_inside_container_two = ElementHandler().create_element(
|
||||
ParagraphElementType(),
|
||||
TextElementType(),
|
||||
page=page,
|
||||
parent_element_id=container.id,
|
||||
place_in_container="1",
|
||||
|
@ -185,15 +181,15 @@ def test_creating_element_in_container_starts_its_own_order_sequence(data_fixtur
|
|||
def test_moving_elements_inside_container(data_fixture):
|
||||
page = data_fixture.create_builder_page()
|
||||
container = ElementHandler().create_element(ColumnElementType(), page=page)
|
||||
root_element = ElementHandler().create_element(ParagraphElementType(), page=page)
|
||||
root_element = ElementHandler().create_element(TextElementType(), page=page)
|
||||
element_inside_container_one = ElementHandler().create_element(
|
||||
ParagraphElementType(),
|
||||
TextElementType(),
|
||||
page=page,
|
||||
parent_element_id=container.id,
|
||||
place_in_container="1",
|
||||
)
|
||||
element_inside_container_two = ElementHandler().create_element(
|
||||
ParagraphElementType(),
|
||||
TextElementType(),
|
||||
page=page,
|
||||
parent_element_id=container.id,
|
||||
place_in_container="1",
|
||||
|
@ -366,7 +362,7 @@ def test_before_places_in_container_removed_no_change(data_fixture):
|
|||
|
||||
@pytest.mark.django_db
|
||||
def test_duplicate_element_single_element(data_fixture):
|
||||
element = data_fixture.create_builder_paragraph_element(value="'test'")
|
||||
element = data_fixture.create_builder_text_element(value="'test'")
|
||||
|
||||
[element_duplicated] = ElementHandler().duplicate_element(element)["elements"]
|
||||
|
||||
|
@ -379,11 +375,11 @@ def test_duplicate_element_single_element(data_fixture):
|
|||
@pytest.mark.django_db
|
||||
def test_duplicate_element_multiple_elements(data_fixture):
|
||||
container_element = data_fixture.create_builder_column_element(column_amount=12)
|
||||
child = data_fixture.create_builder_paragraph_element(
|
||||
value="'test'", parent_element=container_element, page=container_element.page
|
||||
child = data_fixture.create_builder_text_element(
|
||||
page=container_element.page, value="'test'", parent_element=container_element
|
||||
)
|
||||
child_two = data_fixture.create_builder_paragraph_element(
|
||||
value="'test2'", parent_element=container_element, page=container_element.page
|
||||
child_two = data_fixture.create_builder_text_element(
|
||||
page=container_element.page, value="'test2'", parent_element=container_element
|
||||
)
|
||||
|
||||
[
|
||||
|
|
|
@ -181,7 +181,7 @@ def test_get_elements(data_fixture, stub_check_permissions):
|
|||
page = data_fixture.create_builder_page(user=user)
|
||||
element1 = data_fixture.create_builder_heading_element(page=page)
|
||||
element2 = data_fixture.create_builder_heading_element(page=page)
|
||||
element3 = data_fixture.create_builder_paragraph_element(page=page)
|
||||
element3 = data_fixture.create_builder_text_element(page=page)
|
||||
|
||||
assert [p.id for p in ElementService().get_elements(user, page)] == [
|
||||
element1.id,
|
||||
|
@ -259,7 +259,7 @@ def test_move_element(element_updated_mock, data_fixture):
|
|||
page = data_fixture.create_builder_page(user=user)
|
||||
element1 = data_fixture.create_builder_heading_element(page=page)
|
||||
element2 = data_fixture.create_builder_heading_element(page=page)
|
||||
element3 = data_fixture.create_builder_paragraph_element(page=page)
|
||||
element3 = data_fixture.create_builder_text_element(page=page)
|
||||
|
||||
element_moved = ElementService().move_element(
|
||||
user,
|
||||
|
@ -279,7 +279,7 @@ def test_move_element_not_same_page(data_fixture, stub_check_permissions):
|
|||
page2 = data_fixture.create_builder_page(user=user)
|
||||
element1 = data_fixture.create_builder_heading_element(page=page)
|
||||
element2 = data_fixture.create_builder_heading_element(page=page)
|
||||
element3 = data_fixture.create_builder_paragraph_element(page=page2)
|
||||
element3 = data_fixture.create_builder_text_element(page=page2)
|
||||
|
||||
with pytest.raises(ElementNotInSamePage):
|
||||
ElementService().move_element(
|
||||
|
@ -297,7 +297,7 @@ def test_move_element_permission_denied(data_fixture, stub_check_permissions):
|
|||
page = data_fixture.create_builder_page(user=user)
|
||||
element1 = data_fixture.create_builder_heading_element(page=page)
|
||||
element2 = data_fixture.create_builder_heading_element(page=page)
|
||||
element3 = data_fixture.create_builder_paragraph_element(page=page)
|
||||
element3 = data_fixture.create_builder_text_element(page=page)
|
||||
|
||||
with stub_check_permissions(raise_permission_denied=True), pytest.raises(
|
||||
PermissionException
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
|
||||
from baserow.contrib.builder.elements.models import ColumnElement, ParagraphElement
|
||||
from baserow.contrib.builder.elements.models import ColumnElement, TextElement
|
||||
from baserow.contrib.builder.elements.registries import element_type_registry
|
||||
from baserow.contrib.builder.pages.constants import ILLEGAL_PATH_SAMPLE_CHARACTER
|
||||
from baserow.contrib.builder.pages.exceptions import (
|
||||
|
@ -266,7 +266,7 @@ def test_generalise_path():
|
|||
|
||||
@pytest.mark.django_db
|
||||
def test_import_element(data_fixture):
|
||||
element = data_fixture.create_builder_paragraph_element(value="'test'")
|
||||
element = data_fixture.create_builder_text_element(value="'test'")
|
||||
element_type = element_type_registry.get_by_model(element)
|
||||
element_serialized = element_type.export_serialized(element)
|
||||
new_page = data_fixture.create_builder_page(builder=element.page.builder)
|
||||
|
@ -288,28 +288,28 @@ def test_import_element_has_to_import_parent_first(data_fixture):
|
|||
parent_column = data_fixture.create_builder_column_element(
|
||||
page=page, column_amount=15
|
||||
)
|
||||
paragraph_element = data_fixture.create_builder_paragraph_element(
|
||||
text_element = data_fixture.create_builder_text_element(
|
||||
page=page, parent_element=parent_column
|
||||
)
|
||||
parent_serialized = element_type_registry.get_by_model(
|
||||
parent_column
|
||||
).export_serialized(parent_column)
|
||||
element_serialized = element_type_registry.get_by_model(
|
||||
paragraph_element
|
||||
).export_serialized(paragraph_element)
|
||||
new_page = data_fixture.create_builder_page(builder=paragraph_element.page.builder)
|
||||
text_element
|
||||
).export_serialized(text_element)
|
||||
new_page = data_fixture.create_builder_page(builder=text_element.page.builder)
|
||||
|
||||
[imported_column, imported_paragraph] = PageHandler().import_elements(
|
||||
[imported_column, imported_text] = PageHandler().import_elements(
|
||||
new_page,
|
||||
[parent_serialized, element_serialized],
|
||||
{},
|
||||
)
|
||||
|
||||
assert isinstance(imported_column, ColumnElement)
|
||||
assert isinstance(imported_paragraph, ParagraphElement)
|
||||
assert isinstance(imported_text, TextElement)
|
||||
|
||||
assert imported_paragraph.parent_element_id != paragraph_element.parent_element_id
|
||||
assert imported_paragraph.parent_element_id == imported_column.id
|
||||
assert imported_text.parent_element_id != text_element.parent_element_id
|
||||
assert imported_text.parent_element_id == imported_column.id
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
@ -318,25 +318,25 @@ def test_import_element_has_to_instance_already_created(data_fixture):
|
|||
parent_column = data_fixture.create_builder_column_element(
|
||||
page=page, column_amount=15
|
||||
)
|
||||
paragraph_element = data_fixture.create_builder_paragraph_element(
|
||||
text_element = data_fixture.create_builder_text_element(
|
||||
page=page, parent_element=parent_column
|
||||
)
|
||||
parent_serialized = element_type_registry.get_by_model(
|
||||
parent_column
|
||||
).export_serialized(parent_column)
|
||||
element_serialized = element_type_registry.get_by_model(
|
||||
paragraph_element
|
||||
).export_serialized(paragraph_element)
|
||||
new_page = data_fixture.create_builder_page(builder=paragraph_element.page.builder)
|
||||
text_element
|
||||
).export_serialized(text_element)
|
||||
new_page = data_fixture.create_builder_page(builder=text_element.page.builder)
|
||||
|
||||
[imported_column, imported_paragraph] = PageHandler().import_elements(
|
||||
[imported_column, imported_text] = PageHandler().import_elements(
|
||||
new_page,
|
||||
[element_serialized, parent_serialized],
|
||||
{},
|
||||
)
|
||||
|
||||
assert isinstance(imported_column, ColumnElement)
|
||||
assert isinstance(imported_paragraph, ParagraphElement)
|
||||
assert isinstance(imported_text, TextElement)
|
||||
|
||||
assert imported_paragraph.parent_element_id != paragraph_element.parent_element_id
|
||||
assert imported_paragraph.parent_element_id == imported_column.id
|
||||
assert imported_text.parent_element_id != text_element.parent_element_id
|
||||
assert imported_text.parent_element_id == imported_column.id
|
||||
|
|
|
@ -4,8 +4,8 @@ from baserow.contrib.builder.application_types import BuilderApplicationType
|
|||
from baserow.contrib.builder.elements.models import (
|
||||
ColumnElement,
|
||||
HeadingElement,
|
||||
ParagraphElement,
|
||||
TableElement,
|
||||
TextElement,
|
||||
)
|
||||
from baserow.contrib.builder.models import Builder
|
||||
from baserow.contrib.builder.pages.models import Page
|
||||
|
@ -91,12 +91,12 @@ def test_builder_application_export(data_fixture):
|
|||
element1 = data_fixture.create_builder_heading_element(
|
||||
page=page1, level=2, value="foo"
|
||||
)
|
||||
element2 = data_fixture.create_builder_paragraph_element(page=page1)
|
||||
element2 = data_fixture.create_builder_text_element(page=page1)
|
||||
element3 = data_fixture.create_builder_heading_element(page=page2)
|
||||
element_container = data_fixture.create_builder_column_element(
|
||||
page=page1, column_amount=3, column_gap=50
|
||||
)
|
||||
element_inside_container = data_fixture.create_builder_paragraph_element(
|
||||
element_inside_container = data_fixture.create_builder_text_element(
|
||||
page=page1, parent_element=element_container, place_in_container="0"
|
||||
)
|
||||
|
||||
|
@ -199,7 +199,7 @@ def test_builder_application_export(data_fixture):
|
|||
},
|
||||
{
|
||||
"id": element2.id,
|
||||
"type": "paragraph",
|
||||
"type": "text",
|
||||
"order": str(element2.order),
|
||||
"parent_element_id": None,
|
||||
"place_in_container": None,
|
||||
|
@ -247,7 +247,7 @@ def test_builder_application_export(data_fixture):
|
|||
},
|
||||
{
|
||||
"id": element_inside_container.id,
|
||||
"type": "paragraph",
|
||||
"type": "text",
|
||||
"parent_element_id": element_container.id,
|
||||
"place_in_container": "0",
|
||||
"style_background_color": "#ffffffff",
|
||||
|
@ -446,7 +446,7 @@ IMPORT_REFERENCE = {
|
|||
},
|
||||
{
|
||||
"id": 999,
|
||||
"type": "paragraph",
|
||||
"type": "text",
|
||||
"parent_element_id": None,
|
||||
"place_in_container": None,
|
||||
"style_background": "none",
|
||||
|
@ -495,7 +495,7 @@ IMPORT_REFERENCE = {
|
|||
},
|
||||
{
|
||||
"id": 502,
|
||||
"type": "paragraph",
|
||||
"type": "text",
|
||||
"parent_element_id": 500,
|
||||
"place_in_container": "1",
|
||||
"style_background": "none",
|
||||
|
@ -531,7 +531,7 @@ IMPORT_REFERENCE = {
|
|||
},
|
||||
{
|
||||
"id": 501,
|
||||
"type": "paragraph",
|
||||
"type": "text",
|
||||
"parent_element_id": 500,
|
||||
"place_in_container": "0",
|
||||
"style_background": "none",
|
||||
|
@ -715,7 +715,7 @@ def test_builder_application_import(data_fixture):
|
|||
] = specific_iterator(page1.element_set.all())
|
||||
|
||||
assert isinstance(element1, HeadingElement)
|
||||
assert isinstance(element2, ParagraphElement)
|
||||
assert isinstance(element2, TextElement)
|
||||
assert isinstance(container_element, ColumnElement)
|
||||
assert isinstance(table_element, TableElement)
|
||||
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
<template>
|
||||
<div v-if="paragraphs.length">
|
||||
<p
|
||||
v-for="paragraph in paragraphs"
|
||||
:key="paragraph.id"
|
||||
class="paragraph-element"
|
||||
>
|
||||
<p v-for="paragraph in paragraphs" :key="paragraph.id" class="text-element">
|
||||
{{ paragraph.content }}
|
||||
</p>
|
||||
</div>
|
||||
<p v-else class="paragraph-element element--no-value">
|
||||
{{ $t('paragraphElement.noValue') }}
|
||||
<p v-else class="text-element element--no-value">
|
||||
{{ $t('textElement.noValue') }}
|
||||
</p>
|
||||
</template>
|
||||
|
||||
|
@ -19,18 +15,18 @@ import { generateHash } from '@baserow/modules/core/utils/hashing'
|
|||
import { ensureString } from '@baserow/modules/core/utils/validator'
|
||||
|
||||
/**
|
||||
* @typedef Paragraph
|
||||
* @typedef Text
|
||||
* @property {string} content - The text displayed
|
||||
* @property {string} id - The id of the paragraph hashed
|
||||
*/
|
||||
|
||||
export default {
|
||||
name: 'ParagraphElement',
|
||||
name: 'TextElement',
|
||||
mixins: [element],
|
||||
props: {
|
||||
/**
|
||||
* @type {Object}
|
||||
* @property {Array.<Paragraph>} value - A list of paragraphs
|
||||
* @property {Array.<Text>} value - A list of paragraphs
|
||||
*/
|
||||
element: {
|
||||
type: Object,
|
|
@ -2,8 +2,8 @@
|
|||
<form @submit.prevent @keydown.enter.prevent>
|
||||
<ApplicationBuilderFormulaInputGroup
|
||||
v-model="values.value"
|
||||
:label="$t('paragraphElementForm.textTitle')"
|
||||
:placeholder="$t('elementForms.textInputPlaceholder')"
|
||||
:label="$t('textElementForm.textTitle')"
|
||||
:placeholder="$t('textElementForm.textPlaceholder')"
|
||||
:data-providers-allowed="DATA_PROVIDERS_ALLOWED_ELEMENTS"
|
||||
/>
|
||||
</form>
|
||||
|
@ -14,7 +14,7 @@ import ApplicationBuilderFormulaInputGroup from '@baserow/modules/builder/compon
|
|||
import elementForm from '@baserow/modules/builder/mixins/elementForm'
|
||||
|
||||
export default {
|
||||
name: 'ParagraphElementForm',
|
||||
name: 'TextElementForm',
|
||||
components: { ApplicationBuilderFormulaInputGroup },
|
||||
mixins: [elementForm],
|
||||
data() {
|
|
@ -1,8 +1,8 @@
|
|||
import { Registerable } from '@baserow/modules/core/registry'
|
||||
import ParagraphElement from '@baserow/modules/builder/components/elements/components/ParagraphElement'
|
||||
import TextElement from '@baserow/modules/builder/components/elements/components/TextElement.vue'
|
||||
import HeadingElement from '@baserow/modules/builder/components/elements/components/HeadingElement'
|
||||
import LinkElement from '@baserow/modules/builder/components/elements/components/LinkElement'
|
||||
import ParagraphElementForm from '@baserow/modules/builder/components/elements/components/forms/general/ParagraphElementForm'
|
||||
import TextElementForm from '@baserow/modules/builder/components/elements/components/forms/general/TextElementForm.vue'
|
||||
import HeadingElementForm from '@baserow/modules/builder/components/elements/components/forms/general/HeadingElementForm'
|
||||
import LinkElementForm from '@baserow/modules/builder/components/elements/components/forms/general/LinkElementForm'
|
||||
import ImageElementForm from '@baserow/modules/builder/components/elements/components/forms/general/ImageElementForm'
|
||||
|
@ -381,17 +381,17 @@ export class HeadingElementType extends ElementType {
|
|||
}
|
||||
}
|
||||
|
||||
export class ParagraphElementType extends ElementType {
|
||||
export class TextElementType extends ElementType {
|
||||
static getType() {
|
||||
return 'paragraph'
|
||||
return 'text'
|
||||
}
|
||||
|
||||
get name() {
|
||||
return this.app.i18n.t('elementType.paragraph')
|
||||
return this.app.i18n.t('elementType.text')
|
||||
}
|
||||
|
||||
get description() {
|
||||
return this.app.i18n.t('elementType.paragraphDescription')
|
||||
return this.app.i18n.t('elementType.textDescription')
|
||||
}
|
||||
|
||||
get iconClass() {
|
||||
|
@ -399,11 +399,11 @@ export class ParagraphElementType extends ElementType {
|
|||
}
|
||||
|
||||
get component() {
|
||||
return ParagraphElement
|
||||
return TextElement
|
||||
}
|
||||
|
||||
get generalFormComponent() {
|
||||
return ParagraphElementForm
|
||||
return TextElementForm
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,10 @@
|
|||
"userSourcesName": "Benutzer"
|
||||
},
|
||||
"elementType": {
|
||||
"paragraphDescription": "Einzeiliger Text",
|
||||
"textDescription": "Einzeiliger Text",
|
||||
"heading": "Überschrift",
|
||||
"headingDescription": "Titel der Seitenüberschrift",
|
||||
"paragraph": "Paragraph",
|
||||
"text": "Paragraph",
|
||||
"table": "Tabelle",
|
||||
"formContainer": "Formular",
|
||||
"inputText": "Texteingabe",
|
||||
|
@ -89,10 +89,10 @@
|
|||
"textError": "Der Wert ist ungültig.",
|
||||
"textPlaceholder": "Text eingeben..."
|
||||
},
|
||||
"paragraphElement": {
|
||||
"textElement": {
|
||||
"noValue": "Leerer Absatz..."
|
||||
},
|
||||
"paragraphElementForm": {
|
||||
"textElementForm": {
|
||||
"textTitle": "Text",
|
||||
"textPlaceholder": "Text eingeben...",
|
||||
"textError": "Der Wert ist ungültig."
|
||||
|
|
|
@ -68,8 +68,8 @@
|
|||
"elementType": {
|
||||
"heading": "Heading",
|
||||
"headingDescription": "Page heading title",
|
||||
"paragraph": "Paragraph",
|
||||
"paragraphDescription": "Single line text",
|
||||
"text": "Text",
|
||||
"textDescription": "Single line text",
|
||||
"link": "Link",
|
||||
"linkDescription": "A link to page/URL",
|
||||
"image": "Image",
|
||||
|
@ -137,10 +137,10 @@
|
|||
"headingName": "Heading {level} <h{level}>",
|
||||
"textError": "The value is invalid."
|
||||
},
|
||||
"paragraphElement": {
|
||||
"noValue": "Empty paragraph..."
|
||||
"textElement": {
|
||||
"noValue": "Empty text..."
|
||||
},
|
||||
"paragraphElementForm": {
|
||||
"textElementForm": {
|
||||
"textTitle": "Text",
|
||||
"textPlaceholder": "Enter text...",
|
||||
"textError": "The value is invalid."
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
"target": "Abrir en...",
|
||||
"paramsInErrorDescription": "Los parámetros guardados no coinciden con los parámetros de la página. Es probable que la página se haya eliminado o actualizado."
|
||||
},
|
||||
"paragraphElement": {
|
||||
"textElement": {
|
||||
"noValue": "Párrafo vacío..."
|
||||
},
|
||||
"linkFieldForm": {
|
||||
|
@ -96,11 +96,11 @@
|
|||
"elementType": {
|
||||
"table": "Tabla",
|
||||
"formContainer": "Formulario",
|
||||
"paragraphDescription": "Texto de una línea",
|
||||
"textDescription": "Texto de una línea",
|
||||
"heading": "Título",
|
||||
"inputText": "Introducción de texto",
|
||||
"inputTextDescription": "Un campo de entrada de texto",
|
||||
"paragraph": "Párrafo",
|
||||
"text": "Párrafo",
|
||||
"headingDescription": "Título de la página",
|
||||
"image": "Imagen",
|
||||
"tableDescription": "Un elemento de la tabla",
|
||||
|
@ -326,7 +326,7 @@
|
|||
"searchPlaceholder": "Buscar elementos",
|
||||
"noElements": "No se han encontrado elementos"
|
||||
},
|
||||
"paragraphElementForm": {
|
||||
"textElementForm": {
|
||||
"textTitle": "Texto",
|
||||
"textError": "El valor es inválido.",
|
||||
"textPlaceholder": "Introducir texto..."
|
||||
|
|
|
@ -47,8 +47,8 @@
|
|||
},
|
||||
"elementType": {
|
||||
"heading": "Titre",
|
||||
"paragraph": "Paragraphe",
|
||||
"paragraphDescription": "Texte simple",
|
||||
"text": "texte",
|
||||
"textDescription": "Texte simple",
|
||||
"headingDescription": "Titre de page",
|
||||
"link": "Lien",
|
||||
"linkDescription": "Un lien vers une page/URL",
|
||||
|
@ -101,10 +101,10 @@
|
|||
"headingName": "Titre {level} <h{level}>",
|
||||
"textError": "La valeur est invalide."
|
||||
},
|
||||
"paragraphElement": {
|
||||
"noValue": "Paragraphe vide..."
|
||||
"textElement": {
|
||||
"noValue": "texte vide..."
|
||||
},
|
||||
"paragraphElementForm": {
|
||||
"textElementForm": {
|
||||
"textTitle": "Texte",
|
||||
"textPlaceholder": "Saisir le texte...",
|
||||
"textError": "La valeur est invalide."
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
},
|
||||
"elementType": {
|
||||
"heading": "Intestazione",
|
||||
"paragraph": "Paragrafo",
|
||||
"paragraphDescription": "Linea di testo singola",
|
||||
"text": "Paragrafo",
|
||||
"textDescription": "Linea di testo singola",
|
||||
"headingDescription": "Titolo intestazione"
|
||||
},
|
||||
"addElementButton": {
|
||||
|
@ -75,10 +75,10 @@
|
|||
"textError": "Il valore non è valido.",
|
||||
"levelTitle": "Livello"
|
||||
},
|
||||
"paragraphElement": {
|
||||
"textElement": {
|
||||
"noValue": "Paragrafo vuoto..."
|
||||
},
|
||||
"paragraphElementForm": {
|
||||
"textElementForm": {
|
||||
"textTitle": "Testo",
|
||||
"textError": "Il valore non è valido.",
|
||||
"textPlaceholder": "Inserisci testo..."
|
||||
|
|
|
@ -54,8 +54,8 @@
|
|||
"elementType": {
|
||||
"heading": "Kop",
|
||||
"headingDescription": "Titel paginakop",
|
||||
"paragraph": "Paragraaf",
|
||||
"paragraphDescription": "Tekst op één regel",
|
||||
"text": "Paragraaf",
|
||||
"textDescription": "Tekst op één regel",
|
||||
"link": "Link",
|
||||
"image": "Afbeelding",
|
||||
"linkDescription": "Een link naar pagina/URL",
|
||||
|
@ -101,10 +101,10 @@
|
|||
"textError": "De waarde is ongeldig.",
|
||||
"textPlaceholder": "Tekst invoeren..."
|
||||
},
|
||||
"paragraphElement": {
|
||||
"textElement": {
|
||||
"noValue": "Lege paragraaf..."
|
||||
},
|
||||
"paragraphElementForm": {
|
||||
"textElementForm": {
|
||||
"textTitle": "Tekst",
|
||||
"textPlaceholder": "Tekst invoeren...",
|
||||
"textError": "De waarde is ongeldig."
|
||||
|
|
|
@ -90,8 +90,8 @@
|
|||
"elementType": {
|
||||
"heading": "Nagłówek",
|
||||
"headingDescription": "Tytuł nagłówka strony",
|
||||
"paragraph": "Ustęp",
|
||||
"paragraphDescription": "Tekst jednowierszowy",
|
||||
"text": "Ustęp",
|
||||
"textDescription": "Tekst jednowierszowy",
|
||||
"link": "Link",
|
||||
"linkDescription": "Link do strony/URL",
|
||||
"image": "Obraz",
|
||||
|
@ -189,10 +189,10 @@
|
|||
"integrationMessage": "Nowe integracje można tworzyć poprzez dodanie źródła danych, akcji lub uwierzytelnienia użytkownika.",
|
||||
"noIntegrationMessage": "Nie utworzono jeszcze żadnego połączenia. Można je utworzyć poprzez dodanie źródła danych, akcji lub uwierzytelnienia użytkownika."
|
||||
},
|
||||
"paragraphElement": {
|
||||
"textElement": {
|
||||
"noValue": "Pusty akapit..."
|
||||
},
|
||||
"paragraphElementForm": {
|
||||
"textElementForm": {
|
||||
"textTitle": "Tekst",
|
||||
"textPlaceholder": "Wprowadź tekst...",
|
||||
"textError": "Wartość jest nieprawidłowa."
|
||||
|
|
|
@ -27,7 +27,7 @@ import { registerRealtimeEvents } from '@baserow/modules/builder/realtime'
|
|||
import {
|
||||
HeadingElementType,
|
||||
ImageElementType,
|
||||
ParagraphElementType,
|
||||
TextElementType,
|
||||
LinkElementType,
|
||||
InputTextElementType,
|
||||
ColumnElementType,
|
||||
|
@ -153,7 +153,7 @@ export default (context) => {
|
|||
app.$registry.register('errorPage', new PublicSiteErrorPageType(context))
|
||||
|
||||
app.$registry.register('element', new HeadingElementType(context))
|
||||
app.$registry.register('element', new ParagraphElementType(context))
|
||||
app.$registry.register('element', new TextElementType(context))
|
||||
app.$registry.register('element', new LinkElementType(context))
|
||||
app.$registry.register('element', new ImageElementType(context))
|
||||
app.$registry.register('element', new InputTextElementType(context))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@import 'forms/all';
|
||||
@import 'heading_element';
|
||||
@import 'paragraph_element';
|
||||
@import 'text_element';
|
||||
@import 'link-button-element-button';
|
||||
@import 'link_element';
|
||||
@import 'image_element';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@import 'paragraph_element_form';
|
||||
@import 'text_element_form';
|
||||
@import 'link_element_form';
|
||||
@import 'table_element_form';
|
||||
@import 'form_container_element';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.paragraph-element-form__value {
|
||||
.text-element-form__value {
|
||||
resize: vertical;
|
||||
color: $color-neutral-900;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
.paragraph-element {
|
||||
.text-element {
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
color: $black;
|
Loading…
Add table
Reference in a new issue