-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add utils file
- Loading branch information
Showing
4 changed files
with
51 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
// projects table | ||
export const INITIAL_TABLE_ROWS = '20' | ||
export const ROWS_TO_LOAD = '10' | ||
export const SORTABLE_COLUMNS = ['created', 'owner', 'progress', 'role', 'title', 'updated'] | ||
export const HEADER_FORMATTERS = { | ||
title: {render: () => gettext('Name')}, | ||
role: {render: () => gettext('Role')}, | ||
owner: {render: () => gettext('Owner')} , | ||
progress: {render: () => gettext('Progress')}, | ||
created: {render: () => gettext('Created')}, | ||
updated: {render: () => gettext('Last changed')}, | ||
actions: {render: () => null}, | ||
} | ||
|
||
// date format | ||
export const DATE_OPTIONS = { | ||
day: 'numeric', | ||
month: 'short', | ||
year: 'numeric', | ||
hour: 'numeric', | ||
minute: 'numeric' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { isNil } from 'lodash' | ||
|
||
export const getParentPath = (projects, parentId, pathArray = []) => { | ||
const parent = projects.find((project) => project.id === parentId) | ||
if (parent) { | ||
const { title: parentTitle, parent: grandParentId } = parent | ||
pathArray.unshift(parentTitle) | ||
if (!isNil(grandParentId) && typeof grandParentId === 'number') { | ||
return getParentPath(projects, grandParentId, pathArray) | ||
} | ||
} | ||
return pathArray | ||
} | ||
|
||
export const getTitlePath = (projects, title, row) => { | ||
let parentPath = '' | ||
if (row.parent) { | ||
const path = getParentPath(projects, row.parent) | ||
parentPath = path.join(' / ') | ||
} | ||
|
||
const pathArray = parentPath ? [parentPath, title] : [title] | ||
return pathArray.join(' / ') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters