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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -2
  3. data/lib/builder/template/default/boolean.vue.erb +9 -0
  4. data/lib/builder/template/default/datetime.vue.erb +9 -0
  5. data/lib/builder/template/default/decimal.vue.erb +14 -0
  6. data/lib/builder/template/default/form/boolean.vue.erb +6 -0
  7. data/lib/builder/template/default/form/datetime.vue.erb +4 -0
  8. data/lib/builder/template/default/form/decimal.vue.erb +4 -0
  9. data/lib/builder/template/default/form/integer.vue.erb +7 -0
  10. data/lib/builder/template/default/form/string.vue.erb +4 -0
  11. data/lib/builder/template/default/integer.vue.erb +9 -0
  12. data/lib/builder/template/default/js/boolean.js.erb +1 -0
  13. data/lib/builder/template/default/js/datetime.js.erb +1 -0
  14. data/lib/builder/template/default/js/decimal.js.erb +1 -0
  15. data/lib/builder/template/default/js/hooks/data.js.erb +13 -0
  16. data/lib/builder/template/default/js/hooks/methods.js.erb +5 -0
  17. data/lib/builder/template/default/js/hooks/mounted.js.erb +3 -0
  18. data/lib/builder/template/default/js/integer.js.erb +1 -0
  19. data/lib/builder/template/default/js/methods/create.js.erb +9 -0
  20. data/lib/builder/template/default/js/methods/destroy.js.erb +6 -0
  21. data/lib/builder/template/default/js/methods/index.js.erb +4 -0
  22. data/lib/builder/template/default/js/methods/resetForm.js.erb +5 -0
  23. data/lib/builder/template/default/js/methods/show.js.erb +4 -0
  24. data/lib/builder/template/default/js/methods/update.js.erb +11 -0
  25. data/lib/builder/template/default/js/methods/validate.js.erb +4 -0
  26. data/lib/builder/template/default/js/methods/validate_rules.js.erb +4 -0
  27. data/lib/builder/template/default/js/string.js.erb +1 -0
  28. data/lib/builder/template/default/main.vue.erb +30 -0
  29. data/lib/builder/template/default/script.js.erb +8 -0
  30. data/lib/builder/template/default/string.vue.erb +9 -0
  31. data/lib/builder/template/default/table/boolean.vue.erb +4 -0
  32. data/lib/builder/template/default/table/datetime.vue.erb +5 -0
  33. data/lib/builder/template/default/table/decimal.vue.erb +5 -0
  34. data/lib/builder/template/default/table/integer.vue.erb +5 -0
  35. data/lib/builder/template/default/table/string.vue.erb +5 -0
  36. data/lib/builder/template/default/table/table-component.vue.erb +9 -0
  37. data/lib/builder/template/element-plus/main.vue.erb +9 -12
  38. data/lib/vue_component_builder/version.rb +1 -1
  39. data/lib/vue_component_builder.rb +6 -6
  40. metadata +36 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6520cb101838c2379af8c3b3dfb958a443bbb3423719d48d3a5fdb2daaf065fc
4
- data.tar.gz: f63d561a92cc892719da4348cbbc6820fe5f09432926c52107911e5d5a3c9051
3
+ metadata.gz: 2c2d2c3ae4082e3535616040172eca097e4e2becdb87b25e066dedd8e44323d4
4
+ data.tar.gz: d2d949fec4849dfb38b10e8e446a9d2d56ed6d87bc09af4bafbc2107e86017ac
5
5
  SHA512:
