abizvn-general 0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 343c8e74ec686c034435fd2f1fd1dcc6d07e4c589b6484faad357694ba7caf7b
4
+ data.tar.gz: 6b10a3372d6492509728c6fde0633268e85b0844c3cb52e211127392db0366b7
5
+ SHA512:
6
+ metadata.gz: 81f74e9e1749a91effda58be635d7e34151d34a71fff05238fd3884435ce6207aee1eb4a3cf40f55850ac3ee46b9186adc59c19f591807ef9abdb2bd4a401235
7
+ data.tar.gz: '07148d2bb6892e37348bcb5e5b976248e5b0efdeae9904abbfd9eeb3a1acd4e267dda785862fd367c688d28187fa7cffc1dc4c93a4d6b9df2c1919d6946f738d'
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright Juan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Abizvn::General
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem "abizvn-general"
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install abizvn-general
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/setup"
2
+
3
+ load "rails/tasks/statistics.rake"
4
+
5
+ require "bundler/gem_tasks"
@@ -0,0 +1,20 @@
1
+ ActiveAdmin.register Abizvn::General::GeneralSetting, as: 'general_setting' do
2
+ menu label: 'General Settings', parent: "System", priority: 2
3
+
4
+ permit_params do
5
+ permitted = [:code, :value, :active, :order]
6
+ permitted << :group if params[:action] == 'create'
7
+ permitted
8
+ end
9
+
10
+ form do |f|
11
+ f.inputs do
12
+ f.input :group if params[:action] == 'new'
13
+ f.input :code
14
+ f.input :value
15
+ f.input :order
16
+ f.input :active
17
+ end
18
+ f.actions
19
+ end
20
+ end
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/abizvn/general .css
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,6 @@
1
+ module Abizvn
2
+ module General
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Abizvn
2
+ module General
3
+ module ApplicationHelper
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Abizvn
2
+ module General
3
+ class ApplicationJob < ActiveJob::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ module Abizvn
2
+ module General
3
+ class ApplicationMailer < ActionMailer::Base
4
+ default from: "from@example.com"
5
+ layout "mailer"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ module Abizvn
2
+ module General
3
+ class GeneralSetting < Commonbase::ApplicationRecord
4
+ include Commonbase::RansackSearchable
5
+
6
+ self.table_name = 'general_settings'
7
+
8
+ validates :order, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
9
+
10
+ scope :ordered, -> { order(group: :asc, order: :asc) }
11
+ scope :activated, -> { where(active: :true) }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Abizvn general</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= yield :head %>
9
+
10
+ <%= stylesheet_link_tag "abizvn/general/application", media: "all" %>
11
+ </head>
12
+ <body>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Abizvn::General::Engine.routes.draw do
2
+ end
@@ -0,0 +1,11 @@
1
+ class CreateGeneralSettings < ActiveRecord::Migration[7.2]
2
+ def change
3
+ create_table :general_settings do |t|
4
+ t.string :group
5
+ t.string :code
6
+ t.string :value
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class AddIndexIntoGeneralSettings < ActiveRecord::Migration[7.2]
2
+ def change
3
+ add_index :general_settings, [:group, :code], unique: true, name: 'index_general_settings_group_and_code'
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class ReviewGeneralSetting < ActiveRecord::Migration[7.2]
2
+ def change
3
+ add_column :general_settings, :order, :integer, null: false, default: 0
4
+ add_column :general_settings, :active, :boolean, null: false, default: true
5
+ end
6
+ end
@@ -0,0 +1,27 @@
1
+ class CreateEntityStatusCollection < ActiveRecord::Migration[7.2]
2
+ def up
3
+ Abizvn::General::GeneralSetting.find_or_create_by!(group: Abizvn::General::ENTITY_STATUS_GROUP_NAME, code: Abizvn::General::ENTITY_STATUS_CODE_DRAFT) do |entity|
4
+ entity.value = 'Draft'
5
+ end
6
+ Abizvn::General::GeneralSetting.find_or_create_by!(group: Abizvn::General::ENTITY_STATUS_GROUP_NAME, code: Abizvn::General::ENTITY_STATUS_CODE_PUBLIC) do |entity|
7
+ entity.value = 'Public'
8
+ end
9
+ Abizvn::General::GeneralSetting.find_or_create_by!(group: Abizvn::General::ENTITY_STATUS_GROUP_NAME, code: Abizvn::General::ENTITY_STATUS_CODE_INVISIBLE) do |entity|
10
+ entity.value = 'Unlist'
11
+ end
12
+ Abizvn::General::GeneralSetting.find_or_create_by!(group: Abizvn::General::ENTITY_STATUS_GROUP_NAME, code: Abizvn::General::ENTITY_STATUS_CODE_PRIVATE) do |entity|
13
+ entity.value = 'Private'
14
+ end
15
+ end
16
+
17
+ def down
18
+ list_codes = [
19
+ Abizvn::General::ENTITY_STATUS_CODE_DRAFT,
20
+ Abizvn::General::ENTITY_STATUS_CODE_PUBLIC,
21
+ Abizvn::General::ENTITY_STATUS_CODE_INVISIBLE,
22
+ Abizvn::General::ENTITY_STATUS_CODE_PRIVATE
23
+ ]
24
+
25
+ Abizvn::General::GeneralSetting.where(group: Abizvn::General::ENTITY_STATUS_GROUP_NAME, code: list_codes).destroy_all
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ module Abizvn
2
+ module General
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace Abizvn::General
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Abizvn
2
+ module General
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ require "abizvn/general/version"
3
+ require "abizvn/general/engine"
4
+ require "commonbase" # To load the common base gem
5
+
6
+ module Abizvn
7
+ module General
8
+ ENTITY_STATUS_GROUP_NAME = 'entity_status'
9
+
10
+ ENTITY_STATUS_CODE_DRAFT = 'draft'
11
+ ENTITY_STATUS_CODE_PUBLIC = 'public'
12
+ ENTITY_STATUS_CODE_INVISIBLE = 'invisible'
13
+ ENTITY_STATUS_CODE_PRIVATE = 'private'
14
+
15
+ def self.entity_status_collection
16
+ return get_collection_by_group(ENTITY_STATUS_GROUP_NAME)
17
+ end
18
+
19
+ def self.get_collection_by_group(group)
20
+ return Abizvn::General::GeneralSetting.where(group: group).activated.ordered.pluck(:value, :id)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :abizvn_general do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: abizvn-general
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Juan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-02-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '7.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: commonbase
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.1.3
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.1.3
47
+ description: Managing General Settings for an application.
48
+ email:
49
+ - juanonsoftware@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - MIT-LICENSE
55
+ - README.md
56
+ - Rakefile
57
+ - app/admin/general_settings.rb
58
+ - app/assets/config/abizvn_general_manifest.js
59
+ - app/assets/stylesheets/abizvn/general/application.css
60
+ - app/controllers/abizvn/general/application_controller.rb
61
+ - app/helpers/abizvn/general/application_helper.rb
62
+ - app/jobs/abizvn/general/application_job.rb
63
+ - app/mailers/abizvn/general/application_mailer.rb
64
+ - app/models/abizvn/general/general_setting.rb
65
+ - app/views/layouts/abizvn/general/application.html.erb
66
+ - config/routes.rb
67
+ - db/migrate/20241115080211_create_general_settings.rb
68
+ - db/migrate/20241116110614_add_index_into_general_settings.rb
69
+ - db/migrate/20250104054920_review_general_setting.rb
70
+ - db/migrate/20250218110737_create_entity_status_collection.rb
71
+ - lib/abizvn/general.rb
72
+ - lib/abizvn/general/engine.rb
73
+ - lib/abizvn/general/version.rb
74
+ - lib/tasks/abizvn/general_tasks.rake
75
+ homepage: https://abizvn.com
76
+ licenses:
77
+ - MIT
78
+ metadata:
79
+ homepage_uri: https://abizvn.com
80
+ source_code_uri: https://github.com/abizvncom/abizvn-general
81
+ changelog_uri: https://github.com/abizvncom/abizvn-general
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubygems_version: 3.4.19
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: General Settings for an application.
101
+ test_files: []