ecm_blog_backend 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ce66768ab5c0a1e84587e5beb9560e88a9ff648
4
- data.tar.gz: da7c952830aa6119c7334006f1862ab3aa2056d0
3
+ metadata.gz: cf54d74924f38d51e586a0c55ba652bb3cf86a70
4
+ data.tar.gz: ebbbb159658337c88bb8016cbcedf5e7e25e3e58
5
5
  SHA512:
6
- metadata.gz: 88c3b42073ec79d27b9d6dfe946716dd972f6d8906ec67f1a282fee0c5030f07cf8f3afc7504cb93fe22cc519f8afa41945f554fa981f13d0964f2b8b01230aa
7
- data.tar.gz: 044b78ff3b9df562a10169c3bb20bc8fdf46914873b4317e24563474f193b6df5ec2f304a2d9b3f37c5560765f79014ca8673a2eadb8166854af1123eb135fe6
6
+ metadata.gz: 74c79abec7e9c431ff92430357d2f45e56141a77d1c80af27f843e0e9bef4eb498f99909b1111b99e40516fbeab8fddbd672f2656c6e41764cd59831ed6022ac
7
+ data.tar.gz: 7945091a943136644930090987df3bd3a8cfe8151f3deaeb22c4110ab41074d5bb5559a55aba1c0312e81b767b891ded591d8b95a6d2dcea3dfbe8d5708fb319
@@ -2,7 +2,8 @@ module Ecm
2
2
  module Blog
3
3
  module Backend
4
4
  class PostsController < Itsf::Backend::Resource::BaseController
5
- include Controller::ActsAsPublishedConcern
5
+ include ResourcesController::ActsAsPublishedConcern
6
+ include ResourcesController::FriendlyIdConcern
6
7
 
7
8
  helper Ecm::Tags::Backend::ApplicationHelper
8
9
 
@@ -12,16 +13,26 @@ module Ecm
12
13
 
13
14
  private
14
15
 
15
- def collection_scope
16
+ def initialize_resource
17
+ super
18
+ @resource.creator = current_user
19
+ end
20
+
21
+ def initialize_resource_for_create
22
+ super
23
+ @resource.creator = current_user
24
+ end
25
+
26
+ def load_collection_scope
16
27
  super.friendly.order(updated_at: :desc)
17
28
  end
18
29
 
19
- def load_scope
30
+ def load_resource_scope
20
31
  super.friendly
21
32
  end
22
33
 
23
34
  def permitted_params
24
- params.require(:post).permit(:created_by_id, :title, :body, :published, :tag_list)
35
+ params.require(:post).permit(:title, :body, :published, :tag_list)
25
36
  end
26
37
  end
27
38
  end
@@ -1,4 +1,12 @@
1
- = form.association :creator, collection: Ecm::Blog.creator_class_name.constantize.all, label_method: Ecm::Blog::Backend.creator_label_method
1
+ .bottom-margin-1
2
+ %b= Ecm::Blog::Post.human_attribute_name(:creator)
3
+ %br
4
+ - case Ecm::Blog::Backend.creator_label_method
5
+ - when Symbol, String
6
+ = form.object.creator.send(Ecm::Blog::Backend.creator_label_method)
7
+ - when Proc
8
+ = Ecm::Blog::Backend.creator_label_method.call(form.object.creator)
9
+
2
10
  = form.input :title
3
11
  = form.input :body, input_html: { 'data-add-editor': Itsf::Backend.features?(:'ace-rails-ap') } #, 'data-editor-syntax': form.object.handler }
4
12
  = form.input :published, as: :boolean
@@ -1,9 +1,8 @@
1
1
  = table.row :title
2
- = table.row(:tags) do |resource|
3
- = tag_labels_for(resource)
4
2
  = table.row :body
5
- = table.row :published_at
6
- = table.row :creator, as: :association
7
- = table.row :updater, as: :association
8
- = table.row :created_at
9
- = table.row :updated_at
3
+ = table.row(:tags) do |resource|
4
+ - tag_labels_for(resource)
5
+ = table.association :creator, label_method: ->(r) { r.try_all(*Itsf::Backend.resource_title_methods) }
6
+ = table.association :updater, label_method: ->(r) { r.try_all(*Itsf::Backend.resource_title_methods) }
7
+ = table.timestamp :published_at, format: :short
8
+ = table.timestamps format: :short
@@ -1,5 +1,6 @@
1
- = table.column :title, sortable: true
2
- = table.column :body, sortable: true
3
- = table.userstamps
4
- = table.timestamps
1
+ = table.column :title, sort: true
2
+ = table.column :body, sort: true
3
+ = table.association :creator, label_method: ->(r) { r.try_all(*Itsf::Backend.resource_title_methods) }
4
+ = table.association :updater, label_method: ->(r) { r.try_all(*Itsf::Backend.resource_title_methods) }
5
+ = table.timestamps format: :short, sort: true
5
6
  = table.acts_as_published_actions
@@ -1,7 +1,7 @@
1
1
  module Ecm
2
2
  module Blog
3
3
  module Backend
4
- VERSION = "0.0.2"
4
+ VERSION = "0.1.0".freeze
5
5
  end
6
6
  end
7
7
  end
@@ -16,4 +16,10 @@ Ecm::Blog::Backend.configure do |config|
16
16
  #
17
17
  config.registered_services = -> {[
18
18
  ]}
19
+
20
+ # Method to call on creator for display. Can be a symbol,
21
+ # string or Proc.
22
+ #
23
+ # default: config.creator_label_method = :to_s
24
+ config.creator_label_method = :to_s
19
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecm_blog_backend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-31 00:00:00.000000000 Z
11
+ date: 2018-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails