Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ingredients as new content structure #2061

Merged
merged 57 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
5ac5be3
Add Alchemy::Ingredient model
tvdeyen Apr 8, 2021
cf15c5d
Add a Text Ingredient class
tvdeyen Apr 8, 2021
774568f
Add ingredient_attributes class methods to ingredient
tvdeyen Apr 8, 2021
c8a9408
Add more ingredient classes
tvdeyen Apr 8, 2021
1aac6f1
Add File ingredient
tvdeyen Apr 8, 2021
1172261
Add Node and Page ingredients
tvdeyen Apr 8, 2021
a17dfd7
Add Picture ingredient class
tvdeyen Apr 8, 2021
e85957d
Add Richtext ingredient
tvdeyen Apr 8, 2021
b71a93b
Typecast boolean and datetime ingredients
tvdeyen Apr 8, 2021
cd1bf39
Add preview_text to ingredient classes
tvdeyen Apr 8, 2021
d35e875
Return related object from ingredient if present
tvdeyen Apr 8, 2021
ca0e05e
Add has_many ingredients relation to element
tvdeyen Apr 9, 2021
5222d53
Add settings and partial name to Ingredient model
tvdeyen Apr 12, 2021
64320a7
Add predicate methods to ingredient class
tvdeyen Apr 12, 2021
add3f1b
Add hints to Ingredient class
tvdeyen Apr 12, 2021
b1ed76f
Add IngredientEditor
tvdeyen Apr 12, 2021
94f445e
Add ingredient views
tvdeyen Apr 12, 2021
3779b58
Add thumbnail_url to picture ingredient
tvdeyen Apr 14, 2021
2b06cc2
Allow translated ingredient default text
tvdeyen Apr 14, 2021
1e353b4
Update picture ingredient to latest essence picture changes
tvdeyen May 25, 2021
52ab28a
Rewrite ingredient_attributes to class attribute
tvdeyen May 25, 2021
69f2f2f
Adds admin ingredients controller
tvdeyen May 25, 2021
093de6f
Render ingredient editors
tvdeyen Apr 10, 2021
e6e1745
Add Headline ingredient
tvdeyen May 26, 2021
1ac49d7
Update headline partials
tvdeyen May 26, 2021
2ff6fca
Add audio and video ingredients
tvdeyen May 26, 2021
e241902
Add ingredients elements to page layout
tvdeyen May 26, 2021
61d345e
Add custom tinymce config feature to ingredients
tvdeyen May 26, 2021
cae0aad
Add ingredient scopes
tvdeyen May 26, 2021
fd0dd8c
Add has_tinymce? to ingredient
tvdeyen May 26, 2021
4ea76c6
Init tinymce editor for ingredients
tvdeyen May 26, 2021
54e5108
Add *_id methods for related_object_alias
tvdeyen May 28, 2021
4a0e93b
Use fields_for for ingredient editor partials
tvdeyen May 28, 2021
45f8e68
Set related object type when we set the id
tvdeyen May 28, 2021
0e4390e
Remove nonsense spec
tvdeyen Jun 7, 2021
79a9301
Autoformat elements controller spec
tvdeyen Jun 7, 2021
c3f5c9a
Update elements generator for ingredients
tvdeyen Jun 7, 2021
25015a9
Add templates for elements with ingredients
tvdeyen Jun 7, 2021
5e3dd08
Support ingredients in block level helpers
tvdeyen Jun 10, 2021
9efffd4
Make sure to persist ingredient values
tvdeyen Jun 10, 2021
172038e
Add ingredient validations
tvdeyen Jun 10, 2021
210e3c6
Display ingredient validation errors on element editor
tvdeyen Jun 10, 2021
6684d2f
Use CropAction concern in admin ingredients controller
tvdeyen Jun 25, 2021
4d2a437
Use "having picture thumbnails" on picture ingredient
tvdeyen Jun 25, 2021
ff5dffb
Make link dialog work with ingredients
tvdeyen Jun 27, 2021
373a30b
Do not create contents if ingredients are defined as well
tvdeyen Jun 28, 2021
796aec1
Add rake task to migrate elements to ingredients
tvdeyen Jun 28, 2021
c5ea77a
Show element editor if element has no contents but ingredients defined
tvdeyen Jun 28, 2021
c71efbe
Add ingredient generator
tvdeyen Jun 28, 2021
2eb7895
Touch element on changing ingredients
mamhoff Jun 29, 2021
c642161
Destroy contents in migrator
mamhoff Jun 29, 2021
228d73e
Duplicate ingredients with Elements
mamhoff Jun 29, 2021
eb38d58
Pick Ingredients first in ElementBlockHelper
mamhoff Jun 29, 2021
42c2e4d
Use Rails' store_accessor for ingredients data
tvdeyen Jun 29, 2021
c322280
Eager load ingredients in admin and API controllers
tvdeyen Jun 29, 2021
57dc0fb
Update brakeman ignores
tvdeyen Jun 29, 2021
9234ecd
Add an ingredient factory
tvdeyen Jun 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update headline partials
  • Loading branch information
