0351d front end linting (#377)
* feat: disable custom script for trial users * after lint fix * frontend linting --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
55
client/stores/app.js
vendored
55
client/stores/app.js
vendored
@@ -1,10 +1,9 @@
|
||||
import { defineStore } from "pinia"
|
||||
import { nextTick } from "vue"
|
||||
|
||||
import { defineStore } from 'pinia'
|
||||
import { nextTick } from 'vue'
|
||||
|
||||
export const useAppStore = defineStore('app', {
|
||||
export const useAppStore = defineStore("app", {
|
||||
state: () => ({
|
||||
layout: 'default',
|
||||
layout: "default",
|
||||
navbarHidden: false,
|
||||
|
||||
// App Loader
|
||||
@@ -14,36 +13,36 @@ export const useAppStore = defineStore('app', {
|
||||
canSuccess: true,
|
||||
duration: 3000,
|
||||
_timer: null,
|
||||
_cut: null
|
||||
}
|
||||
_cut: null,
|
||||
},
|
||||
}),
|
||||
actions: {
|
||||
hideNavbar () {
|
||||
hideNavbar() {
|
||||
this.navbarHidden = true
|
||||
},
|
||||
showNavbar () {
|
||||
showNavbar() {
|
||||
this.navbarHidden = false
|
||||
},
|
||||
setLayout (layout) {
|
||||
this.layout = layout ?? 'default'
|
||||
setLayout(layout) {
|
||||
this.layout = layout ?? "default"
|
||||
},
|
||||
loaderIncrease (num) {
|
||||
loaderIncrease(num) {
|
||||
this.loader.percent = this.loader.percent + Math.floor(num)
|
||||
},
|
||||
loaderDecrease (num) {
|
||||
loaderDecrease(num) {
|
||||
this.loader.percent = this.loader.percent - Math.floor(num)
|
||||
},
|
||||
loaderFinish () {
|
||||
loaderFinish() {
|
||||
this.loader.percent = 100
|
||||
this.loaderHide()
|
||||
},
|
||||
loaderSetTimer (timerVal) {
|
||||
loaderSetTimer(timerVal) {
|
||||
this.loader._timer = timerVal
|
||||
},
|
||||
loaderPause () {
|
||||
loaderPause() {
|
||||
clearInterval(this.loader._timer)
|
||||
},
|
||||
loaderHide () {
|
||||
loaderHide() {
|
||||
this.loaderPause()
|
||||
this.loader._timer = null
|
||||
setTimeout(() => {
|
||||
@@ -55,10 +54,10 @@ export const useAppStore = defineStore('app', {
|
||||
})
|
||||
}, 500)
|
||||
},
|
||||
loaderFail () {
|
||||
loaderFail() {
|
||||
this.loader.canSuccess = false
|
||||
},
|
||||
loaderStart () {
|
||||
loaderStart() {
|
||||
this.loader.show = true
|
||||
this.loader.canSuccess = true
|
||||
if (this.loader._timer) {
|
||||
@@ -67,12 +66,14 @@ export const useAppStore = defineStore('app', {
|
||||
}
|
||||
this.loader._cut = 10000 / Math.floor(this.loader.duration)
|
||||
|
||||
this.loaderSetTimer(setInterval(() => {
|
||||
this.loaderIncrease(this.loader._cut * Math.random())
|
||||
if (this.loader.percent > 95) {
|
||||
this.loaderFinish()
|
||||
}
|
||||
}, 100))
|
||||
}
|
||||
}
|
||||
this.loaderSetTimer(
|
||||
setInterval(() => {
|
||||
this.loaderIncrease(this.loader._cut * Math.random())
|
||||
if (this.loader.percent > 95) {
|
||||
this.loaderFinish()
|
||||
}
|
||||
}, 100),
|
||||
)
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
24
client/stores/auth.js
vendored
24
client/stores/auth.js
vendored
@@ -1,6 +1,6 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import { defineStore } from "pinia"
|
||||
|
||||
export const useAuthStore = defineStore('auth', {
|
||||
export const useAuthStore = defineStore("auth", {
|
||||
state: () => {
|
||||
return {
|
||||
token: null,
|
||||
@@ -9,8 +9,9 @@ export const useAuthStore = defineStore('auth', {
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
check: (state) => (state.user !== null && state.user !== undefined),
|
||||
isImpersonating: (state) => (state.admin_token !== null && state.admin_token !== undefined)
|
||||
check: (state) => state.user !== null && state.user !== undefined,
|
||||
isImpersonating: (state) =>
|
||||
state.admin_token !== null && state.admin_token !== undefined,
|
||||
},
|
||||
actions: {
|
||||
// Stores admin token temporarily for impersonation
|
||||
@@ -24,12 +25,12 @@ export const useAuthStore = defineStore('auth', {
|
||||
},
|
||||
|
||||
setToken(token) {
|
||||
this.setCookie('token', token)
|
||||
this.setCookie("token", token)
|
||||
this.token = token
|
||||
},
|
||||
|
||||
setAdminToken(token) {
|
||||
this.setCookie('admin_token', token)
|
||||
this.setCookie("admin_token", token)
|
||||
this.admin_token = token
|
||||
},
|
||||
|
||||
@@ -46,7 +47,7 @@ export const useAuthStore = defineStore('auth', {
|
||||
|
||||
setUser(user) {
|
||||
if (!user) {
|
||||
console.error('No user, logging out.')
|
||||
console.error("No user, logging out.")
|
||||
this.setToken(null)
|
||||
}
|
||||
|
||||
@@ -68,16 +69,15 @@ export const useAuthStore = defineStore('auth', {
|
||||
},
|
||||
|
||||
logout() {
|
||||
opnFetch('logout', {method: 'POST'}).catch((error) => {
|
||||
})
|
||||
opnFetch("logout", { method: "POST" }).catch(() => {})
|
||||
|
||||
this.user = null
|
||||
this.setToken(null)
|
||||
},
|
||||
|
||||
async fetchOauthUrl(provider) {
|
||||
// async fetchOauthUrl() {
|
||||
// const {data} = await axios.post(`/api/oauth/${provider}`)
|
||||
// return data.url
|
||||
}
|
||||
}
|
||||
// },
|
||||
},
|
||||
})
|
||||
|
||||
14
client/stores/errors.js
vendored
14
client/stores/errors.js
vendored
@@ -1,15 +1,15 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { defineStore } from "pinia"
|
||||
|
||||
export const useErrorsStore = defineStore('errors', {
|
||||
export const useErrorsStore = defineStore("errors", {
|
||||
state: () => ({
|
||||
content: null
|
||||
content: null,
|
||||
}),
|
||||
actions: {
|
||||
set (error) {
|
||||
set(error) {
|
||||
this.content = error
|
||||
},
|
||||
clear () {
|
||||
clear() {
|
||||
this.content = null
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
35
client/stores/form_integrations.js
vendored
35
client/stores/form_integrations.js
vendored
@@ -1,13 +1,12 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {useContentStore} from "~/composables/stores/useContentStore.js";
|
||||
import integrationsList from '~/data/forms/integrations.json'
|
||||
import { defineStore } from "pinia"
|
||||
import { useContentStore } from "~/composables/stores/useContentStore.js"
|
||||
import integrationsList from "~/data/forms/integrations.json"
|
||||
|
||||
export const formIntegrationsEndpoint = '/open/forms/{formid}/integrations'
|
||||
|
||||
export const useFormIntegrationsStore = defineStore('form_integrations', () => {
|
||||
export const formIntegrationsEndpoint = "/open/forms/{formid}/integrations"
|
||||
|
||||
export const useFormIntegrationsStore = defineStore("form_integrations", () => {
|
||||
const contentStore = useContentStore()
|
||||
const integrations = ref(new Map)
|
||||
const integrations = ref(new Map())
|
||||
|
||||
const availableIntegrations = computed(() => {
|
||||
const user = useAuthStore().user
|
||||
@@ -18,7 +17,7 @@ export const useFormIntegrationsStore = defineStore('form_integrations', () => {
|
||||
enrichedIntegrations.set(key, {
|
||||
...integration,
|
||||
id: key,
|
||||
requires_subscription: !user.is_subscribed && integration.is_pro
|
||||
requires_subscription: !user.is_subscribed && integration.is_pro,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -26,29 +25,31 @@ export const useFormIntegrationsStore = defineStore('form_integrations', () => {
|
||||
})
|
||||
|
||||
const integrationsBySection = computed(() => {
|
||||
const groupedObject = {};
|
||||
const groupedObject = {}
|
||||
for (const [key, integration] of availableIntegrations.value.entries()) {
|
||||
const sectionName = integration.section_name;
|
||||
const sectionName = integration.section_name
|
||||
if (!groupedObject[sectionName]) {
|
||||
groupedObject[sectionName] = {};
|
||||
groupedObject[sectionName] = {}
|
||||
}
|
||||
groupedObject[sectionName][key] = integration
|
||||
}
|
||||
return groupedObject;
|
||||
return groupedObject
|
||||
})
|
||||
|
||||
const fetchFormIntegrations = (formId) => {
|
||||
contentStore.resetState()
|
||||
contentStore.startLoading()
|
||||
return useOpnApi(formIntegrationsEndpoint.replace('{formid}', formId)).then((response) => {
|
||||
contentStore.save(response.data.value)
|
||||
contentStore.stopLoading()
|
||||
})
|
||||
return useOpnApi(formIntegrationsEndpoint.replace("{formid}", formId)).then(
|
||||
(response) => {
|
||||
contentStore.save(response.data.value)
|
||||
contentStore.stopLoading()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
const getAllByFormId = (formId) => {
|
||||
return contentStore.getAll.value.filter((item) => {
|
||||
return (item.form_id) ? item.form_id === formId : false
|
||||
return item.form_id ? item.form_id === formId : false
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
41
client/stores/forms.js
vendored
41
client/stores/forms.js
vendored
@@ -1,18 +1,19 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {useContentStore} from "~/composables/stores/useContentStore.js";
|
||||
import { defineStore } from "pinia"
|
||||
import { useContentStore } from "~/composables/stores/useContentStore.js"
|
||||
|
||||
export const formsEndpoint = '/open/workspaces/{workspaceId}/forms'
|
||||
export const singleFormEndpoint = '/open/forms/{slug}'
|
||||
export const formsEndpoint = "/open/workspaces/{workspaceId}/forms"
|
||||
export const singleFormEndpoint = "/open/forms/{slug}"
|
||||
|
||||
export const useFormsStore = defineStore('forms', () => {
|
||||
|
||||
const contentStore = useContentStore('slug')
|
||||
export const useFormsStore = defineStore("forms", () => {
|
||||
const contentStore = useContentStore("slug")
|
||||
const allLoaded = ref(false)
|
||||
const currentPage = ref(1)
|
||||
|
||||
const loadAll = (workspaceId) => {
|
||||
contentStore.startLoading()
|
||||
return opnFetch(formsEndpoint.replace('{workspaceId}', workspaceId),{query: {page: currentPage.value}})
|
||||
return opnFetch(formsEndpoint.replace("{workspaceId}", workspaceId), {
|
||||
query: { page: currentPage.value },
|
||||
})
|
||||
.then((response) => {
|
||||
if (currentPage.value === 1) {
|
||||
contentStore.resetState()
|
||||
@@ -28,7 +29,8 @@ export const useFormsStore = defineStore('forms', () => {
|
||||
contentStore.stopLoading()
|
||||
currentPage.value = 1
|
||||
}
|
||||
}).catch((error) => {
|
||||
})
|
||||
.catch((error) => {
|
||||
contentStore.stopLoading()
|
||||
currentPage.value = 1
|
||||
throw error
|
||||
@@ -36,8 +38,8 @@ export const useFormsStore = defineStore('forms', () => {
|
||||
}
|
||||
const loadForm = (slug) => {
|
||||
contentStore.startLoading()
|
||||
return opnFetch(singleFormEndpoint.replace('{slug}', slug))
|
||||
.then(response => {
|
||||
return opnFetch(singleFormEndpoint.replace("{slug}", slug))
|
||||
.then((response) => {
|
||||
contentStore.save(response)
|
||||
})
|
||||
.finally(() => {
|
||||
@@ -47,10 +49,11 @@ export const useFormsStore = defineStore('forms', () => {
|
||||
|
||||
const load = (workspaceId, slug) => {
|
||||
contentStore.startLoading()
|
||||
return opnFetch(formsEndpoint.replace('{workspaceId}', workspaceId) + '/' + slug)
|
||||
.finally(() => {
|
||||
contentStore.stopLoading()
|
||||
})
|
||||
return opnFetch(
|
||||
formsEndpoint.replace("{workspaceId}", workspaceId) + "/" + slug,
|
||||
).finally(() => {
|
||||
contentStore.stopLoading()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,20 +61,20 @@ export const useFormsStore = defineStore('forms', () => {
|
||||
*/
|
||||
const publicLoad = (slug) => {
|
||||
contentStore.startLoading()
|
||||
return useOpnApi('/forms/' + slug)
|
||||
return useOpnApi("/forms/" + slug)
|
||||
}
|
||||
|
||||
const publicFetch = (slug) => {
|
||||
contentStore.startLoading()
|
||||
return opnFetch('/forms/' + slug)
|
||||
return opnFetch("/forms/" + slug)
|
||||
}
|
||||
|
||||
const allTags = computed(() => {
|
||||
let tags = []
|
||||
contentStore.getAll.value.forEach((form) => {
|
||||
if (form.tags && form.tags.length) {
|
||||
if (typeof form.tags === 'string' || form.tags instanceof String ) {
|
||||
tags = tags.concat(form.tags.split(','))
|
||||
if (typeof form.tags === "string" || form.tags instanceof String) {
|
||||
tags = tags.concat(form.tags.split(","))
|
||||
} else if (Array.isArray(form.tags)) {
|
||||
tags = tags.concat(form.tags)
|
||||
}
|
||||
|
||||
15
client/stores/notion_pages.js
vendored
15
client/stores/notion_pages.js
vendored
@@ -1,8 +1,7 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {useContentStore} from "~/composables/stores/useContentStore.js";
|
||||
import opnformConfig from "~/opnform.config.js";
|
||||
export const useNotionPagesStore = defineStore('notion_pages', () => {
|
||||
|
||||
import { defineStore } from "pinia"
|
||||
import { useContentStore } from "~/composables/stores/useContentStore.js"
|
||||
import opnformConfig from "~/opnform.config.js"
|
||||
export const useNotionPagesStore = defineStore("notion_pages", () => {
|
||||
const contentStore = useContentStore()
|
||||
|
||||
const load = (pageId) => {
|
||||
@@ -10,9 +9,9 @@ export const useNotionPagesStore = defineStore('notion_pages', () => {
|
||||
|
||||
const apiUrl = opnformConfig.notion.worker
|
||||
return useFetch(`${apiUrl}/page/${pageId}`)
|
||||
.then(({data, error})=> {
|
||||
.then(({ data }) => {
|
||||
const val = data.value
|
||||
val['id'] = pageId
|
||||
val["id"] = pageId
|
||||
contentStore.save(val)
|
||||
})
|
||||
.finally(() => {
|
||||
@@ -22,6 +21,6 @@ export const useNotionPagesStore = defineStore('notion_pages', () => {
|
||||
|
||||
return {
|
||||
...contentStore,
|
||||
load
|
||||
load,
|
||||
}
|
||||
})
|
||||
|
||||
12
client/stores/records.js
vendored
12
client/stores/records.js
vendored
@@ -1,14 +1,13 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { useContentStore } from '~/composables/stores/useContentStore'
|
||||
import { defineStore } from "pinia"
|
||||
import { useContentStore } from "~/composables/stores/useContentStore"
|
||||
|
||||
/**
|
||||
* Loads records from database
|
||||
*/
|
||||
export const useRecordsStore = defineStore('records', ()=>{
|
||||
|
||||
export const useRecordsStore = defineStore("records", () => {
|
||||
const contentStore = useContentStore()
|
||||
|
||||
const loadRecord = (request)=> {
|
||||
const loadRecord = (request) => {
|
||||
contentStore.resetState()
|
||||
contentStore.startLoading()
|
||||
return request.then((data) => {
|
||||
@@ -16,6 +15,5 @@ export const useRecordsStore = defineStore('records', ()=>{
|
||||
contentStore.stopLoading()
|
||||
})
|
||||
}
|
||||
return {...contentStore, loadRecord}
|
||||
|
||||
return { ...contentStore, loadRecord }
|
||||
})
|
||||
|
||||
39
client/stores/templates.js
vendored
39
client/stores/templates.js
vendored
@@ -1,28 +1,31 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {useContentStore} from "~/composables/stores/useContentStore.js";
|
||||
import { defineStore } from "pinia"
|
||||
import { useContentStore } from "~/composables/stores/useContentStore.js"
|
||||
import templateTypes from "~/data/forms/templates/types.json"
|
||||
import industryTypes from "~/data/forms/templates/industries.json"
|
||||
|
||||
const templatesEndpoint = 'templates'
|
||||
export const useTemplatesStore = defineStore('templates', () => {
|
||||
|
||||
const contentStore = useContentStore('slug')
|
||||
const templatesEndpoint = "templates"
|
||||
export const useTemplatesStore = defineStore("templates", () => {
|
||||
const contentStore = useContentStore("slug")
|
||||
|
||||
const allLoaded = ref(false)
|
||||
const industries = ref(new Map)
|
||||
const types = ref(new Map)
|
||||
const industries = ref(new Map())
|
||||
const types = ref(new Map())
|
||||
|
||||
const getTemplateTypes = (slugs) => {
|
||||
if (!slugs) return []
|
||||
return slugs.map((slug) => {
|
||||
return types.value.get(slug)
|
||||
}).filter((item) => item !== undefined)
|
||||
return slugs
|
||||
.map((slug) => {
|
||||
return types.value.get(slug)
|
||||
})
|
||||
.filter((item) => item !== undefined)
|
||||
}
|
||||
const getTemplateIndustries = (slugs) => {
|
||||
if (!slugs) return []
|
||||
return slugs.map((slug) => {
|
||||
return industries.value.get(slug)
|
||||
}).filter((item) => item !== undefined)
|
||||
return slugs
|
||||
.map((slug) => {
|
||||
return industries.value.get(slug)
|
||||
})
|
||||
.filter((item) => item !== undefined)
|
||||
}
|
||||
|
||||
const initTypesAndIndustries = () => {
|
||||
@@ -41,23 +44,23 @@ export const useTemplatesStore = defineStore('templates', () => {
|
||||
allLoaded,
|
||||
getTemplateTypes,
|
||||
getTemplateIndustries,
|
||||
initTypesAndIndustries
|
||||
initTypesAndIndustries,
|
||||
}
|
||||
})
|
||||
|
||||
export const fetchTemplate = (slug, options = {}) => {
|
||||
return useOpnApi(templatesEndpoint + '/' + slug, options)
|
||||
return useOpnApi(templatesEndpoint + "/" + slug, options)
|
||||
}
|
||||
|
||||
export const fetchAllTemplates = (options = {}) => {
|
||||
return useOpnApi(templatesEndpoint, options)
|
||||
}
|
||||
|
||||
export const loadAllTemplates = async (store, options={}) => {
|
||||
export const loadAllTemplates = async (store, options = {}) => {
|
||||
if (!store.allLoaded) {
|
||||
store.startLoading()
|
||||
store.initTypesAndIndustries()
|
||||
const {data,error} = await fetchAllTemplates(options)
|
||||
const { data } = await fetchAllTemplates(options)
|
||||
store.set(data.value)
|
||||
store.stopLoading()
|
||||
store.allLoaded = true
|
||||
|
||||
36
client/stores/working_form.js
vendored
36
client/stores/working_form.js
vendored
@@ -1,54 +1,58 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { defineStore } from "pinia"
|
||||
|
||||
export const useWorkingFormStore = defineStore('working_form', {
|
||||
export const useWorkingFormStore = defineStore("working_form", {
|
||||
state: () => ({
|
||||
content: null,
|
||||
|
||||
// Field being edited
|
||||
selectedFieldIndex: null,
|
||||
showEditFieldSidebar: null,
|
||||
showAddFieldSidebar: null
|
||||
showAddFieldSidebar: null,
|
||||
}),
|
||||
actions: {
|
||||
set (form) {
|
||||
set(form) {
|
||||
this.content = form
|
||||
},
|
||||
setProperties (properties) {
|
||||
setProperties(properties) {
|
||||
this.content.properties = [...properties]
|
||||
},
|
||||
openSettingsForField (index) {
|
||||
openSettingsForField(index) {
|
||||
// If field is passed, compute index
|
||||
if (typeof index === 'object') {
|
||||
index = this.content.properties.findIndex(prop => prop.id === index.id)
|
||||
if (typeof index === "object") {
|
||||
index = this.content.properties.findIndex(
|
||||
(prop) => prop.id === index.id,
|
||||
)
|
||||
}
|
||||
this.selectedFieldIndex = index
|
||||
this.showEditFieldSidebar = true
|
||||
this.showAddFieldSidebar = false
|
||||
},
|
||||
closeEditFieldSidebar () {
|
||||
closeEditFieldSidebar() {
|
||||
this.selectedFieldIndex = null
|
||||
this.showEditFieldSidebar = false
|
||||
this.showAddFieldSidebar = false
|
||||
},
|
||||
openAddFieldSidebar (index) {
|
||||
openAddFieldSidebar(index) {
|
||||
// If field is passed, compute index
|
||||
if (index !== null && typeof index === 'object') {
|
||||
index = this.content.properties.findIndex(prop => prop.id === index.id)
|
||||
if (index !== null && typeof index === "object") {
|
||||
index = this.content.properties.findIndex(
|
||||
(prop) => prop.id === index.id,
|
||||
)
|
||||
}
|
||||
this.selectedFieldIndex = index
|
||||
this.showAddFieldSidebar = true
|
||||
this.showEditFieldSidebar = false
|
||||
},
|
||||
closeAddFieldSidebar () {
|
||||
closeAddFieldSidebar() {
|
||||
this.selectedFieldIndex = null
|
||||
this.showAddFieldSidebar = false
|
||||
this.showEditFieldSidebar = false
|
||||
},
|
||||
reset () {
|
||||
reset() {
|
||||
this.content = null
|
||||
this.selectedFieldIndex = null
|
||||
this.showEditFieldSidebar = null
|
||||
this.showAddFieldSidebar = null
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
22
client/stores/workspaces.js
vendored
22
client/stores/workspaces.js
vendored
@@ -1,12 +1,10 @@
|
||||
import {defineStore} from 'pinia'
|
||||
import {useStorage} from "@vueuse/core"
|
||||
import {useContentStore} from "~/composables/stores/useContentStore.js";
|
||||
import { defineStore } from "pinia"
|
||||
import { useContentStore } from "~/composables/stores/useContentStore.js"
|
||||
|
||||
export const workspaceEndpoint = 'open/workspaces/'
|
||||
export const workspaceEndpoint = "open/workspaces/"
|
||||
|
||||
export const useWorkspacesStore = defineStore('workspaces', () => {
|
||||
|
||||
const storedWorkspaceId = useCookie('currentWorkspace')
|
||||
export const useWorkspacesStore = defineStore("workspaces", () => {
|
||||
const storedWorkspaceId = useCookie("currentWorkspace")
|
||||
|
||||
const contentStore = useContentStore()
|
||||
const currentId = ref(storedWorkspaceId)
|
||||
@@ -21,13 +19,13 @@ export const useWorkspacesStore = defineStore('workspaces', () => {
|
||||
}
|
||||
|
||||
const set = (items) => {
|
||||
contentStore.content.value = new Map
|
||||
contentStore.content.value = new Map()
|
||||
save(items)
|
||||
}
|
||||
|
||||
const save = (items) => {
|
||||
contentStore.save(items)
|
||||
if ((getCurrent.value == null) && contentStore.length.value) {
|
||||
if (getCurrent.value == null && contentStore.length.value) {
|
||||
setCurrentId(items[0].id)
|
||||
}
|
||||
}
|
||||
@@ -35,7 +33,9 @@ export const useWorkspacesStore = defineStore('workspaces', () => {
|
||||
const remove = (itemId) => {
|
||||
contentStore.remove(itemId)
|
||||
if (currentId.value === itemId) {
|
||||
setCurrentId(contentStore.length.value > 0 ? contentStore.getAll.value[0].id : null)
|
||||
setCurrentId(
|
||||
contentStore.length.value > 0 ? contentStore.getAll.value[0].id : null,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ export const useWorkspacesStore = defineStore('workspaces', () => {
|
||||
setCurrentId,
|
||||
set,
|
||||
save,
|
||||
remove
|
||||
remove,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user