Skip to content

Commit c57017f

Browse files
Merge pull request #94 from JSON-ms/dev
Bug fixes and UX improvements
2 parents 3b8d02e + a543b4b commit c57017f

12 files changed

Lines changed: 34 additions & 29 deletions

File tree

docs/structure.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The following YAML example defines a simplified section for an admin panel, spec
3737
sections:
3838
home: # Customizable key
3939
label: Home page
40+
title: My data # Optional (to be displayed in the data sidebar)
4041
fields:
4142
title: # Customizable key
4243
type: i18n

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@json.ms/www",
33
"private": true,
44
"type": "module",
5-
"version": "1.2.20",
5+
"version": "1.2.21",
66
"scripts": {
77
"dev": "vite --host",
88
"build": "run-p type-check \"build-only {@}\" --",

src/components/ActionBar.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const reset = () => {
7979
<div v-if="!structureIsPristine">
8080
<v-tooltip v-if="layoutSize.data < 850" location="top" text="Please save your structure before continuing.">
8181
<template #activator="{ props }">
82-
<v-btn icon color="error" variant="tonal" style="cursor: default">
82+
<v-btn icon color="error" variant="tonal" size="x-small" style="cursor: default">
8383
<v-icon v-bind="props" icon="mdi-alert" />
8484
</v-btn>
8585
</template>
@@ -155,8 +155,9 @@ const reset = () => {
155155
:readonly="userDataSaved"
156156
:color="canSave ? 'primary' : undefined"
157157
:class="['w-100', {
158-
'pr-16': globalStore.admin.structure
158+
'pr-10': globalStore.admin.structure
159159
}]"
160+
size="small"
160161
@click.stop.prevent="save"
161162
>
162163
<template v-if="!userDataSaved">
@@ -177,8 +178,9 @@ const reset = () => {
177178
v-if="globalStore.admin.structure"
178179
v-bind="props"
179180
:disabled="!userDataHasChanged"
180-
variant="flat"
181181
:color="userDataHasChanged ? 'primary' : undefined"
182+
variant="flat"
183+
size="small"
182184
class="position-absolute"
183185
style="right: 0; border-top-left-radius: 0; border-bottom-left-radius: 0"
184186
min-width="0"
@@ -210,6 +212,7 @@ const reset = () => {
210212
<v-btn
211213
:disabled="!userDataHasChanged"
212214
variant="text"
215+
size="small"
213216
style="flex: 1"
214217
@click="reset"
215218
>

src/components/DataEditor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const canEditData = computed((): boolean => {
8282
<div v-else class="d-flex flex-column pa-4" style="gap: 1rem">
8383
<div>
8484
<h1 class="mb-2">
85-
{{ selectedSection.label }}
85+
{{ selectedSection.title || selectedSection.label }}
8686
</h1>
8787
<v-divider />
8888
</div>

src/components/GlobalComponents.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
import Prompt from '@/components/Prompt.vue';
33
import Error from '@/components/Error.vue';
44
import Snack from '@/components/Snack.vue';
5-
import IntroductionDialog from '@/components/IntroductionDialog.vue';
65
</script>
76

87
<template>
98
<Prompt />
109
<Error />
1110
<Snack />
12-
<IntroductionDialog />
1311
</template>

src/components/JSONms.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ if (globalStore.session.loggedIn) {
398398
<template v-if="!splitTabs">
399399
<v-expand-transition group>
400400
<div v-if="globalStore.admin.structure && windowWidth > 900">
401-
<v-tabs v-model="tab" grow>
401+
<v-tabs v-model="tab" height="44" grow>
402402
<v-tab value="data">
403403
<v-icon icon="mdi-pencil" start />
404404
Data
@@ -467,8 +467,9 @@ if (globalStore.session.loggedIn) {
467467
v-if="showActionBar"
468468
flat
469469
location="bottom"
470-
style="border-top: rgba(0, 0, 0, 0.1) solid 1px"
471-
class="pl-3"
470+
color="background"
471+
class="pl-3 py-0"
472+
height="44"
472473
>
473474
<div class="w-100 d-flex align-center justify-space-between">
474475
<ActionBar

src/components/SitePreview.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const loaded = ref(false);
2424
const loading = ref(false);
2525
const killIframe = ref(false);
2626
const siteNotCompatibleSnack = ref(false);
27-
const expanded = ref(false);
2827
const { layoutSize, windowHeight, layoutPx } = useLayout();
2928
const { reloading, siteCompatible, sendMessageToIframe, getPathsFromSectionKey, listenIframeMessage, sendUserDataToIframe } = useIframe();
3029
const { userDataLoading } = useUserData();
@@ -33,7 +32,7 @@ const iframeErrorMsg = ref('This site is not JSONms compatible');
3332
const editorHeight = computed((): number => {
3433
const padding = (globalStore.userSettings.data.layoutSitePreviewPadding ? 96 : 63);
3534
const result = windowHeight.value - padding;
36-
if (expanded.value) {
35+
if (globalStore.admin.editorExpanded) {
3736
return result + 32;
3837
}
3938
return result - layoutSize.value.preview.height;
@@ -244,11 +243,11 @@ defineExpose({
244243
<template #header.end>
245244
<v-btn
246245
size="small"
247-
@click="expanded = !expanded"
246+
@click="globalStore.admin.editorExpanded = !globalStore.admin.editorExpanded"
248247
>
249-
<span v-if="expanded">Collapse</span>
248+
<span v-if="globalStore.admin.editorExpanded">Collapse</span>
250249
<span v-else>Expand</span>
251-
<v-icon v-if="expanded" icon="mdi-unfold-less-horizontal" end />
250+
<v-icon v-if="globalStore.admin.editorExpanded" icon="mdi-unfold-less-horizontal" end />
252251
<v-icon v-else icon="mdi-unfold-more-horizontal" end />
253252
</v-btn>
254253
</template>

src/composables/typings.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export function useTypings() {
5151
keys['i18n:' + key] = keys[key];
5252
})
5353
keys.i18n = 'string';
54-
5554
let type = keys[field.type || 'string'];
5655
if (field?.items && typeof field.items === 'string' && field.items.startsWith('enums.')) {
5756
const name = field.items.split('enums.');
@@ -65,7 +64,7 @@ export function useTypings() {
6564
if (!field.required && !field.multiple) {
6665
i18nType += ' | null';
6766
}
68-
type = `JmsLocaleSet<${i18nType}>`;
67+
type = `JmsLocaleSet<${i18nType}> | null`;
6968
} else if (!field.required && !field.multiple && type !== '[]') {
7069
type += ' | null';
7170
} else if (field.multiple) {
@@ -85,14 +84,15 @@ export function useTypings() {
8584
if (lastKey) {
8685
if (isFieldType(field, 'array')) {
8786
const name = getStructureName(nameKey + '.' + lastKey + '.items');
88-
const jmsArrStructure = { name, fields: [] };
87+
const nameSingular = getStructureName(nameKey + '.' + lastKey + '.item');
88+
const jmsArrStructure = { name: nameSingular, fields: [] };
8989
const fields = structuredClone(field.fields);
9090
fields.hash = { type: 'string', required: true, label: '', fields: {} }
9191
innerLoop(fields, lastKey, jmsArrStructure, nameKey);
9292
if (isFieldI18n(field)) {
93-
jmsStructure.fields.push({ key: lastKey, type: `JmsLocaleSet<Jms${name}[]>` })
93+
jmsStructure.fields.push({ key: lastKey, type: `JmsLocaleSet<Jms${nameSingular}[]>` })
9494
} else {
95-
jmsStructure.fields.push({ key: lastKey, type: `Jms${name}[]` })
95+
jmsStructure.fields.push({ key: lastKey, type: `Jms${nameSingular}[]` })
9696
}
9797
} else if (isFieldType(field, 'node')) {
9898
const nodeKey = nameKey + '.' + path;

src/interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export interface IAdmin {
3333
previewMode: 'mobile' | 'desktop' | null,
3434
dataTab: 'data' | 'settings' | 'docs',
3535
editorTab: 'structure' | 'blueprints' | 'settings' | 'integration',
36+
editorExpanded: boolean,
3637
}
3738

3839
export interface ISnack {

src/stores/global.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const useGlobalStore = defineStore('global', {
4646
previewMode: window.innerWidth >= 1400 ? 'desktop' : 'mobile',
4747
dataTab: 'data',
4848
editorTab: 'structure',
49+
editorExpanded: false,
4950
},
5051
session: {
5152
loggedIn: false,

0 commit comments

Comments
 (0)