klastera 1.1.2 → 1.1.3
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5852cf2afca5ca451495ec4edfc3424c2eef664b6f848bf0bf7160570cefc8e5
|
4
|
+
data.tar.gz: 8d7cdd33fa148b3aa6186953c6e20b49570442229150684da761d6e82c5511c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5044d1067b784b9b2a51fc77ddbd173478fc6b157126f13162ae329f4e276a449de01a2f0ef9318bf0dc8371ef933da9ff17e2d9f454446b0e4454663895168d
|
7
|
+
data.tar.gz: a3d59a38ba31e0686e17ce57172ce999527cb0b1f900ae5f93cb5e737c6b42f3e165ad448dfeb4c8a178873c90a354c0c55c67755b6b0228bc5c8ceec57dce11
|
@@ -5,6 +5,10 @@ module Klastera::Concerns::ClusterFilter
|
|
5
5
|
include ActiveModel::Model
|
6
6
|
include ActiveModel::Validations::Callbacks
|
7
7
|
attr_accessor :cluster_id
|
8
|
+
|
9
|
+
def kcluster_id
|
10
|
+
self.cluster_id == 'without_cluster' ? nil : self.cluster_id
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
14
|
module ClassMethods
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<%=yield(f)%>
|
8
8
|
|
9
9
|
<% if cluster_organization.is_in_cluster_mode? %>
|
10
|
-
<% cluster_collection = cluster_clusters.map{|c|[c.name,c.id]} %>
|
10
|
+
<% cluster_collection = cluster_clusters.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 %>
|
data/config/locales/es.yml
CHANGED
data/lib/klastera/version.rb
CHANGED
data/lib/klastera.rb
CHANGED
@@ -14,8 +14,18 @@ module Klastera
|
|
14
14
|
scope_klass = scope_klass.where(organization_id: organization)
|
15
15
|
|
16
16
|
session_clusters(user,organization) do |clusters|
|
17
|
-
|
18
|
-
|
17
|
+
clusters = clusters.reject{|c|c.id.blank?}
|
18
|
+
with_clusters = nil; without_clusters = nil
|
19
|
+
|
20
|
+
if organization.required_suborganization_mode? || clusters.present?
|
21
|
+
with_clusters = "#{scope.table_name}.cluster_id IN (#{clusters.map(&:id).join(',')})"
|
22
|
+
end
|
23
|
+
|
24
|
+
if organization.optional_mode?
|
25
|
+
without_clusters = "#{with_clusters.blank? ? '' : ' OR ' }#{scope.table_name}.cluster_id IS NULL"
|
26
|
+
end
|
27
|
+
|
28
|
+
scope_klass = scope_klass.where("#{with_clusters}#{without_clusters}")
|
19
29
|
end
|
20
30
|
|
21
31
|
scope_klass
|
@@ -38,10 +48,11 @@ module Klastera
|
|
38
48
|
def session_clusters(user,organization)
|
39
49
|
clusters = []
|
40
50
|
if organization.is_in_cluster_mode?
|
41
|
-
unless user.can_admin_clusters?
|
51
|
+
unless user.can_admin_clusters?
|
42
52
|
# TODO: 1: return a Cluster::ActiveRecord_Relation and then remove to_a in ::Cluster.of line
|
43
53
|
# TODO: 2: fix call to ::Cluster instead of Klastera::Cluster
|
44
54
|
clusters = ::ClusterUser.of(user,organization).map{|cu|::Cluster.find(cu.cluster_id)}
|
55
|
+
clusters << ::Cluster.new({nid: :without_cluster, name: I18n.t('klastera.without_cluster')}) if organization.optional_mode?
|
45
56
|
else
|
46
57
|
# TODO: remove "to_a" after ClusterUser.of result became a Cluster::ActiveRecord_Relation object
|
47
58
|
clusters = ::Cluster.of(organization).to_a
|
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.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gino Barahona
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|