vue_component_builder 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -2
- data/lib/builder/template/default/boolean.vue.erb +9 -0
- data/lib/builder/template/default/datetime.vue.erb +9 -0
- data/lib/builder/template/default/decimal.vue.erb +14 -0
- data/lib/builder/template/default/form/boolean.vue.erb +6 -0
- data/lib/builder/template/default/form/datetime.vue.erb +4 -0
- data/lib/builder/template/default/form/decimal.vue.erb +4 -0
- data/lib/builder/template/default/form/integer.vue.erb +7 -0
- data/lib/builder/template/default/form/string.vue.erb +4 -0
- data/lib/builder/template/default/integer.vue.erb +9 -0
- data/lib/builder/template/default/js/boolean.js.erb +1 -0
- data/lib/builder/template/default/js/datetime.js.erb +1 -0
- data/lib/builder/template/default/js/decimal.js.erb +1 -0
- data/lib/builder/template/default/js/hooks/data.js.erb +13 -0
- data/lib/builder/template/default/js/hooks/methods.js.erb +5 -0
- data/lib/builder/template/default/js/hooks/mounted.js.erb +3 -0
- data/lib/builder/template/default/js/integer.js.erb +1 -0
- data/lib/builder/template/default/js/methods/create.js.erb +9 -0
- data/lib/builder/template/default/js/methods/destroy.js.erb +6 -0
- data/lib/builder/template/default/js/methods/index.js.erb +4 -0
- data/lib/builder/template/default/js/methods/resetForm.js.erb +5 -0
- data/lib/builder/template/default/js/methods/show.js.erb +4 -0
- data/lib/builder/template/default/js/methods/update.js.erb +11 -0
- data/lib/builder/template/default/js/methods/validate.js.erb +4 -0
- data/lib/builder/template/default/js/methods/validate_rules.js.erb +4 -0
- data/lib/builder/template/default/js/string.js.erb +1 -0
- data/lib/builder/template/default/main.vue.erb +30 -0
- data/lib/builder/template/default/script.js.erb +8 -0
- data/lib/builder/template/default/string.vue.erb +9 -0
- data/lib/builder/template/default/table/boolean.vue.erb +4 -0
- data/lib/builder/template/default/table/datetime.vue.erb +5 -0
- data/lib/builder/template/default/table/decimal.vue.erb +5 -0
- data/lib/builder/template/default/table/integer.vue.erb +5 -0
- data/lib/builder/template/default/table/string.vue.erb +5 -0
- data/lib/builder/template/default/table/table-component.vue.erb +9 -0
- data/lib/builder/template/element-plus/main.vue.erb +9 -12
- data/lib/vue_component_builder/version.rb +1 -1
- data/lib/vue_component_builder.rb +6 -6
- metadata +36 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c2d2c3ae4082e3535616040172eca097e4e2becdb87b25e066dedd8e44323d4
|
4
|
+
data.tar.gz: d2d949fec4849dfb38b10e8e446a9d2d56ed6d87bc09af4bafbc2107e86017ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78b3b399ffa11bb94d1d7a0a9b67cf17c40cc3a0e1416a2ddae8359f784c22a6f1ebf8bb84e8866b71bc3b422c448a31c165779f843dc607d1f9e4e1455d005c
|
7
|
+
data.tar.gz: 8c70a5b66e01fd7baf95c8eccb4c39e1989ba755b17e95e4e8e94004a9e768c944b6b519567fc6f9f753b5579eae2146154f62a4f0161f3b71bc9e3b994d9292
|
data/README.md
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
# Vue Component Builder
|
2
2
|
Generate Vue component CRUD from Rails model mapping
|
3
3
|
|
4
|
+
### Preview
|
5
|
+
|
6
|
+
Default theme
|
7
|
+
|
8
|
+
![](./scheenshot/default.png)
|
9
|
+
|
10
|
+
Element-plus theme
|
11
|
+
|
12
|
+
![](./scheenshot/element-plus.png)
|
13
|
+
|
14
|
+
|
15
|
+
### Compatibility
|
16
|
+
|
17
|
+
vue 3.x to element-plus theme
|
18
|
+
|
4
19
|
### Install
|
5
20
|
|
6
21
|
In development section of your **Gemfile** put:
|
@@ -30,18 +45,19 @@ $ bundle install
|
|
30
45
|
```ruby
|
31
46
|
model=Fruit
|
32
47
|
component=MyFruitComponent
|
33
|
-
theme=element-plus
|
48
|
+
theme=default [default or element-plus]
|
34
49
|
exclude=id,created_at,updated_at [optional]
|
35
50
|
```
|
36
51
|
|
37
52
|
```shell
|
38
|
-
$ rails g vue_component_builder:new model=Fruit component=MyFruitComponent theme=
|
53
|
+
$ rails g vue_component_builder:new model=Fruit component=MyFruitComponent theme=default exclude=id,created_at,updated_at
|
39
54
|
```
|
40
55
|
|
41
56
|
The new component will be generated inside in your Rails public folder
|
42
57
|
```shell
|
43
58
|
public/MyFruitComponent.vue
|
44
59
|
```
|
60
|
+
Then you can copy this component to your Vue application folder.
|
45
61
|
|
46
62
|
### TODO / coming soon
|
47
63
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<!-- <%= "#{@field[:name]}" %> -->
|
2
|
+
<el-row :gutter='24'>
|
3
|
+
<el-col :span='24'>
|
4
|
+
<el-form-item label='<%= @field[:label] %>' :label-width='formLabelWidth'>
|
5
|
+
<el-switch v-model='this.<%= "#{@options[:model][:name]}.#{@field[:name]}" %>'></el-switch>
|
6
|
+
</el-form-item>
|
7
|
+
</el-col>
|
8
|
+
</el-row>
|
9
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<!-- <%= "#{@field[:name]}" %> -->
|
2
|
+
<el-row :gutter='24'>
|
3
|
+
<el-col :span='24'>
|
4
|
+
<el-form-item label='<%= @field[:label] %>' :label-width='formLabelWidth'>
|
5
|
+
<el-date-picker v-model='this.<%= "#{@options[:model][:name]}.#{@field[:name]}" %>' type='date'></el-date-picker>
|
6
|
+
</el-form-item>
|
7
|
+
</el-col>
|
8
|
+
</el-row>
|
9
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!-- <%= "#{@field[:name]}" %> -->
|
2
|
+
<el-row :gutter='24'>
|
3
|
+
<el-col :span='24'>
|
4
|
+
<el-form-item label='<%= @field[:label] %>' :label-width='formLabelWidth'>
|
5
|
+
<el-input-number
|
6
|
+
v-model='this.<%= "#{@options[:model][:name]}.#{@field[:name]}" %>'
|
7
|
+
:precision="2"
|
8
|
+
:step="0.1"
|
9
|
+
:max="10"
|
10
|
+
autocomplete='off'></el-input-number>
|
11
|
+
</el-form-item>
|
12
|
+
</el-col>
|
13
|
+
</el-row>
|
14
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<!-- <%= "#{@field[:name]}" %> -->
|
2
|
+
<el-row :gutter='24'>
|
3
|
+
<el-col :span='24'>
|
4
|
+
<el-form-item label='<%= @field[:label] %>' :label-width='formLabelWidth'>
|
5
|
+
<el-input-number v-model='this.<%= "#{@options[:model][:name]}.#{@field[:name]}" %>' autocomplete='off'></el-input-number>
|
6
|
+
</el-form-item>
|
7
|
+
</el-col>
|
8
|
+
</el-row>
|
9
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
<%=@attribute[:name] %>: false
|
@@ -0,0 +1 @@
|
|
1
|
+
<%=@attribute[:name] %>: ""
|
@@ -0,0 +1 @@
|
|
1
|
+
<%=@attribute[:name] %>: 0.0
|
@@ -0,0 +1 @@
|
|
1
|
+
<%=@attribute[:name] %>: 0
|
@@ -0,0 +1,9 @@
|
|
1
|
+
async <%=@method_name %>() {
|
2
|
+
if(this.validateForm()){
|
3
|
+
const payload = this.<%= @options[:model][:name] %>
|
4
|
+
const response = await api.post(`<%= @options[:model][:name].pluralize %>`, payload);
|
5
|
+
alert(response.data.message)
|
6
|
+
this.resetForm();
|
7
|
+
this.index();
|
8
|
+
}
|
9
|
+
},
|
@@ -0,0 +1,6 @@
|
|
1
|
+
async <%=@method_name %>() {
|
2
|
+
const response = await api.delete(`<%= "#{@options[:model][:name].pluralize}/${this.#{@options[:model][:name]}.id}" %>`,);
|
3
|
+
this.<%= @options[:model][:name].pluralize %> = response.data;
|
4
|
+
alert(response.data.message)
|
5
|
+
this.index();
|
6
|
+
},
|
@@ -0,0 +1,11 @@
|
|
1
|
+
async update() {
|
2
|
+
if(this.validateForm()){
|
3
|
+
const payload = this.<%= @options[:model][:name] %>
|
4
|
+
const response = await api.put(
|
5
|
+
`<%= "#{@options[:model][:name].pluralize}/${this.#{@options[:model][:name]}.id}" %>`,
|
6
|
+
payload
|
7
|
+
);
|
8
|
+
alert(response.data.message)
|
9
|
+
this.index();
|
10
|
+
}
|
11
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
<%=@attribute[:name] %>: ""
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<template>
|
2
|
+
<div style="padding: 20px">
|
3
|
+
<h3><%= @options[:model][:name].capitalize %></h3>
|
4
|
+
<form>
|
5
|
+
<%= @form_attributes %>
|
6
|
+
<button-group>
|
7
|
+
<button v-if='this.<%= @options[:model][:name] %>.id' @click='this.update()' type='button'>Update</button>
|
8
|
+
<button v-else @click='this.create()' type='button'>Save</button>
|
9
|
+
<button @click="this.destroy()" type='button'>Delete</button>
|
10
|
+
<button @click='this.resetForm()' type='button'>New</button>
|
11
|
+
</button-group>
|
12
|
+
</form>
|
13
|
+
|
14
|
+
<%= @table %>
|
15
|
+
|
16
|
+
</div>
|
17
|
+
</template>
|
18
|
+
|
19
|
+
<style>
|
20
|
+
table span {
|
21
|
+
cursor: pointer;
|
22
|
+
color: rgb(64, 158, 255);
|
23
|
+
display: block;
|
24
|
+
padding: 5px;
|
25
|
+
}
|
26
|
+
</style>
|
27
|
+
|
28
|
+
<script>
|
29
|
+
<%= @script %>
|
30
|
+
</script>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<!-- <%= "#{@field[:name]}" %> -->
|
2
|
+
<el-row :gutter='24'>
|
3
|
+
<el-col :span='24'>
|
4
|
+
<el-form-item label='<%= @field[:label] %>' :label-width='formLabelWidth'>
|
5
|
+
<el-input v-model='this.<%= "#{@options[:model][:name]}.#{@field[:name]}" %>' :step='1'></el-input>
|
6
|
+
</el-form-item>
|
7
|
+
</el-col>
|
8
|
+
</el-row>
|
9
|
+
|
@@ -1,11 +1,8 @@
|
|
1
1
|
<template>
|
2
|
-
<div style=
|
2
|
+
<div style="width: 100%;">
|
3
3
|
<el-main>
|
4
4
|
<el-row :gutter='24'>
|
5
|
-
<el-col :span='
|
6
|
-
...
|
7
|
-
</el-col>
|
8
|
-
<el-col :span='24'>
|
5
|
+
<el-col :span='13'>
|
9
6
|
<el-tabs v-model='this.activeTabName' type='border-card'>
|
10
7
|
<el-tab-pane name='<%= @options[:model][:name] %>_tab'>
|
11
8
|
|
@@ -18,22 +15,22 @@
|
|
18
15
|
<%= @form_attributes %>
|
19
16
|
|
20
17
|
<el-button-group>
|
21
|
-
<el-button v-if='this.<%= @options[:model][:name] %>.id' @click='this.update()' plain type='primary'>
|
22
|
-
<el-button v-else @click='this.create()' plain type='success'>
|
18
|
+
<el-button v-if='this.<%= @options[:model][:name] %>.id' @click='this.update()' plain type='primary'>Update</el-button>
|
19
|
+
<el-button v-else @click='this.create()' plain type='success'>Save</el-button>
|
23
20
|
<el-popconfirm
|
24
21
|
v-if='this.<%= @options[:model][:name] %>.id'
|
25
|
-
confirm-button-text='
|
26
|
-
cancel-button-text='
|
22
|
+
confirm-button-text='Yes'
|
23
|
+
cancel-button-text='No'
|
27
24
|
icon='el-icon-info'
|
28
25
|
icon-color='orange'
|
29
|
-
title='
|
26
|
+
title='Are you sure delete this item?'
|
30
27
|
@confirm='this.destroy()'
|
31
28
|
>
|
32
29
|
<template #reference>
|
33
|
-
<el-button type='danger'>
|
30
|
+
<el-button type='danger'>Delete</el-button>
|
34
31
|
</template>
|
35
32
|
</el-popconfirm>
|
36
|
-
<el-button @click='this.resetForm()' plain type='info'>
|
33
|
+
<el-button @click='this.resetForm()' plain type='info'>New</el-button>
|
37
34
|
</el-button-group>
|
38
35
|
</el-form>
|
39
36
|
<br>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require "vue_component_builder/version"
|
2
|
-
require 'rails/generators
|
2
|
+
require 'rails/generators'
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
5
|
module VueComponentBuilder
|
@@ -14,12 +14,12 @@ module VueComponentBuilder
|
|
14
14
|
|
15
15
|
Be sure to have informed the params needed:
|
16
16
|
e.g
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
model=Fruit
|
18
|
+
component=MyFruitComponent
|
19
|
+
theme=default [default or element-plus]
|
20
|
+
exclude=id,created_at,updated_at [optional]
|
21
21
|
|
22
|
-
rails g vue_component_builder:new model=Fruit component=MyFruitComponent theme=
|
22
|
+
rails g vue_component_builder:new model=Fruit component=MyFruitComponent theme=default exclude=id,created_at,updated_at
|
23
23
|
ERROR
|
24
24
|
end
|
25
25
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vue_component_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yonatha Almeida
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -68,6 +68,40 @@ files:
|
|
68
68
|
- Rakefile
|
69
69
|
- bin/console
|
70
70
|
- bin/setup
|
71
|
+
- lib/builder/template/default/boolean.vue.erb
|
72
|
+
- lib/builder/template/default/datetime.vue.erb
|
73
|
+
- lib/builder/template/default/decimal.vue.erb
|
74
|
+
- lib/builder/template/default/form/boolean.vue.erb
|
75
|
+
- lib/builder/template/default/form/datetime.vue.erb
|
76
|
+
- lib/builder/template/default/form/decimal.vue.erb
|
77
|
+
- lib/builder/template/default/form/integer.vue.erb
|
78
|
+
- lib/builder/template/default/form/string.vue.erb
|
79
|
+
- lib/builder/template/default/integer.vue.erb
|
80
|
+
- lib/builder/template/default/js/boolean.js.erb
|
81
|
+
- lib/builder/template/default/js/datetime.js.erb
|
82
|
+
- lib/builder/template/default/js/decimal.js.erb
|
83
|
+
- lib/builder/template/default/js/hooks/data.js.erb
|
84
|
+
- lib/builder/template/default/js/hooks/methods.js.erb
|
85
|
+
- lib/builder/template/default/js/hooks/mounted.js.erb
|
86
|
+
- lib/builder/template/default/js/integer.js.erb
|
87
|
+
- lib/builder/template/default/js/methods/create.js.erb
|
88
|
+
- lib/builder/template/default/js/methods/destroy.js.erb
|
89
|
+
- lib/builder/template/default/js/methods/index.js.erb
|
90
|
+
- lib/builder/template/default/js/methods/resetForm.js.erb
|
91
|
+
- lib/builder/template/default/js/methods/show.js.erb
|
92
|
+
- lib/builder/template/default/js/methods/update.js.erb
|
93
|
+
- lib/builder/template/default/js/methods/validate.js.erb
|
94
|
+
- lib/builder/template/default/js/methods/validate_rules.js.erb
|
95
|
+
- lib/builder/template/default/js/string.js.erb
|
96
|
+
- lib/builder/template/default/main.vue.erb
|
97
|
+
- lib/builder/template/default/script.js.erb
|
98
|
+
- lib/builder/template/default/string.vue.erb
|
99
|
+
- lib/builder/template/default/table/boolean.vue.erb
|
100
|
+
- lib/builder/template/default/table/datetime.vue.erb
|
101
|
+
- lib/builder/template/default/table/decimal.vue.erb
|
102
|
+
- lib/builder/template/default/table/integer.vue.erb
|
103
|
+
- lib/builder/template/default/table/string.vue.erb
|
104
|
+
- lib/builder/template/default/table/table-component.vue.erb
|
71
105
|
- lib/builder/template/element-plus/boolean.vue.erb
|
72
106
|
- lib/builder/template/element-plus/datetime.vue.erb
|
73
107
|
- lib/builder/template/element-plus/decimal.vue.erb
|