tvdeyen committed Jun 28, 2021
commit 1ac49d74a855e99057e641161688c027939c0298
25 changes: 11 additions & 14 deletions app/views/alchemy/ingredients/_headline_editor.html.erb
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
<%= content_tag :div,
id: essence_headline_editor.dom_id,
class: essence_headline_editor.css_classes,
data: essence_headline_editor.data_attributes do %>
<%= content_label(essence_headline_editor) %>
class: headline_editor.css_classes,
data: headline_editor.data_attributes do %>
<%= ingredient_label(headline_editor, counter: headline_editor_counter) %>
<%= text_field_tag(
essence_headline_editor.form_field_name,
essence_headline_editor.essence.body,
id: essence_headline_editor.form_field_id
headline_editor.form_field_name(counter: headline_editor_counter),
headline_editor.value
) %>

<div class="input-row">
<% essence = essence_headline_editor.essence %>
<% if essence.level_options.length > 1 %>
<% if headline_editor.level_options.length > 1 %>
<div class="input-column">
<%= label_tag Alchemy::EssenceHeadline.human_attribute_name(:level) %>
<%= select_tag(
essence_headline_editor.form_field_name(:level),
options_for_select(essence_headline_editor.essence.level_options, essence_headline_editor.essence.level),
headline_editor.form_field_name(:level, counter: headline_editor_counter),
options_for_select(headline_editor.level_options, headline_editor.level),
class: "alchemy_selectbox full_width"
) %>
</div>
<% end %>

<% if essence.size_options.length > 1 %>
<% if headline_editor.size_options.length > 1 %>
<div class="input-column">
<%= label_tag Alchemy::EssenceHeadline.human_attribute_name(:size) %>
<%= select_tag(
essence_headline_editor.form_field_name(:size),
options_for_select(essence_headline_editor.essence.size_options, essence_headline_editor.essence.size),
headline_editor.form_field_name(:size, counter: headline_editor_counter),
options_for_select(headline_editor.size_options, headline_editor.size),
class: "alchemy_selectbox full_width"
) %>
</div>
Expand Down
6 changes: 3 additions & 3 deletions app/views/alchemy/ingredients/_headline_view.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<%- html_options = local_assigns.fetch(:html_options, {}) -%>

<%= content_tag "h#{content.essence.level}",
content.essence.ingredient,
<%= content_tag "h#{headline_view.level}",
headline_view.value,
class: [
content.essence.size ? "h#{content.essence.size}" : nil,
headline_view.size ? "h#{headline_view.size}" : nil,
html_options[:class]
]
%>
63 changes: 63 additions & 0 deletions spec/views/alchemy/ingredients/headline_editor_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe "alchemy/ingredients/_headline_editor" do
let(:element) { build(:alchemy_element) }

let(:ingredient) do
stub_model(
Alchemy::Ingredients::Headline,
element: element,
role: "headline",
)
end

let(:headline_editor) { Alchemy::IngredientEditor.new(ingredient) }
let(:settings) { {} }

subject do
render partial: "alchemy/ingredients/headline_editor", locals: {
headline_editor: headline_editor,
headline_editor_counter: 0,
}
rendered
end

before do
view.class.send(:include, Alchemy::Admin::IngredientsHelper)
allow(ingredient).to receive(:settings) { settings }
end

it "renders a text input" do
is_expected.to have_selector("input[type='text'][name='element[ingredients_attributes][0][value]']")
end

it "renders a level select" do
is_expected.to have_selector("select[name='element[ingredients_attributes][0][level]']")
end

context "when only one level is given" do
let(:settings) do
{ levels: [1] }
end

it "does not render a level select" do
is_expected.to_not have_selector("select[name='element[ingredients_attributes][0][level]']")
end
end

it "does not render a size select" do
is_expected.to_not have_selector("select[name='element[ingredients_attributes][0][size]']")
end

context "when sizes are given" do
let(:settings) do
{ sizes: [1, 2] }
end

it "renders a size select" do
is_expected.to have_selector("select[name='element[ingredients_attributes][0][size]']")
end
end
end
29 changes: 29 additions & 0 deletions spec/views/alchemy/ingredients/headline_view_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe "alchemy/ingredients/_headline_view" do
let(:ingredient) { Alchemy::Ingredients::Headline.new(value: "Hello", level: 2) }

it "renders headline for level" do
render ingredient
expect(rendered).to have_selector("h2")
expect(rendered).to have_content("Hello")
end

context "without size" do
it "does not add size class" do
render ingredient
expect(rendered).to_not have_selector(".h1")
end
end

context "with size" do
let(:ingredient) { Alchemy::Ingredients::Headline.new(value: "Hello", level: 2, size: 1) }

it "adds size class" do
render ingredient
expect(rendered).to have_selector("h2.h1")
end
end
end