Skip to content

Commit bc24882

Browse files
committed
refactor: use show-success in c-admin-method
1 parent 2496798 commit bc24882

File tree

2 files changed

+63
-80
lines changed

2 files changed

+63
-80
lines changed

playground/Coalesce.Web.Vue3/src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<i class="fa fa-caret-down pl-1"></i>
3030
</v-btn>
3131
</template>
32-
<v-list>
32+
<v-list density="compact">
3333
<v-list-item
3434
v-for="t in Object.values($metadata.types).filter(
3535
(t) => t.type == 'model',

src/coalesce-vue-vuetify3/src/components/admin/c-admin-method.vue

Lines changed: 62 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -68,92 +68,75 @@
6868
:loaders="{
6969
'no-initial-content no-error-content no-loading-content': [caller],
7070
}"
71+
:show-success="methodMeta.return.type == 'void' || !!caller.message"
7172
style="min-height: 55px"
7273
>
73-
<h3>
74-
Result:
75-
<v-btn
76-
v-if="caller.result && methodMeta.return.type == 'file'"
77-
color="primary"
78-
@click="downloadFileResult"
79-
:loading="caller.isLoading"
80-
size="x-small"
81-
outlined
82-
>
83-
<v-icon start small>fa fa-download</v-icon>
84-
Save to Disk
85-
</v-btn>
86-
</h3>
87-
88-
<span
89-
v-if="
90-
caller.wasSuccessful &&
91-
(methodMeta.return.type == 'void' || caller.message)
92-
"
93-
class="c-method--result-success"
94-
>
95-
<v-alert type="success" dense>
96-
<span
97-
class="text-pre-wrap"
98-
v-text="caller.message || 'Success'"
99-
></span>
100-
</v-alert>
101-
</span>
74+
<template v-if="methodMeta.return.type !== 'void'">
75+
<h3>
76+
Result:
77+
<v-btn
78+
v-if="caller.result && methodMeta.return.type == 'file'"
79+
color="primary"
80+
@click="downloadFileResult"
81+
:loading="caller.isLoading"
82+
size="x-small"
83+
outlined
84+
>
85+
<v-icon start small>fa fa-download</v-icon>
86+
Save to Disk
87+
</v-btn>
88+
</h3>
10289

103-
<div v-if="caller.result && methodMeta.return.type == 'file'">
104-
<pre
105-
>{{ caller.result.name }} • {{ caller.result.type }} • {{
106-
caller.result.size.toLocaleString()
107-
}} bytes</pre
108-
>
90+
<div v-if="caller.result && methodMeta.return.type == 'file'">
91+
<pre
92+
>{{ caller.result.name }} • {{ caller.result.type }} • {{
93+
caller.result.size.toLocaleString()
94+
}} bytes</pre
95+
>
10996

110-
<br />
97+
<br />
11198

112-
<template
113-
v-if="
114-
fileDownloadKind == 'preview' && 'getResultObjectUrl' in caller
115-
"
116-
>
117-
<img
118-
v-if="caller.result.type.indexOf('image') >= 0"
119-
:src="caller.getResultObjectUrl(instance.proxy)"
120-
:alt="caller.result.name"
121-
class="elevation-1"
122-
style="max-width: 100%"
123-
/>
124-
<video
125-
v-else-if="caller.result.type.indexOf('video') >= 0"
126-
:src="caller.getResultObjectUrl(instance.proxy)"
127-
:alt="caller.result.name"
128-
class="elevation-1"
129-
controls
130-
style="max-width: 100%"
131-
/>
132-
<pre v-else>Unable to show preview.</pre>
133-
</template>
134-
</div>
99+
<template
100+
v-if="
101+
fileDownloadKind == 'preview' &&
102+
'getResultObjectUrl' in caller
103+
"
104+
>
105+
<img
106+
v-if="caller.result.type.indexOf('image') >= 0"
107+
:src="caller.getResultObjectUrl(instance.proxy)"
108+
:alt="caller.result.name"
109+
class="elevation-1"
110+
style="max-width: 100%"
111+
/>
112+
<video
113+
v-else-if="caller.result.type.indexOf('video') >= 0"
114+
:src="caller.getResultObjectUrl(instance.proxy)"
115+
:alt="caller.result.name"
116+
class="elevation-1"
117+
controls
118+
style="max-width: 100%"
119+
/>
120+
<pre v-else>Unable to show preview.</pre>
121+
</template>
122+
</div>
135123

136-
<c-display
137-
v-else-if="
138-
caller.result != null && methodMeta.return.type !== 'void'
139-
"
140-
element="pre"
141-
class="c-method--result-value"
142-
v-model="caller.result"
143-
:for="methodMeta.return"
144-
:options="resultDisplayOptions"
145-
/>
124+
<c-display
125+
v-else-if="caller.result != null"
126+
element="pre"
127+
class="c-method--result-value"
128+
v-model="caller.result"
129+
:for="methodMeta.return"
130+
:options="resultDisplayOptions"
131+
/>
146132

147-
<span
148-
v-else-if="
149-
caller.wasSuccessful != null &&
150-
caller.result == null &&
151-
methodMeta.return.type !== 'void'
152-
"
153-
class="c-method--result-null"
154-
>
155-
<pre>{{ "" + caller.result }}</pre>
156-
</span>
133+
<span
134+
v-else-if="caller.wasSuccessful != null && caller.result == null"
135+
class="c-method--result-null"
136+
>
137+
<pre>{{ "" + caller.result }}</pre>
138+
</span>
139+
</template>
157140
</c-loader-status>
158141
</v-col>
159142
</v-row>

0 commit comments

Comments
 (0)