-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add archive feature, enhance search filter (#55)
* Changed filter to have by keywords and sort only added ui for archived hopefully i can figure it out * Added Archive Feature * last archive changes * Add default value (false) to archive flag migration * Clean up archive UI, add archived asset indication * Whoop add a little more iconography * Update filter dropdown with slick UI * Remove "delete asset" route * Fix typeerrors * Remove unnecessary changes to python dependencies, requirements.txt * Make keywords in asset search legally distinct * Format new-asset-form * Remove comment * Clean up navbar-filter --------- Co-authored-by: Thomas Shaw <[email protected]>
- Loading branch information
1 parent
cb7b21d
commit 6e21734
Showing
16 changed files
with
332 additions
and
175 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
34 changes: 34 additions & 0 deletions
34
backend/migrations/versions/200e409da11c_add_archived_assets.py
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,34 @@ | ||
"""Add archived assets | ||
Revision ID: 200e409da11c | ||
Revises: 33e6aa9a48d7 | ||
Create Date: 2024-04-29 16:12:48.187569 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "200e409da11c" | ||
down_revision: Union[str, None] = "33e6aa9a48d7" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
"assets", | ||
sa.Column("archived", sa.Boolean(), nullable=False, server_default=sa.false()), | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("assets", "archived") | ||
# ### end Alembic commands ### |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
75 changes: 75 additions & 0 deletions
75
frontend/src/renderer/src/components/input/filter-keywords-input.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,75 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { HiPlus, HiXMark } from 'react-icons/hi2'; | ||
|
||
import Label from './label'; | ||
|
||
interface ControlledInputProps { | ||
inputName: string; | ||
inputs: string[]; | ||
setInputs: (query: string[]) => void; | ||
} | ||
|
||
function ControlledInput({ inputName, inputs, setInputs }: ControlledInputProps) { | ||
const [inputText, setInputText] = useState(''); | ||
|
||
useEffect(() => { | ||
// Update internal state when store's keywords change | ||
setInputText(''); // Clear input after store update (optional) | ||
}, [inputs]); | ||
|
||
const addInput = () => { | ||
const formatted = inputText.trim().toLowerCase(); | ||
if (formatted.length === 0 || inputs.includes(formatted)) return; | ||
const updatedInputs = [...inputs, formatted]; | ||
setInputs(updatedInputs); | ||
setInputText(''); | ||
}; | ||
|
||
const removeInput = (index) => { | ||
// setKeywords(keywords.filter((_, i) => i !== index)); | ||
const updatedInputs = inputs.filter((_, i) => i !== index); | ||
setInputs(updatedInputs); | ||
}; | ||
|
||
return ( | ||
<label className="block"> | ||
<Label label={`By ${inputName}`} /> | ||
<div className="relative w-full"> | ||
<input | ||
type="text" | ||
value={inputText} | ||
onChange={(e) => setInputText(e.target.value)} | ||
onKeyDown={(e) => { | ||
if (e.key === 'Enter') { | ||
e.preventDefault(); | ||
addInput(); | ||
} | ||
}} | ||
className="input input-bordered w-full" | ||
/> | ||
<button | ||
type="button" | ||
onClick={addInput} | ||
disabled={inputText.length === 0} | ||
className="btn btn-circle btn-ghost btn-sm absolute right-2 top-1/2 -translate-y-1/2" | ||
> | ||
<HiPlus /> | ||
</button> | ||
</div> | ||
<ul className="mt-3 flex w-full max-w-xs flex-wrap gap-1"> | ||
{inputs.map((input, index) => ( | ||
<li key={index}> | ||
<button | ||
className="btn btn-outline btn-sm inline-flex font-normal" | ||
onClick={() => removeInput(index)} | ||
> | ||
{input} <HiXMark /> | ||
</button> | ||
</li> | ||
))} | ||
</ul> | ||
</label> | ||
); | ||
} | ||
|
||
export default ControlledInput; |
Oops, something went wrong.