6
- metadata.gz: cd13245bc12a763a8b259f7f547cd08f39dc23c5033258113be4b7f2c0d4ee512418870cc751f804d027f2348032f35d4902b474b96404541702cb437781d8f1
7
- data.tar.gz: bdf646a8fbf56a40ff4a2cc86739b42a4bcbff1a488c9b52b36c21ab04730e7e6ad9918304e906f9a35c0c7fee0495221da31036709fa3fd6dfac668abfdb02e
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=element-plus exclude=id,created_at,updated_at
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,6 @@
1
+ <div>
2
+ <%= @attribute[:label] %>:
3
+ <input
4
+ v-model='<%= "#{@options[:model][:name]}.#{@attribute[:name]}" %>'
5
+ type="checkbox" name="<%= @attribute[:name] %>" :checked="<%= @attribute[:name] %>">
6
+ </div>
@@ -0,0 +1,4 @@
1
+ <div>
2
+ <%= @attribute[:label] %>:
3
+ <input v-model='<%= "#{@options[:model][:name]}.#{@attribute[:name]}" %>' type='date'>
4
+ </div>
@@ -0,0 +1,4 @@
1
+ <div>
2
+ <%= @attribute[:label] %>:
3
+ <input v-model='<%= "#{@options[:model][:name]}.#{@attribute[:name]}" %>' autocomplete='off'>
4
+ </div>
@@ -0,0 +1,7 @@
1
+ <div>
2
+ <%= @attribute[:label] %>:
3
+ <input v-model='<%= "#{@options[:model][:name]}.#{@attribute[:name]}" %>'
4
+ type="number"
5
+ min="0" max="100"
6
+ autocomplete='off'>
7
+ </div>
@@ -0,0 +1,4 @@
1
+ <div>
2
+ <%= @attribute[:label] %>:
3
+ <input v-model='<%= "#{@options[:model][:name]}.#{@attribute[:name]}" %>' autocomplete='off'>
4
+ </div>
@@ -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,13 @@
1
+ data() {
2
+ return {
3
+ activeTabName: '<%= @options[:model][:name] %>_tab',
4
+ formLabelWidth: '120px',
5
+
6
+ <%= @options[:model][:name] %>:
7
+ {
8
+ id: null,
9
+ <%= @attributes %>
10
+ },
11
+ <%= @options[:model][:name].pluralize %>:[],
12
+ }
13
+ }
@@ -0,0 +1,5 @@
1
+ methods: {
2
+ <%=@methods %>,
3
+ <%=@validateForm %>
4
+ <%=@resetForm %>
5
+ }
@@ -0,0 +1,3 @@
1
+ mounted() {
2
+ this.index();
3
+ },
@@ -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,4 @@
1
+ async <%=@method_name %>() {
2
+ const response = await api.get(`<%= @options[:model][:name].pluralize %>`);
3
+ this.<%= @options[:model][:name].pluralize %> = response.data;
4
+ },
@@ -0,0 +1,5 @@
1
+ resetForm() {
2
+ this.<%= @options[:model][:name] %> = {
3
+ <%= @attributes %>
4
+ }
5
+ }
@@ -0,0 +1,4 @@
1
+ async <%=@method_name %>(id) {
2
+ const response = await api.get(`<%= @options[:model][:name].pluralize %>/${id}`);
3
+ this.<%= @options[:model][:name] %> = response.data;
4
+ },
@@ -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,4 @@
1
+ validateForm() {
2
+ <%= @rules %>
3
+ return true
4
+ },
@@ -0,0 +1,4 @@
1
+ if (this.<%= @options[:model][:name] %>.<%= @attribute[:name] %> === null) {
2
+ alert('O campo <%= @attribute[:label] %> deve ser preenchido')
3
+ return false
4
+ }
@@ -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,8 @@
1
+ import {api} from '../../api/index';
2
+
3
+ export default {
4
+ components: {},
5
+ <%= "#{@data_hook}," %>
6
+ <%= "#{@mounted_hook}" %>
7
+ <%= "#{@methods_hook}" %>
8
+ };
@@ -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
+
@@ -0,0 +1,4 @@
1
+ <td>
2
+ <span v-if='<%= "item.#{@attribute[:name]}" %>' type='success'>Yes</span>
3
+ <span v-else type='danger'>No</span>
4
+ </td>
@@ -0,0 +1,5 @@
1
+ <td>
2
+ <span @click='show(item.id)'>
3
+ {{ <%= "item.#{@attribute[:name]}" %> }}
4
+ </span>
5
+ </td>
@@ -0,0 +1,5 @@
1
+ <td>
2
+ <span @click='show(item.id)'>
3
+ {{ <%= "item.#{@attribute[:name]}" %> }}
4
+ </span>
5
+ </td>
@@ -0,0 +1,5 @@
1
+ <td>
2
+ <span @click='show(item.id)'>
3
+ {{ <%= "item.#{@attribute[:name]}" %> }}
4
+ </span>
5
+ </td>
@@ -0,0 +1,5 @@
1
+ <td>
2
+ <span @click='show(item.id)'>
3
+ {{ <%= "item.#{@attribute[:name]}" %> }}
4
+ </span>
5
+ </td>
@@ -0,0 +1,9 @@
1
+ <div>
2
+ <table>
3
+ <tbody>
4
+ <tr v-for="(item,i) in <%= @options[:model][:name].pluralize %>" :key="i">
5
+ <%= @columns %>
6
+ </tr>
7
+ </tbody>
8
+ </table>
9
+ </div>
@@ -1,11 +1,8 @@
1
1
  <template>
2
- <div style='width: 100%'>
2
+ <div style="width: 100%;">
3
3
  <el-main>
4
4
  <el-row :gutter='24'>
5
- <el-col :span='4'>
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'>Atualizar</el-button>
22
- <el-button v-else @click='this.create()' plain type='success'>Salvar</el-button>
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='Sim'
26
- cancel-button-text='Não'
22
+ confirm-button-text='Yes'
23
+ cancel-button-text='No'
27
24
  icon='el-icon-info'
28
25
  icon-color='orange'
29
- title='Deseja realmente excluir este registro?'
26
+ title='Are you sure delete this item?'
30
27
  @confirm='this.destroy()'
31
28
  >
32
29
  <template #reference>
33
- <el-button type='danger'>Excluir</el-button>
30
+ <el-button type='danger'>Delete</el-button>
34
31
  </template>
35
32
  </el-popconfirm>
36
- <el-button @click='this.resetForm()' plain type='info'>Novo</el-button>
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,3 +1,3 @@
1
1
  module VueComponentBuilder
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  require "vue_component_builder/version"
2
- require 'rails/generators/base'
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
- model=Fruit
18
- component=MyFruitComponent
19
- theme=element-plus
20
- exclude=id,created_at,updated_at [optional]
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=element-plus exclude=id,created_at,updated_at
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.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-07 00:00:00.000000000 Z
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