fix lint issue

This commit is contained in:
Maurits Lourens 2021-07-28 00:09:15 +02:00
parent c84cf22129
commit c9dd9594bc
3 changed files with 18 additions and 20 deletions

View File

@ -20,11 +20,11 @@
name: string().required("Your application must have a name"), name: string().required("Your application must have a name"),
} }
export let app; export let app
let modal; let modal
let valid = false let valid = false
let dirty = false; let dirty = false
$: checkValidity($values, validator) $: checkValidity($values, validator)
$: { $: {
// prevent validation by setting name to undefined without an app // prevent validation by setting name to undefined without an app
@ -65,8 +65,8 @@
async function updateApp() { async function updateApp() {
try { try {
// Update App // Update App
await apps.update(app.instance._id, $values.name); await apps.update(app.instance._id, $values.name)
hide(); hide()
} catch (error) { } catch (error) {
console.error(error) console.error(error)
notifications.error(error) notifications.error(error)
@ -81,14 +81,14 @@
} }
const onCancel = () => { const onCancel = () => {
hide(); hide()
} }
const onShow = () => { const onShow = () => {
dirty = false; dirty = false
} }
</script> </script>
<Modal bind:this={modal} on:hide={onCancel} on:show={onShow}> <Modal bind:this={modal} on:hide={onCancel} on:show={onShow}>
<ModalContent <ModalContent
title={"Update app"} title={"Update app"}
@ -104,7 +104,7 @@
bind:value={$values.name} bind:value={$values.name}
error={$touched.name && $errors.name} error={$touched.name && $errors.name}
on:blur={() => ($touched.name = true)} on:blur={() => ($touched.name = true)}
on:change={() => dirty = true} on:change={() => (dirty = true)}
label="Name" label="Name"
/> />
</ModalContent> </ModalContent>

View File

@ -297,11 +297,7 @@
Are you sure you want to unpublish the app <b>{selectedApp?.name}</b>? Are you sure you want to unpublish the app <b>{selectedApp?.name}</b>?
</ConfirmDialog> </ConfirmDialog>
<UpdateAppModal <UpdateAppModal app={selectedApp} bind:this={updatingModal} />
app={selectedApp}
bind:this={updatingModal}
>
</UpdateAppModal>
<style> <style>
.title, .title,

View File

@ -1,7 +1,7 @@
import { writable } from "svelte/store" import { writable } from "svelte/store"
import { get } from "builderStore/api" import { get } from "builderStore/api"
import { AppStatus } from "../../constants" import { AppStatus } from "../../constants"
import api from "../../builderStore/api"; import api from "../../builderStore/api"
export function createAppStore() { export function createAppStore() {
const store = writable([]) const store = writable([])
@ -58,11 +58,13 @@ export function createAppStore() {
const response = await api.put(`/api/applications/${appId}`, { name }) const response = await api.put(`/api/applications/${appId}`, { name })
if (response.status === 200) { if (response.status === 200) {
store.update(state => { store.update(state => {
const updatedAppIndex = state.findIndex(app => app.instance._id === appId); const updatedAppIndex = state.findIndex(
app => app.instance._id === appId
)
if (updatedAppIndex !== -1) { if (updatedAppIndex !== -1) {
const updatedApp = state[updatedAppIndex]; const updatedApp = state[updatedAppIndex]
updatedApp.name = name; updatedApp.name = name
state.apps = state.splice(updatedAppIndex, 1, updatedApp); state.apps = state.splice(updatedAppIndex, 1, updatedApp)
} }
return state return state
}) })