Skip to content
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

Feature/JS-6325: Gallery name setting #1183

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
JS-6325: gallery name setting
ra3orblade committed Jan 28, 2025
commit f81d3456d3810c85933ffe5f56ace845129cfc7b
6 changes: 5 additions & 1 deletion src/scss/widget/view/gallery.scss
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
.inner { display: flex; flex-direction: column; height: 100%; align-items: stretch; }

.cover {
position: relative; height: 80px; background-position: top center; display: flex; align-items: center; flex-shrink: 0px;
position: relative; height: 80px; background-position: top center; display: flex; align-items: center; flex-shrink: 0;
background-color: var(--color-shape-highlight-medium); width: 100%; justify-content: center; border-radius: 8px 8px 0px 0px; overflow: hidden;
}

@@ -50,6 +50,10 @@
}
}

.item.withoutName {
.cover { border-radius: 8px; }
}

.item:hover, .item.active { background: var(--color-shape-highlight-light); }
}
}
8 changes: 6 additions & 2 deletions src/ts/component/menu/dataview/relation/list.tsx
Original file line number Diff line number Diff line change
@@ -30,9 +30,12 @@ const MenuRelationList = observer(class MenuRelationList extends React.Component
};

render () {
const { getId, setHover } = this.props;
const { getId, setHover, param } = this.props;
const { data } = param;
const { getView } = data;
const isReadonly = this.isReadonly();
const items = this.getItems();
const view = getView();

items.map((it: any) => {
const { format, name } = it.relation;
@@ -43,7 +46,8 @@ const MenuRelationList = observer(class MenuRelationList extends React.Component
));

const Item = SortableElement((item: any) => {
const canHide = !isReadonly && (item.relationKey != 'name');
const isName = item.relationKey == 'name';
const canHide = !isReadonly && (!isName || (view.type == I.ViewType.Gallery));
const cn = [ 'item' ];

if (item.relation.isHidden) {
16 changes: 12 additions & 4 deletions src/ts/component/widget/view/gallery/item.tsx
Original file line number Diff line number Diff line change
@@ -30,11 +30,17 @@ const WidgetGalleryItem = observer(forwardRef<{}, Props>(({
const canDrop = !isEditing && S.Block.isAllowed(restrictions, [ I.RestrictionObject.Block ]);
const cn = [ 'item' ];
const cover = view ? Dataview.getCoverObject(subId, object, view.coverRelationKey) : null;
const nameRelation = view.getRelation('name');
const withName = !cover || (cover && nameRelation.isVisible);

if (cover) {
cn.push('withCover');
};

if (!withName) {
cn.push('withoutName');
};

const onClick = (e: React.MouseEvent) => {
if (e.button) {
return;
@@ -97,10 +103,12 @@ const WidgetGalleryItem = observer(forwardRef<{}, Props>(({
<div className="inner" onMouseDown={onClick}>
<ObjectCover object={cover} />

<div className="info">
{icon}
<ObjectName object={object} />
</div>
{withName ? (
<div className="info">
{icon}
<ObjectName object={object} />
</div>
) : ''}
</div>
);

2 changes: 1 addition & 1 deletion src/ts/lib/dataview.ts
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ class Dataview {
const ret = relations.filter(it => it).map(relation => {
const vr = (view.relations || []).filter(it => it).find(it => it.relationKey == relation.relationKey) || {};

if (relation.relationKey == 'name') {
if ((view.type != I.ViewType.Gallery) && (relation.relationKey == 'name')) {
vr.isVisible = true;
};