focalboard/webapp/src/boardUtils.ts
Jesús Espino 5979d19e73
Porting the card limits frontend to main branch (#3174)
* Porting the cards limits to main branch

* Fixing Issue 3124 (#3162)

* Fixing Issue 3124

* Update webapp/src/components/cardLimitNotification.tsx

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* Some polishing in the card limit notifications components (#3169)

* Adding missing selector

* Adding some small missing parts

* Fixing some tests type checks adding the roles attribute to the users

* Feature to show hidden card count (#3094)

* Shows "(Deleted User)" instead of UUID when user not found (#2354) (#2465)

* Shows "(Deleted User)" instead of long, unreadable UUID in case the user is not found

In case a user is not found, at present unreadable and long UUIDs are shown which kill the look and feel of the application. This patch replaces the UUID with a more explanatory string.

* Update server/services/store/mattermostauthlayer/mattermostauthlayer.go

Co-authored-by: Doug Lauder <wiggin77@warpmail.net>
(cherry picked from commit 68819185a4)

Co-authored-by: Akshay Vasudeva Rao <51395864+akkivasu@users.noreply.github.com>

* Update CHANGELOG.md for v0.15

Added one more merged PR to the list

* GH-2212 - Update global link on board (#2492) (#2495)

(cherry picked from commit 49df41f9b2)

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>

* GH-2387 - Fixing link in comments (#2480) (#2498)

(cherry picked from commit 5e2cf0b386)

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>

* Addead feature to start product tour on using the welcome template (#2468)

* Fixed a bug where images of the welcome board were not copied over. (#2453)

* Fixed a buig where images of welcome board were not copied over

* Lint fixes

* Fixed test

* Fixed test

* GH-2496 - Updating board title truncation issue (#2497) (#2503)

(cherry picked from commit f9cef8e4a0)

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>

* set min-height on empty date to allow click (#2466) (#2504)

(cherry picked from commit 20fe19a50d)

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* Fix problem with viewId 0 in the URL (#2474) (#2510)

(cherry picked from commit 4cb3a0fae4)

Co-authored-by: Jesús Espino <jespinog@gmail.com>

* don't display temlate page if readonly and access revoked (#2499) (#2515)

(cherry picked from commit 61f1a3cc65)

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* GH-2447 - Updating label overflow (#2479) (#2517)

* GH-2447 - Updating label overflow

* Updating labels css

(cherry picked from commit 923437cc57)

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>

* Gh-2437 - Updating share board modal (#2511) (#2522)

* Gh-2437 - Updating share board modal

* Updating test

* Updating card dialog and test

* Updating comment list

(cherry picked from commit 50ded69852)

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>

* updated/synced prior PR (#2509) (#2523)

* updated/synced prior PR

* add title back for cypress tests

* update unit test for cypress fix

* move to function

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
(cherry picked from commit 5b309e8e25)

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* modify error page redirects (#2518) (#2532)

(cherry picked from commit 84a3f8f1fb)

Co-authored-by: Doug Lauder <wiggin77@warpmail.net>

* Dismiss tour from overlay (#2525) (#2531)

* Shows "(Deleted User)" instead of UUID when user not found (#2354) (#2465)

* Shows "(Deleted User)" instead of long, unreadable UUID in case the user is not found

In case a user is not found, at present unreadable and long UUIDs are shown which kill the look and feel of the application. This patch replaces the UUID with a more explanatory string.

* Update server/services/store/mattermostauthlayer/mattermostauthlayer.go

Co-authored-by: Doug Lauder <wiggin77@warpmail.net>
(cherry picked from commit 68819185a4)

Co-authored-by: Akshay Vasudeva Rao <51395864+akkivasu@users.noreply.github.com>

* Update CHANGELOG.md for v0.15

Added one more merged PR to the list

* Added ability to dismiss tour from overlay

* GH-2212 - Update global link on board (#2492) (#2495)

(cherry picked from commit 49df41f9b2)

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>

* GH-2387 - Fixing link in comments (#2480) (#2498)

(cherry picked from commit 5e2cf0b386)

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>

* Addead feature to start product tour on using the welcome template (#2468)

* Fixed a bug where images of the welcome board were not copied over. (#2453)

* Fixed a buig where images of welcome board were not copied over

* Lint fixes

* Fixed test

* Fixed test

* Fixed intended behavio

* lint fixes

* Fixed tests

* Fixed tests

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Akshay Vasudeva Rao <51395864+akkivasu@users.noreply.github.com>
Co-authored-by: Winson Wu <93531870+wuwinson@users.noreply.github.com>
Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
(cherry picked from commit a53e947489)

Co-authored-by: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com>

* Updated Mac what's new for v0.15

* Done with the frontend for limited card count

* Updated the code and done with the unit test case

* Updated the code according to the review comment and fixed the test cases and ES lints issue

* Fixed the import for css file

* Changes made according to review comments, Reverted back whatsnew.txt

* Minor changes

* Updated the code considering review comments

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Akshay Vasudeva Rao <51395864+akkivasu@users.noreply.github.com>
Co-authored-by: Winson Wu <93531870+wuwinson@users.noreply.github.com>
Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>
Co-authored-by: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
Co-authored-by: Jesús Espino <jespinog@gmail.com>
Co-authored-by: Doug Lauder <wiggin77@warpmail.net>
Co-authored-by: Chen-I Lim <chenilim@gmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>

* Fixing some tests

* Fixing tests

* Fixing some compilation errors

* More types error fixes

* Fixing eslint

* Fixing a typing problem

* Updating snapshots

* Fixing two small problems

* Removing unneeded scss empty file

* fixing jest test

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
Co-authored-by: Rajat Dabade <rajat.dabade@mattermost.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Akshay Vasudeva Rao <51395864+akkivasu@users.noreply.github.com>
Co-authored-by: Winson Wu <93531870+wuwinson@users.noreply.github.com>
Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>
Co-authored-by: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com>
Co-authored-by: Doug Lauder <wiggin77@warpmail.net>
Co-authored-by: Chen-I Lim <chenilim@gmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-06-20 20:39:20 +02:00

57 lines
2.5 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Utils} from './utils'
import {Card} from './blocks/card'
import {IPropertyTemplate, IPropertyOption, BoardGroup} from './blocks/board'
export function groupCardsByOptions(cards: Card[], optionIds: string[], groupByProperty?: IPropertyTemplate): BoardGroup[] {
const groups = []
for (const optionId of optionIds) {
if (optionId) {
const option = groupByProperty?.options.find((o) => o.id === optionId)
if (option) {
const c = cards.filter((o) => optionId === o.fields?.properties[groupByProperty!.id])
const group: BoardGroup = {
option,
cards: c,
}
groups.push(group)
} else {
Utils.logError(`groupCardsByOptions: Missing option with id: ${optionId}`)
}
} else {
// Empty group
const emptyGroupCards = cards.filter((card) => {
const groupByOptionId = card.fields.properties[groupByProperty?.id || '']
return !groupByOptionId || !groupByProperty?.options.find((option) => option.id === groupByOptionId)
})
const group: BoardGroup = {
option: {id: '', value: `No ${groupByProperty?.name}`, color: ''},
cards: emptyGroupCards,
}
groups.push(group)
}
}
return groups
}
export function getVisibleAndHiddenGroups(cards: Card[], visibleOptionIds: string[], hiddenOptionIds: string[], groupByProperty?: IPropertyTemplate): {visible: BoardGroup[], hidden: BoardGroup[]} {
let unassignedOptionIds: string[] = []
if (groupByProperty) {
unassignedOptionIds = groupByProperty.options.
filter((o: IPropertyOption) => !visibleOptionIds.includes(o.id) && !hiddenOptionIds.includes(o.id)).
map((o: IPropertyOption) => o.id)
}
const allVisibleOptionIds = [...visibleOptionIds, ...unassignedOptionIds]
// If the empty group positon is not explicitly specified, make it the first visible column
if (!allVisibleOptionIds.includes('') && !hiddenOptionIds.includes('')) {
allVisibleOptionIds.unshift('')
}
const visibleGroups = groupCardsByOptions(cards, allVisibleOptionIds, groupByProperty)
const hiddenGroups = groupCardsByOptions(cards, hiddenOptionIds, groupByProperty)
return {visible: visibleGroups, hidden: hiddenGroups}
}