Skip to content

Commit

Permalink
#24797 Filtering the current identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelrojas committed May 3, 2023
1 parent 6ef4fa8 commit bda0c67
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 7 deletions.
Expand Up @@ -72,6 +72,7 @@ export class DotBlockEditorComponent implements OnInit, OnDestroy {
@Input() charLimit: number;
@Input() customBlocks = '';
@Input() content: Content = '';
@Input() identifier: string;
@Input() set showVideoThumbnail(value) {
this.dotMarketingConfigService.setProperty(
EDITOR_MARKETING_KEYS.SHOW_VIDEO_THUMBNAIL,
Expand Down Expand Up @@ -357,7 +358,8 @@ export class DotBlockEditorComponent implements OnInit, OnDestroy {
DotConfigExtension({
lang: this.lang,
allowedContentTypes: this.allowedContentTypes,
allowedBlocks: this._allowedBlocks
allowedBlocks: this._allowedBlocks,
identifier: this.identifier
}),
DotComands,
DotPlaceholder.configure({ placeholder: 'Type "/" for commands' }),
Expand Down
Expand Up @@ -250,7 +250,7 @@ export const ActionsMenu = (
}

function setUpSuggestionComponent(editor: Editor, range: Range) {
const { allowedBlocks, allowedContentTypes, lang } = editor.storage.dotConfig;
const { allowedBlocks, allowedContentTypes, lang, identifier } = editor.storage.dotConfig;
const editorAllowedBlocks = allowedBlocks.length > 1 ? allowedBlocks : [];
const items = getItems({ allowedBlocks: editorAllowedBlocks, editor, range });

Expand All @@ -260,6 +260,8 @@ export const ActionsMenu = (
suggestionsComponent.instance.items = items;
suggestionsComponent.instance.currentLanguage = lang;
suggestionsComponent.instance.allowedContentTypes = allowedContentTypes;
suggestionsComponent.instance.identifier = identifier;

suggestionsComponent.instance.onSelectContentlet = (props) => {
clearFilter({ type: ItemsType.CONTENT, editor, range, suggestionKey, ItemsType });
onSelection({ editor, range, props });
Expand Down
Expand Up @@ -16,6 +16,7 @@ export interface ContentletFilters {
contentType: string;
filter: string;
currentLanguage: number;
identifier: string;
}

export enum NodeTypes {
Expand Down
Expand Up @@ -2,4 +2,5 @@ export interface DotConfigModel {
lang: number;
allowedContentTypes: string;
allowedBlocks: string[];
identifier: string;
}
Expand Up @@ -50,6 +50,7 @@ export class SuggestionsComponent implements OnInit {
@Input() noResultsMessage = 'No Results';
@Input() currentLanguage = DEFAULT_LANG_ID;
@Input() allowedContentTypes = '';
@Input() identifier = '';

private itemsLoaded: ItemsType;
private selectedContentType: DotCMSContentType;
Expand Down Expand Up @@ -199,7 +200,8 @@ export class SuggestionsComponent implements OnInit {
.getContentlets({
contentType: contentType.variable,
filter,
currentLanguage: this.currentLanguage
currentLanguage: this.currentLanguage,
identifier: this.identifier
})
.pipe(take(1))
.subscribe((contentlets) => {
Expand Down
Expand Up @@ -37,11 +37,14 @@ export class SuggestionsService {
getContentlets({
contentType,
filter,
currentLanguage
currentLanguage,
identifier
}: ContentletFilters): Observable<DotCMSContentlet[]> {
const identifierQuery = identifier ? `-identifier:${identifier}` : '';

return this.http
.post('/api/content/_search', {
query: `+contentType:${contentType} +languageId:${currentLanguage} +deleted:false +working:true +catchall:*${filter}* `,
query: `+contentType:${contentType} ${identifierQuery} +languageId:${currentLanguage} +deleted:false +working:true +catchall:*${filter}* `,
sort: 'modDate desc',
offset: 0,
limit: 40
Expand Down
2 changes: 1 addition & 1 deletion dotCMS/src/main/webapp/html/dotcms-block-editor.js

Large diffs are not rendered by default.

Expand Up @@ -164,6 +164,7 @@
String displayCountBar = "";
String charLimit = "";
String customBlocks = "";
String identifier = contentlet.getIdentifier();
Boolean showVideoThumbnail = Config.getBooleanProperty("SHOW_VIDEO_THUMBNAIL", true);
// By default this is an empty JSON `{}`.
Expand Down Expand Up @@ -208,7 +209,10 @@
display-count-bar="<%=displayCountBar%>"
char-limit="<%=charLimit%>"
lang="<%=contentLanguage%>"
custom-blocks='<%=customBlocks%>'>
custom-blocks='<%=customBlocks%>'
identifier='<%=identifier%>'
>

</dotcms-block-editor>
<input type="hidden" name="<%=field.getFieldContentlet()%>" id="editor-input-value-<%=field.getVelocityVarName()%>"/>

Expand Down

0 comments on commit bda0c67

Please sign in to comment.