App update validation updates
This commit is contained in:
parent
8d98f6ac02
commit
a5dae87fa9
|
@ -348,7 +348,7 @@
|
|||
name: $store.name,
|
||||
url: $store.url,
|
||||
icon: $store.icon,
|
||||
devId: $store.appId,
|
||||
appId: $store.appId,
|
||||
}}
|
||||
onUpdateComplete={async () => {
|
||||
await initialiseApp()
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
export let app
|
||||
export let onUpdateComplete
|
||||
|
||||
$: appIdParts = app.appId ? app.appId?.split("_") : []
|
||||
$: appId = appIdParts.slice(-1)[0]
|
||||
|
||||
const values = writable({
|
||||
name: app.name,
|
||||
url: app.url,
|
||||
|
@ -35,8 +38,20 @@
|
|||
|
||||
const setupValidation = async () => {
|
||||
const applications = svelteGet(apps)
|
||||
appValidation.name(validation, { apps: applications, currentApp: app })
|
||||
appValidation.url(validation, { apps: applications, currentApp: app })
|
||||
appValidation.name(validation, {
|
||||
apps: applications,
|
||||
currentApp: {
|
||||
...app,
|
||||
appId,
|
||||
},
|
||||
})
|
||||
appValidation.url(validation, {
|
||||
apps: applications,
|
||||
currentApp: {
|
||||
...app,
|
||||
appId,
|
||||
},
|
||||
})
|
||||
// init validation
|
||||
const { url } = $values
|
||||
validation.check({
|
||||
|
@ -47,7 +62,7 @@
|
|||
|
||||
async function updateApp() {
|
||||
try {
|
||||
await apps.update(app.devId, {
|
||||
await apps.update(app.appId, {
|
||||
name: $values.name?.trim(),
|
||||
url: $values.url?.trim(),
|
||||
icon: {
|
||||
|
|
|
@ -52,7 +52,13 @@ export const url = (validation, { apps, currentApp } = { apps: [] }) => {
|
|||
}
|
||||
return !apps
|
||||
.map(app => app.url)
|
||||
.some(appUrl => appUrl?.toLowerCase() === value.toLowerCase())
|
||||
.some(appUrl => {
|
||||
const url =
|
||||
appUrl?.[0] === "/"
|
||||
? appUrl.substring(1, appUrl.length)
|
||||
: appUrl
|
||||
return url?.toLowerCase() === value.toLowerCase()
|
||||
})
|
||||
}
|
||||
)
|
||||
.test("valid-url", "Not a valid URL", value => {
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
name: $store.name,
|
||||
url: $store.url,
|
||||
icon: $store.icon,
|
||||
devId: $store.appId,
|
||||
appId: $store.appId,
|
||||
}}
|
||||
onUpdateComplete={async () => {
|
||||
await initialiseApp()
|
||||
|
|
Loading…
Reference in New Issue