Skip to content

Commit 6a4193a

Browse files
committed
1.4.0-alpha
1. break mobile device page generate into /pages/mobile/xxxx 2. mobile device landing page and [id] page different file 3. nuxt lod prime vue bad directive
1 parent 757767e commit 6a4193a

15 files changed

Lines changed: 651 additions & 38 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@simitgroup/simpleapp-generator",
3-
"version": "1.3.5-alpha",
3+
"version": "1.4.0-alpha",
44
"description": "frontend nuxtjs and backend nests code generator using jsonschema",
55
"main": "dist/index.js",
66
"scripts": {

src/generate.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,7 @@ const generateSchema = ( docname: string,
288288
as: `Form${_.upperFirst(docname)}.vue`,
289289
validate: validateWritePage
290290
},
291-
'pages.[id].vue.eta': {
292-
to:`pages/[xorg]/${docname}`,
293-
as:'[id].vue',
294-
validate: validateWritePage
295-
},
291+
296292
'component.select.vue.eta': {
297293
to:'components/select',
298294
as: `Select${_.upperFirst(docname)}.vue`,
@@ -303,10 +299,25 @@ const generateSchema = ( docname: string,
303299
as: `Viewer${_.upperFirst(docname)}.vue`,
304300
validate: validateWritePage
305301
},
302+
'pages.[id].vue.eta': {
303+
to:`pages/[xorg]/${docname}`,
304+
as:'[id].vue',
305+
validate: validateWritePage
306+
},
306307
'pages.landing.vue.eta': {
307308
to:`pages/[xorg]/${docname}`,
308309
as:`../${docname}.vue`,
309310
validate: validateWritePage
311+
},
312+
'pages.mobile.[id].vue.eta': {
313+
to:`pages/[xorg]/mobile/${docname}`,
314+
as:'[id].vue',
315+
validate: validateWritePage
316+
},
317+
'pages.mobile.landing.vue.eta': {
318+
to:`pages/[xorg]/mobile/${docname}`,
319+
as:`index.vue`,
320+
validate: validateWritePage
310321
},
311322
'simpleapp.doc.ts.eta': {
312323
to:`simpleapp/docs`,

templates/basic/nuxt/pages.[id].vue.eta

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<LazyForm<%=it.typename%> :_id="_id" @after="after"/>
2+
<LazyForm<%=it.typename%> :_id="_id" class="w-full" @after="after"/>
33
</template>
44

55
<script setup lang="ts">
@@ -12,8 +12,8 @@
1212

1313
import {<%= it.typename %>} from '~/simpleapp/generate/types'
1414
const doc = useNuxtApp().$<%= it.typename %>Doc()
15+
const _id = getPathPara('id','')
1516

16-
const props = defineProps<{_id:string}>();
1717
const after = (actionName: string, data: <%= it.typename %>) => {
1818
console.log("<%= it.typename %> capture after emits ", actionName)
1919
switch (actionName) {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<template>
2+
<LazyForm<%=it.typename%> :_id="_id" class="w-full" @after="after"/>
3+
</template>
4+
5+
<script setup lang="ts">
6+
/**
7+
* This file was automatically generated by simpleapp generator.
8+
* --remove-this-line-to-prevent-override--
9+
* last change 2023-09-09
10+
* author: Ks Tan
11+
*/
12+
13+
import {<%= it.typename %>} from '~/simpleapp/generate/types'
14+
const doc = useNuxtApp().$<%= it.typename %>Doc()
15+
const _id = getPathPara('id','')
16+
17+
const after = (actionName: string, data: <%= it.typename %>) => {
18+
console.log("<%= it.typename %> capture after emits ", actionName)
19+
switch (actionName) {
20+
case "exit":
21+
goTo(doc.getDocName());
22+
break;
23+
case "create":
24+
goTo(doc.getDocName(), data._id);
25+
refreshDocumentList(doc.getDocName())
26+
useNuxtApp().$event('CloseDialog',doc.getDocName().toLowerCase())
27+
break;
28+
case "update":
29+
refreshDocumentList(doc.getDocName());
30+
useNuxtApp().$event('CloseDialog',doc.getDocName().toLowerCase())
31+
break;
32+
case "delete":
33+
goTo(doc.getDocName(), "new");
34+
refreshDocumentList(doc.getDocName())
35+
useNuxtApp().$event('CloseDialog',doc.getDocName().toLowerCase())
36+
break;
37+
}
38+
};
39+
</script>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<% const skipcolumns = ['_id','createdBy','created','updatedBy','updated','orgId','branchId','tenantId','doctype'] %>
2+
<template>
3+
4+
<PageDocList :document="doc" :columns="columns" :data="docdata" :sorts="sorts">
5+
<template #mobileList="{index,item}">
6+
</template>
7+
<template #dataTableColumns>
8+
<%Object.keys(it.jsonschema.properties).forEach(function(key) { %>
9+
<%let obj=it.jsonschema.properties[key] %>
10+
<%let config=it.jsonschema['x-simpleapp-config'] %>
11+
<%if(skipcolumns.indexOf(key)>=0){%>
12+
<%} else if(config['uniqueKey'] && (config['uniqueKey']==key || config['documentTitle']==key) ){%>
13+
<Column #body="{index,data}" :header="t('<%=key%>')">
14+
<RendererLink :value="data" :setting="{path:'<%=it.name%>'}" :fields="['<%=key%>']">{{ data.<%=key%> }}</RendererLink>
15+
</Column>
16+
17+
<%} else if(['string','number','integer','boolean'].indexOf(obj.type)>=0){%>
18+
<Column #body="{index,data}" :header="t('<%=key%>')">
19+
{{data.<%=key%>}}
20+
</Column>
21+
<%} else if(obj.type =='object' && obj['x-foreignkey'] ){%>
22+
<Column #body="{index,data}" :header="t('<%=key%>')">
23+
<RendererViewer :value="data.<%=key%>" :setting="{documentName:'<%=obj["x-foreignkey"]%>'}" :fields="['<%=key%>']">{{ data.label }}</RendererViewer>
24+
</Column>
25+
<%}%>
26+
<%})%>
27+
</template>
28+
<template #default><div><NuxtPage :_id="id ?? 'new'"/></div></template>
29+
</PageDocList>
30+
</template>
31+
<script setup lang="ts">
32+
/**
33+
* This file was automatically generated by simpleapp generator.
34+
* --remove-this-line-to-prevent-override--
35+
* last change 2023-09-09
36+
* author: Ks Tan
37+
*/
38+
39+
40+
const {$<%= it.typename %>Doc,$listen } = useNuxtApp();
41+
const doc = $<%= it.typename %>Doc()
42+
const docdata = doc.getReactiveData();
43+
44+
definePageMeta({
45+
menuPath:'nocategory/<%= it.name %>'
46+
});
47+
48+
const columns= [<%Object.keys(it.jsonschema.properties).forEach(function(key) { %>
49+
<%let obj=it.jsonschema.properties[key] %>
50+
<%let config=it.jsonschema['x-simpleapp-config'] %>
51+
<%if(skipcolumns.indexOf(key)>=0){%>
52+
<%}else if(['string','number','integer','boolean'].indexOf(obj.type)>=0){%>'<%=key%>',
53+
<%} %>
54+
<%})%>]
55+
56+
57+
58+
59+
60+
const sorts:string[][] = [
61+
<%if(it.jsonschema['x-simpleapp-config'] && it.jsonschema['x-simpleapp-config']['uniqueKey']){%>
62+
['<%=it.jsonschema['x-simpleapp-config']['uniqueKey']%>','asc'],
63+
<%}%>
64+
]
65+
66+
const id=computed(()=>useRoute().params.id)
67+
</script>
68+
69+

templates/nuxt/app.vue._eta

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<EventDocumentViewer></EventDocumentViewer>
55
<EventDecision/>
66
<EventNotification/>
7-
<NuxtPage />
7+
<NuxtPage/>
88
</NuxtLayout>
99
</template>
1010

@@ -17,8 +17,9 @@
1717
*/
1818
watch(()=>useRoute().params['xorg'],async (newval,oldvalue)=>{
1919
await reloadUserStore()
20-
if(!getUserProfile()?.currentGroup) goTo('pickgroup')
21-
20+
if(getPathPara('xorg','')!=''){
21+
if(!getUserProfile()?.currentGroup) goTo('pickgroup')
22+
}
2223
})
2324

2425
const getLayout = ()=>{
@@ -33,7 +34,6 @@ const getLayout = ()=>{
3334

3435
onMounted(()=>{
3536
const currentgroup = useCookie('currentGroup').value
36-
3737
//if no xorg, no enforce pick group
3838
if(getCurrentXorg() && !currentgroup) goTo('pickgroup')
3939
})

templates/nuxt/components/page/PageDocList.vue.eta

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,12 @@ watch(showDialog, () => {
154154
watch(
155155
() => useRoute().path,
156156
async () => {
157-
if (getPathPara("id")) {
158-
showDialog.value = true;
159-
} else {
160-
showDialog.value = false;
157+
if(!isMobile()){
158+
if (getPathPara("id")) {
159+
showDialog.value = true;
160+
} else {
161+
showDialog.value = false;
162+
}
161163
}
162164
},
163165
);

templates/nuxt/composables/goTo.generate.ts.eta

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
* Author: Ks Tan
66
*/
77
export const getDocumentUrl = (document:string,id?:string,querystr?:string)=>{
8-
let path = `/${getCurrentXorg()}/${document}`
8+
9+
let path = useRoute().path.includes('/mobile/') || isMobile() ?
10+
`/${getCurrentXorg()}/mobile/${document}`
11+
: `/${getCurrentXorg()}/${document}`
912
if(id){
1013
path = path + '/'+id
1114
}

templates/nuxt/nuxt.config.ts._eta

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* This file was automatically generated by simpleapp generator during initialization. It is changable.
3-
* --remove-this-line-to-prevent-override--
4-
* last change 2024-02-22
5-
* author: Ks Tan
2+
* This file was automatically generated by simpleapp generator. Every
3+
* MODIFICATION OVERRIDE BY GENERATEOR
4+
* last change 2023-10-28
5+
* Author: Ks Tan
66
*/
77
import path from 'path'
88
export default defineNuxtConfig({
@@ -27,6 +27,15 @@ export default defineNuxtConfig({
2727
}
2828
}
2929
},
30+
app: {
31+
// pageTransition: {
32+
// name: 'slide-fade',
33+
// mode: 'out-in',
34+
// css: false,
35+
36+
// },
37+
// layoutTransition: { name: 'layout', mode: 'default' }
38+
},
3039
tailwindcss: {
3140
// Options
3241
},
@@ -36,7 +45,7 @@ devServer: {
3645
modules: [
3746
// "@hebilicious/authjs-nuxt",
3847
'@nuxtjs/color-mode',
39-
'@nuxtjs/device',
48+
'@nuxtjs/device',
4049
'@nuxtjs/i18n',
4150
'dayjs-nuxt',
4251
'@sidebase/nuxt-auth',
@@ -52,19 +61,18 @@ devServer: {
5261
['defineStore', 'definePiniaStore'], // import { defineStore as definePiniaStore } from 'pinia'
5362
],
5463
}],
55-
56-
57-
58-
],
64+
],
65+
dayjs:{
66+
plugins: [ 'utc', 'duration']
67+
},
5968
device: {
6069
refreshOnResize: true
61-
},
70+
},
6271
i18n: {
6372
lazy: true,
6473
langDir: "lang/",
6574
strategy: "no_prefix",
66-
locales: [
67-
75+
locales: [
6876
{
6977
code: "en",
7078
iso: "en",
@@ -82,17 +90,18 @@ devServer: {
8290
defaultLocale: "en",
8391
},
8492
primevue: {
93+
8594
options: {
86-
//unstyled: true,
8795
ripple: true,
88-
inputStyle: 'filled'
96+
inputStyle: 'filled',
97+
8998
},
9099
components: {
91100
include: '*',
92-
exclude: ['chart']
101+
// exclude: ['chart']
93102
},
94103
directives: {
95-
include: ['Ripple', 'Tooltip','BadgeDirective','FocusTrap']
104+
include: ['Ripple', 'Tooltip','Badge','FocusTrap']
96105
},
97106
cssLayerOrder: 'tailwind-base, primevue, tailwind-utilities',
98107
importPT: { as: 'SimpleAppPT', from: path.resolve(__dirname,'./assets/primevue/passthrough.ts') },
@@ -105,9 +114,6 @@ devServer: {
105114
auth: {
106115
globalAppMiddleware: false
107116
},
108-
dayjs:{
109-
plugins: [ 'utc', 'duration']
110-
},
111117
// security: {
112118
// corsHandler:{
113119
// origin: '*' //| 'null' | (string | RegExp)[] | ((origin: string) => boolean);
@@ -136,10 +142,11 @@ devServer: {
136142
css: [
137143
'primeicons/primeicons.css',
138144
path.resolve(__dirname,'./assets/css/style.css'),
145+
path.resolve(__dirname,'./assets/css/listview.css'),
139146
path.resolve(__dirname,'./assets/css/calendar.css'),
140147
],
141148
},
142-
149+
143150
// devtools: { enabled: true },
144151
// build: {
145152
// // transpile: ["primevue"]

0 commit comments

Comments
 (0)