Add archive board
This commit is contained in:
@@ -71,7 +71,8 @@ const addButton = {
|
|||||||
const title = submitEvent.currentTarget.childNodes[0].value
|
const title = submitEvent.currentTarget.childNodes[0].value
|
||||||
store.dispatch('createBoard', {
|
store.dispatch('createBoard', {
|
||||||
title: title,
|
title: title,
|
||||||
color: '#000000'
|
hashedColor: '#000000',
|
||||||
|
color: '000000'
|
||||||
})
|
})
|
||||||
addButton.classes = []
|
addButton.classes = []
|
||||||
},
|
},
|
||||||
@@ -99,7 +100,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
loading: this.loading,
|
loading: this.loading,
|
||||||
items: defaultCategories
|
items: defaultCategories
|
||||||
.concat(this.$store.getters.boards.map(boardToMenuItem))
|
.concat(this.$store.getters.noneArchivedBoards.map(boardToMenuItem))
|
||||||
.concat([this.addButton])
|
.concat([this.addButton])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,32 +20,37 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const boardActions = [
|
import store from './../store/main'
|
||||||
{
|
|
||||||
action: () => {
|
function boardActions(board) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
action: () => {
|
||||||
|
},
|
||||||
|
icon: 'icon-edit',
|
||||||
|
text: t('deck', 'Edit board')
|
||||||
},
|
},
|
||||||
icon: 'icon-edit',
|
{
|
||||||
text: t('deck', 'Edit board')
|
action: function() {
|
||||||
},
|
store.dispatch('archiveBoard', board)
|
||||||
{
|
},
|
||||||
action: () => {
|
icon: 'icon-archive',
|
||||||
|
text: t('deck', 'Archive board')
|
||||||
},
|
},
|
||||||
icon: 'icon-archive',
|
{
|
||||||
text: t('deck', 'Archive board')
|
action: () => {
|
||||||
},
|
},
|
||||||
{
|
icon: 'icon-delete',
|
||||||
action: () => {
|
text: t('deck', 'Delete board')
|
||||||
},
|
},
|
||||||
icon: 'icon-delete',
|
{
|
||||||
text: t('deck', 'Delete board')
|
action: () => {
|
||||||
},
|
},
|
||||||
{
|
icon: 'icon-settings',
|
||||||
action: () => {
|
text: t('deck', 'Board details')
|
||||||
},
|
}
|
||||||
icon: 'icon-settings',
|
]
|
||||||
text: t('deck', 'Board details')
|
}
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps an API board to a menu item.
|
* Maps an API board to a menu item.
|
||||||
@@ -64,7 +69,8 @@ export const boardToMenuItem = board => {
|
|||||||
params: { id: board.id }
|
params: { id: board.id }
|
||||||
},
|
},
|
||||||
utils: {
|
utils: {
|
||||||
actions: boardActions
|
actions: boardActions(board)
|
||||||
}
|
},
|
||||||
|
board: board
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ import { translate, translatePlural } from 'nextcloud-server/dist/l10n'
|
|||||||
import { generateFilePath } from 'nextcloud-server/dist/router'
|
import { generateFilePath } from 'nextcloud-server/dist/router'
|
||||||
import VTooltip from 'v-tooltip'
|
import VTooltip from 'v-tooltip'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Board model
|
||||||
|
*
|
||||||
|
* @typedef {Object} Board
|
||||||
|
* @property {String} title
|
||||||
|
* @property {boolean} archived
|
||||||
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
__webpack_nonce__ = btoa(OC.requestToken)
|
__webpack_nonce__ = btoa(OC.requestToken)
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
|
|||||||
@@ -32,15 +32,36 @@ export class BoardApi {
|
|||||||
return OC.generateUrl(url)
|
return OC.generateUrl(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a board.
|
||||||
|
*
|
||||||
|
* @param {Board} board
|
||||||
|
* @return Promise
|
||||||
|
*/
|
||||||
|
updateBoard(board) {
|
||||||
|
return axios.put(this.url(`/boards/${board.id}`), board)
|
||||||
|
.then(
|
||||||
|
(response) => {
|
||||||
|
return Promise.resolve(response.data)
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
return Promise.reject(err)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.catch((err) => {
|
||||||
|
return Promise.reject(err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new board.
|
* Creates a new board.
|
||||||
*
|
*
|
||||||
* @param {{String title, String color}} boardData The board data with title and color in hex format, e.g. "#ff0000"
|
* @param {{String title, String color, String hashedColor}} boardData The board data to send.
|
||||||
|
* hashedColor is the color in hex format, e.g. "#ff0000"
|
||||||
|
* color is the same color without the "#"
|
||||||
* @return Promise
|
* @return Promise
|
||||||
*/
|
*/
|
||||||
createBoard(boardData) {
|
createBoard(boardData) {
|
||||||
boardData.color = boardData.color.substr(1)
|
|
||||||
|
|
||||||
return axios.post(this.url('/boards'), boardData)
|
return axios.post(this.url('/boards'), boardData)
|
||||||
.then(
|
.then(
|
||||||
(response) => {
|
(response) => {
|
||||||
|
|||||||
@@ -50,10 +50,15 @@ export default new Vuex.Store({
|
|||||||
boards: state => {
|
boards: state => {
|
||||||
return state.boards
|
return state.boards
|
||||||
},
|
},
|
||||||
|
noneArchivedBoards: state => {
|
||||||
|
return state.boards.filter(board => {
|
||||||
|
return board.archived === false
|
||||||
|
})
|
||||||
|
},
|
||||||
filteredBoards: state => {
|
filteredBoards: state => {
|
||||||
// filters the boards depending on the active filter
|
// filters the boards depending on the active filter
|
||||||
const boards = state.boards.filter(board => {
|
const boards = state.boards.filter(board => {
|
||||||
return state.boardFilter === BOARD_FILTERS.ALL
|
return (state.boardFilter === BOARD_FILTERS.ALL && board.archived === false)
|
||||||
|| (state.boardFilter === BOARD_FILTERS.ARCHIVED && board.archived === true)
|
|| (state.boardFilter === BOARD_FILTERS.ARCHIVED && board.archived === true)
|
||||||
|| (state.boardFilter === BOARD_FILTERS.SHARED && board.shared === 1)
|
|| (state.boardFilter === BOARD_FILTERS.SHARED && board.shared === 1)
|
||||||
})
|
})
|
||||||
@@ -62,7 +67,15 @@ export default new Vuex.Store({
|
|||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
addBoard(state, board) {
|
addBoard(state, board) {
|
||||||
state.boards.push(board)
|
const indexExisting = state.boards.findIndex((b) => {
|
||||||
|
return board.id === b.id
|
||||||
|
})
|
||||||
|
|
||||||
|
if (indexExisting > -1) {
|
||||||
|
Vue.set(state.boards, indexExisting, board)
|
||||||
|
} else {
|
||||||
|
state.boards.push(board)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
toggleNav(state) {
|
toggleNav(state) {
|
||||||
state.navShown = !state.navShown
|
state.navShown = !state.navShown
|
||||||
@@ -81,6 +94,19 @@ export default new Vuex.Store({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
/**
|
||||||
|
* @param commit
|
||||||
|
* @param state
|
||||||
|
* @param {Board} board
|
||||||
|
*/
|
||||||
|
archiveBoard({ commit }, board) {
|
||||||
|
const boardCopy = JSON.parse(JSON.stringify(board))
|
||||||
|
boardCopy.archived = true
|
||||||
|
apiClient.updateBoard(boardCopy)
|
||||||
|
.then((board) => {
|
||||||
|
commit('addBoard', board)
|
||||||
|
})
|
||||||
|
},
|
||||||
createBoard({ commit }, boardData) {
|
createBoard({ commit }, boardData) {
|
||||||
apiClient.createBoard(boardData)
|
apiClient.createBoard(boardData)
|
||||||
.then((board) => {
|
.then((board) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user