rhino_project_core 0.30.0.alpha.17 → 0.30.0.alpha.21
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/lib/generators/rhino/ui/route/route_generator.rb +49 -0
- data/lib/generators/rhino/ui/route/templates/$id.edit.tsx.tt +12 -0
- data/lib/generators/rhino/ui/route/templates/$id.index.tsx.tt +12 -0
- data/lib/generators/rhino/ui/route/templates/index.tsx.tt +10 -0
- data/lib/generators/rhino/ui/route/templates/new.tsx.tt +17 -0
- data/lib/rhino/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9487682c70255bd7dd52c50dab776e8dd93a2c0c01ace5c1e099cfe1060a50e
|
4
|
+
data.tar.gz: 1f146f927c331e9d0683a39537f707e7fd695e4f5b29f3cfaf5d4aeef99e734d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eaa698359acab69557abb23a11b9c1fa039aa669ead34abf9c937215a664099f11e7e73d37dd2c4e1ee6cc09136cce153f32ef92f06ad38c6bd47249294e864f
|
7
|
+
data.tar.gz: 2780ecd7d10d67d9b51b77acedca245bcb8846bb9719d55f4a6e47c39393099fbbf43a1a1a1a5e508b4ae7eb6fff290c1dcd8830d3471ebbb005954477c817a3
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rhino
|
4
|
+
module Generators
|
5
|
+
module Ui
|
6
|
+
class RouteGenerator < ::Rails::Generators::NamedBase
|
7
|
+
class_option :routes_directory, type: :string, desc: "The directory to copy the routes to",
|
8
|
+
default: "app/frontend/routes", group: :route
|
9
|
+
class_option :route_path, type: :string, desc: "The path to routes relative to the routes directory", default: "_authenticated/$owner", group: :route
|
10
|
+
class_option :copy_index, type: :boolean, desc: "Copy the index route", default: true, group: :route
|
11
|
+
class_option :copy_show, type: :boolean, desc: "Copy the show route", default: true, group: :route
|
12
|
+
class_option :copy_create, type: :boolean, desc: "Copy the create route", default: true, group: :route
|
13
|
+
class_option :copy_edit, type: :boolean, desc: "Copy the edit route", default: true, group: :route
|
14
|
+
|
15
|
+
source_root File.expand_path("templates", __dir__)
|
16
|
+
|
17
|
+
def copy_index_route
|
18
|
+
return unless options.copy_index?
|
19
|
+
template "index.tsx", route_file_path("index.tsx")
|
20
|
+
end
|
21
|
+
|
22
|
+
def copy_show_route
|
23
|
+
return unless options.copy_show?
|
24
|
+
template "$id.index.tsx", route_file_path("$id.index.tsx")
|
25
|
+
end
|
26
|
+
|
27
|
+
def copy_create_route
|
28
|
+
return unless options.copy_create?
|
29
|
+
template "new.tsx", route_file_path("new.tsx")
|
30
|
+
end
|
31
|
+
|
32
|
+
def copy_edit_route
|
33
|
+
return unless options.copy_edit?
|
34
|
+
template "$id.edit.tsx", route_file_path("$id.edit.tsx")
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def route_file_path(file_name)
|
39
|
+
File.join(options[:routes_directory], options[:route_path], singular_table_name, file_name)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Begin and end with a slash
|
43
|
+
def route_path
|
44
|
+
File.join("/", options[:route_path], singular_table_name, "/")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { ModelEditPage } from '@rhino-project/ui-heroui';
|
2
|
+
import { createFileRoute } from '@tanstack/react-router';
|
3
|
+
|
4
|
+
export const Route = createFileRoute('<%= route_path %>$id/edit')({
|
5
|
+
component: RouteComponent
|
6
|
+
});
|
7
|
+
|
8
|
+
function RouteComponent() {
|
9
|
+
const { id: modelId } = Route.useParams();
|
10
|
+
|
11
|
+
return <ModelEditPage model="<%= singular_table_name %>" modelId={modelId} />;
|
12
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { ModelShowPage } from '@rhino-project/ui-heroui';
|
2
|
+
import { createFileRoute } from '@tanstack/react-router';
|
3
|
+
|
4
|
+
export const Route = createFileRoute('<%= route_path %>$id/')({
|
5
|
+
component: RouteComponent
|
6
|
+
});
|
7
|
+
|
8
|
+
function RouteComponent() {
|
9
|
+
const { id: modelId } = Route.useParams();
|
10
|
+
|
11
|
+
return <ModelShowPage model="<%= singular_table_name %>" modelId={modelId} />;
|
12
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { ModelIndexPage } from '@rhino-project/ui-heroui';
|
2
|
+
import { createFileRoute } from '@tanstack/react-router';
|
3
|
+
|
4
|
+
export const Route = createFileRoute('<%= route_path %>')({
|
5
|
+
component: RouteComponent
|
6
|
+
});
|
7
|
+
|
8
|
+
function RouteComponent() {
|
9
|
+
return <ModelIndexPage model="<%= singular_table_name %>" syncUrl />;
|
10
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { ModelCreatePage } from '@rhino-project/ui-heroui';
|
2
|
+
import { createFileRoute } from '@tanstack/react-router';
|
3
|
+
|
4
|
+
export const Route = createFileRoute('<%= route_path %>new')({
|
5
|
+
validateSearch: (search: Record<string, unknown>): { parentId: number } => {
|
6
|
+
return {
|
7
|
+
parentId: Number(search?.parentId)
|
8
|
+
};
|
9
|
+
},
|
10
|
+
component: RouteComponent
|
11
|
+
});
|
12
|
+
|
13
|
+
function RouteComponent() {
|
14
|
+
const { parentId } = Route.useSearch();
|
15
|
+
|
16
|
+
return <ModelCreatePage model="<%= singular_table_name %>" parentId={parentId} />;
|
17
|
+
}
|
data/lib/rhino/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhino_project_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.30.0.alpha.
|
4
|
+
version: 0.30.0.alpha.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Rosevear
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-05 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rails
|
@@ -449,6 +449,11 @@ files:
|
|
449
449
|
- lib/generators/rhino/module/templates/test/test_helper.rb
|
450
450
|
- lib/generators/rhino/policy/policy_generator.rb
|
451
451
|
- lib/generators/rhino/policy/templates/policy.rb.tt
|
452
|
+
- lib/generators/rhino/ui/route/route_generator.rb
|
453
|
+
- lib/generators/rhino/ui/route/templates/$id.edit.tsx.tt
|
454
|
+
- lib/generators/rhino/ui/route/templates/$id.index.tsx.tt
|
455
|
+
- lib/generators/rhino/ui/route/templates/index.tsx.tt
|
456
|
+
- lib/generators/rhino/ui/route/templates/new.tsx.tt
|
452
457
|
- lib/generators/rhino/update/update_generator.rb
|
453
458
|
- lib/generators/test_unit/rhino_policy_generator.rb
|
454
459
|
- lib/generators/test_unit/templates/policy_test.rb.tt
|