Skip to content

Commit 6b1f246

Browse files
committed
Add newButtonLabel and modelTitle to AutoQueryGrid
1 parent 5b11f72 commit 6b1f246

File tree

3 files changed

+3657
-3657
lines changed

3 files changed

+3657
-3657
lines changed

src/components/AutoQueryGrid.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</div>
88
<div v-else class="pt-1">
99
<div v-if="create && apis.Create">
10-
<EnsureAccessDialog v-if="invalidCreateAccess" :title="`Create ${dataModelName}`" :invalid-access="invalidCreateAccess" alert-class="text-yellow-700" @done="createDone" />
10+
<EnsureAccessDialog v-if="invalidCreateAccess" :title="`Create ${modelTitle}`" :invalid-access="invalidCreateAccess" alert-class="text-yellow-700" @done="createDone" />
1111
<slot v-else-if="slots.createform" name="createform" :type="apis.Create.request.name" :configure="configureField" :done="createDone" :save="createSave"></slot>
1212
<AutoCreateForm ref="createForm" v-else :type="apis.Create.request.name" :configure="configureField" @done="createDone" @save="createSave">
1313
<template #header>
@@ -19,7 +19,7 @@
1919
</AutoCreateForm>
2020
</div>
2121
<div v-else-if="edit && apis.AnyUpdate">
22-
<EnsureAccessDialog v-if="invalidUpdateAccess" :title="`Update ${dataModelName}`" :invalid-access="invalidUpdateAccess" alert-class="text-yellow-700" @done="editDone" />
22+
<EnsureAccessDialog v-if="invalidUpdateAccess" :title="`Update ${modelTitle}`" :invalid-access="invalidUpdateAccess" alert-class="text-yellow-700" @done="editDone" />
2323
<slot v-else-if="slots.editform" name="editform" :model="edit" :type="apis.AnyUpdate.request.name" :deleteType="canDelete ? apis.Delete!.request.name : null"
2424
:configure="configureField" :done="editDone" :save="editSave"></slot>
2525
<AutoEditForm ref="editForm" v-else v-model="edit" :type="apis.AnyUpdate.request.name" :deleteType="canDelete ? apis.Delete!.request.name : null"
@@ -37,7 +37,7 @@
3737
<QueryPrefs v-if="showQueryPrefs" :columns="viewModelColumns" :prefs="apiPrefs" @done="showQueryPrefs=false" @save="saveApiPrefs" />
3838
<div class="pl-1 pt-1 flex flex-wrap">
3939
<div class="flex mt-1">
40-
<button v-if="show('preferences')" type="button" class=" text-gray-700 dark:text-gray-300 hover:text-indigo-600 dark:hover:text-indigo-400" :title="`${dataModelName} Preferences`" @click="showQueryPrefs=!showQueryPrefs">
40+
<button v-if="show('preferences')" type="button" class=" text-gray-700 dark:text-gray-300 hover:text-indigo-600 dark:hover:text-indigo-400" :title="`${modelTitle} Preferences`" @click="showQueryPrefs=!showQueryPrefs">
4141
<svg class="w-8 h-8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g stroke-width="1.5" fill="none"><path d="M9 3H3.6a.6.6 0 0 0-.6.6v16.8a.6.6 0 0 0 .6.6H9M9 3v18M9 3h6M9 21h6m0-18h5.4a.6.6 0 0 1 .6.6v16.8a.6.6 0 0 1-.6.6H15m0-18v18" stroke="currentColor" /></g></svg>
4242
</button>
4343

@@ -119,9 +119,9 @@
119119
</div>
120120

121121
<div v-if="show('newItem') && apis.Create && canCreate" class="pl-2 mt-1">
122-
<button type="button" @click="onShowNewItem" :title="dataModelName" :class="toolbarButtonClass">
122+
<button type="button" @click="onShowNewItem" :title="modelTitle" :class="toolbarButtonClass">
123123
<svg class="w-5 h-5 mr-1 text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-50" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" fill="currentColor"></path></svg>
124-
<span class="whitespace-nowrap">New {{ dataModelName }}</span>
124+
<span class="whitespace-nowrap">{{ newButtonLabel }}</span>
125125
</button>
126126
</div>
127127

@@ -220,6 +220,8 @@ const props = withDefaults(defineProps<{
220220
visibleFrom?: {[name:string]:Breakpoint|"never"}
221221
rowClass?:(model:any,i:number) => string
222222
rowStyle?:(model:any,i:number) => StyleValue | undefined
223+
modelTitle?: string
224+
newButtonLabel?: string
223225
224226
apiPrefs?: ApiPrefs
225227
canFilter?:(column:string) => boolean
@@ -603,6 +605,8 @@ function onShowNewItem() {
603605
604606
const typeName = computed(() => getTypeName(props.type))
605607
const dataModelName = computed(() => typeName.value || apis.value.AnyQuery?.dataModel.name)
608+
const modelTitle = computed(() => props.modelTitle || dataModelName.value)
609+
const newButtonLabel = computed(() => props.newButtonLabel || `New ${modelTitle.value}`)
606610
const prefsCacheKey = () => `${props.id}/ApiPrefs/${typeName.value || apis.value.AnyQuery?.dataModel.name}`
607611
const columnCacheKey = (name:string) => `Column/${props.id}:${typeName.value || apis.value.AnyQuery?.dataModel.name}.${name}`
608612

src/demo/App.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
<MarkdownInput id="richtext" v-model="richtext" />
106106

107107
<h1 class="my-8 text-3xl">AutoQueryGrid</h1>
108-
<AutoQueryGrid class="mb-3" type="Tracks" />
108+
<AutoQueryGrid class="mb-3" type="Tracks" modelTitle="Record" newButtonLabel="New CD" />
109109

110110
<AutoQueryGrid class="mb-3" type="Customer" />
111111

@@ -691,7 +691,8 @@ const { Formats, currency, formatDate, relativeTime } = useFormatters()
691691
692692
loadMetadata({
693693
olderThan: 60 * 60 * 1000,
694-
resolvePath: 'https://localhost:5001/metadata/app.json',
694+
//resolvePath: 'https://localhost:5001/metadata/app.json',
695+
resolvePath: 'https://blazor-gallery.servicestack.net/metadata/app.json',
695696
})
696697
697698
setConfig({

0 commit comments

Comments
 (0)