diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index c390e29e9..223b57d31 100644 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -11,6 +11,12 @@ "BoardComponent.no-property-title": "Items with an empty {property} property will go here. This column cannot be removed.", "BoardComponent.show": "Show", "Comment.delete": "Delete", + "FilterComponent.add-filter": "+ Add Filter", + "FilterComponent.delete": "Delete", + "FilterComponent.includes": "includes", + "FilterComponent.is-empty": "is empty", + "FilterComponent.is-not-empty": "is not empty", + "FilterComponent.not-includes": "doesn't include", "Sidebar.add-board": "+ Add Board", "Sidebar.delete-board": "Delete Board", "Sidebar.export-archive": "Export Archive", diff --git a/webapp/i18n/es.json b/webapp/i18n/es.json index a14ae0cf5..f9fac23dd 100644 --- a/webapp/i18n/es.json +++ b/webapp/i18n/es.json @@ -11,6 +11,12 @@ "BoardComponent.no-property-title": "Elementos sin la propiedad {property} irán aquí. Esta columna no se puede eliminar.", "BoardComponent.show": "Mostrar", "Comment.delete": "Borrar", + "FilterComponent.add-filter": "+ Añadir filtro", + "FilterComponent.delete": "Borrar", + "FilterComponent.includes": "incluye", + "FilterComponent.is-empty": "está vacío", + "FilterComponent.is-not-empty": "no está vacío", + "FilterComponent.not-includes": "no incluye", "Sidebar.add-board": "+ Añadir Panel", "Sidebar.delete-board": "Borrar Panel", "Sidebar.export-archive": "Exportar Archivo", diff --git a/webapp/src/components/filterComponent.tsx b/webapp/src/components/filterComponent.tsx index 60b0467e3..cfa96b232 100644 --- a/webapp/src/components/filterComponent.tsx +++ b/webapp/src/components/filterComponent.tsx @@ -1,6 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react' +import {FormattedMessage, IntlShape, injectIntl} from 'react-intl' import {IPropertyTemplate} from '../blocks/board' @@ -17,6 +18,7 @@ import Menu from '../widgets/menu' type Props = { boardTree: BoardTree onClose: () => void + intl: IntlShape } class FilterComponent extends React.Component { @@ -47,8 +49,25 @@ class FilterComponent extends React.Component { this.props.onClose() } - render(): JSX.Element { + private conditionClicked = (optionId: string, filter: FilterClause): void => { const {boardTree} = this.props + const {activeView: view} = boardTree + + const filterIndex = view.filter.filters.indexOf(filter) + Utils.assert(filterIndex >= 0, "Can't find filter") + + const filterGroup = new FilterGroup(view.filter) + const newFilter = filterGroup.filters[filterIndex] as FilterClause + + Utils.assert(newFilter, `No filter at index ${filterIndex}`) + if (newFilter.condition !== optionId) { + newFilter.condition = optionId as FilterCondition + mutator.changeViewFilter(view, filterGroup) + } + } + + render(): JSX.Element { + const {boardTree, intl} = this.props const {board, activeView} = boardTree // TODO: Handle FilterGroups (compound filter statements) @@ -92,10 +111,31 @@ class FilterComponent extends React.Component { />))} -
this.conditionClicked(e, filter)} - >{FilterClause.filterConditionDisplayString(filter.condition)}
+ +
{FilterClause.filterConditionDisplayString(filter.condition)}
+ + this.conditionClicked(id, filter)} + /> + this.conditionClicked(id, filter)} + /> + this.conditionClicked(id, filter)} + /> + this.conditionClicked(id, filter)} + /> + +
{ this.filterValue(filter, template) } @@ -103,7 +143,12 @@ class FilterComponent extends React.Component {
this.deleteClicked(filter)} - >Delete
+ > + + ) })} @@ -112,7 +157,12 @@ class FilterComponent extends React.Component {
this.addFilterClicked()} - >+ Add Filter
+ > + + ) } @@ -142,31 +192,6 @@ class FilterComponent extends React.Component { return undefined } - private conditionClicked(e: React.MouseEvent, filter: FilterClause) { - const {boardTree} = this.props - const {activeView: view} = boardTree - - const filterIndex = view.filter.filters.indexOf(filter) - Utils.assert(filterIndex >= 0, "Can't find filter") - - OldMenu.shared.options = [ - {id: 'includes', name: 'includes'}, - {id: 'notIncludes', name: "doesn't include"}, - {id: 'isEmpty', name: 'is empty'}, - {id: 'isNotEmpty', name: 'is not empty'}, - ] - OldMenu.shared.onMenuClicked = (optionId: string, type?: string) => { - const filterGroup = new FilterGroup(view.filter) - const newFilter = filterGroup.filters[filterIndex] as FilterClause - Utils.assert(newFilter, `No filter at index ${filterIndex}`) - if (newFilter.condition !== optionId) { - newFilter.condition = optionId as FilterCondition - mutator.changeViewFilter(view, filterGroup) - } - } - OldMenu.shared.showAtElement(e.target as HTMLElement) - } - private valuesClicked(e: React.MouseEvent, filter: FilterClause) { const {boardTree} = this.props const {board, activeView: view} = boardTree @@ -228,4 +253,4 @@ class FilterComponent extends React.Component { } } -export {FilterComponent} +export default injectIntl(FilterComponent) diff --git a/webapp/src/components/viewHeader.tsx b/webapp/src/components/viewHeader.tsx index a734743bd..aad7dd8c1 100644 --- a/webapp/src/components/viewHeader.tsx +++ b/webapp/src/components/viewHeader.tsx @@ -18,7 +18,7 @@ import Menu from '../widgets/menu' import MenuWrapper from '../widgets/menuWrapper' import {Editable} from './editable' -import {FilterComponent} from './filterComponent' +import FilterComponent from './filterComponent' type Props = { boardTree?: BoardTree diff --git a/webapp/src/pages/boardPage.tsx b/webapp/src/pages/boardPage.tsx index 42902baac..2a518d0a9 100644 --- a/webapp/src/pages/boardPage.tsx +++ b/webapp/src/pages/boardPage.tsx @@ -1,11 +1,9 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react' -import ReactDOM from 'react-dom' import {BoardView} from '../blocks/boardView' import {MutableBoardTree} from '../viewModel/boardTree' -import {FilterComponent} from '../components/filterComponent' import {WorkspaceComponent} from '../components/workspaceComponent' import {FlashMessage} from '../flashMessage' import mutator from '../mutator'