replace Vue.set with direct setting

Signed-off-by: grnd-alt <github@belakkaf.net>
This commit is contained in:
grnd-alt
2025-05-12 11:10:40 +02:00
parent 30e74a7919
commit f4acf38035
13 changed files with 62 additions and 88 deletions

15
package-lock.json generated
View File

@@ -23,7 +23,6 @@
"@nextcloud/notify_push": "^1.3.0", "@nextcloud/notify_push": "^1.3.0",
"@nextcloud/router": "^3.0.1", "@nextcloud/router": "^3.0.1",
"@nextcloud/vue": "^9.0.0-alpha.7", "@nextcloud/vue": "^9.0.0-alpha.7",
"@vue/compat": "^3.5.13",
"@vue/compiler-sfc": "^3.5.13", "@vue/compiler-sfc": "^3.5.13",
"@vue/vue3-jest": "^29.2.6", "@vue/vue3-jest": "^29.2.6",
"@vueuse/core": "^13.1.0", "@vueuse/core": "^13.1.0",
@@ -5753,20 +5752,6 @@
"integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==", "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==",
"license": "ISC" "license": "ISC"
}, },
"node_modules/@vue/compat": {
"version": "3.5.13",
"resolved": "https://registry.npmjs.org/@vue/compat/-/compat-3.5.13.tgz",
"integrity": "sha512-Q3xRdTPN4l+kddxU98REyUBgvc0meAo9CefCWE2lW8Fg3dyPn3vSCce52b338ihrJAx1RQQhO5wMWhJ/PAKUpA==",
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.25.3",
"estree-walker": "^2.0.2",
"source-map-js": "^1.2.0"
},
"peerDependencies": {
"vue": "3.5.13"
}
},
"node_modules/@vue/compiler-core": { "node_modules/@vue/compiler-core": {
"version": "3.5.13", "version": "3.5.13",
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.13.tgz", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.13.tgz",

View File

@@ -44,7 +44,6 @@
"@nextcloud/notify_push": "^1.3.0", "@nextcloud/notify_push": "^1.3.0",
"@nextcloud/router": "^3.0.1", "@nextcloud/router": "^3.0.1",
"@nextcloud/vue": "^9.0.0-alpha.7", "@nextcloud/vue": "^9.0.0-alpha.7",
"@vue/compat": "^3.5.13",
"@vue/compiler-sfc": "^3.5.13", "@vue/compiler-sfc": "^3.5.13",
"@vue/vue3-jest": "^29.2.6", "@vue/vue3-jest": "^29.2.6",
"@vueuse/core": "^13.1.0", "@vueuse/core": "^13.1.0",

View File

@@ -260,7 +260,6 @@ export default {
this.$refs.shortcutModal?.focus() this.$refs.shortcutModal?.focus()
}, },
close() { close() {
console.log("HHHHH")
this.card = null this.card = null
this.selector = null this.selector = null
}, },

View File

@@ -94,7 +94,7 @@
non-drag-area-selector=".dragDisabled" non-drag-area-selector=".dragDisabled"
:drag-handle-selector="dragHandleSelector" :drag-handle-selector="dragHandleSelector"
data-dragscroll-enabled data-dragscroll-enabled
@should-accept-drop="canEdit" :should-accept-drop="() => canEdit"
@drag-start="draggingCard = true" @drag-start="draggingCard = true"
@drag-end="draggingCard = false" @drag-end="draggingCard = false"
@drop="($event) => onDropCard(stack.id, $event)"> @drop="($event) => onDropCard(stack.id, $event)">

View File

@@ -3,38 +3,34 @@
* SPDX-License-Identifier: AGPL-3.0-or-later * SPDX-License-Identifier: AGPL-3.0-or-later
*/ */
import Vue from 'vue'
import './../css/collections.css' import './../css/collections.css'
import FileSharingPicker from './views/FileSharingPicker.js' import FileSharingPicker from './views/FileSharingPicker.js'
import { buildSelector } from './helpers/selector.js' import { buildSelector } from './helpers/selector.js'
import './shared-init.js' import './shared-init.js'
Vue.prototype.t = t export function initCollections() {
Vue.prototype.n = n window.addEventListener('DOMContentLoaded', () => {
Vue.prototype.OC = OC if (OCA.Sharing && OCA.Sharing.ShareSearch) {
OCA.Sharing.ShareSearch.addNewResult(FileSharingPicker)
}
window.addEventListener('DOMContentLoaded', () => { window.OCP.Collaboration.registerType('deck', {
if (OCA.Sharing && OCA.Sharing.ShareSearch) { action: () => {
OCA.Sharing.ShareSearch.addNewResult(FileSharingPicker) const BoardSelector = () => import('./BoardSelector.vue')
} return buildSelector(BoardSelector)
},
typeString: t('deck', 'Link to a board'),
typeIconClass: 'icon-deck',
})
window.OCP.Collaboration.registerType('deck', { window.OCP.Collaboration.registerType('deck-card', {
action: () => { action: () => {
const BoardSelector = () => import('./BoardSelector.vue') const CardSelector = () => import('./CardSelector.vue')
return buildSelector(BoardSelector) return buildSelector(CardSelector)
}, },
typeString: t('deck', 'Link to a board'), typeString: t('deck', 'Link to a card'),
typeIconClass: 'icon-deck', typeIconClass: 'icon-deck',
})
}) })
}
window.OCP.Collaboration.registerType('deck-card', {
action: () => {
const CardSelector = () => import('./CardSelector.vue')
return buildSelector(CardSelector)
},
typeString: t('deck', 'Link to a card'),
typeIconClass: 'icon-deck',
})
})

View File

@@ -13,9 +13,7 @@ import ClickOutside from 'vue-click-outside'
import './shared-init.js' import './shared-init.js'
import './models/index.js' import './models/index.js'
import './sessions.js' import './sessions.js'
import { configureCompat } from '@vue/compat' import { initCollections } from './init-collections.js'
configureCompat({ MODE: 3, INSTANCE_SCOPED_SLOTS: false, ATTR_ENUMERATED_COERCION: true, INSTANCE_EVENT_EMITTER: true, OPTIONS_BEFORE_DESTROY: true, CUSTOM_DIR: true, OPTIONS_DESTROYED: true, INSTANCE_LISTENERS: true, GLOBAL_SET: true })
// the server snap.js conflicts with vertical scrolling so we disable it // the server snap.js conflicts with vertical scrolling so we disable it
document.body.setAttribute('data-snap-ignore', 'true') document.body.setAttribute('data-snap-ignore', 'true')
@@ -24,6 +22,9 @@ const app = createApp(App)
app.config.globalProperties.t = translate app.config.globalProperties.t = translate
app.config.globalProperties.n = translatePlural app.config.globalProperties.n = translatePlural
app.config.globalProperties.OC = OC
initCollections({ t, n, OC })
app.directive('click-outside', ClickOutside) app.directive('click-outside', ClickOutside)

View File

@@ -4,7 +4,6 @@
*/ */
import { AttachmentApi } from './../services/AttachmentApi.js' import { AttachmentApi } from './../services/AttachmentApi.js'
import Vue from 'vue'
const apiClient = new AttachmentApi() const apiClient = new AttachmentApi()
@@ -24,20 +23,20 @@ export default {
mutations: { mutations: {
createAttachment(state, { cardId, attachment }) { createAttachment(state, { cardId, attachment }) {
if (typeof state.attachments[cardId] === 'undefined') { if (typeof state.attachments[cardId] === 'undefined') {
Vue.set(state.attachments, cardId, [attachment]) state.attachments[cardId] = [attachment]
} else { } else {
state.attachments[cardId].push(attachment) state.attachments[cardId].push(attachment)
} }
}, },
createAttachments(state, { cardId, attachments }) { createAttachments(state, { cardId, attachments }) {
Vue.set(state.attachments, cardId, attachments) state.attachments[cardId] = attachments
}, },
updateAttachment(state, { cardId, attachment }) { updateAttachment(state, { cardId, attachment }) {
const existingIndex = state.attachments[attachment.cardId].findIndex(a => a.id === attachment.id && a.type === attachment.type) const existingIndex = state.attachments[attachment.cardId].findIndex(a => a.id === attachment.id && a.type === attachment.type)
if (existingIndex !== -1) { if (existingIndex !== -1) {
Vue.set(state.attachments[cardId], existingIndex, attachment) state.attachments[cardId][existingIndex] = attachment
} }
}, },

View File

@@ -5,7 +5,6 @@
import { CardApi } from './../services/CardApi.js' import { CardApi } from './../services/CardApi.js'
import moment from 'moment' import moment from 'moment'
import Vue from 'vue'
const apiClient = new CardApi() const apiClient = new CardApi()
@@ -180,6 +179,7 @@ export default {
.sort((a, b) => a.order - b.order || a.createdAt - b.createdAt) .sort((a, b) => a.order - b.order || a.createdAt - b.createdAt)
}, },
cardById: state => (id) => { cardById: state => (id) => {
alert('cardById')
return state.cards.find((card) => card.id === id) return state.cards.find((card) => card.id === id)
}, },
}, },
@@ -190,7 +190,7 @@ export default {
const existingIndex = state.cards.findIndex(_card => _card.id === card.id) const existingIndex = state.cards.findIndex(_card => _card.id === card.id)
if (existingIndex !== -1) { if (existingIndex !== -1) {
const existingCard = state.cards.find(_card => _card.id === card.id) const existingCard = state.cards.find(_card => _card.id === card.id)
Vue.set(state.cards, existingIndex, Object.assign({}, existingCard, card)) state.cards[existingIndex] = { ...existingCard, ...card }
} else { } else {
state.cards.push(card) state.cards.push(card)
} }
@@ -204,15 +204,15 @@ export default {
updateCard(state, card) { updateCard(state, card) {
const existingIndex = state.cards.findIndex(_card => _card.id === card.id) const existingIndex = state.cards.findIndex(_card => _card.id === card.id)
if (existingIndex !== -1) { if (existingIndex !== -1) {
Vue.set(state.cards, existingIndex, Object.assign({}, state.cards[existingIndex], card)) state.cards[existingIndex] = { ...state.cards[existingIndex], ...card }
} }
}, },
updateCardsReorder(state, cards) { updateCardsReorder(state, cards) {
for (const newCard of cards) { for (const newCard of cards) {
const existingIndex = state.cards.findIndex(_card => _card.id === newCard.id) const existingIndex = state.cards.findIndex(_card => _card.id === newCard.id)
if (existingIndex !== -1) { if (existingIndex !== -1) {
Vue.set(state.cards[existingIndex], 'order', newCard.order) state.cards[existingIndex].order = newCard.order
Vue.set(state.cards[existingIndex], 'stackId', newCard.stackId) state.cards[existingIndex].stackId = newCard.stackId
} }
} }
}, },
@@ -234,26 +234,26 @@ export default {
updateCardProperty(state, { card, property }) { updateCardProperty(state, { card, property }) {
const existingIndex = state.cards.findIndex(_card => _card.id === card.id) const existingIndex = state.cards.findIndex(_card => _card.id === card.id)
if (existingIndex !== -1) { if (existingIndex !== -1) {
Vue.set(state.cards[existingIndex], property, card[property]) state.cards[existingIndex][property] = card[property]
Vue.set(state.cards[existingIndex], 'lastModified', Date.now() / 1000) state.cards[existingIndex].lastModifiedBy = Date.now() / 1000
} }
}, },
cardSetAttachmentCount(state, { cardId, count }) { cardSetAttachmentCount(state, { cardId, count }) {
const existingIndex = state.cards.findIndex(_card => _card.id === cardId) const existingIndex = state.cards.findIndex(_card => _card.id === cardId)
if (existingIndex !== -1) { if (existingIndex !== -1) {
Vue.set(state.cards[existingIndex], 'attachmentCount', count) state.cards[existingIndex].attachmentCount = count
} }
}, },
cardIncreaseAttachmentCount(state, cardId) { cardIncreaseAttachmentCount(state, cardId) {
const existingIndex = state.cards.findIndex(_card => _card.id === cardId) const existingIndex = state.cards.findIndex(_card => _card.id === cardId)
if (existingIndex !== -1) { if (existingIndex !== -1) {
Vue.set(state.cards[existingIndex], 'attachmentCount', state.cards[existingIndex].attachmentCount + 1) state.cards[existingIndex].attachmentCount = state.cards[existingIndex].attachmentCount + 1
} }
}, },
cardDecreaseAttachmentCount(state, cardId) { cardDecreaseAttachmentCount(state, cardId) {
const existingIndex = state.cards.findIndex(_card => _card.id === cardId) const existingIndex = state.cards.findIndex(_card => _card.id === cardId)
if (existingIndex !== -1) { if (existingIndex !== -1) {
Vue.set(state.cards[existingIndex], 'attachmentCount', state.cards[existingIndex].attachmentCount - 1) state.cards[existingIndex].attachmentCount = state.cards[existingIndex].attachmentCount - 1
} }
}, },
addNewCard(state, card) { addNewCard(state, card) {
@@ -344,6 +344,7 @@ export default {
commit('removeUserFromCard', user) commit('removeUserFromCard', user)
}, },
async addLabel({ commit }, data) { async addLabel({ commit }, data) {
alert('hello world')
await apiClient.assignLabelToCard(data) await apiClient.assignLabelToCard(data)
commit('updateCardProperty', { property: 'labels', card: data.card }) commit('updateCardProperty', { property: 'labels', card: data.card })
}, },

View File

@@ -34,10 +34,10 @@ export default {
}, },
addComments(state, { comments, cardId }) { addComments(state, { comments, cardId }) {
if (state.comments[cardId] === undefined) { if (state.comments[cardId] === undefined) {
Vue.set(state.comments, cardId, { state.comments[cardId] = {
hasMore: comments.length > 0, hasMore: comments.length >= 0,
comments: [...comments], comments: [...comments],
}) }
} else { } else {
const newComments = comments.filter((comment) => { const newComments = comments.filter((comment) => {
return state.comments[cardId].comments.findIndex((item) => item.id === comment.id) === -1 return state.comments[cardId].comments.findIndex((item) => item.id === comment.id) === -1
@@ -59,11 +59,11 @@ export default {
}, },
markCommentsAsRead(state, cardId) { markCommentsAsRead(state, cardId) {
state.comments[cardId].comments.forEach(_comment => { state.comments[cardId].comments.forEach(_comment => {
Vue.set(_comment, 'isUnread', false) _comment.isUnread = false
}) })
}, },
setReplyTo(state, comment) { setReplyTo(state, comment) {
Vue.set(state, 'replyTo', comment) state.replyTo = comment
}, },
}, },
actions: { actions: {

View File

@@ -6,7 +6,6 @@
import 'url-search-params-polyfill' import 'url-search-params-polyfill'
import { loadState } from '@nextcloud/initial-state' import { loadState } from '@nextcloud/initial-state'
import Vue from 'vue'
import { createStore } from 'vuex' import { createStore } from 'vuex'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { generateOcsUrl, generateUrl } from '@nextcloud/router' import { generateOcsUrl, generateUrl } from '@nextcloud/router'
@@ -129,7 +128,7 @@ const store = createStore({
}, },
mutations: { mutations: {
setFullApp(state, isFullApp) { setFullApp(state, isFullApp) {
Vue.set(state, 'isFullApp', isFullApp) state.isFullApp = isFullApp
}, },
setHasCardSaveError(state, hasCardSaveError) { setHasCardSaveError(state, hasCardSaveError) {
Vue.set(state, 'hasCardSaveError', hasCardSaveError) Vue.set(state, 'hasCardSaveError', hasCardSaveError)
@@ -144,11 +143,11 @@ const store = createStore({
}) })
if (indexExisting > -1) { if (indexExisting > -1) {
Vue.set(state.boards[indexExisting].settings, configKey, value) state.boards[indexExisting].settings[configKey] = value
} }
break break
default: default:
Vue.set(state.config, key, value) state.config[key] = value
} }
}, },
setSearchQuery(state, searchQuery) { setSearchQuery(state, searchQuery) {
@@ -161,7 +160,7 @@ const store = createStore({
Object.keys(filter).forEach((key) => { Object.keys(filter).forEach((key) => {
switch (key) { switch (key) {
case 'due': case 'due':
Vue.set(state.filter, key, filter.due) state.filter[key] = filter.due
break break
default: default:
filter[key].forEach((item) => { filter[key].forEach((item) => {
@@ -188,7 +187,7 @@ const store = createStore({
}) })
if (indexExisting > -1) { if (indexExisting > -1) {
Vue.set(state.boards, indexExisting, board) state.boards[indexExisting] = board
} else { } else {
state.boards.push(board) state.boards.push(board)
} }
@@ -200,7 +199,7 @@ const store = createStore({
}) })
if (indexExisting > -1) { if (indexExisting > -1) {
Vue.set(state.boards, indexExisting, board) state.boards[indexExisting] = board
} else { } else {
state.boards.push(board) state.boards.push(board)
} }
@@ -233,7 +232,7 @@ const store = createStore({
state.boards = boards state.boards = boards
}, },
setSharees(state, shareesUsersAndGroups) { setSharees(state, shareesUsersAndGroups) {
Vue.set(state, 'sharees', shareesUsersAndGroups.exact.users) state.sharees = shareesUsersAndGroups.exact.users
state.sharees.push(...shareesUsersAndGroups.exact.groups) state.sharees.push(...shareesUsersAndGroups.exact.groups)
state.sharees.push(...shareesUsersAndGroups.exact.circles) state.sharees.push(...shareesUsersAndGroups.exact.circles)
@@ -283,7 +282,7 @@ const store = createStore({
updateAclFromCurrentBoard(state, acl) { updateAclFromCurrentBoard(state, acl) {
for (const acl_ in state.currentBoard.acl) { for (const acl_ in state.currentBoard.acl) {
if (state.currentBoard.acl[acl_].participant.uid === acl.participant.uid) { if (state.currentBoard.acl[acl_].participant.uid === acl.participant.uid) {
Vue.set(state.currentBoard.acl, acl_, acl) state.currentBoard.acl[acl_] = acl
break break
} }
} }
@@ -299,7 +298,7 @@ const store = createStore({
} }
if (removeIndex > -1) { if (removeIndex > -1) {
Vue.delete(state.currentBoard.acl, removeIndex) state.currentBoard.acl.splice(removeIndex, 1)
} }
}, },
TOGGLE_SHORTCUT_LOCK(state, lock) { TOGGLE_SHORTCUT_LOCK(state, lock) {

View File

@@ -3,20 +3,18 @@
* SPDX-License-Identifier: AGPL-3.0-or-later * SPDX-License-Identifier: AGPL-3.0-or-later
*/ */
import Vue from 'vue' import { createStore } from 'vuex/dist/vuex.cjs.js'
import Vuex from 'vuex'
import { OverviewApi } from '../services/OverviewApi.js' import { OverviewApi } from '../services/OverviewApi.js'
Vue.use(Vuex)
const apiClient = new OverviewApi() const apiClient = new OverviewApi()
export default { export default createStore({
state: { state: {
assignedCards: [], assignedCards: [],
loading: false, loading: false,
}, },
getters: { getters: {
assignedCardsDashboard: state => { assignedCardsDashboard(state) {
return state.assignedCards return () => state.assignedCards
}, },
}, },
mutations: { mutations: {
@@ -46,4 +44,4 @@ export default {
return promise return promise
}, },
}, },
} })

View File

@@ -3,7 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later * SPDX-License-Identifier: AGPL-3.0-or-later
*/ */
import Vue from 'vue'
import { StackApi } from './../services/StackApi.js' import { StackApi } from './../services/StackApi.js'
import applyOrderToArray from './../helpers/applyOrderToArray.js' import applyOrderToArray from './../helpers/applyOrderToArray.js'
@@ -26,7 +25,7 @@ export default {
const existingIndex = state.stacks.findIndex(_stack => _stack.id === stack.id) const existingIndex = state.stacks.findIndex(_stack => _stack.id === stack.id)
if (existingIndex !== -1) { if (existingIndex !== -1) {
const existingStack = state.stacks.find(_stack => _stack.id === stack.id) const existingStack = state.stacks.find(_stack => _stack.id === stack.id)
Vue.set(state.stacks, existingIndex, Object.assign({}, existingStack, stack)) state.stacks[existingIndex] = { ...existingStack, ...stack }
} else { } else {
state.stacks.push(stack) state.stacks.push(stack)
} }

View File

@@ -7,7 +7,7 @@ const isDevServer = process.env.WEBPACK_SERVE
webpackConfig.entry = { webpackConfig.entry = {
...webpackConfig.entry, ...webpackConfig.entry,
collections: path.join(__dirname, 'src', 'init-collections.js'), // collections: path.join(__dirname, 'src', 'init-collections.js'),
dashboard: path.join(__dirname, 'src', 'init-dashboard.js'), dashboard: path.join(__dirname, 'src', 'init-dashboard.js'),
calendar: path.join(__dirname, 'src', 'init-calendar.js'), calendar: path.join(__dirname, 'src', 'init-calendar.js'),
talk: path.join(__dirname, 'src', 'init-talk.js'), talk: path.join(__dirname, 'src', 'init-talk.js'),
@@ -30,7 +30,5 @@ if (isDevServer) {
modules: true, modules: true,
} }
} }
// Workaround for https://github.com/nextcloud/webpack-vue-config/pull/432 causing problems with nextcloud-vue-collections
webpackConfig.resolve.alias = { vue: '@vue/compat' }
module.exports = webpackConfig module.exports = webpackConfig