maquina 0.2.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a7e451e89b0cc87b356302a33dd2bf6e0ee95f3435f7f8161697e49cedac9bd
4
- data.tar.gz: 4f9502c3d4d0a5ff9bd41769c542e277ec255e217370fac3dd00fafdb8cf7bc6
3
+ metadata.gz: 253e32217b0c2f5e0a8a352ff4ac26a1e0d904184293205135f1d60fd43392d2
4
+ data.tar.gz: a347016c5e76c08fc3165662b47684ff181667a4bea70c25e340bc71e760b1cc
5
5
  SHA512:
6
- metadata.gz: 0ecf0e0e1fead4ee3594ccb5d9991f7490ad6b8bad8cc6a76def65ccd4ad0ccea18f7b267d7d9dba11aaeb4ffa27463185cf57ade1fdd97e43f53261c55e5f71
7
- data.tar.gz: dfb73cdf21f2d9761c0ff263c12015a11a9be2fc0a1c19e48ceaf17372356de6a877df4aeafe7bb75d60306d053e71c570ee22c3959a9c64e695b0b156274e5a
6
+ metadata.gz: 77c5d7eb9e6927194b0ea5635f8a535b898010b755e42e254258e2af675c6c4ba08c70372141056e2fd296008d7a120d938019f5fa55966d3d3314cc61744621
7
+ data.tar.gz: 1013008ff3b86923b4d055c894d62e01ba23e84c4cad7d029454d1d8f9e80865ac038be1f5693c39a9828cebec1fc57c0a6591d6b16c4c7d134a83d321ef4acd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maquina (0.2.0)
4
+ maquina (0.2.1)
5
5
  action_policy (~> 0.6.3)
6
6
  bcrypt (~> 3.1.7)
7
7
  importmap-rails (~> 1.2.0)
