Skip to content

feat: widgets #28

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

Merged
merged 4 commits into from
May 1, 2023
Merged

feat: widgets #28

merged 4 commits into from
May 1, 2023

Conversation

blocknotes
Copy link
Owner

@blocknotes blocknotes commented May 1, 2023

In this PR:

  • introduce widgets support.

Usage example:

# config
root:
  widgets:
    - LatestAuthorsWidget
    - LatestPostsWidget
class LatestAuthorsWidget < TinyAdmin::Views::BasicWidget
  def template
    h2 { 'Latest authors' }

    ul {
      Author.last(3).each do |author|
        li {
          a(href: TinyAdmin.route_for('authors', reference: author.id)) { author.to_s }
        }
      end
    }
  end
end

class LatestPostsWidget < TinyAdmin::Views::BasicWidget
  def template
    h2 { 'Latest posts' }

    ul {
      Post.last(3).each do |post|
        li {
          a(href: TinyAdmin.route_for('posts', reference: post.id)) { post.to_s }
        }
      end
    }
  end
end

@blocknotes blocknotes added the enhancement New feature or request label May 1, 2023
@blocknotes blocknotes self-assigned this May 1, 2023
@blocknotes blocknotes force-pushed the feat/widgets branch 2 times, most recently from 83a5f4c to 5be607f Compare May 1, 2023 07:29
@blocknotes blocknotes force-pushed the feat/widgets branch 2 times, most recently from da86793 to 0a1f997 Compare May 1, 2023 07:41
@blocknotes blocknotes marked this pull request as ready for review May 1, 2023 08:09
@blocknotes blocknotes merged commit 23a143f into main May 1, 2023
@blocknotes blocknotes deleted the feat/widgets branch May 1, 2023 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant