-
Notifications
You must be signed in to change notification settings - Fork 22
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
keyword search for quantifiers & Quantify multiple praise #499
Merged
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
937b648
Added option to quantify multiple praises at once
nebs-dev 086e226
Change multiple quantify button & component name
nebs-dev ac0ff3f
Moved select all checkbox, fixed issue with duplicate praise scores, …
nebs-dev 6ad48cb
Merge branch 'main' into enh/quantifiers_keyword_search
nebs-dev da5b6d6
Fix: Added InternalServerError import
kristoferlund 7e27097
move quantify logic from controller to utils, modify icon buttons, fi…
nebs-dev 013ebff
Merge branch 'enh/quantifiers_keyword_search' of https://github.com/c…
nebs-dev 7acf2a1
Fix: Margins and colours
kristoferlund 316f94a
Add: IconRoundButton
kristoferlund 4cdb995
Fix: removed round button code from IconButton
kristoferlund e697acd
Fix: Remove unused imports
kristoferlund File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 |
---|---|---|
|
@@ -3,15 +3,17 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | |
|
||
interface SearchInputProps { | ||
handleChange: (element) => void; | ||
value: string; | ||
value?: string; | ||
placeholder?: string; | ||
} | ||
|
||
const SearchInput = ({ | ||
handleChange, | ||
value, | ||
placeholder = 'Search', | ||
}: SearchInputProps): JSX.Element => { | ||
return ( | ||
<div className="relative flex items-center border border-warm-gray-400 h-[42px]"> | ||
<div className="relative flex items-center border border-warm-gray-400 h-10"> | ||
<div className="absolute inset-y-0 left-0 flex items-center pl-3"> | ||
<span className="text-warm-gray-800 dark:text-white"> | ||
<FontAwesomeIcon | ||
|
@@ -25,7 +27,7 @@ const SearchInput = ({ | |
className="block pl-8 bg-transparent border-none outline-none focus:ring-0" | ||
name="search" | ||
type="text" | ||
placeholder="Search" | ||
placeholder={placeholder} | ||
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. 👍 |
||
value={value} | ||
onChange={(e: React.ChangeEvent<HTMLInputElement>): void => | ||
handleChange(e.target.value) | ||
|
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
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 |
---|---|---|
|
@@ -3,25 +3,26 @@ import { faMinusCircle } from '@fortawesome/free-solid-svg-icons'; | |
|
||
interface Props { | ||
disabled?: boolean; | ||
small?: boolean; | ||
onClick(); | ||
} | ||
|
||
const MarkDismissedButton = ({ | ||
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. I'd suggest creating a more generic component, similar to |
||
disabled = false, | ||
onClick, | ||
small, | ||
}: Props): JSX.Element => { | ||
const disabledClass = disabled ? 'praise-button-disabled' : 'praise-button'; | ||
const smallClass = small ? 'praise-button-round' : ''; | ||
|
||
return ( | ||
<button | ||
disabled={disabled} | ||
className={ | ||
disabled | ||
? 'praise-button-disabled space-x-2' | ||
: 'praise-button space-x-2' | ||
} | ||
className={`space-x-2 ${disabledClass} ${smallClass}`} | ||
onClick={onClick} | ||
> | ||
<FontAwesomeIcon icon={faMinusCircle} size="1x" /> | ||
<span>Dismiss</span> | ||
{!small ? <span>Dismiss</span> : null} | ||
</button> | ||
); | ||
}; | ||
|
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
30 changes: 30 additions & 0 deletions
30
packages/frontend/src/pages/QuantifyPeriodReceiver/components/QuantifyMultipleButton.tsx
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,30 @@ | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { faScaleUnbalanced } from '@fortawesome/free-solid-svg-icons'; | ||
|
||
interface Props { | ||
disabled?: boolean; | ||
small?: boolean; | ||
onClick(); | ||
} | ||
|
||
const QuantifyMultipleButton = ({ | ||
disabled = false, | ||
onClick, | ||
small, | ||
}: Props): JSX.Element => { | ||
const disabledClass = disabled ? 'praise-button-disabled' : 'praise-button'; | ||
const smallClass = small ? 'praise-button-round' : ''; | ||
|
||
return ( | ||
<button | ||
disabled={disabled} | ||
className={`space-x-2 ${disabledClass} ${smallClass}`} | ||
onClick={onClick} | ||
> | ||
<FontAwesomeIcon icon={faScaleUnbalanced} size="1x" /> | ||
{!small ? <span>Quantify</span> : null} | ||
</button> | ||
); | ||
}; | ||
|
||
export default QuantifyMultipleButton; |
63 changes: 63 additions & 0 deletions
63
packages/frontend/src/pages/QuantifyPeriodReceiver/components/QuantifyMultipleDialog.tsx
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,63 @@ | ||
import ScrollableDialog from '@/components/ScrollableDialog'; | ||
import QuantifyMultipleButton from '@/pages/QuantifyPeriodReceiver/components/QuantifyMultipleButton'; | ||
import QuantifySlider from '@/pages/QuantifyPeriodReceiver/components/QuantifySlider'; | ||
import { faCalculator, faTimes } from '@fortawesome/free-solid-svg-icons'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { PraiseDto } from 'api/dist/praise/types'; | ||
import { useState } from 'react'; | ||
|
||
interface QuantifyMultipleDialogProps { | ||
open: boolean; | ||
onClose(): void; | ||
selectedPraises: PraiseDto[]; | ||
allowedValues: number[]; | ||
onSetScore(newScore: number, selectedPraises: PraiseDto[]); | ||
} | ||
|
||
const QuantifyMultipleDialog = ({ | ||
open = false, | ||
onClose, | ||
selectedPraises, | ||
allowedValues, | ||
onSetScore, | ||
}: QuantifyMultipleDialogProps): JSX.Element | null => { | ||
const [score, setScore] = useState<number>(0); | ||
|
||
return ( | ||
<ScrollableDialog open={open} onClose={onClose}> | ||
<div className="w-full h-full"> | ||
<div className="flex justify-end p-6"> | ||
<button className="praise-button-round" onClick={onClose}> | ||
<FontAwesomeIcon icon={faTimes} size="1x" /> | ||
</button> | ||
</div> | ||
<div className="px-20 space-y-6"> | ||
<div className="flex justify-center"> | ||
<FontAwesomeIcon icon={faCalculator} size="2x" /> | ||
</div> | ||
<h2 className="text-center"> | ||
Quantify selected ({selectedPraises.length}) praise items. | ||
</h2> | ||
|
||
<div className="text-center"> | ||
<QuantifySlider | ||
allowedScores={allowedValues} | ||
onChange={(newScore): void => setScore(newScore)} | ||
/> | ||
</div> | ||
|
||
<div className="flex justify-center"> | ||
<QuantifyMultipleButton | ||
onClick={(): void => { | ||
onSetScore(score, selectedPraises); | ||
onClose(); | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</ScrollableDialog> | ||
); | ||
}; | ||
|
||
export default QuantifyMultipleDialog; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This function will need to have same logic used in the
quantify
function to determine all the praises with an affectedscoreRealized
. It probably makes sense to pull that logic out into a utility function and use it in both controllers.The reason for that logic is so the "Duplicate Score" display is updated when the original praise's score is updated. See the screencast below:
Kazam_screencast_00003.mp4
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.
☝️☝️ @nebs-dev, this remains to be done.