Skip to content

Commit

Permalink
make gallery year tag clickable (#7381)
Browse files Browse the repository at this point in the history
Co-authored-by: zhouwenxuan <[email protected]>
  • Loading branch information
Aries-0331 and zhouwenxuan authored Jan 17, 2025
1 parent 7d4a9f4 commit 07cec87
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions frontend/src/metadata/views/gallery/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ const Content = ({
'onContextMenu': onContextMenu,
};

const isDateTagClickable = mode === GALLERY_DATE_MODE.MONTH || mode === GALLERY_DATE_MODE.YEAR;

return (
<div
key={name}
Expand All @@ -144,12 +146,12 @@ const Content = ({
>
{mode !== GALLERY_DATE_MODE.ALL && childrenStartIndex === 0 && (
<div
className={classNames('metadata-gallery-date-tag', { 'hover': mode === GALLERY_DATE_MODE.MONTH })}
className={classNames('metadata-gallery-date-tag', { 'hover': isDateTagClickable })}
style={{ height: paddingTop }}
onClick={(event) => onDateTagClick(event, name)}
>
{name || gettext('Empty')}
{mode === GALLERY_DATE_MODE.MONTH && <i className="metadata-gallery-date-tag-arrow sf3-font-down sf3-font rotate-270" />}
{isDateTagClickable && <i className="metadata-gallery-date-tag-arrow sf3-font-down sf3-font rotate-270" />}
</div>
)}
<div
Expand Down
12 changes: 7 additions & 5 deletions frontend/src/metadata/views/gallery/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,13 @@ const Main = ({ isLoadingMore, metadata, onDelete, onLoadMore, duplicateRecord,

const handleDateTagClick = useCallback((event, groupName) => {
event.preventDefault();
if (mode === GALLERY_DATE_MODE.MONTH) {
const image = groups.find(group => group.name === groupName)?.children[0]?.children[0];
if (image) {
lastState.current = { ...lastState.current, targetGroupFirstImageId: image.id };
}
const image = groups.find(group => group.name === groupName)?.children[0]?.children[0];
if (image) {
lastState.current = { ...lastState.current, targetGroupFirstImageId: image.id };
}
if (mode === GALLERY_DATE_MODE.YEAR) {
window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.SWITCH_GALLERY_GROUP_BY, GALLERY_DATE_MODE.MONTH);
} else if (mode === GALLERY_DATE_MODE.MONTH) {
window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.SWITCH_GALLERY_GROUP_BY, GALLERY_DATE_MODE.DAY);
}
}, [mode, groups]);
Expand Down

0 comments on commit 07cec87

Please sign in to comment.