1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-11-27 08:31:20 +02:00

eslint fixes

This commit is contained in:
Chen-I Lim 2020-10-21 19:54:21 -07:00
parent d2cb5c9b1b
commit 3516e6b26c
5 changed files with 43 additions and 33 deletions

View File

@ -6,7 +6,7 @@ import {OctoUtils} from './octoUtils'
import {Utils} from './utils'
class CsvExporter {
static exportTableCsv(boardTree: BoardTree, view?: BoardView) {
static exportTableCsv(boardTree: BoardTree, view?: BoardView): void {
const {activeView} = boardTree
const viewToExport = view ?? activeView

View File

@ -9,7 +9,7 @@ class FilterClause {
condition: FilterCondition
values: string[]
static filterConditionDisplayString(filterCondition: FilterCondition) {
static filterConditionDisplayString(filterCondition: FilterCondition): string {
switch (filterCondition) {
case 'includes': return 'includes'
case 'notIncludes': return "doesn't include"
@ -28,7 +28,7 @@ class FilterClause {
this.values = o.values?.slice() || []
}
isEqual(o: FilterClause) {
isEqual(o: FilterClause): boolean {
return (
this.propertyId === o.propertyId &&
this.condition === o.condition &&

View File

@ -15,14 +15,16 @@ class FilterGroup {
constructor(o: any = {}) {
this.operation = o.operation || 'and'
this.filters = o.filters ?
o.filters.map((p: any) => {
if (o.filters) {
this.filters = o.filters.map((p: any) => {
if (FilterGroup.isAnInstanceOf(p)) {
return new FilterGroup(p)
}
return new FilterClause(p)
}) :
[]
})
} else {
this.filters = []
}
}
}

View File

@ -21,18 +21,18 @@ class Menu {
private menu?: HTMLElement
private subMenu?: Menu
private onBodyClick: any
private onBodyKeyDown: any
private onBodyClick?: () => void
private onBodyKeyDown?: (e: KeyboardEvent) => void
get view() {
get view(): HTMLElement {
return this.menu
}
get isVisible() {
get isVisible(): boolean {
return (this.menu !== undefined)
}
createMenuElement() {
createMenuElement(): HTMLElement {
const menu = Utils.htmlToElement('<div class="menu noselect"></div>')
const menuElement = menu.appendChild(Utils.htmlToElement('<div class="menu-options"></div>'))
this.appendMenuOptions(menuElement)
@ -40,10 +40,10 @@ class Menu {
return menu
}
appendMenuOptions(menuElement: HTMLElement) {
appendMenuOptions(menuElement: HTMLElement): void {
for (const option of this.options) {
if (option.type === 'separator') {
const optionElement = menuElement.appendChild(Utils.htmlToElement('<div class="menu-separator"></div>'))
menuElement.appendChild(Utils.htmlToElement('<div class="menu-separator"></div>'))
} else {
const optionElement = menuElement.appendChild(Utils.htmlToElement('<div class="menu-option"></div>'))
optionElement.id = option.id
@ -51,7 +51,7 @@ class Menu {
nameElement.innerText = option.name
if (option.type === 'submenu') {
optionElement.appendChild(Utils.htmlToElement('<div class="imageSubmenuTriangle" style="float: right;"></div>'))
optionElement.onmouseenter = (e) => {
optionElement.onmouseenter = () => {
// Calculate offset taking window scroll into account
const bodyRect = document.body.getBoundingClientRect()
const rect = optionElement.getBoundingClientRect()
@ -61,10 +61,21 @@ class Menu {
if (option.icon) {
let iconName: string
switch (option.icon) {
case 'checked': { iconName = 'imageMenuCheck'; break }
case 'sortUp': { iconName = 'imageMenuSortUp'; break }
case 'sortDown': { iconName = 'imageMenuSortDown'; break }
default: { Utils.assertFailure(`Unsupported menu icon: ${option.icon}`) }
case 'checked': {
iconName = 'imageMenuCheck'
break
}
case 'sortUp': {
iconName = 'imageMenuSortUp'
break
}
case 'sortDown': {
iconName = 'imageMenuSortDown'
break
}
default: {
Utils.assertFailure(`Unsupported menu icon: ${option.icon}`)
}
}
if (iconName) {
optionElement.appendChild(Utils.htmlToElement(`<div class="${iconName}" style="float: right;"></div>`))
@ -111,7 +122,7 @@ class Menu {
}
}
showAtElement(element: HTMLElement) {
showAtElement(element: HTMLElement): void {
const bodyRect = document.body.getBoundingClientRect()
const rect = element.getBoundingClientRect()
@ -119,7 +130,7 @@ class Menu {
this.showAt(rect.left - bodyRect.left, rect.bottom - bodyRect.top)
}
showAt(pageX: number, pageY: number) {
showAt(pageX: number, pageY: number): void {
if (this.menu) {
this.hide()
}
@ -129,13 +140,13 @@ class Menu {
document.body.appendChild(this.menu)
this.onBodyClick = (e: MouseEvent) => {
console.log('onBodyClick')
this.onBodyClick = () => {
Utils.log('onBodyClick')
this.hide()
}
this.onBodyKeyDown = (e: KeyboardEvent) => {
console.log(`onBodyKeyDown, target: ${e.target}`)
Utils.log(`onBodyKeyDown, target: ${e.target}`)
// Ignore keydown events on other elements
if (e.target !== document.body) {
@ -154,7 +165,7 @@ class Menu {
}, 20)
}
hide() {
hide(): void {
if (!this.menu) {
return
}
@ -171,15 +182,15 @@ class Menu {
this.onBodyKeyDown = undefined
}
hideSubMenu() {
hideSubMenu(): void {
if (this.subMenu) {
this.subMenu.hide()
this.subMenu = undefined
}
}
private showSubMenu(pageX: number, pageY: number, id: string) {
console.log(`showSubMenu: ${id}`)
private showSubMenu(pageX: number, pageY: number, id: string): void {
Utils.log(`showSubMenu: ${id}`)
const options: MenuOption[] = this.subMenuOptions.get(id) || []
if (this.subMenu) {

View File

@ -1,6 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {MutableBlock} from './blocks/block'
import {IBlock, MutableBlock} from './blocks/block'
import {Board, IPropertyOption, IPropertyTemplate, MutableBoard, PropertyType} from './blocks/board'
import {BoardView, ISortOption, MutableBoardView} from './blocks/boardView'
import {Card, MutableCard} from './blocks/card'
@ -9,7 +9,6 @@ import {IOrderedBlock, MutableOrderedBlock} from './blocks/orderedBlock'
import {BoardTree} from './viewModel/boardTree'
import {FilterGroup} from './filterGroup'
import octoClient from './octoClient'
import {IBlock} from './blocks/block'
import undoManager from './undomanager'
import {Utils} from './utils'
@ -161,7 +160,7 @@ class Mutator {
await this.updateBlocks(changedBlocks, oldBlocks, description)
}
async duplicatePropertyTemplate(boardTree: BoardTree, propertyId: string): Promise<IBlock[]> {
async duplicatePropertyTemplate(boardTree: BoardTree, propertyId: string) {
const {board, activeView} = boardTree
const oldBlocks: IBlock[] = [board]
@ -194,8 +193,6 @@ class Mutator {
}
await this.updateBlocks(changedBlocks, oldBlocks, description)
return changedBlocks
}
async changePropertyTemplateOrder(board: Board, template: IPropertyTemplate, destIndex: number) {