-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
337d1bf
commit 17415f2
Showing
26 changed files
with
250 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<li class="dropdown pull-right"> | ||
<a href="#" data-toggle="dropdown"> | ||
<%= translate_scoped("actions.label") %> <span class="caret"></span> | ||
</a> | ||
<ul class="dropdown-menu"> | ||
<% if policy(@resource).show? && action_name != "show" %> | ||
<li> | ||
<%= link_to translate_scoped("actions.show"), [*@resource_parents, @resource] %> | ||
</li> | ||
<% end %> | ||
<% if policy(@resource).edit? && action_name != "edit" %> | ||
<li> | ||
<%= link_to translate_scoped("actions.edit"), [:edit, *@resource_parents, @resource] %> | ||
</li> | ||
<% end %> | ||
<% if policy(@resource).destroy? %> | ||
<li> | ||
<%= link_to translate_scoped("actions.destroy"), [*@resource_parents, @resource], method: :delete, | ||
data: { confirm: translate_scoped("actions.confirm_message") } %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</li> | ||
|
||
<% if @resource_service.has_many_map.present? %> | ||
<li class="dropdown pull-right"> | ||
<a href="#" data-toggle="dropdown"> | ||
<%= translate_scoped("associations.label") %> <span class="caret"></span> | ||
</a> | ||
<ul class="dropdown-menu"> | ||
<% @resource_service.has_many_map.each do |name, options| %> | ||
<% if policy(options[:class_name].constantize).index? %> | ||
<li> | ||
<%= link_to(options[:class_name].constantize.model_name.human(count: 2), | ||
send("#{@resource_class.name.underscore}_#{name}_path", @resource)) %> | ||
</li> | ||
<% end %> | ||
<% end %> | ||
</ul> | ||
</li> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<% if policy(@resource_service.build_resource({})).new? %> | ||
<%= link_to t("helpers.submit.create", model: @resource_class.model_name.human), [:new, @resource_class.model_name.singular_route_key], class: "btn btn-default" %> | ||
<%= link_to t("helpers.submit.create", model: @resource_class.model_name.human), [:new, *@resource_parents, @resource_class.model_name.singular_route_key], class: "btn btn-default" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Godmin | ||
module Resources | ||
module ResourceService | ||
module Associations | ||
extend ActiveSupport::Concern | ||
|
||
delegate :has_many_map, to: "self.class" | ||
|
||
module ClassMethods | ||
def has_many_map | ||
@has_many_map ||= {} | ||
end | ||
|
||
def has_many(attr, options = {}) | ||
has_many_map[attr] = { | ||
class_name: attr.to_s.singularize.classify | ||
}.merge(options) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class CommentsController < ApplicationController | ||
include Godmin::Resources::ResourceController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Comment < ActiveRecord::Base | ||
belongs_to :article | ||
|
||
def to_s | ||
title | ||
end | ||
end |
Oops, something went wrong.