mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-10 20:39:48 +08:00
add ADempiere template to make components, views and store modules files (#352)
* add ADempiere template to make components, views and store modules files * fix store modules template. Co-authored-by: Edwin Betancourt <EdwinBetanc0urt@hotmail.com>
This commit is contained in:
parent
b44b71f418
commit
a1bb5a0e1e
25
plop-templates/ADempiere/component/index.hbs
Normal file
25
plop-templates/ADempiere/component/index.hbs
Normal file
@ -0,0 +1,25 @@
|
||||
{{#if template}}
|
||||
<template>
|
||||
<div />
|
||||
</template>
|
||||
{{/if}}
|
||||
|
||||
{{#if script}}
|
||||
<script>
|
||||
export default {
|
||||
name: '{{ properCase name }}',
|
||||
props: {},
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
computed: {},
|
||||
methods: {}
|
||||
}
|
||||
</script>
|
||||
{{/if}}
|
||||
|
||||
{{#if style}}
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
{{/if}}
|
55
plop-templates/ADempiere/component/prompt.js
Normal file
55
plop-templates/ADempiere/component/prompt.js
Normal file
@ -0,0 +1,55 @@
|
||||
const { notEmpty } = require('../../utils.js')
|
||||
|
||||
module.exports = {
|
||||
description: 'Generate ADempiere .vue component',
|
||||
prompts: [{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'ADempiere Component name: ',
|
||||
validate: notEmpty('name')
|
||||
},
|
||||
{
|
||||
type: 'checkbox',
|
||||
name: 'blocks',
|
||||
message: 'Blocks:',
|
||||
choices: [{
|
||||
name: '<template>',
|
||||
value: 'template',
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
name: '<script>',
|
||||
value: 'script',
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
name: 'style',
|
||||
value: 'style',
|
||||
checked: true
|
||||
}
|
||||
],
|
||||
validate(value) {
|
||||
if (value.indexOf('script') === -1 && value.indexOf('template') === -1) {
|
||||
return 'Components require at least a <script> or <template> tag.'
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
],
|
||||
actions: data => {
|
||||
const name = '{{properCase name}}'
|
||||
const actions = [{
|
||||
type: 'add',
|
||||
path: `src/components/ADempiere/${name}/index.vue`,
|
||||
templateFile: 'plop-templates/component/index.hbs',
|
||||
data: {
|
||||
name: name,
|
||||
template: data.blocks.includes('template'),
|
||||
script: data.blocks.includes('script'),
|
||||
style: data.blocks.includes('style')
|
||||
}
|
||||
}]
|
||||
|
||||
return actions
|
||||
}
|
||||
}
|
22
plop-templates/ADempiere/store/index.hbs
Normal file
22
plop-templates/ADempiere/store/index.hbs
Normal file
@ -0,0 +1,22 @@
|
||||
const {{name}} = {
|
||||
{{#if state}}
|
||||
state: {
|
||||
{{name}}: {}
|
||||
},
|
||||
{{/if}}
|
||||
{{#if mutations}}
|
||||
mutations: {},
|
||||
{{/if}}
|
||||
{{#if actions}}
|
||||
actions: {},
|
||||
{{/if}}
|
||||
{{#if getters}}
|
||||
getters: {
|
||||
get{{name}}: (state) => {
|
||||
return state.{{name}}
|
||||
}
|
||||
}
|
||||
{{/if}}
|
||||
}
|
||||
|
||||
export default {{name}}
|
61
plop-templates/ADempiere/store/prompt.js
Normal file
61
plop-templates/ADempiere/store/prompt.js
Normal file
@ -0,0 +1,61 @@
|
||||
const { notEmpty } = require('../../utils.js')
|
||||
|
||||
module.exports = {
|
||||
description: 'Generate a ADempiere Store Module',
|
||||
prompts: [{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'ADempiere Store Module name: ',
|
||||
validate: notEmpty('name')
|
||||
},
|
||||
{
|
||||
type: 'checkbox',
|
||||
name: 'blocks',
|
||||
message: 'Blocks:',
|
||||
choices: [{
|
||||
name: 'state',
|
||||
value: 'state',
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
name: 'mutations',
|
||||
value: 'mutations',
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
name: 'actions',
|
||||
value: 'actions',
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
name: 'getters',
|
||||
value: 'getters',
|
||||
checked: true
|
||||
}
|
||||
],
|
||||
validate(value) {
|
||||
if (value.indexOf('state') === -1 && value.indexOf('mutations') === -1) {
|
||||
return 'Store Module require at least a state or mutations.'
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
],
|
||||
actions: data => {
|
||||
const name = '{{name}}'
|
||||
const actions = [{
|
||||
type: 'add',
|
||||
path: `src/store/modules/ADempiere/${name}.js`,
|
||||
templateFile: 'plop-templates/ADempiere/store/index.hbs',
|
||||
data: {
|
||||
name: name,
|
||||
state: data.blocks.includes('state'),
|
||||
mutations: data.blocks.includes('mutations'),
|
||||
actions: data.blocks.includes('actions'),
|
||||
getters: data.blocks.includes('getters')
|
||||
}
|
||||
}]
|
||||
|
||||
return actions
|
||||
}
|
||||
}
|
27
plop-templates/ADempiere/view/index.hbs
Normal file
27
plop-templates/ADempiere/view/index.hbs
Normal file
@ -0,0 +1,27 @@
|
||||
{{#if template}}
|
||||
<template>
|
||||
<div />
|
||||
</template>
|
||||
{{/if}}
|
||||
|
||||
{{#if script}}
|
||||
<script>
|
||||
export default {
|
||||
name: '{{ properCase name }}',
|
||||
props: {},
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
computed: {},
|
||||
created() {},
|
||||
mounted() {},
|
||||
methods: {}
|
||||
}
|
||||
</script>
|
||||
{{/if}}
|
||||
|
||||
{{#if style}}
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
{{/if}}
|
55
plop-templates/ADempiere/view/prompt.js
Normal file
55
plop-templates/ADempiere/view/prompt.js
Normal file
@ -0,0 +1,55 @@
|
||||
const { notEmpty } = require('../../utils.js')
|
||||
|
||||
module.exports = {
|
||||
description: 'Generate a ADempiere View',
|
||||
prompts: [{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'ADempiere View name: ',
|
||||
validate: notEmpty('name')
|
||||
},
|
||||
{
|
||||
type: 'checkbox',
|
||||
name: 'blocks',
|
||||
message: 'Blocks:',
|
||||
choices: [{
|
||||
name: '<template>',
|
||||
value: 'template',
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
name: '<script>',
|
||||
value: 'script',
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
name: 'style',
|
||||
value: 'style',
|
||||
checked: true
|
||||
}
|
||||
],
|
||||
validate(value) {
|
||||
if (value.indexOf('script') === -1 && value.indexOf('template') === -1) {
|
||||
return 'View require at least a <script> or <template> tag.'
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
],
|
||||
actions: data => {
|
||||
const name = '{{name}}'
|
||||
const actions = [{
|
||||
type: 'add',
|
||||
path: `src/views/ADempiere/${name}/index.vue`,
|
||||
templateFile: 'plop-templates/view/index.hbs',
|
||||
data: {
|
||||
name: name,
|
||||
template: data.blocks.includes('template'),
|
||||
script: data.blocks.includes('script'),
|
||||
style: data.blocks.includes('style')
|
||||
}
|
||||
}]
|
||||
|
||||
return actions
|
||||
}
|
||||
}
|
@ -1,7 +1,13 @@
|
||||
const viewGenerator = require('./plop-templates/view/prompt')
|
||||
const componentGenerator = require('./plop-templates/component/prompt')
|
||||
const ADempiereView = require('./plop-templates/ADempiere/view/prompt')
|
||||
const ADempiereComponent = require('./plop-templates/ADempiere/component/prompt')
|
||||
const ADempiereStore = require('./plop-templates/ADempiere/store/prompt')
|
||||
|
||||
module.exports = function(plop) {
|
||||
plop.setGenerator('view', viewGenerator)
|
||||
plop.setGenerator('component', componentGenerator)
|
||||
plop.setGenerator('ADempiere View', ADempiereView)
|
||||
plop.setGenerator('ADempiere Component', ADempiereComponent)
|
||||
plop.setGenerator('ADempiere Store Module', ADempiereStore)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user