@@ -25,7 +25,7 @@ export default class extends Controller {
25
25
  event.preventDefault()
26
26
 
27
27
  if (this.hasFrameTarget && this.contentTarget.classList.contains("hidden")) {
28
- let url = event["detail"]["src"] || this.element.dataset["frameSrc"]
28
+ let url = event.target.getAttribute("href") || this.element.dataset["frameSrc"]
29
29
  this.frameTarget.setAttribute("src", url)
30
30
  } else if (!this.contentTarget.classList.contains("hidden")) {
31
31
  this.frameTarget.setAttribute("src", "")
@@ -1,15 +1,10 @@
1
1
  import { Controller } from "@hotwired/stimulus";
2
- import { useDispatch } from "stimulus-use";
3
2
 
4
3
  export default class extends Controller {
5
- static targets = [];
6
-
7
- connect() {
8
- useDispatch(this)
9
- }
4
+ static outlets = ["modal"];
10
5
 
11
6
  open(event) {
12
- event.preventDefault();
13
- this.dispatch("toggle", {src: event.target.getAttribute("href")});
7
+ event.preventDefault()
8
+ this.modalOutlets.forEach(modal => modal.toggleModal(event))
14
9
  }
15
10
  }
@@ -35,6 +35,9 @@ module Maquina
35
35
  active_session = ActiveSession.eager_load(user: {memberships: :organization})
36
36
  .where(maquina_memberships: {blocked_at: nil})
37
37
  .where(maquina_organizations: {active: true})
38
+ .or(
39
+ ActiveSession.where(maquina_users: {management: true})
40
+ )
38
41
  .find_by(id: active_session_id)
39
42
 
40
43
  return if active_session.blank?
@@ -11,13 +11,13 @@ module Maquina
11
11
  end
12
12
 
13
13
  class_methods do
14
- def search_scope(fields: [], options: {})
14
+ def search_scope(fields: [], options: {}, associated_against: {})
15
15
  return if fields.empty?
16
16
 
17
17
  default_options = {tsearch: {prefix: true, any_word: true}}
18
18
  search_options = options.deep_merge(default_options)
19
19
 
20
- pg_search_scope :search_full, against: fields, using: search_options # , ignoring: :accents
20
+ pg_search_scope :search_full, against: fields, using: search_options, associated_against: associated_against # , ignoring: :accents
21
21
  end
22
22
  end
23
23
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "pg_search"
4
-
5
3
  module Maquina
6
4
  class ApplicationRecord < ActiveRecord::Base
7
5
  self.abstract_class = true
8
6
 
9
- include PgSearch::Model
7
+ def self.searchable?
8
+ false
9
+ end
10
10
  end
11
11
  end
@@ -25,8 +25,6 @@ module Maquina
25
25
  # attributes and use the provided methods and scopes for querying and manipulating plan data.
26
26
 
27
27
  class Plan < ApplicationRecord
28
- include Searchable
29
-
30
28
  has_many :organizations, class_name: "Maquina::Organization", foreign_key: :maquina_plan_id, dependent: :nullify
31
29
 
32
30
  monetize :price_cents
@@ -34,7 +32,5 @@ module Maquina
34
32
  validates :price, numericality: {greater_than_or_equal_to: 0}, if: ->(plan) { plan.free? }
35
33
  validates :price, numericality: {greater_than: 0}, if: ->(plan) { !plan.free? }
36
34
  validates :name, presence: true, uniqueness: true
37
-
38
- search_scope(fields: [:name])
39
35
  end
40
36
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Maquina
4
4
  class User < ApplicationRecord
5
- include Maquina::Searchable
6
5
  include Maquina::RetainPasswords
7
6
  include Maquina::AuthenticateBy
8
7
  include Maquina::Blockeable
@@ -18,8 +17,6 @@ module Maquina
18
17
 
19
18
  before_save :downcase_email
20
19
 
21
- search_scope(fields: [:email])
22
-
23
20
  def expired_password?
24
21
  return false if password_expires_at.blank?
25
22
 
@@ -3,11 +3,11 @@
3
3
  module Maquina
4
4
  class InvitationPolicy < ApplicationPolicy
5
5
  def new?
6
- management?
6
+ management? || admin?
7
7
  end
8
8
 
9
9
  def create?
10
- new?
10
+ new? || admin?
11
11
  end
12
12
  end
13
13
  end
@@ -6,7 +6,7 @@
6
6
  <%= render Maquina::Navbar::Menu.new %>
7
7
  </div>
8
8
 
9
- <%= render Maquina::Navbar::Search.new(query: params[:q], url: collection_path) if action_name == "index" && respond_to?(:collection_path) && collection_path.present? %>
9
+ <%= render Maquina::Navbar::Search.new(query: params[:q], url: collection_path) if action_name == "index" && respond_to?(:collection_path) && collection_path.present? && respond_to?(:resource_class) && resource_class.searchable? %>
10
10
 
11
11
  <%= render Maquina::Navbar::MobileButton.new %>
12
12
 
@@ -27,7 +27,7 @@ module Maquina
27
27
  return if policy_class.blank? || !allowed_to?(:new?, with: policy_class)
28
28
 
29
29
  options = {}
30
- options[:data] = {controller: "modal-open", action: "modal-open#open"} if policy_class.present? && allowed_to?(:new_modal?, with: policy_class)
30
+ options[:data] = {controller: "modal-open", modal_open_modal_outlet: ".modal", action: "modal-open#open"} if policy_class.present? && allowed_to?(:new_modal?, with: policy_class)
31
31
 
32
32
  div(class: "mt-4 sm:mt-0 sm:ml-16 sm:flex-none") do
33
33
  a(href: new_resource_path, class: "inline-flex items-center justify-center button button-accented", **options) { add_new }
@@ -7,9 +7,7 @@ module Maquina
7
7
  register_element :turbo_frame
8
8
 
9
9
  def template
10
- div(data_controller: "modal",
11
- data_action: " modal-open:toggle@window->modal#toggleModal close-frame-modal:toggle@window->modal#toggleModal",
12
- data_frame_src: "") do
10
+ div(data_controller: "modal", class: "modal", data_frame_src: "") do
13
11
  div(class: "fixed inset-0 z-30 hidden overflow-y-auto", aria_labelledby: "modal-title", role: "dialog",
14
12
  aria_modal: "true", data_modal_target: "container") do
15
13
  div(class: "flex items-end justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0") do
@@ -24,9 +24,5 @@ module Maquina
24
24
  def copy_migrations
25
25
  rake "maquina:install:migrations"
26
26
  end
27
-
28
- def build_tailwind
29
- rake "maquina:tailwindcss:build"
30
- end
31
27
  end
32
28
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ Maquina.configure do |config|
4
+ # Configure membership roles.
5
+ config.membership_roles = Maquina.postgresql? ? {admin: "admin", member: "member"} : {admin: 0, member: 1}
6
+ end
@@ -1,3 +1,3 @@
1
1
  module Maquina
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/maquina.rb CHANGED
@@ -11,6 +11,10 @@ require "pagy"
11
11
  module Maquina
12
12
  class << self
13
13
  attr_accessor :configuration
14
+
15
+ def postgresql?
16
+ ActiveRecord::Base.connection_db_config.configuration_hash[:adapter].downcase == "postgresql"
17
+ end
14
18
  end
15
19
 
16
20
  class Configuration
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maquina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Alberto Chávez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-30 00:00:00.000000000 Z
11
+ date: 2023-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -434,7 +434,7 @@ files:
434
434
  - lib/generators/maquina/tailwind_config/templates/lib/generators/tailwind_config/tailwind_config_generator.rb.tt
435
435
  - lib/generators/maquina/tailwind_config/templates/lib/generators/tailwind_config/templates/config/tailwind.config.js.tt
436
436
  - lib/generators/maquina/tailwind_config/templates/lib/tasks/tailwind.rake.tt
437
- - lib/generators/maquina/templates/config/initializers/maquina.rb
437
+ - lib/generators/maquina/templates/config/initializers/maquina.rb.tt
438
438
  - lib/maquina.rb
439
439
  - lib/maquina/engine.rb
440
440
  - lib/maquina/version.rb
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # TODO: Have and initializer