keystone_ui-preferences 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: 01e15e5f655d70c8bfd4b7b0d1c976705de25a0f0c0d24645e5aa3afe5c9e8ee
4
- data.tar.gz: ec05d21e7991ff5378e817f8f70be35fbae4f92f6a141467fc188447176b1850
3
+ metadata.gz: 1c5ad1323692c3d86b07e82ecf8557ef9d85894d4e6136e77bfa4dfb5242ae17
4
+ data.tar.gz: 8e9e97a645d1eff47df36b3cc58b141fa41f6cbc53ca33899147137a5a7d32b7
5
5
  SHA512:
6
- metadata.gz: b82309fb9a0f5881748b3de2152973e348076aa1ae474fceb55be7476929e771732a3f023f655e22e8f4e34b3725218ff15a2d8c092a64a46842b5f94b9943c3
7
- data.tar.gz: d6617f9f3c90e2931f7ef5a29fcd6b103b4e32da8a2d4c5f1026828831d31609e8ac3af82fe390953c7e01c12c986c890ca988b760872aab22fcf8f37c8d4b53
6
+ metadata.gz: 8fd7e871629c061dc439d333ff15a3a54be431583e71d6936f6bb2b58ddf8e42ae6e5070dccca93f756c4e93acc9cd57b91d3f5443b84d1b6ab939c6eba740d4
7
+ data.tar.gz: 6d6255c5097eab889c34469150e92cb925d7286f02c296f36a47bea17fed1c254ce79cad4bcd9da0de4e9474c823948e97f74b3a998973e74c571d82ff2b8abe
data/README.md CHANGED
@@ -81,7 +81,15 @@ SettingsHub.section :account_layouts, area: :account, title: "Table layouts",
81
81
  runs: "KeystoneUi::Preferences::PickAccountLayouts"
82
82
  ```
83
83
 
84
- The section lists each component key the admin or the account has a saved layout for. Each key has the members-choose switch and, when the admin has a saved layout of their own, a button that makes it the account's layout.
84
+ The section lists each component key the admin or the account has a saved layout for, by the name the app gives it, or by the key in words when it has none:
85
+
86
+ ```ruby
87
+ KeystoneUi::Preferences.configure do |config|
88
+ config.name_component :revenue_projection_months, "Revenue projection – By month"
89
+ end
90
+ ```
91
+
92
+ Each key has the members-choose switch and, when the admin has a saved layout of their own, a button that makes it the account's layout.
85
93
 
86
94
  ## What is stored
87
95
 
@@ -4,7 +4,7 @@
4
4
  <% component_keys.each do |component_key| %>
5
5
  <div data-component-key="<%= component_key %>">
6
6
  <% account_preference = preferences.find { |preference| preference.component_key == component_key && preference.owned_by?(account) } %>
7
- <%= ui_section(title: component_key.humanize, spacing: :sm) do %>
7
+ <%= ui_section(title: KeystoneUi::Preferences.configuration.component_name(component_key), spacing: :sm) do %>
8
8
  <%= form_with(url: submit_url, method: :patch, data: { turbo: false }) do %>
9
9
  <%= hidden_field_tag "component_key", component_key, id: nil %>
10
10
  <%= hidden_field_tag "members_choose", "0", id: nil %>
@@ -8,6 +8,15 @@ module KeystoneUi
8
8
  def initialize
9
9
  @current_owner_method = :current_user
10
10
  @authentication_method = :authenticate_user!
11
+ @component_names = {}
12
+ end
13
+
14
+ def name_component(component_key, name)
15
+ @component_names[component_key.to_s] = name
16
+ end
17
+
18
+ def component_name(component_key)
19
+ @component_names.fetch(component_key.to_s) { component_key.to_s.humanize }
11
20
  end
12
21
  end
13
22
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module KeystoneUi
4
4
  module Preferences
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keystone_ui-preferences
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider