Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion app/assets/builds/alchemy/admin.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/article-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/book-2-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/code-block.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion app/assets/images/alchemy/element_icons/default.svg

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/gallery-view.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/hashtag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/heading.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/image-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/list-check-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/mail-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/movie-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/music-2-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/news-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/palette-line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/seo-line.svg
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/separator.svg
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/stacked-view.svg
1 change: 1 addition & 0 deletions app/assets/images/alchemy/element_icons/text-block.svg
3 changes: 2 additions & 1 deletion app/components/alchemy/admin/element_select.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def elements_options

elements.sort_by(&:name).map do |element|
{
text: Element.display_name_for(element.name),
name: Element.display_name_for(element.name),
hint: element.hint,
icon: element.icon_file,
id: element.name
}
Expand Down
4 changes: 2 additions & 2 deletions app/components/alchemy/admin/list_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ module Admin
class ListFilter < ViewComponent::Base
erb_template <<~ERB
<alchemy-list-filter items-selector="<%= items_selector %>" name-attribute="<%= name_attribute %>">
<input type="text" class="js_filter_field" />
<input type="search" class="js_filter_field" />
<alchemy-icon name="search"></alchemy-icon>
<button type="button" class="js_filter_field_clear icon_button">
<button type="reset" class="js_filter_field_clear icon_button">
<alchemy-icon name="close" size="1x"></alchemy-icon>
</button>
</alchemy-list-filter>
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/alchemy/admin/page_definitions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Alchemy
module Admin
class PageDefinitionsController < ResourcesController
def index
@page_definitions = PageDefinition.all
end

private

def resource_handler
@_resource_handler ||= ::Alchemy::Resource.new(controller_path, alchemy_module, PageDefinition)
end
end
end
end
30 changes: 21 additions & 9 deletions app/javascript/alchemy_admin/components/element_select.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import { hightlightTerm } from "alchemy_admin/components/remote_select"

const formatItem = (icon, text) => {
return `<div class="element-select-item">${icon} ${text}</div>`
const formatSelection = (option) => {
return `
<div class="element-select-name">${option.icon} ${option.name}</div>
`
}

const formatItem = (icon, name, hint) => {
const description = hint
? `<div class="element-select-description">${hint}</div>`
: ""
return `
<div class="element-select-item">
${formatSelection({ icon, name })}
${description}
</div>
`
}

class ElementSelect extends HTMLElement {
Expand All @@ -20,18 +34,16 @@ class ElementSelect extends HTMLElement {
formatResult: (option, _el, search) => {
let text

if (option.id === "") return option.text
if (option.id === "") return option.name
if (search.term !== "") {
text = hightlightTerm(option.text, search.term)
text = hightlightTerm(option.name, search.term)
} else {
text = option.text
text = option.name
}

return formatItem(option.icon, text)
},
formatSelection: (option) => {
return formatItem(option.icon, option.text)
return formatItem(option.icon, text, option.hint)
},
formatSelection,
placeholder: this.placeholder
}
$(this.inputField).select2(options)
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/alchemy_admin/components/list_filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ class ListFilter extends HTMLElement {
}

get clearButton() {
return this.querySelector('button[type="button"]')
return this.querySelector('button[type="reset"]')
}

get filterField() {
return this.querySelector('input[type="text"]')
return this.querySelector('input[type="search"]')
}

get items() {
Expand Down
9 changes: 7 additions & 2 deletions app/models/alchemy/element_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class ElementDefinition

delegate :blank?, to: :name

DEFAULT_ICON_NAME = "layout-bottom-2-line"

class << self
# Returns the definitions from elements.yml file.
#
Expand Down Expand Up @@ -168,8 +170,7 @@ def icon_name
case icon
when TrueClass then name
when String then icon
else
"default"
else determine_default_icon_name
end
end

Expand All @@ -186,5 +187,9 @@ def icons_root_path
def hint_translation_scope
:element_hints
end

def determine_default_icon_name
Alchemy.config.element_icon_finder.call(name) || DEFAULT_ICON_NAME
end
end
end
Loading
Loading