@stacksjs/defaults 0.75.571 → 0.75.572
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/skills/stacks-actions/SKILL.md +1 -1
- package/ai/skills/stacks-cms/SKILL.md +1 -1
- package/ai/skills/stacks-dashboard/SKILL.md +283 -12
- package/ai/skills/stacks-database/SKILL.md +3 -1
- package/ai/skills/stacks-native/CATALOG.md +2 -2
- package/ai/skills/stacks-orm/SKILL.md +5 -1
- package/app/Actions/Dashboard/Content/CommentUpdateAction.ts +1 -1
- package/app/Actions/Dashboard/Content/PostStoreAction.ts +1 -1
- package/app/Actions/Dashboard/Content/PostUpdateAction.ts +1 -1
- package/app/Actions/Dashboard/Marketing/marketing-list-records.test.ts +2 -2
- package/app/Actions/Dashboard/Marketing/marketing-list-records.ts +4 -4
- package/app/Actions/Dashboard/Models/ModelShowAction.ts +42 -43
- package/app/Actions/Dashboard/Models/ModelUpdateAction.ts +17 -3
- package/app/Actions/Dashboard/Models/model-filters.ts +429 -0
- package/app/Actions/Dashboard/Models/model-switches.ts +159 -0
- package/app/Actions/Dashboard/Models/model-write.ts +6 -0
- package/app/Models/Comment.ts +3 -3
- package/app/Models/Content/Post.ts +3 -3
- package/app/Models/EmailList.ts +8 -6
- package/app/Models/Subscriber.ts +2 -0
- package/app/Models/Team.ts +2 -0
- package/app/Models/User.ts +3 -0
- package/functions/dashboard-model-filters.ts +219 -0
- package/functions/dashboard-model-record.ts +42 -8
- package/ide/vscode/package.json +1 -1
- package/package.json +3 -3
- package/resources/components/Dashboard/Commerce/CommerceCategoryDialog.stx +3 -1
- package/resources/components/Dashboard/Commerce/CommerceCouponDialog.stx +3 -1
- package/resources/components/Dashboard/Commerce/CommerceGiftCardDialog.stx +9 -3
- package/resources/components/Dashboard/Commerce/CommerceManufacturerDialog.stx +3 -4
- package/resources/components/Dashboard/Commerce/CommerceProductDialog.stx +3 -1
- package/resources/components/Dashboard/Commerce/CommerceReviewEditDialog.stx +6 -8
- package/resources/components/Dashboard/Commerce/CommerceTaxDialog.stx +6 -14
- package/resources/components/Dashboard/Commerce/CommerceUnitDialog.stx +3 -7
- package/resources/components/Dashboard/Commerce/Delivery/DigitalDeliveryDialog.stx +6 -2
- package/resources/components/Dashboard/Content/BlogPostEditorDialog.stx +2 -8
- package/resources/components/Dashboard/Content/PageEditorDialog.stx +3 -7
- package/resources/components/Dashboard/Content/PostEditorDialog.stx +3 -4
- package/resources/components/Dashboard/Data/DataModelRecords.stx +12 -75
- package/resources/components/Dashboard/Data/DataStatCards.stx +110 -0
- package/resources/components/Dashboard/Email/InboxSettingsDashboard.stx +20 -36
- package/resources/components/Dashboard/Marketing/MarketingListDialog.stx +7 -14
- package/resources/components/Dashboard/Marketing/MarketingListsDashboard.stx +3 -2
- package/resources/components/Dashboard/Models/ModelFieldInputs.stx +10 -13
- package/resources/components/Dashboard/Models/ModelFilterPanel.stx +166 -0
- package/resources/components/Dashboard/Models/ModelRecordDetail.stx +18 -0
- package/resources/components/Dashboard/Models/ModelRecordEdit.stx +3 -2
- package/resources/components/Dashboard/Models/ModelRecordsDashboard.stx +96 -29
- package/resources/components/Dashboard/Models/ModelRegion.stx +25 -0
- package/resources/components/Dashboard/Models/ModelRegionFor.stx +31 -0
- package/resources/components/Dashboard/Operations/RecoveryDestinationDialog.stx +2 -2
- package/resources/components/Dashboard/Operations/RecoveryPolicyDialog.stx +3 -1
- package/resources/components/Dashboard/Operations/RecoveryRestoreDialog.stx +3 -1
- package/resources/components/Dashboard/Settings/AppearanceSettingsDashboard.stx +11 -14
- package/resources/components/Dashboard/Settings/SettingsDashboard.stx +6 -9
- package/resources/components/Dashboard/UI/Toggle.stx +16 -12
- package/resources/functions/dashboard/regions.ts +113 -0
- package/resources/functions/dashboard/sidebar.ts +2 -0
- package/views/dashboard/composables/useModelList.ts +52 -0
- package/views/dashboard/composables/useModelRecord.ts +46 -0
- package/views/dashboard/stores/model-page.ts +105 -0
|
@@ -180,9 +180,15 @@ function errorMessages(): string[] {
|
|
|
180
180
|
<label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Customer ID</span><input x-model="customerId" type="number" min="1" step="1" placeholder="Optional" class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
|
|
181
181
|
<label class="block sm:col-span-2"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Template ID</span><input x-model="templateId" type="text" placeholder="Optional" class="mt-1 px-3 py-2 w-full font-mono text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
|
|
182
182
|
<div class="grid gap-3 grid-cols-1 sm:col-span-2 sm:grid-cols-3">
|
|
183
|
-
<
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
184
|
+
<Toggle v-model:checked="isActive" label="Enabled" labelPosition="left" />
|
|
185
|
+
</div>
|
|
186
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
187
|
+
<Toggle v-model:checked="isDigital" label="Digital delivery" labelPosition="left" />
|
|
188
|
+
</div>
|
|
189
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
190
|
+
<Toggle v-model:checked="isReloadable" label="Reloadable" labelPosition="left" />
|
|
191
|
+
</div>
|
|
186
192
|
</div>
|
|
187
193
|
</div>
|
|
188
194
|
</form>
|
|
@@ -70,10 +70,9 @@ function errorMessages(): string[] {
|
|
|
70
70
|
<span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Country</span>
|
|
71
71
|
<input x-model="country" type="text" maxlength="100" required class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" />
|
|
72
72
|
</label>
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
</label>
|
|
73
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
74
|
+
<Toggle v-model:checked="featured" label="Featured manufacturer" labelPosition="left" />
|
|
75
|
+
</div>
|
|
77
76
|
</div>
|
|
78
77
|
</form>
|
|
79
78
|
<template #footer>
|
|
@@ -155,7 +155,9 @@ function errorMessages(): string[] {
|
|
|
155
155
|
<label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Price ({{ currency() }})</span><input x-model="price" type="number" min="0" :step="moneyInputStep(currency())" inputmode="decimal" required :aria-invalid="price() !== '' && priceError() !== ''" class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" /><span :if="price() !== '' && priceError()" class="block mt-1 text-red-600 text-xs dark:text-red-400">{{ priceError() }}</span></label>
|
|
156
156
|
<label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Inventory count</span><input x-model="inventoryCount" type="number" min="0" step="1" required class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
|
|
157
157
|
<label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Preparation time (minutes)</span><input x-model="preparationTime" type="number" min="1" step="1" required class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
|
|
158
|
-
<
|
|
158
|
+
<div class="self-end px-3 py-2 min-h-10 bg-gray-50 dark:bg-neutral-900/60 border border-gray-200 rounded-md dark:border-neutral-700">
|
|
159
|
+
<Toggle v-model:checked="isAvailable" label="Available for commerce" labelPosition="left" />
|
|
160
|
+
</div>
|
|
159
161
|
<label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Category</span><select x-model="categoryId" class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700"><option value="">Unassigned category</option><option :for="option in categories()" :key="option.id" :value="option.id">{{ option.label }}</option></select></label>
|
|
160
162
|
<label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Manufacturer</span><select x-model="manufacturerId" class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700"><option value="">Unassigned manufacturer</option><option :for="option in manufacturers()" :key="option.id" :value="option.id">{{ option.label }}</option></select></label>
|
|
161
163
|
<label class="block sm:col-span-2"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Image URL</span><input x-model="imageUrl" type="url" placeholder="Optional persisted asset URL" class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" /></label>
|
|
@@ -81,14 +81,12 @@ function errorMessages(): string[] {
|
|
|
81
81
|
</select>
|
|
82
82
|
</label>
|
|
83
83
|
<div class="grid gap-3 grid-cols-1 sm:grid-cols-2">
|
|
84
|
-
<
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Featured</span>
|
|
91
|
-
</label>
|
|
84
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
85
|
+
<Toggle v-model:checked="approved" label="Approved" labelPosition="left" />
|
|
86
|
+
</div>
|
|
87
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
88
|
+
<Toggle v-model:checked="featured" label="Featured" labelPosition="left" />
|
|
89
|
+
</div>
|
|
92
90
|
</div>
|
|
93
91
|
</div>
|
|
94
92
|
</form>
|
|
@@ -115,25 +115,17 @@ function errorMessages(): string[] {
|
|
|
115
115
|
<input x-model="code" type="text" placeholder="sales" class="mt-1 px-3 py-2 w-full font-mono text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" />
|
|
116
116
|
<span class="block mt-1 text-gray-500 text-xs dark:text-neutral-400">What the application matches on. Renaming the rate above does not change what is charged; changing this can.</span>
|
|
117
117
|
</label>
|
|
118
|
-
<
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
<span class="block font-medium text-gray-700 text-sm dark:text-neutral-200">Default tax rate</span>
|
|
122
|
-
<span class="block mt-0.5 text-gray-500 text-xs dark:text-neutral-400">Selecting this clears the default flag from every other rate.</span>
|
|
123
|
-
</span>
|
|
124
|
-
</label>
|
|
118
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
119
|
+
<Toggle v-model:checked="isDefault" label="Default tax rate" description="Selecting this clears the default flag from every other rate." labelPosition="left" />
|
|
120
|
+
</div>
|
|
125
121
|
{{--
|
|
126
122
|
Spelled out rather than labelled "exempt", because the two read
|
|
127
123
|
alike and mean opposite things: this marks the component as one an
|
|
128
124
|
exemption can lift, not one that is currently unpaid.
|
|
129
125
|
--}}
|
|
130
|
-
<
|
|
131
|
-
<
|
|
132
|
-
|
|
133
|
-
<span class="block font-medium text-gray-700 text-sm dark:text-neutral-200">Can be exempted</span>
|
|
134
|
-
<span class="block mt-0.5 text-gray-500 text-xs dark:text-neutral-400">Customers who qualify for an exemption are not charged this component. Leave off for anything owed regardless - an excise or a city levy is usually still due.</span>
|
|
135
|
-
</span>
|
|
136
|
-
</label>
|
|
126
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
127
|
+
<Toggle v-model:checked="exemptible" label="Can be exempted" description="Customers who qualify for an exemption are not charged this component. Leave off for anything owed regardless - an excise or a city levy is usually still due." labelPosition="left" />
|
|
128
|
+
</div>
|
|
137
129
|
</div>
|
|
138
130
|
</form>
|
|
139
131
|
<template #footer>
|
|
@@ -152,13 +152,9 @@ function errorMessages(): string[] {
|
|
|
152
152
|
<span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Description</span>
|
|
153
153
|
<textarea x-model="description" rows="3" maxlength="255" class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700"></textarea>
|
|
154
154
|
</label>
|
|
155
|
-
<
|
|
156
|
-
<
|
|
157
|
-
|
|
158
|
-
<span class="block font-medium text-gray-700 text-sm dark:text-neutral-200">Default for this type</span>
|
|
159
|
-
<span class="block mt-0.5 text-gray-500 text-xs dark:text-neutral-400">Selecting this clears any other default in the same unit type.</span>
|
|
160
|
-
</span>
|
|
161
|
-
</label>
|
|
155
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
156
|
+
<Toggle v-model:checked="isDefault" label="Default for this type" description="Selecting this clears any other default in the same unit type." labelPosition="left" />
|
|
157
|
+
</div>
|
|
162
158
|
</div>
|
|
163
159
|
</form>
|
|
164
160
|
<template #footer>
|
|
@@ -97,8 +97,12 @@ function submit(): void {
|
|
|
97
97
|
<label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Expiry days</span><input x-model="expiryDays" type="number" required min="0" step="1" inputmode="numeric" class="mt-1 px-3 py-2 w-full tabular-nums text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700" /><span class="block mt-1 text-gray-500 text-xs dark:text-neutral-500">Use 0 for access without expiry.</span></label>
|
|
98
98
|
</div>
|
|
99
99
|
<div class="grid gap-3 grid-cols-1 sm:grid-cols-2">
|
|
100
|
-
<
|
|
101
|
-
|
|
100
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
101
|
+
<Toggle v-model:checked="requiresLogin" label="Require login" description="Only authenticated customers can download." labelPosition="left" />
|
|
102
|
+
</div>
|
|
103
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
104
|
+
<Toggle v-model:checked="automaticDelivery" label="Automatic delivery" description="Fulfill automatically after payment." labelPosition="left" />
|
|
105
|
+
</div>
|
|
102
106
|
</div>
|
|
103
107
|
<label class="block"><span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Status</span><select x-model="status" class="mt-1 px-3 py-2 w-full text-gray-900 text-sm dark:text-white bg-white dark:bg-neutral-900 border border-gray-300 rounded-md dark:border-neutral-700"><option value="active">Active</option><option value="inactive">Inactive</option></select></label>
|
|
104
108
|
</div>
|
|
@@ -177,14 +177,8 @@ function submit(): void {
|
|
|
177
177
|
</div>
|
|
178
178
|
|
|
179
179
|
<div class="flex flex-col gap-3 sm:flex-row sm:gap-6 pt-2 border-neutral-200 border-t dark:border-neutral-800">
|
|
180
|
-
<
|
|
181
|
-
|
|
182
|
-
<span>Draft, keep off the public blog</span>
|
|
183
|
-
</label>
|
|
184
|
-
<label class="flex gap-2 items-center text-sm">
|
|
185
|
-
<input x-model="featured" name="featured" type="checkbox" class="h-4 w-4 text-blue-600 border-neutral-300 rounded dark:border-neutral-600" />
|
|
186
|
-
<span>Feature at the top of the listing</span>
|
|
187
|
-
</label>
|
|
180
|
+
<Toggle v-model:checked="draft" name="draft" label="Draft, keep off the public blog" />
|
|
181
|
+
<Toggle v-model:checked="featured" name="featured" label="Feature at the top of the listing" />
|
|
188
182
|
</div>
|
|
189
183
|
</form>
|
|
190
184
|
|
|
@@ -69,13 +69,9 @@ function submit(): void {
|
|
|
69
69
|
<option value="contact">Contact</option>
|
|
70
70
|
</select>
|
|
71
71
|
</label>
|
|
72
|
-
<
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
<span class="block font-medium text-gray-700 text-sm dark:text-neutral-200">Published</span>
|
|
76
|
-
<span class="block mt-1 text-gray-500 text-xs dark:text-neutral-400">Published pages receive a timestamp. Clearing this returns the page to draft.</span>
|
|
77
|
-
</span>
|
|
78
|
-
</label>
|
|
72
|
+
<div class="p-3 bg-gray-50 dark:bg-neutral-900/50 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
73
|
+
<Toggle v-model:checked="published" name="published" label="Published" description="Published pages receive a timestamp. Clearing this returns the page to draft." labelPosition="left" />
|
|
74
|
+
</div>
|
|
79
75
|
</form>
|
|
80
76
|
|
|
81
77
|
<div :if="error()" role="alert" class="mt-4 p-3 text-red-700 text-sm dark:text-red-300 bg-red-50 dark:bg-red-950/30 border border-red-200 rounded-lg dark:border-red-900">
|
|
@@ -137,10 +137,9 @@ function submit(): void {
|
|
|
137
137
|
<option :for="author in authors()" :value="author.id">{{ author.name }} ({{ author.email }})</option>
|
|
138
138
|
</select>
|
|
139
139
|
</label>
|
|
140
|
-
<
|
|
141
|
-
<
|
|
142
|
-
|
|
143
|
-
</label>
|
|
140
|
+
<div class="self-end px-3 py-2 min-h-10 bg-gray-50 dark:bg-neutral-900/60 border border-gray-200 rounded-md dark:border-neutral-700">
|
|
141
|
+
<Toggle v-model:checked="featured" name="featured" label="Featured post" labelPosition="left" />
|
|
142
|
+
</div>
|
|
144
143
|
</div>
|
|
145
144
|
<label>
|
|
146
145
|
<span class="font-medium text-gray-700 text-sm dark:text-neutral-200">Poster URL</span>
|
|
@@ -1,54 +1,24 @@
|
|
|
1
1
|
<script client>
|
|
2
2
|
// The Users, Teams and Subscribers pages. Each is the model's own list, the
|
|
3
|
-
// one every model has, hosted under the page's name
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// one every model has, hosted under the page's name. Nothing about the rows
|
|
4
|
+
// is this page's: paging, search, columns, actions and selection are the
|
|
5
|
+
// list's, so they are built once.
|
|
6
6
|
//
|
|
7
|
-
// What is the page's own: what it is called
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// (`recordsPage`, `pageStats`). What goes in the list's slot is read against
|
|
12
|
-
// the list's own names first, and a `page` here was read as the list's page
|
|
13
|
-
// number: the first card said "Total undefined".
|
|
14
|
-
import type { DataStats } from '../../../../functions/data'
|
|
15
|
-
import { fetchDashboardStats } from '../../../../functions/data'
|
|
16
|
-
|
|
7
|
+
// What is the page's own: what it is called and what it is for. The row of
|
|
8
|
+
// numbers above the list is the model's, placed there by the model
|
|
9
|
+
// (`dashboard.regions.listTop`, `Data/DataStatCards.stx`), so it is on the
|
|
10
|
+
// model's list wherever that list is shown.
|
|
17
11
|
type RecordsPage = 'users' | 'teams' | 'subscribers'
|
|
18
12
|
|
|
19
13
|
const pageMode = useReactiveProp<RecordsPage>('mode', 'users')
|
|
20
|
-
// Null until the numbers have come. A card says nothing until then: a 0 is a
|
|
21
|
-
// count, and "no users" is not what is known while the page is still asking.
|
|
22
|
-
const pageStats = state<DataStats | null>(null)
|
|
23
14
|
|
|
24
|
-
const PAGES: Record<RecordsPage, { model: string, title: string, description: string
|
|
25
|
-
users: { model: 'user', title: 'Users', description: 'Review registered application users.'
|
|
26
|
-
teams: { model: 'team', title: 'Teams', description: 'Review collaborative teams and membership totals.'
|
|
27
|
-
subscribers: { model: 'subscriber', title: 'Subscribers', description: 'Review subscription status and acquisition sources.'
|
|
15
|
+
const PAGES: Record<RecordsPage, { model: string, title: string, description: string }> = {
|
|
16
|
+
users: { model: 'user', title: 'Users', description: 'Review registered application users.' },
|
|
17
|
+
teams: { model: 'team', title: 'Teams', description: 'Review collaborative teams and membership totals.' },
|
|
18
|
+
subscribers: { model: 'subscriber', title: 'Subscribers', description: 'Review subscription status and acquisition sources.' },
|
|
28
19
|
}
|
|
29
20
|
|
|
30
21
|
const recordsPage = derived(() => PAGES[pageMode()] ?? PAGES.users)
|
|
31
|
-
/** Each page's stats fill their row: three cards in a four-column grid left a hole. */
|
|
32
|
-
const pageStatsGrid = derived(() => recordsPage().cards === 3 ? 'grid-cols-1 sm:grid-cols-3' : 'grid-cols-2 lg:grid-cols-4')
|
|
33
|
-
|
|
34
|
-
function pageStat(key: string): string {
|
|
35
|
-
const numbers = pageStats()
|
|
36
|
-
return numbers ? Number(numbers[key] || 0).toLocaleString() : '-'
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function loadPageStats(): Promise<void> {
|
|
40
|
-
try {
|
|
41
|
-
pageStats.set(await fetchDashboardStats(pageMode()))
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
// The list below says what is wrong when the model cannot be read; the
|
|
45
|
-
// numbers stay as they were.
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
onMount(() => {
|
|
50
|
-
void loadPageStats()
|
|
51
|
-
})
|
|
52
22
|
</script>
|
|
53
23
|
|
|
54
24
|
<ModelRecordsDashboard
|
|
@@ -56,37 +26,4 @@ onMount(() => {
|
|
|
56
26
|
:heading="recordsPage().title"
|
|
57
27
|
:description="recordsPage().description"
|
|
58
28
|
:home="'/data/' + pageMode()"
|
|
59
|
-
|
|
60
|
-
>
|
|
61
|
-
<template #summary>
|
|
62
|
-
<div class="grid gap-4" :class="pageStatsGrid()" data-page-stats>
|
|
63
|
-
<StatsCard :title="'Total ' + recordsPage().title" :icon="recordsPage().icon" iconBg="primary">
|
|
64
|
-
<template #value>{{ pageStat('total') }}</template>
|
|
65
|
-
</StatsCard>
|
|
66
|
-
<StatsCard :if="pageMode() === 'users'" title="New This Week" icon="i-hugeicons-user-add-01" iconBg="success">
|
|
67
|
-
<template #value>{{ pageStat('newThisWeek') }}</template>
|
|
68
|
-
</StatsCard>
|
|
69
|
-
<StatsCard :if="pageMode() === 'users'" title="Email Verified" icon="i-hugeicons-mail-validation-01" iconBg="info">
|
|
70
|
-
<template #value>{{ pageStat('verified') }}</template>
|
|
71
|
-
</StatsCard>
|
|
72
|
-
<StatsCard :if="pageMode() === 'teams'" title="Active Teams" icon="i-hugeicons-checkmark-circle-02" iconBg="success">
|
|
73
|
-
<template #value>{{ pageStat('active') }}</template>
|
|
74
|
-
</StatsCard>
|
|
75
|
-
<StatsCard :if="pageMode() === 'teams'" title="Members" icon="i-hugeicons-user-multiple" iconBg="info">
|
|
76
|
-
<template #value>{{ pageStat('members') }}</template>
|
|
77
|
-
</StatsCard>
|
|
78
|
-
<StatsCard :if="pageMode() === 'teams'" title="New This Month" icon="i-hugeicons-calendar-add-01" iconBg="warning">
|
|
79
|
-
<template #value>{{ pageStat('newThisMonth') }}</template>
|
|
80
|
-
</StatsCard>
|
|
81
|
-
<StatsCard :if="pageMode() === 'subscribers'" title="Subscribed" icon="i-hugeicons-mail-open-01" iconBg="success">
|
|
82
|
-
<template #value>{{ pageStat('subscribed') }}</template>
|
|
83
|
-
</StatsCard>
|
|
84
|
-
<StatsCard :if="pageMode() === 'subscribers'" title="Unsubscribed" icon="i-hugeicons-mail-remove-01" iconBg="warning">
|
|
85
|
-
<template #value>{{ pageStat('unsubscribed') }}</template>
|
|
86
|
-
</StatsCard>
|
|
87
|
-
<StatsCard :if="pageMode() === 'subscribers'" title="New This Month" icon="i-hugeicons-calendar-add-01" iconBg="info">
|
|
88
|
-
<template #value>{{ pageStat('newThisMonth') }}</template>
|
|
89
|
-
</StatsCard>
|
|
90
|
-
</div>
|
|
91
|
-
</template>
|
|
92
|
-
</ModelRecordsDashboard>
|
|
29
|
+
/>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<script client>
|
|
2
|
+
// The row of numbers above the Users, Teams and Subscribers lists.
|
|
3
|
+
//
|
|
4
|
+
// Each of those models places this on its own list
|
|
5
|
+
// (`dashboard.regions.listTop`), which is how a model puts anything of its
|
|
6
|
+
// own on a page the dashboard draws. So the numbers are on `/data/users` and
|
|
7
|
+
// on `/models/user` alike: they belong to the model, not to one of its pages.
|
|
8
|
+
//
|
|
9
|
+
// It is handed the model and nothing else. The numbers are its own to ask
|
|
10
|
+
// for, and it asks again when the list says a record was changed.
|
|
11
|
+
import type { DataMode, DataStats } from '../../../../functions/data'
|
|
12
|
+
import { useModelList } from '@stacksjs/defaults/views/dashboard/composables/useModelList'
|
|
13
|
+
import { fetchDashboardStats } from '../../../../functions/data'
|
|
14
|
+
|
|
15
|
+
interface StatCard {
|
|
16
|
+
/** The number's name in the stats the model's endpoint answers. */
|
|
17
|
+
key: string
|
|
18
|
+
title: string
|
|
19
|
+
icon: string
|
|
20
|
+
tone: 'primary' | 'success' | 'info' | 'warning'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const STAT_CARDS: Record<string, { mode: DataMode, cards: StatCard[] }> = {
|
|
24
|
+
user: {
|
|
25
|
+
mode: 'users',
|
|
26
|
+
cards: [
|
|
27
|
+
{ key: 'total', title: 'Total Users', icon: 'i-hugeicons-user-group', tone: 'primary' },
|
|
28
|
+
{ key: 'newThisWeek', title: 'New This Week', icon: 'i-hugeicons-user-add-01', tone: 'success' },
|
|
29
|
+
{ key: 'verified', title: 'Email Verified', icon: 'i-hugeicons-mail-validation-01', tone: 'info' },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
team: {
|
|
33
|
+
mode: 'teams',
|
|
34
|
+
cards: [
|
|
35
|
+
{ key: 'total', title: 'Total Teams', icon: 'i-hugeicons-user-multiple-02', tone: 'primary' },
|
|
36
|
+
{ key: 'active', title: 'Active Teams', icon: 'i-hugeicons-checkmark-circle-02', tone: 'success' },
|
|
37
|
+
{ key: 'members', title: 'Members', icon: 'i-hugeicons-user-multiple', tone: 'info' },
|
|
38
|
+
{ key: 'newThisMonth', title: 'New This Month', icon: 'i-hugeicons-calendar-add-01', tone: 'warning' },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
subscriber: {
|
|
42
|
+
mode: 'subscribers',
|
|
43
|
+
cards: [
|
|
44
|
+
{ key: 'total', title: 'Total Subscribers', icon: 'i-hugeicons-mail-account-01', tone: 'primary' },
|
|
45
|
+
{ key: 'subscribed', title: 'Subscribed', icon: 'i-hugeicons-mail-open-01', tone: 'success' },
|
|
46
|
+
{ key: 'unsubscribed', title: 'Unsubscribed', icon: 'i-hugeicons-mail-remove-01', tone: 'warning' },
|
|
47
|
+
{ key: 'newThisMonth', title: 'New This Month', icon: 'i-hugeicons-calendar-add-01', tone: 'info' },
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const statModel = useReactiveProp('model', '')
|
|
53
|
+
// Null until the numbers have come. A card says nothing until then: a 0 is a
|
|
54
|
+
// count, and "no users" is not what is known while the page is still asking.
|
|
55
|
+
const statNumbers = state<DataStats | null>(null)
|
|
56
|
+
const statCards = derived(() => STAT_CARDS[statModel()]?.cards ?? [])
|
|
57
|
+
/** Each model's cards fill their row: three in a four-column grid left a hole. */
|
|
58
|
+
const statGrid = derived(() => statCards().length === 3 ? 'grid-cols-1 sm:grid-cols-3' : 'grid-cols-2 lg:grid-cols-4')
|
|
59
|
+
const { changes } = useModelList()
|
|
60
|
+
// Stops watching the list. Set while this is on the page, and only then.
|
|
61
|
+
let stopWatchingList: (() => void) | null = null
|
|
62
|
+
|
|
63
|
+
function statValue(key: string): string {
|
|
64
|
+
const numbers = statNumbers()
|
|
65
|
+
return numbers ? Number(numbers[key] || 0).toLocaleString() : '-'
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function loadStatNumbers(): Promise<void> {
|
|
69
|
+
const shown = STAT_CARDS[statModel()]
|
|
70
|
+
if (!shown)
|
|
71
|
+
return
|
|
72
|
+
try {
|
|
73
|
+
statNumbers.set(await fetchDashboardStats(shown.mode))
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// The list below says what is wrong when the model cannot be read; the
|
|
77
|
+
// numbers stay as they were.
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Everything this does starts here and stops in onDestroy. A model's
|
|
82
|
+
// component is drawn on every page that has its place, and its script runs
|
|
83
|
+
// there whether or not it is put on the page: an `effect` at the top of the
|
|
84
|
+
// script would ask for users' numbers every time a team was deleted, and
|
|
85
|
+
// would never be stopped (stacksjs/stx#2189). The model is also a prop, which
|
|
86
|
+
// is not bound sooner.
|
|
87
|
+
onMount(() => {
|
|
88
|
+
void loadStatNumbers()
|
|
89
|
+
// What the list had changed before now is already in the numbers just asked for.
|
|
90
|
+
let seen = changes()
|
|
91
|
+
stopWatchingList = effect(() => {
|
|
92
|
+
const count = changes()
|
|
93
|
+
if (count === seen)
|
|
94
|
+
return
|
|
95
|
+
seen = count
|
|
96
|
+
void loadStatNumbers()
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
onDestroy(() => {
|
|
101
|
+
stopWatchingList?.()
|
|
102
|
+
stopWatchingList = null
|
|
103
|
+
})
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<div :if="statCards().length > 0" class="grid gap-4" :class="statGrid()" data-page-stats>
|
|
107
|
+
<div :for="card in statCards()" class="contents">
|
|
108
|
+
<StatsCard :title="card.title" :value="statValue(card.key)" :icon="card.icon" :iconBg="card.tone" />
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
@@ -80,14 +80,12 @@
|
|
|
80
80
|
</select>
|
|
81
81
|
</div>
|
|
82
82
|
|
|
83
|
-
<div
|
|
84
|
-
<
|
|
85
|
-
<label for="sendAndArchive" class="block ml-2 text-gray-700 text-sm dark:text-neutral-300">Show "Send & Archive" button in reply</label>
|
|
83
|
+
<div>
|
|
84
|
+
<Toggle id="sendAndArchive" v-model:checked="sendAndArchive" :label="sendAndArchiveLabel" labelPosition="left" />
|
|
86
85
|
</div>
|
|
87
86
|
|
|
88
|
-
<div
|
|
89
|
-
<
|
|
90
|
-
<label for="desktopNotifications" class="block ml-2 text-gray-700 text-sm dark:text-neutral-300">Enable desktop notifications</label>
|
|
87
|
+
<div>
|
|
88
|
+
<Toggle id="desktopNotifications" v-model:checked="desktopNotifications" label="Enable desktop notifications" labelPosition="left" />
|
|
91
89
|
</div>
|
|
92
90
|
</div>
|
|
93
91
|
</div>
|
|
@@ -164,21 +162,13 @@
|
|
|
164
162
|
<p class="mt-1 text-gray-500 text-sm dark:text-neutral-400">Choose how new mailbox activity is announced on this device.</p>
|
|
165
163
|
|
|
166
164
|
<div class="mt-5 space-y-4">
|
|
167
|
-
<
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
</
|
|
174
|
-
|
|
175
|
-
<label class="flex items-start">
|
|
176
|
-
<input id="notificationPreview" type="checkbox" x-model="notificationPreview" class="mt-0.5 h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" />
|
|
177
|
-
<span class="ml-3">
|
|
178
|
-
<span class="block font-medium text-gray-700 text-sm dark:text-neutral-200">Message previews</span>
|
|
179
|
-
<span class="block text-gray-500 text-xs dark:text-neutral-400">Include sender and subject in notifications.</span>
|
|
180
|
-
</span>
|
|
181
|
-
</label>
|
|
165
|
+
<div>
|
|
166
|
+
<Toggle id="desktopNotificationsDelivery" v-model:checked="desktopNotifications" label="Desktop notifications" description="Show a system notification when new mail arrives." labelPosition="left" />
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
<div>
|
|
170
|
+
<Toggle id="notificationPreview" v-model:checked="notificationPreview" label="Message previews" description="Include sender and subject in notifications." labelPosition="left" />
|
|
171
|
+
</div>
|
|
182
172
|
|
|
183
173
|
<div>
|
|
184
174
|
<label for="notificationSound" class="block font-medium text-gray-700 text-sm dark:text-neutral-300">Notification sound</label>
|
|
@@ -228,21 +218,13 @@
|
|
|
228
218
|
<p class="mt-1 text-gray-500 text-sm dark:text-neutral-400">Remote content stays blocked by default to reduce tracking and untrusted requests.</p>
|
|
229
219
|
|
|
230
220
|
<div class="mt-5 space-y-4">
|
|
231
|
-
<
|
|
232
|
-
<
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
</
|
|
238
|
-
|
|
239
|
-
<label class="flex items-start">
|
|
240
|
-
<input id="showExternalContent" type="checkbox" x-model="showExternalContent" class="mt-0.5 h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500" />
|
|
241
|
-
<span class="ml-3">
|
|
242
|
-
<span class="block font-medium text-gray-700 text-sm dark:text-neutral-200">Show external content</span>
|
|
243
|
-
<span class="block text-gray-500 text-xs dark:text-neutral-400">Permit embedded content from message authors.</span>
|
|
244
|
-
</span>
|
|
245
|
-
</label>
|
|
221
|
+
<div>
|
|
222
|
+
<Toggle id="loadRemoteImages" v-model:checked="loadRemoteImages" label="Load remote images" description="Allow message images hosted outside your application." labelPosition="left" />
|
|
223
|
+
</div>
|
|
224
|
+
|
|
225
|
+
<div>
|
|
226
|
+
<Toggle id="showExternalContent" v-model:checked="showExternalContent" label="Show external content" description="Permit embedded content from message authors." labelPosition="left" />
|
|
227
|
+
</div>
|
|
246
228
|
</div>
|
|
247
229
|
</div>
|
|
248
230
|
</div>
|
|
@@ -309,6 +291,8 @@ const isLoading = state(true)
|
|
|
309
291
|
const displayDensity = state<DisplayDensity>('default')
|
|
310
292
|
const defaultReplyBehavior = state<ReplyBehavior>('replyAll')
|
|
311
293
|
const sendAndArchive = state(true)
|
|
294
|
+
// Said here because it has quotation marks of its own, which an attribute cannot hold.
|
|
295
|
+
const sendAndArchiveLabel = 'Show "Send & Archive" button in reply'
|
|
312
296
|
const autoAdvance = state<AutoAdvance>('newer')
|
|
313
297
|
const desktopNotifications = state(true)
|
|
314
298
|
const notificationSound = state<NotificationSound>('default')
|
|
@@ -101,20 +101,13 @@ function submit(): void {
|
|
|
101
101
|
</select>
|
|
102
102
|
</label>
|
|
103
103
|
<div class="grid gap-3 sm:grid-cols-2">
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
</
|
|
111
|
-
<label class="flex gap-3 items-start p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
112
|
-
<input x-model="doubleOptIn" type="checkbox" class="mt-0.5 h-4 w-4 text-blue-600 border-gray-300 rounded" />
|
|
113
|
-
<span>
|
|
114
|
-
<span class="block font-medium text-gray-700 text-sm dark:text-neutral-200">Double opt-in</span>
|
|
115
|
-
<span class="block mt-0.5 text-gray-500 text-xs dark:text-neutral-400">Require confirmation before activation.</span>
|
|
116
|
-
</span>
|
|
117
|
-
</label>
|
|
104
|
+
<!-- Yes or no is the shared switch, as in every model form. -->
|
|
105
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
106
|
+
<Toggle v-model:checked="isPublic" label="Public signup" description="Allow signup forms to target this list." labelPosition="left" />
|
|
107
|
+
</div>
|
|
108
|
+
<div class="p-3 border border-gray-200 rounded-lg dark:border-neutral-700">
|
|
109
|
+
<Toggle v-model:checked="doubleOptIn" label="Double opt-in" description="Require confirmation before activation." labelPosition="left" />
|
|
110
|
+
</div>
|
|
118
111
|
</div>
|
|
119
112
|
</div>
|
|
120
113
|
</form>
|
|
@@ -128,10 +128,11 @@ async function saveList(payload: MarketingListPayload): Promise<void> {
|
|
|
128
128
|
editing ? `/api/dashboard/marketing/lists/${current.id}` : '/api/dashboard/marketing/lists',
|
|
129
129
|
{
|
|
130
130
|
method: editing ? 'PATCH' : 'POST',
|
|
131
|
+
// Yes or no go as they are: the columns are booleans.
|
|
131
132
|
body: {
|
|
132
133
|
...payload,
|
|
133
|
-
isPublic: payload.isPublic
|
|
134
|
-
doubleOptIn: payload.doubleOptIn
|
|
134
|
+
isPublic: Boolean(payload.isPublic),
|
|
135
|
+
doubleOptIn: Boolean(payload.doubleOptIn),
|
|
135
136
|
},
|
|
136
137
|
},
|
|
137
138
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script client>
|
|
2
2
|
// The inputs of a model's form, one per field, each in the control its kind
|
|
3
|
-
// calls for: a select for a choice, a
|
|
3
|
+
// calls for: a select for a choice, a switch for yes or no, a date or a
|
|
4
4
|
// date-and-time picker, a number box, a tall box for prose and for JSON, a
|
|
5
5
|
// search for another model's record, a file chooser, a Markdown editor, and a
|
|
6
6
|
// line of text for the rest. Under each, the sentence the model wrote for it,
|
|
@@ -58,21 +58,18 @@ function change(field: ModelCreateField, value: string | boolean): void {
|
|
|
58
58
|
|
|
59
59
|
<div class="flex flex-col gap-5">
|
|
60
60
|
<div :for="field in fields()" class="contents">
|
|
61
|
-
<
|
|
62
|
-
<
|
|
61
|
+
<div :if="field.type === 'boolean'" class="p-3 border border-neutral-200 rounded-lg dark:border-neutral-700">
|
|
62
|
+
<Toggle
|
|
63
63
|
:name="field.name"
|
|
64
|
-
type="checkbox"
|
|
65
64
|
:checked="values()[field.name] === true"
|
|
66
|
-
:
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
:label="field.label"
|
|
66
|
+
:description="hint(field)"
|
|
67
|
+
:error="error(field)"
|
|
68
|
+
:disabled="disabled() || field.disabled === true"
|
|
69
|
+
labelPosition="left"
|
|
70
|
+
@update:checked="change(field, $event)"
|
|
69
71
|
/>
|
|
70
|
-
|
|
71
|
-
<span class="block font-medium text-neutral-900 text-sm dark:text-white">{{ field.label }}</span>
|
|
72
|
-
<span :if="hint(field) && !error(field)" class="block mt-0.5 text-neutral-500 text-xs dark:text-neutral-400">{{ hint(field) }}</span>
|
|
73
|
-
<span :if="error(field)" role="alert" class="block mt-0.5 text-red-600 text-xs dark:text-red-400">{{ error(field) }}</span>
|
|
74
|
-
</span>
|
|
75
|
-
</label>
|
|
72
|
+
</div>
|
|
76
73
|
|
|
77
74
|
<Select
|
|
78
75
|
:if="field.type === 'enum'"
|