Skip to content

Commit

Permalink
Rename element_type into name
Browse files Browse the repository at this point in the history
This attribute has been renamed by the alchemy-json_api gem
and reflects what this attribute is called in Alchemy core.
  • Loading branch information
tvdeyen committed Nov 6, 2020
1 parent 00f5c05 commit 8b0572d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/components/FallbackElement.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="alchemy-fallback-element">
<h2>I am a dummy {{ element.element_type }} Alchemy element component</h2>
<h2>I am a dummy {{ element.name }} Alchemy element component</h2>
<p>
To replace me put a Vue component into
<kbd>~/components/Alchemy/Elements/</kbd>
Expand Down
4 changes: 2 additions & 2 deletions src/components/__tests__/fallback-element.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ function getComponent() {
return shallowMount(FallbackElement, {
propsData: {
element: {
element_type: "main_header",
name: "main_header",
essences: [
{
role: "headline",
},
],
nested_elements: [
{
element_type: "header",
name: "header",
},
],
},
Expand Down
10 changes: 5 additions & 5 deletions src/mixins/__tests__/element.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const AlchemyElementComponent = {
describe("Alchemy element mixin", () => {
it("has access to the element", () => {
const element = {
element_type: "content_page",
name: "content_page",
essences: [],
}
const comp = shallowMount(AlchemyElementComponent, {
Expand All @@ -26,7 +26,7 @@ describe("Alchemy element mixin", () => {
const comp = shallowMount(AlchemyElementComponent, {
propsData: {
element: {
element_type: "content_page",
name: "content_page",
essences: [],
},
},
Expand All @@ -41,7 +41,7 @@ describe("Alchemy element mixin", () => {
const comp = shallowMount(AlchemyElementComponent, {
propsData: {
element: {
element_type: "content_page",
name: "content_page",
essences: [headline],
},
},
Expand All @@ -57,7 +57,7 @@ describe("Alchemy element mixin", () => {
const comp = shallowMount(AlchemyElementComponent, {
propsData: {
element: {
element_type: "content_page",
name: "content_page",
essences: [],
},
},
Expand All @@ -72,7 +72,7 @@ describe("Alchemy element mixin", () => {
const comp = shallowMount(AlchemyElementComponent, {
propsData: {
element: {
element_type: "content_page",
name: "content_page",
essences: [headline],
},
},
Expand Down
8 changes: 4 additions & 4 deletions src/mixins/__tests__/page.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("Alchemy page mixin", () => {
describe("elementByName", () => {
describe("if element exists", () =>{
it("returns element", () => {
const element = { element_type: "header" }
const element = { name: "header" }
const component = shallowMount(AlchemyPageComponent, {
propsData: {
page: {
Expand Down Expand Up @@ -70,7 +70,7 @@ describe("Alchemy page mixin", () => {
describe("elementsByName", () => {
describe("if element exists", () =>{
it("returns element", () => {
const elements = [{ element_type: "header" }]
const elements = [{ name: "header" }]
const component = shallowMount(AlchemyPageComponent, {
propsData: {
page: {
Expand Down Expand Up @@ -103,7 +103,7 @@ describe("Alchemy page mixin", () => {
const component = shallowMount(AlchemyPageComponent, {
propsData: {
page: {
elements: [{ element_type: "element_component" }],
elements: [{ name: "element_component" }],
},
},
})
Expand All @@ -118,7 +118,7 @@ describe("Alchemy page mixin", () => {
const component = shallowMount(AlchemyPageComponent, {
propsData: {
page: {
elements: [{ element_type: "something" }],
elements: [{ name: "something" }],
},
},
})
Expand Down
4 changes: 2 additions & 2 deletions src/mixins/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {
},
methods: {
elementType(element) {
const name = element.element_type
const name = element.name
if (this.$options.components[name]) {
return name
}
Expand All @@ -20,7 +20,7 @@ export default {
return this.elementsByName(name)[0]
},
elementsByName(name) {
return this.page.elements.filter((e) => e.element_type === name)
return this.page.elements.filter((e) => e.name === name)
},
},
}

0 comments on commit 8b0572d

Please sign in to comment.