klastera 1.4.3 → 1.4.4.3.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 +4 -4
- data/app/models/klastera/clusterizable.rb +5 -0
- data/app/models/klastera/concerns/clusterizable.rb +10 -3
- data/app/models/klastera/concerns/organization.rb +12 -1
- data/app/models/klastera/concerns/user.rb +12 -12
- data/app/views/layouts/klastera/_cluster_entity_fields.html.erb +1 -1
- data/app/views/layouts/klastera/_cluster_filter.html.erb +1 -1
- data/app/views/layouts/klastera/_cluster_user_fields.html.erb +1 -1
- data/db/migrate/20200908180057_add_cluster_config_to_organization.rb +5 -0
- data/lib/klastera.rb +1 -1
- data/lib/klastera/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5360c25a358007e11929e1c705ed18f97538d0a2dcfa7817e838dc422457a3f7
|
4
|
+
data.tar.gz: 319361af1415f3337408b376703a6b8e8021975d137be787c4ec8e2ea318ad4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56d74c36d8de04066a89ac3d0cb05abfedca150d6e5264872cb1e283138f76e828eadfca43824e7977020898a7a69287f2392b9263a6316eb4cd6b9ca5e8d397
|
7
|
+
data.tar.gz: 39917be78a6bac52e0077d0f6cf40e915c2c11fd360d79ee51881fec65577c21093c9080f06e3b74cbcc0f514b0cc6cca1bbc8b0e6720eca23b0fc08203e56f0
|
@@ -1,13 +1,16 @@
|
|
1
1
|
module Klastera::Concerns::Clusterizable
|
2
2
|
extend ActiveSupport::Concern
|
3
|
+
|
3
4
|
included do
|
5
|
+
class MutipleClustersOperationError < StandardError; end
|
6
|
+
|
4
7
|
belongs_to :cluster
|
5
8
|
|
6
9
|
has_many :cluster_entities, as: :entity, class_name: Klastera::ClusterEntity
|
7
10
|
accepts_nested_attributes_for :cluster_entities, reject_if: :all_blank, allow_destroy: true
|
8
11
|
|
9
|
-
validates :cluster_id, presence: true, if:
|
10
|
-
validate :at_least_one_cluster_entity, if:
|
12
|
+
validates :cluster_id, presence: true, if: -> { cluster_id.present? && organization.present? && organization.required_suborganization_mode? }
|
13
|
+
validate :at_least_one_cluster_entity, if: -> { organization.present? && organization.required_suborganization_mode? }
|
11
14
|
validate :uniqueness_of_cluster_entity_record
|
12
15
|
|
13
16
|
scope :includes_cluster, -> { includes(cluster_entities: :cluster) }
|
@@ -18,6 +21,10 @@ module Klastera::Concerns::Clusterizable
|
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
24
|
+
def allow_multiple_clusters?(default=:one)
|
25
|
+
organization.present? && organization.cluster_cardinality_of(self.class, default: default) == :many
|
26
|
+
end
|
27
|
+
|
21
28
|
##
|
22
29
|
# This is a legacy method and we don't recommend using it.
|
23
30
|
# Implement directly Klastera.entity_clusters_string_list instead of this method.
|
@@ -25,7 +32,7 @@ module Klastera::Concerns::Clusterizable
|
|
25
32
|
##
|
26
33
|
def clusters_string_separated_by(separator,attribute=:name)
|
27
34
|
Klastera.entity_clusters_string_list!(
|
28
|
-
|
35
|
+
cluster_entities, separator, attribute
|
29
36
|
)
|
30
37
|
end
|
31
38
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Klastera::Concerns::Organization
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
included do
|
4
|
-
|
4
|
+
serialize :cluster_config
|
5
5
|
has_many :clusters
|
6
6
|
|
7
7
|
validates :use_cluster_as, inclusion: { in: ::Cluster::MODES.map{|m|m.to_s}, message: I18n.t('klastera.clusters.wrong_option') }, if: proc{ use_cluster_as.present? }
|
@@ -11,6 +11,17 @@ module Klastera::Concerns::Organization
|
|
11
11
|
self.use_cluster_as.to_s.to_sym
|
12
12
|
end
|
13
13
|
|
14
|
+
def cluster_cardinality_of(entity, default: :many)
|
15
|
+
if cluster_config.is_a?(Hash)
|
16
|
+
entities_cardinality = cluster_config[:entities]&.[](:cardinality)||{}
|
17
|
+
entity = entity.to_s.to_sym
|
18
|
+
if entities_cardinality.has_key?(entity)
|
19
|
+
default = entities_cardinality[entity]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
default.to_s.to_sym
|
23
|
+
end
|
24
|
+
|
14
25
|
##
|
15
26
|
# Return a boolean if one of three of options was set in organization
|
16
27
|
# As useless option you can retrieve the value passing false as argument.
|
@@ -11,29 +11,29 @@ module Klastera::Concerns::User
|
|
11
11
|
|
12
12
|
has_many :cluster_users, inverse_of: :user, class_name: ::ClusterUser.to_s
|
13
13
|
accepts_nested_attributes_for :cluster_users, reject_if: :all_blank, allow_destroy: true
|
14
|
-
validates :cluster_role, presence: true, if:
|
15
|
-
validates :cluster_role, inclusion: { in: CLUSTER_ROLES , message: I18n.t('klastera.clusters.wrong_option') }, if:
|
16
|
-
validate :at_least_one_role, if:
|
14
|
+
validates :cluster_role, presence: true, if: -> { organization.present? && organization.is_in_cluster_mode? }
|
15
|
+
validates :cluster_role, inclusion: { in: CLUSTER_ROLES , message: I18n.t('klastera.clusters.wrong_option') }, if: -> { cluster_role.present? }
|
16
|
+
validate :at_least_one_role, if: -> { use_cluster? && try(:need_cluster_assignation?) }
|
17
17
|
|
18
|
-
def use_cluster?;
|
18
|
+
def use_cluster?; cluster_role.present?; end
|
19
19
|
|
20
|
-
def is_a_cluster_root?;
|
21
|
-
def is_a_cluster_admin?;
|
22
|
-
def is_a_cluster_user?;
|
20
|
+
def is_a_cluster_root?; cluster_role == CLUSTER_ROOT; end
|
21
|
+
def is_a_cluster_admin?; cluster_role == CLUSTER_ADMIN; end
|
22
|
+
def is_a_cluster_user?; cluster_role == CLUSTER_USER; end
|
23
23
|
|
24
24
|
def need_cluster_assignation?
|
25
|
-
|
25
|
+
organization.present? && organization.required_suborganization_mode? && is_a_cluster_user?
|
26
26
|
end
|
27
27
|
|
28
28
|
def can_admin_clusters?
|
29
|
-
|
29
|
+
organization.present? && organization.is_in_cluster_mode? && ( is_a_cluster_admin? || is_a_cluster_root? )
|
30
30
|
end
|
31
31
|
|
32
32
|
#
|
33
33
|
# It tells if this user should see what they cluster role or organization dictates
|
34
34
|
# Adminers and users from show cluster modes skip cluster clause
|
35
35
|
def cannot_skip_cluster_clause?
|
36
|
-
! (
|
36
|
+
! ( is_a_cluster_admin? || is_a_cluster_root? || ( organization.present? && organization.optional_suborganization_mode? && cluster_users.blank? ) )
|
37
37
|
end
|
38
38
|
|
39
39
|
#
|
@@ -43,9 +43,9 @@ module Klastera::Concerns::User
|
|
43
43
|
# cluster_id is present (on show/use mode organizations).
|
44
44
|
#
|
45
45
|
def try_to_clusterify!(role,cluster_ids)
|
46
|
-
if
|
46
|
+
if organization.present? && organization.is_in_cluster_mode?
|
47
47
|
self.cluster_role = role
|
48
|
-
if
|
48
|
+
if ( organization.present? && organization.required_suborganization_mode? ) || cluster_ids.present?
|
49
49
|
timestamp = DateTime.now.to_i
|
50
50
|
nested_attributes = {}
|
51
51
|
cluster_ids.each do |cluster_id|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<tr class="nested-fields">
|
2
2
|
<td class="field">
|
3
|
-
<%= f.select :cluster_id, @clusters_session.map{|c|[c.name,c.id]}, { include_blank: true }, { class: 'form-control' } %>
|
3
|
+
<%= f.select :cluster_id, @clusters_session.order(:order,:name).map{|c|[c.name,c.id]}, { include_blank: true }, { class: 'form-control' } %>
|
4
4
|
</td>
|
5
5
|
<td class="action vertical-align-middle text-center" width="44">
|
6
6
|
<%= link_to_remove_association f, class: 'btn btn-danger btn-xs text-danger' do %>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<%=yield(f) if block_given? %>
|
8
8
|
|
9
9
|
<% if cluster_organization.is_in_cluster_mode? %>
|
10
|
-
<% cluster_collection = cluster_list.map{|c|[c.name,(c.id||c.nid)]} %>
|
10
|
+
<% cluster_collection = cluster_list.order(:order, :name).map{|c|[c.name,(c.id||c.nid)]} %>
|
11
11
|
<% if cluster_collection.size > 1 %>
|
12
12
|
<div class="inline-label-control-block">
|
13
13
|
<%= f.input :cluster_id, collection: cluster_collection, prompt: t('klastera.clusters.all'), label: false, wrapper: false %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<tr class="nested-fields">
|
2
2
|
<td class="field">
|
3
|
-
<%= f.select :cluster_id, @user.organization.clusters.map{|c|[c.name,c.id]}, { include_blank: true }, { class: 'form-control' } %>
|
3
|
+
<%= f.select :cluster_id, @user.organization.clusters.order(:order, :name).map{|c|[c.name,c.id]}, { include_blank: true }, { class: 'form-control' } %>
|
4
4
|
</td>
|
5
5
|
<td class="action vertical-align-middle text-center" width="44">
|
6
6
|
<%= link_to_remove_association f, class: 'btn btn-danger btn-xs text-danger' do %>
|
data/lib/klastera.rb
CHANGED
data/lib/klastera/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: klastera
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.3
|
4
|
+
version: 1.4.4.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gino Barahona
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- app/models/klastera/cluster_entity.rb
|
59
59
|
- app/models/klastera/cluster_filter.rb
|
60
60
|
- app/models/klastera/cluster_user.rb
|
61
|
+
- app/models/klastera/clusterizable.rb
|
61
62
|
- app/models/klastera/concerns/cluster.rb
|
62
63
|
- app/models/klastera/concerns/cluster_entity.rb
|
63
64
|
- app/models/klastera/concerns/cluster_filter.rb
|
@@ -93,6 +94,7 @@ files:
|
|
93
94
|
- db/migrate/20200330010551_create_klastera_cluster_users.rb
|
94
95
|
- db/migrate/20200330221601_add_order_field_to_clusters.rb
|
95
96
|
- db/migrate/20200518142609_create_klastera_cluster_entities.rb
|
97
|
+
- db/migrate/20200908180057_add_cluster_config_to_organization.rb
|
96
98
|
- lib/klastera.rb
|
97
99
|
- lib/klastera/engine.rb
|
98
100
|
- lib/klastera/version.rb
|