adminpanel 2.3.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1417bec9885c7f685524fceea628b7c79865ae67
4
- data.tar.gz: 9c53619401e07fea797f1967059d8373dc8842af
3
+ metadata.gz: 1aafbc35eee8d10953a446e2e0a9c8f499d87d2a
4
+ data.tar.gz: 37dbeddb83a4a4a1b95b415bd3a9e8a9416ad24b
5
5
  SHA512:
6
- metadata.gz: b4f9aa5c9059bbd9752fdf286c48d513551e1491faf8e608e72a8465d4e76b7653b5f5905cb3c76ea030848440626ab5836d24755588af0d13581896c1c8c660
7
- data.tar.gz: 0c78dfe91781b13aa9e70677d24b3f87ef80347546659e9b72c573af48654c19dbfb88d610230a9302d37b2690aacaa1ea7cee6ae3fae612e7819894695a6595
6
+ metadata.gz: 9d96d604d98c7fd68d23763cc2d267b0220f0db279566134f4fa210a452b7d9ca5079f9ef9d230a48969fb90c330d0dac9feb8db425f25e3f2c0d75cbcfc70d5
7
+ data.tar.gz: b77117eaa2fab041e598175d36ebbe4035692cb67c565cccbc4acac9c8f14964861759544ebf1c7b9206d2545d8f1d2f8a774ddfd93ba39040ca3d182089beff
@@ -28,7 +28,7 @@ module Adminpanel
28
28
  validates_format_of :description, with: VALID_EMAIL_REGEX, if: :is_email?
29
29
 
30
30
  default_scope do
31
- order("page ASC")
31
+ order :order => :asc
32
32
  end
33
33
 
34
34
  scope :of_page, -> (page) do
@@ -1,3 +1,3 @@
1
1
  module Adminpanel
2
- VERSION = "2.3.1"
2
+ VERSION = "2.4.0"
3
3
  end
@@ -77,6 +77,7 @@ class CreateAdminpanelTables < ActiveRecord::Migration
77
77
  t.string :page
78
78
  t.boolean :has_image
79
79
  t.integer :max_files, default: 0
80
+ t.integer :order
80
81
  t.timestamps
81
82
  end
82
83
  add_index :adminpanel_sections, [:key]
@@ -4,16 +4,24 @@ namespace :adminpanel do
4
4
  task :section, [:name, :section, :type] => :environment do |t, args|
5
5
  args.with_defaults(:section => "home", :name => "greeting", :type => "")
6
6
  puts "Creating #{args[:name]} in #{args[:section]} section" unless Rails.env.test?
7
+ page_name = args[:section].capitalize
8
+ order = Adminpanel::Section.find_by(:page => page_name)
7
9
 
8
10
  s = Adminpanel::Section.new(
9
11
  :name => args[:name].titleize,
10
12
  :has_description => false,
11
13
  :description => "",
12
14
  :key => (args[:name].downcase.tr(' ','_')),
13
- :page => args[:section].capitalize,
15
+ :page => page_name,
14
16
  :has_image => false
15
17
  )
16
18
 
19
+ if order.nil?
20
+ s.order = Adminpanel::Section.count + 1
21
+ else
22
+ s.order = order.order
23
+ end
24
+
17
25
  args[:type].split(" ").each do |type|
18
26
  case type
19
27
  when "wysiwyg" || "description"
@@ -116,6 +116,7 @@ ActiveRecord::Schema.define do
116
116
  t.string :page
117
117
  t.datetime :created_at, null: false
118
118
  t.datetime :updated_at, null: false
119
+ t.integer :order
119
120
  t.boolean :has_description
120
121
  end
121
122
  create_table :adminpanel_test_objects do |t|
@@ -23,7 +23,7 @@ module Adminpanel
23
23
  def test_default_scope
24
24
  assert_equal(
25
25
  Adminpanel::Section.all.to_sql,
26
- Adminpanel::Section.reorder('').order('page ASC').to_sql
26
+ Adminpanel::Section.reorder('').order(:order => :asc).to_sql
27
27
  )
28
28
  end
29
29
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adminpanel
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Ramon Camacho
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-26 00:00:00.000000000 Z
12
+ date: 2014-12-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails