sun-sword 0.0.1 → 0.0.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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -10
  3. data/lib/generators/sun_sword/frontend_generator.rb +43 -19
  4. data/lib/generators/sun_sword/init_generator.rb +15 -0
  5. data/lib/generators/sun_sword/scaffold_generator.rb +160 -9
  6. data/lib/generators/sun_sword/templates_frontend/config/devise.rb +313 -0
  7. data/lib/generators/sun_sword/templates_frontend/controllers/application_controller.rb.tt +7 -3
  8. data/lib/generators/sun_sword/templates_frontend/controllers/site_controller.rb +1 -0
  9. data/lib/generators/sun_sword/templates_frontend/db/migrate/20241117042039_devise_create_auths.rb +47 -0
  10. data/lib/generators/sun_sword/templates_frontend/db/migrate/20241117043154_create_models_accounts.rb +11 -0
  11. data/lib/generators/sun_sword/templates_frontend/db/migrate/20241117044142_create_models_users.rb +16 -0
  12. data/lib/generators/sun_sword/templates_frontend/db/seeds.rb +3 -0
  13. data/lib/generators/sun_sword/templates_frontend/db/structures/example.yaml.tt +106 -0
  14. data/lib/generators/sun_sword/templates_frontend/frontend/pages/web.js +2 -8
  15. data/lib/generators/sun_sword/templates_frontend/models/models/account.rb +4 -0
  16. data/lib/generators/sun_sword/templates_frontend/models/models/auth.rb +8 -0
  17. data/lib/generators/sun_sword/templates_frontend/models/models/user.rb +5 -0
  18. data/lib/generators/sun_sword/templates_frontend/views/layouts/dashboard/_sidebar.html.erb.tt +11 -1
  19. data/lib/generators/sun_sword/templates_frontend/views/layouts/dashboard/application.html.erb.tt +6 -9
  20. data/lib/generators/sun_sword/templates_init/config/initializers/sun_sword.rb +3 -0
  21. data/lib/generators/sun_sword/templates_scaffold/controllers/controller.rb.tt +31 -20
  22. data/lib/generators/sun_sword/templates_scaffold/views/_form.html.erb.tt +3 -8
  23. data/lib/generators/sun_sword/templates_scaffold/views/components/menu/link.html.erb.tt +1 -1
  24. data/lib/generators/sun_sword/templates_scaffold/views/index.html.erb.tt +4 -4
  25. data/lib/generators/sun_sword/templates_scaffold/views/show.html.erb.tt +2 -2
  26. data/lib/sun-sword.rb +4 -2
  27. data/lib/sun_sword/configuration.rb +29 -0
  28. data/lib/sun_sword/version.rb +1 -1
  29. metadata +28 -3
  30. data/lib/generators/sun_sword/templates_frontend/controllers/dashboard/site_controller.rb +0 -6
@@ -0,0 +1,313 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Assuming you have not yet modified this file, each configuration option below
4
+ # is set to its default value. Note that some are commented out while others
5
+ # are not: uncommented lines are intended to protect your configuration from
6
+ # breaking changes in upgrades (i.e., in the event that future versions of
7
+ # Devise change the default values for those options).
8
+ #
9
+ # Use this hook to configure devise mailer, warden hooks and so forth.
10
+ # Many of these configuration options can be set straight in your model.
11
+ Devise.setup do |config|
12
+ # The secret key used by Devise. Devise uses this key to generate
13
+ # random tokens. Changing this key will render invalid all existing
14
+ # confirmation, reset password and unlock tokens in the database.
15
+ # Devise will use the `secret_key_base` as its `secret_key`
16
+ # by default. You can change it below and use your own secret key.
17
+ # config.secret_key = '15930dd1ce83086d9191b621b8e19208f021ada98fcb3264bb0c0fc5150c5988d663dccf08e0b6b297f934f7a29fa55cee5bd62a7a513622b81c7c9e736aba9f'
18
+
19
+ # ==> Controller configuration
20
+ # Configure the parent class to the devise controllers.
21
+ # config.parent_controller = 'DeviseController'
22
+
23
+ # ==> Mailer Configuration
24
+ # Configure the e-mail address which will be shown in Devise::Mailer,
25
+ # note that it will be overwritten if you use your own mailer class
26
+ # with default "from" parameter.
27
+ config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
28
+
29
+ # Configure the class responsible to send e-mails.
30
+ # config.mailer = 'Devise::Mailer'
31
+
32
+ # Configure the parent class responsible to send e-mails.
33
+ # config.parent_mailer = 'ActionMailer::Base'
34
+
35
+ # ==> ORM configuration
36
+ # Load and configure the ORM. Supports :active_record (default) and
37
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
38
+ # available as additional gems.
39
+ require 'devise/orm/active_record'
40
+
41
+ # ==> Configuration for any authentication mechanism
42
+ # Configure which keys are used when authenticating a user. The default is
43
+ # just :email. You can configure it to use [:username, :subdomain], so for
44
+ # authenticating a user, both parameters are required. Remember that those
45
+ # parameters are used only when authenticating and not when retrieving from
46
+ # session. If you need permissions, you should implement that in a before filter.
47
+ # You can also supply a hash where the value is a boolean determining whether
48
+ # or not authentication should be aborted when the value is not present.
49
+ # config.authentication_keys = [:email]
50
+
51
+ # Configure parameters from the request object used for authentication. Each entry
52
+ # given should be a request method and it will automatically be passed to the
53
+ # find_for_authentication method and considered in your model lookup. For instance,
54
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
55
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
56
+ # config.request_keys = []
57
+
58
+ # Configure which authentication keys should be case-insensitive.
59
+ # These keys will be downcased upon creating or modifying a user and when used
60
+ # to authenticate or find a user. Default is :email.
61
+ config.case_insensitive_keys = [:email]
62
+
63
+ # Configure which authentication keys should have whitespace stripped.
64
+ # These keys will have whitespace before and after removed upon creating or
65
+ # modifying a user and when used to authenticate or find a user. Default is :email.
66
+ config.strip_whitespace_keys = [:email]
67
+
68
+ # Tell if authentication through request.params is enabled. True by default.
69
+ # It can be set to an array that will enable params authentication only for the
70
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
71
+ # enable it only for database (email + password) authentication.
72
+ # config.params_authenticatable = true
73
+
74
+ # Tell if authentication through HTTP Auth is enabled. False by default.
75
+ # It can be set to an array that will enable http authentication only for the
76
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
77
+ # enable it only for database authentication.
78
+ # For API-only applications to support authentication "out-of-the-box", you will likely want to
79
+ # enable this with :database unless you are using a custom strategy.
80
+ # The supported strategies are:
81
+ # :database = Support basic authentication with authentication key + password
82
+ # config.http_authenticatable = false
83
+
84
+ # If 401 status code should be returned for AJAX requests. True by default.
85
+ # config.http_authenticatable_on_xhr = true
86
+
87
+ # The realm used in Http Basic Authentication. 'Application' by default.
88
+ # config.http_authentication_realm = 'Application'
89
+
90
+ # It will change confirmation, password recovery and other workflows
91
+ # to behave the same regardless if the e-mail provided was right or wrong.
92
+ # Does not affect registerable.
93
+ # config.paranoid = true
94
+
95
+ # By default Devise will store the user in session. You can skip storage for
96
+ # particular strategies by setting this option.
97
+ # Notice that if you are skipping storage for all authentication paths, you
98
+ # may want to disable generating routes to Devise's sessions controller by
99
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
100
+ config.skip_session_storage = [:http_auth]
101
+
102
+ # By default, Devise cleans up the CSRF token on authentication to
103
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
104
+ # requests for sign in and sign up, you need to get a new CSRF token
105
+ # from the server. You can disable this option at your own risk.
106
+ # config.clean_up_csrf_token_on_authentication = true
107
+
108
+ # When false, Devise will not attempt to reload routes on eager load.
109
+ # This can reduce the time taken to boot the app but if your application
110
+ # requires the Devise mappings to be loaded during boot time the application
111
+ # won't boot properly.
112
+ # config.reload_routes = true
113
+
114
+ # ==> Configuration for :database_authenticatable
115
+ # For bcrypt, this is the cost for hashing the password and defaults to 12. If
116
+ # using other algorithms, it sets how many times you want the password to be hashed.
117
+ # The number of stretches used for generating the hashed password are stored
118
+ # with the hashed password. This allows you to change the stretches without
119
+ # invalidating existing passwords.
120
+ #
121
+ # Limiting the stretches to just one in testing will increase the performance of
122
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
123
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
124
+ # algorithm), the cost increases exponentially with the number of stretches (e.g.
125
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
126
+ config.stretches = Rails.env.test? ? 1 : 12
127
+
128
+ # Set up a pepper to generate the hashed password.
129
+ # config.pepper = '03a3aa57eb88dc6caa0afb067aba22d84c6737569ccb2bfae0ab30441b2a5618467ee85fead9a4c6d1ec56ad962596765837abec68aa91e994e5117c183bf162'
130
+
131
+ # Send a notification to the original email when the user's email is changed.
132
+ # config.send_email_changed_notification = false
133
+
134
+ # Send a notification email when the user's password is changed.
135
+ # config.send_password_change_notification = false
136
+
137
+ # ==> Configuration for :confirmable
138
+ # A period that the user is allowed to access the website even without
139
+ # confirming their account. For instance, if set to 2.days, the user will be
140
+ # able to access the website for two days without confirming their account,
141
+ # access will be blocked just in the third day.
142
+ # You can also set it to nil, which will allow the user to access the website
143
+ # without confirming their account.
144
+ # Default is 0.days, meaning the user cannot access the website without
145
+ # confirming their account.
146
+ # config.allow_unconfirmed_access_for = 2.days
147
+
148
+ # A period that the user is allowed to confirm their account before their
149
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
150
+ # their account within 3 days after the mail was sent, but on the fourth day
151
+ # their account can't be confirmed with the token any more.
152
+ # Default is nil, meaning there is no restriction on how long a user can take
153
+ # before confirming their account.
154
+ # config.confirm_within = 3.days
155
+
156
+ # If true, requires any email changes to be confirmed (exactly the same way as
157
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
158
+ # db field (see migrations). Until confirmed, new email is stored in
159
+ # unconfirmed_email column, and copied to email column on successful confirmation.
160
+ config.reconfirmable = true
161
+
162
+ # Defines which key will be used when confirming an account
163
+ # config.confirmation_keys = [:email]
164
+
165
+ # ==> Configuration for :rememberable
166
+ # The time the user will be remembered without asking for credentials again.
167
+ # config.remember_for = 2.weeks
168
+
169
+ # Invalidates all the remember me tokens when the user signs out.
170
+ config.expire_all_remember_me_on_sign_out = true
171
+
172
+ # If true, extends the user's remember period when remembered via cookie.
173
+ # config.extend_remember_period = false
174
+
175
+ # Options to be passed to the created cookie. For instance, you can set
176
+ # secure: true in order to force SSL only cookies.
177
+ # config.rememberable_options = {}
178
+
179
+ # ==> Configuration for :validatable
180
+ # Range for password length.
181
+ config.password_length = 6..128
182
+
183
+ # Email regex used to validate email formats. It simply asserts that
184
+ # one (and only one) @ exists in the given string. This is mainly
185
+ # to give user feedback and not to assert the e-mail validity.
186
+ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
187
+
188
+ # ==> Configuration for :timeoutable
189
+ # The time you want to timeout the user session without activity. After this
190
+ # time the user will be asked for credentials again. Default is 30 minutes.
191
+ # config.timeout_in = 30.minutes
192
+
193
+ # ==> Configuration for :lockable
194
+ # Defines which strategy will be used to lock an account.
195
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
196
+ # :none = No lock strategy. You should handle locking by yourself.
197
+ # config.lock_strategy = :failed_attempts
198
+
199
+ # Defines which key will be used when locking and unlocking an account
200
+ # config.unlock_keys = [:email]
201
+
202
+ # Defines which strategy will be used to unlock an account.
203
+ # :email = Sends an unlock link to the user email
204
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
205
+ # :both = Enables both strategies
206
+ # :none = No unlock strategy. You should handle unlocking by yourself.
207
+ # config.unlock_strategy = :both
208
+
209
+ # Number of authentication tries before locking an account if lock_strategy
210
+ # is failed attempts.
211
+ # config.maximum_attempts = 20
212
+
213
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
214
+ # config.unlock_in = 1.hour
215
+
216
+ # Warn on the last attempt before the account is locked.
217
+ # config.last_attempt_warning = true
218
+
219
+ # ==> Configuration for :recoverable
220
+ #
221
+ # Defines which key will be used when recovering the password for an account
222
+ # config.reset_password_keys = [:email]
223
+
224
+ # Time interval you can reset your password with a reset password key.
225
+ # Don't put a too small interval or your users won't have the time to
226
+ # change their passwords.
227
+ config.reset_password_within = 6.hours
228
+
229
+ # When set to false, does not sign a user in automatically after their password is
230
+ # reset. Defaults to true, so a user is signed in automatically after a reset.
231
+ # config.sign_in_after_reset_password = true
232
+
233
+ # ==> Configuration for :encryptable
234
+ # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
235
+ # You can use :sha1, :sha512 or algorithms from others authentication tools as
236
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
237
+ # for default behavior) and :restful_authentication_sha1 (then you should set
238
+ # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
239
+ #
240
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
241
+ # config.encryptor = :sha512
242
+
243
+ # ==> Scopes configuration
244
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
245
+ # "users/sessions/new". It's turned off by default because it's slower if you
246
+ # are using only default views.
247
+ # config.scoped_views = false
248
+
249
+ # Configure the default scope given to Warden. By default it's the first
250
+ # devise role declared in your routes (usually :user).
251
+ # config.default_scope = :user
252
+
253
+ # Set this configuration to false if you want /users/sign_out to sign out
254
+ # only the current scope. By default, Devise signs out all scopes.
255
+ # config.sign_out_all_scopes = true
256
+
257
+ # ==> Navigation configuration
258
+ # Lists the formats that should be treated as navigational. Formats like
259
+ # :html should redirect to the sign in page when the user does not have
260
+ # access, but formats like :xml or :json, should return 401.
261
+ #
262
+ # If you have any extra navigational formats, like :iphone or :mobile, you
263
+ # should add them to the navigational formats lists.
264
+ #
265
+ # The "*/*" below is required to match Internet Explorer requests.
266
+ # config.navigational_formats = ['*/*', :html, :turbo_stream]
267
+
268
+ # The default HTTP method used to sign out a resource. Default is :delete.
269
+ config.sign_out_via = :get
270
+
271
+ # ==> OmniAuth
272
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
273
+ # up on your models and hooks.
274
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
275
+
276
+ # ==> Warden configuration
277
+ # If you want to use other strategies, that are not supported by Devise, or
278
+ # change the failure app, you can configure them inside the config.warden block.
279
+ #
280
+ # config.warden do |manager|
281
+ # manager.intercept_401 = false
282
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
283
+ # end
284
+
285
+ # ==> Mountable engine configurations
286
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
287
+ # is mountable, there are some extra configurations to be taken into account.
288
+ # The following options are available, assuming the engine is mounted as:
289
+ #
290
+ # mount MyEngine, at: '/my_engine'
291
+ #
292
+ # The router that invoked `devise_for`, in the example above, would be:
293
+ # config.router_name = :my_engine
294
+ #
295
+ # When using OmniAuth, Devise cannot automatically set OmniAuth path,
296
+ # so you need to do it manually. For the users scope, it would be:
297
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
298
+
299
+ # ==> Hotwire/Turbo configuration
300
+ # When using Devise with Hotwire/Turbo, the http status for error responses
301
+ # and some redirects must match the following. The default in Devise for existing
302
+ # apps is `200 OK` and `302 Found` respectively, but new apps are generated with
303
+ # these new defaults that match Hotwire/Turbo behavior.
304
+ # Note: These might become the new default in future versions of Devise.
305
+ config.responder.error_status = :unprocessable_entity
306
+ config.responder.redirect_status = :see_other
307
+
308
+ # ==> Configuration for :registerable
309
+
310
+ # When set to false, does not sign a user in automatically after their password is
311
+ # changed. Defaults to true, so a user is signed in automatically after changing a password.
312
+ # config.sign_in_after_change_password = true
313
+ end
@@ -1,12 +1,16 @@
1
1
  class ApplicationController < ActionController::Base
2
+ add_flash_types :error, :success, :notice
2
3
  # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
3
4
  allow_browser versions: :modern
4
5
 
5
6
  protected
6
7
 
8
+ def <%=SunSword.scope_owner_column%>
9
+ current_auth.account.id
10
+ end
11
+
7
12
  def build_contract(params)
8
- # { "<%=RiderKick.scope_owner_column.to_s%>": current_auth.account.id SecureRandom.uuid }.merge(params)
9
- { <%=RiderKick.scope_owner_column.to_s%>: SecureRandom.uuid }.merge(params)
13
+ { <%=SunSword.scope_owner_column.to_s%>: <%=SunSword.scope_owner_column.to_s%> }.merge(params)
10
14
  end
11
15
 
12
16
  def build_form_errors(params, model, errors)
@@ -31,6 +35,6 @@ class ApplicationController < ActionController::Base
31
35
 
32
36
  def set_layouts
33
37
  # "#{current_auth.user.role}/application"
34
- 'dashboard/application'
38
+ "owner/application"
35
39
  end
36
40
  end
@@ -1,4 +1,5 @@
1
1
  class SiteController < ApplicationController
2
+ layout :set_layouts
2
3
  def stimulus
3
4
  @comment = '- WELCOME -'
4
5
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ class DeviseCreateAuths < ActiveRecord::Migration[7.2]
4
+ def change
5
+ create_table :auths, id: :uuid do |t|
6
+ ## Database authenticatable
7
+ t.string :email, null: false, default: ''
8
+ t.string :encrypted_password, null: false, default: ''
9
+ t.uuid :account_id, null: false
10
+ t.uuid :user_id, null: false
11
+
12
+ ## Recoverable
13
+ t.string :reset_password_token
14
+ t.datetime :reset_password_sent_at
15
+
16
+ ## Rememberable
17
+ t.datetime :remember_created_at
18
+
19
+ ## Trackable
20
+ # t.integer :sign_in_count, default: 0, null: false
21
+ # t.datetime :current_sign_in_at
22
+ # t.datetime :last_sign_in_at
23
+ # t.string :current_sign_in_ip
24
+ # t.string :last_sign_in_ip
25
+
26
+ ## Confirmable
27
+ # t.string :confirmation_token
28
+ # t.datetime :confirmed_at
29
+ # t.datetime :confirmation_sent_at
30
+ # t.string :unconfirmed_email # Only if using reconfirmable
31
+
32
+ ## Lockable
33
+ # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
34
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
35
+ # t.datetime :locked_at
36
+
37
+ t.timestamps null: false
38
+ end
39
+
40
+ add_index :auths, :email, unique: true
41
+ add_index :auths, :user_id, unique: true
42
+ add_index :auths, :reset_password_token, unique: true
43
+ add_index :auths, :account_id
44
+ add_index :auths, :created_at
45
+ add_index :auths, :updated_at
46
+ end
47
+ end
@@ -0,0 +1,11 @@
1
+ class CreateModelsAccounts < ActiveRecord::Migration[7.2]
2
+ def change
3
+ create_table :accounts, id: :uuid do |t|
4
+ t.string :name, null: false
5
+
6
+ t.timestamps
7
+ end
8
+ add_index :accounts, :created_at
9
+ add_index :accounts, :updated_at
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ class CreateModelsUsers < ActiveRecord::Migration[7.2]
2
+ def change
3
+ create_table :users, id: :uuid do |t|
4
+ t.uuid :account_id, null: false
5
+ t.string :full_name, null: false
6
+ t.string :role, null: false
7
+
8
+ t.timestamps
9
+ end
10
+ add_index :users, :full_name
11
+ add_index :users, :role
12
+ add_index :users, :account_id
13
+ add_index :users, :created_at
14
+ add_index :users, :updated_at
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ account = Models::Account.first_or_create(name: 'KOTAROISME')
2
+ user = Models::User.create(full_name: 'Kotaro Minami', account_id: account.id, role: 'owner')
3
+ Models::Auth.create(email: 'kotaroisme@gmail.com', password: 'blankblank', password_confirmation: 'blankblank', account_id: account.id, user_id: user.id)
@@ -0,0 +1,106 @@
1
+ model: <%= @model_class %>
2
+ resource_name: <%= @scope_path %>
3
+ actor: <%= @actor %>
4
+ fields:
5
+ <% @model_class.columns.each do |field| -%>
6
+ - <%= field.name.to_s %>
7
+ <% end -%>
8
+ <% @uploaders.each do |field| -%>
9
+ - <%= field %>
10
+ <% end -%>
11
+ uploaders:
12
+ <% @uploaders.each do |field| -%>
13
+ - <%= field %>
14
+ <% end -%>
15
+ search_able:
16
+ <% contract_fields.each do |field| -%>
17
+ <% if ['title', 'name'].include?(field) -%>
18
+ - <%= field %>
19
+ <% end -%>
20
+ <% end -%>
21
+ controllers:
22
+ list_fields:
23
+ <% @fields.each do |field| -%>
24
+ - <%= field %>
25
+ <% end -%>
26
+ show_fields:
27
+ <% @model_class.columns.each do |field| -%>
28
+ - <%= field.name.to_s %>
29
+ <% end -%>
30
+ <% @uploaders.each do |field| -%>
31
+ - <%= field %>
32
+ <% end -%>
33
+ form_fields:
34
+ <% (@fields).each do |field| -%>
35
+ - name: <%= field %>
36
+ type: string
37
+ <% end -%>
38
+ <% (@uploaders).each do |field| -%>
39
+ - name: <%= field %>
40
+ type: file
41
+ <% end -%>
42
+ domains:
43
+ action_list:
44
+ endpoint:
45
+ is_auth: true
46
+ is_skip: false
47
+ parameters:
48
+ use_case:
49
+ contract:
50
+ action_fetch_by_id:
51
+ endpoint:
52
+ is_auth: true
53
+ is_skip: false
54
+ parameters:
55
+ use_case:
56
+ contract:
57
+ - required(:id).filled(:string)
58
+ action_create:
59
+ endpoint:
60
+ is_auth: true
61
+ is_skip: false
62
+ parameters:
63
+ use_case:
64
+ contract:
65
+ <% (@fields + @uploaders).each do |field| -%>
66
+ <% column_type = get_column_type(field) -%>
67
+ <% dry_type = @type_mapping[column_type.to_s] || ':string' -%>
68
+ <% if @uploaders.include?(field) -%>
69
+ - optional(:<%= field %>).maybe(<%= dry_type %>)
70
+ <% else -%>
71
+ - required(:<%= field %>).filled(<%= dry_type %>)
72
+ <% end -%>
73
+ <% end -%>
74
+ action_update:
75
+ endpoint:
76
+ is_auth: true
77
+ is_skip: false
78
+ parameters:
79
+ use_case:
80
+ contract:
81
+ - required(:id).filled(:string)
82
+ <% (@fields + @uploaders).each do |field| -%>
83
+ <% column_type = get_column_type(field) -%>
84
+ <% dry_type = @type_mapping[column_type.to_s] || ':string' -%>
85
+ <% if @uploaders.include?(field) -%>
86
+ - optional(:<%= field %>).maybe(<%= dry_type %>)
87
+ <% else -%>
88
+ - optional(:<%= field %>).maybe(<%= dry_type %>)
89
+ <% end -%>
90
+ <% end -%>
91
+ action_destroy:
92
+ endpoint:
93
+ is_auth: true
94
+ is_skip: false
95
+ parameters:
96
+ use_case:
97
+ contract:
98
+ - required(:id).filled(:string)
99
+ entity:
100
+ skipped_fields:
101
+ - id
102
+ - created_at
103
+ - updated_at
104
+ <% if @model_class.columns.map(&:name).include?(:type) -%>
105
+ - type
106
+ <% end -%>
@@ -37,19 +37,15 @@ export default class extends Controller {
37
37
  }
38
38
 
39
39
  sidebarToggle(event) {
40
- const toggleClose = document.querySelector(".sidebar-toggle-close");
41
- const toggeleOpen = document.querySelector(".sidebar-toggle-open");
42
40
  const backdropActive = document.querySelector(".backdrop-active");
43
41
  const sidebar = document.querySelector(".sidebar");
44
42
  if (sidebar.classList.contains('side_hide')) {
45
- toggleClose.classList.remove('hidden');
46
- toggeleOpen.classList.add('hidden');
47
43
  sidebar.classList.remove('side_hide');
48
44
  backdropActive.classList.remove('hidden');
49
45
  anime({
50
46
  targets: ".backdrop-active",
51
47
  translateX: 0,
52
- opacity: [0, 0.6],
48
+ opacity: [0, 0.8],
53
49
  easing: 'easeInOutSine',
54
50
  complete: function (anim) {
55
51
  console.log('Backdrop Active');
@@ -65,8 +61,6 @@ export default class extends Controller {
65
61
  }
66
62
  });
67
63
  } else {
68
- toggleClose.classList.add('hidden');
69
- toggeleOpen.classList.remove('hidden');
70
64
  sidebar.classList.add('side_hide');
71
65
  anime({
72
66
  targets: '.sidebar',
@@ -80,7 +74,7 @@ export default class extends Controller {
80
74
  anime({
81
75
  targets: ".backdrop-active",
82
76
  translateX: 0,
83
- opacity: [0.6, 0],
77
+ opacity: [0.8, 0],
84
78
  easing: 'easeInOutSine',
85
79
  complete: function (anim) {
86
80
  backdropActive.classList.add('hidden');
@@ -0,0 +1,4 @@
1
+ class Models::Account < ApplicationRecord
2
+ has_many :auths, foreign_key: 'account_id', class_name: 'Models::Auth'
3
+ has_many :users, foreign_key: 'account_id', class_name: 'Models::User'
4
+ end
@@ -0,0 +1,8 @@
1
+ class Models::Auth < ApplicationRecord
2
+ # Include default devise modules. Others available are:
3
+ # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
4
+ devise :database_authenticatable, :registerable,
5
+ :recoverable, :rememberable, :validatable
6
+ belongs_to :account, class_name: 'Models::Account', foreign_key: 'account_id'
7
+ belongs_to :user, class_name: 'Models::User', foreign_key: 'user_id'
8
+ end
@@ -0,0 +1,5 @@
1
+ class Models::User < ApplicationRecord
2
+ belongs_to :account, class_name: 'Models::Account', foreign_key: 'account_id'
3
+
4
+ enum role: { owner: 'owner', contact: 'contact' }
5
+ end
@@ -1,4 +1,14 @@
1
1
  <!-- Sidebar component, swap this element with another sidebar if you like -->
2
+ <div class="flex items-center px-4 lg:hidden sidebar-toggle-close">
3
+ <div class="py-2.5">
4
+ <button type="button" class="hover:bg-gray-100 rounded-lg p-2.5 mt-2 m-1 text-gray-700 lg:hidden cursor-pointer" data-action="click->web#sidebarToggle">
5
+ <span class="sr-only">Open sidebar</span>
6
+ <svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
7
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12"/>
8
+ </svg>
9
+ </button>
10
+ </div>
11
+ </div>
2
12
  <div class="flex grow flex-col gap-y-5 overflow-y-auto px-6 pb-2">
3
13
  <div class="flex h-16 shrink-0 items-center">
4
14
  <%%= render 'components/layouts/sidebar_logo' %>
@@ -17,7 +27,7 @@
17
27
  </button>
18
28
  <!-- Expandable link section, show/hide based on state. -->
19
29
  <ul class="mt-1 px-2" id="sub-menu-1">
20
- <%# generate_link %>
30
+ <%%# generate_link %>
21
31
  </ul>
22
32
  </div>
23
33
  </li>
@@ -29,26 +29,23 @@
29
29
  <%%# mobile %>
30
30
  <div class="fixed bg-white rounded-2xl m-2 inset-y-0 w-64 -left-[300px] lg:hidden sidebar side_hide z-50" data-action="click->web#onSidebarClick">
31
31
  <nav class="flex h-full min-h-0 flex-col">
32
- <%%= render "layouts/dashboard/sidebar", from: :mobile %>
32
+ <%%= render "components/layouts/sidebar", from: :mobile %>
33
33
  </nav>
34
34
  </div>
35
35
 
36
36
  <%%# browser %>
37
37
  <div class="fixed inset-y-0 w-64 max-lg:hidden">
38
38
  <nav class="flex h-full min-h-0 flex-col">
39
- <%%= render "layouts/dashboard/sidebar", from: :browser %>
39
+ <%%= render "components/layouts/sidebar", from: :browser %>
40
40
  </nav>
41
41
  </div>
42
42
 
43
43
  <%%# Sidebar Toggle %>
44
- <div class="z-50 relative flex items-center px-4 lg:hidden">
44
+ <div class="flex items-center px-4 lg:hidden sidebar-toggle-open">
45
45
  <div class="py-2.5">
46
- <button type="button" class="-m-2.5 p-2.5 text-gray-700 lg:hidden cursor-pointer" data-action="click->web#sidebarToggle">
46
+ <button type="button" class="hover:bg-gray-100 rounded-lg p-2.5 mt-2 m-1 text-gray-700 lg:hidden cursor-pointer" data-action="click->web#sidebarToggle">
47
47
  <span class="sr-only">Open sidebar</span>
48
- <svg class="sidebar-toggle-close w-6 h-6 hidden" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
49
- <path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12"/>
50
- </svg>
51
- <svg class="sidebar-toggle-open w-6 h-6" data-slot="icon" viewBox="0 0 20 20" aria-hidden="true">
48
+ <svg class="w-6 h-6" data-slot="icon" viewBox="0 0 20 20" aria-hidden="true">
52
49
  <path d="M2 6.75C2 6.33579 2.33579 6 2.75 6H17.25C17.6642 6 18 6.33579 18 6.75C18 7.16421 17.6642 7.5 17.25 7.5H2.75C2.33579 7.5 2 7.16421 2 6.75ZM2 13.25C2 12.8358 2.33579 12.5 2.75 12.5H17.25C17.6642 12.5 18 12.8358 18 13.25C18 13.6642 17.6642 14 17.25 14H2.75C2.33579 14 2 13.6642 2 13.25Z"></path>
53
50
  </svg>
54
51
  </button>
@@ -56,7 +53,7 @@
56
53
  </div>
57
54
 
58
55
  <main class="flex flex-1 flex-col pb-2 lg:min-w-0 lg:pl-64 lg:pr-2 lg:pt-2">
59
- <div class="fixed inset-0 bg-gray-900/60 backdrop-blur-sm backdrop-active opacity-0 hidden lg:hidden" aria-hidden="true"></div>
56
+ <div class="fixed inset-0 bg-gray-900 backdrop-blur-lg backdrop-active opacity-0 hidden lg:hidden" aria-hidden="true"></div>
60
57
  <div class="grow p-6 lg:rounded-lg lg:bg-white lg:p-10 lg:shadow-sm lg:ring-1 lg:ring-zinc-950/5 dark:lg:bg-zinc-900 dark:lg:ring-white/10">
61
58
  <div class="mx-auto max-w-6xl">
62
59
  <%%= yield %>
@@ -0,0 +1,3 @@
1
+ SunSword.setup do |config|
2
+ config.scope_owner_column = :account_id
3
+ end