-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(BEDS-481) API: dashboards notifications struct adjustments #873
Changes from 4 commits
f0174b1
b29696d
b38dbbb
facc404
46ff8a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import type { ApiPagingResponse } from '~/types/api/common' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* This function wraps each element in an `ApiPagingResponse` interface with a unique id field `wrapped_identifier`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* @param response The api response to wrap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* @param getIdFromRow A function that takes a row and builds a unique identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* @returns The wrapped response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export function wrapWithIdentifier<T>(response: ApiPagingResponse<T> | undefined, ...keys: (keyof T)[]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (!response) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data: response.data.map(row => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
...row, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
wrapped_identifier: keys.map(key => row[key]).join('-'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
})), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
paging: response.paging, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. np: something like that would be kewl
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe think about generalize this function (is it important for the function that there has to be a row?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pushed the changes, ptal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when using
<BcTable>
and usingwrapedWithIdentifier
function, which has the consequence thatdata-key
would be always thewrapped_identifier
key...It would be nice if
BcTable
would be refactored thatdata-key
is not needed anymoreThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to refactor
BcTable
to do that though? As far as the prime vue component goes,data-key
is optional and only optimizes performance, which may be lost if we wrap every time when usingBcTable
. I would suggest investigating whetherBcTable
truly needs a unique ID first (at a later time) and keeping this for now.