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

Editor Viewer Bar: Limit media name characters #2878

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
36 changes: 35 additions & 1 deletion ui/src/layout-editor/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2423,6 +2423,37 @@ lD.dropItemAdd = function(droppable, draggable, dropPosition) {
draggableData.originalHeight,
);

// Limit name for an element
const limitStringLength = function(
originalString,
maxLength,
) {
const words =
originalString.split(',').map((word) => word.trim());
let result = '';

for (let word of words) {
// Check if single words exceeds max lenght
// and trim it
if (word.length > maxLength) {
// If it does, trim it to maxLength
word = word.slice(0, maxLength);
}

// Check if adding the next word would exceed the maxLength
if (
(result + (result ? ', ' : '') + word).length <=
maxLength
) {
result += (result ? ', ' : '') + word;
} else {
break;
}
}

return result;
};

// Element options
const elementOptions = {
id: draggableData.templateId,
Expand All @@ -2437,7 +2468,10 @@ lD.dropItemAdd = function(droppable, draggable, dropPosition) {
extendsOverride: draggableData.extendsOverride,
extendsOverrideId: draggableData.extendsOverrideId,
mediaId: draggableData.mediaId,
mediaName: draggableData.cardTitle,
mediaName: limitStringLength(
draggableData.cardTitle,
95,
),
isVisible: draggableData.isVisible,
};

Expand Down
12 changes: 12 additions & 0 deletions ui/src/style/bottombar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,21 @@
text-overflow: ellipsis;
}


& > .mediaTemplate {
white-space: nowrap;
}

& > .mediaInfo {
display: inline-flex;
gap: 6px;
overflow: hidden;

.mediaInfoName {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/templates/bottombar-viewer.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{else eq object.type "element"}}
<div class="info">
<div class="label-name">
<strong>{{objectTypeName}}</strong> | <div title="{{trans.templateName}}">{{object.template.title}}</div>
<strong>{{objectTypeName}}</strong> | <div class="mediaTemplate" title="{{trans.templateName}}">{{object.template.title}}</div>
{{#if object.elementName}} - <div class="name" title="{{trans.elementName}}">"{{object.elementName}}"</div>{{/if}}
{{#if object.elementMediaInfo}}
- <div class="mediaInfo">[
Expand Down