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

Allows opening resource manager folders with double-click #5352

Merged
merged 2 commits into from
Oct 24, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ export interface DnnRmFolderListItemCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLDnnRmFolderListItemElement;
}
export interface DnnRmItemsCardviewCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLDnnRmItemsCardviewElement;
}
export interface DnnRmItemsListviewCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLDnnRmItemsListviewElement;
}
export interface DnnRmMoveItemsCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLDnnRmMoveItemsElement;
Expand Down Expand Up @@ -558,12 +566,20 @@ declare namespace LocalJSX {
* The list of current items.
*/
"currentItems": GetFolderContentResponse;
/**
* Fires when a folder is double-clicked and emits the folder ID into the event.detail
*/
"onDnnRmFolderDoubleClicked"?: (event: DnnRmItemsCardviewCustomEvent<number>) => void;
}
interface DnnRmItemsListview {
/**
* The list of current items.
*/
"currentItems": GetFolderContentResponse;
/**
* Fires when a folder is double-clicked and emits the folder ID into the event.detail
*/
"onDnnRmFolderDoubleClicked"?: (event: DnnRmItemsListviewCustomEvent<number>) => void;
}
interface DnnRmLeftPane {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ export class DnnRmFolderListItem {
}
}

@Listen("dnnRmFolderDoubleClicked", {target: "document"})
handleFolderDoubleClicked(e: CustomEvent<number>) {
if (e.detail == Number.parseInt(this.folder.data.key)) {
this.dnnRmFolderListItemClicked.emit(this.folder);
this.handleUserExpanded();
this.expanded = true;
}
}

@State() folderIconUrl: string;

@Element() el!: HTMLDnnRmFolderListItemElement;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Host, h, Prop, Element } from '@stencil/core';
import { Component, Event, EventEmitter, Host, h, Prop, Element } from '@stencil/core';
import { GetFolderContentResponse, Item } from '../../services/ItemsClient';
import state from '../../store/store';
import { selectionUtilities } from '../../utilities/selection-utilities';
Expand All @@ -15,6 +15,9 @@ export class DnnRmItemsCardview {

@Element() el: HTMLDnnRmItemsCardviewElement;

/** Fires when a folder is double-clicked and emits the folder ID into the event.detail */
@Event() dnnRmFolderDoubleClicked: EventEmitter<number>;

componentWillLoad() {
document.addEventListener("click", this.dismissContextMenu.bind(this));
}
Expand Down Expand Up @@ -48,6 +51,12 @@ export class DnnRmItemsCardview {
return;
}

private handleDoubleClick(item: Item): void {
if (item.isFolder) {
this.dnnRmFolderDoubleClicked.emit(item.itemId);
}
}

render() {
return (
<Host>
Expand All @@ -58,6 +67,7 @@ export class DnnRmItemsCardview {
class="card"
onClick={() => selectionUtilities.toggleItemSelected(item)}
onContextMenu={e => this.handleContextMenu(e, item)}
onDblClick={() => this.handleDoubleClick(item)}
>
<div class={selectionUtilities.isItemSelected(item) ? "radio selected" : "radio"}>
{selectionUtilities.isItemSelected(item) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
| `currentItems` _(required)_ | -- | The list of current items. | `GetFolderContentResponse` | `undefined` |


## Events

| Event | Description | Type |
| -------------------------- | ----------------------------------------------------------------------------------- | --------------------- |
| `dnnRmFolderDoubleClicked` | Fires when a folder is double-clicked and emits the folder ID into the event.detail | `CustomEvent<number>` |


## Dependencies

### Used by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Host, h, Prop, Element } from '@stencil/core';
import { Component, Event, EventEmitter, Host, h, Prop, Element } from '@stencil/core';
import { GetFolderContentResponse, Item } from '../../services/ItemsClient'
import state from '../../store/store';
import { selectionUtilities } from "../../utilities/selection-utilities";
Expand All @@ -15,6 +15,9 @@ export class DnnRmItemsListview {

@Element() el: HTMLDnnRmItemsListviewElement;

/** Fires when a folder is double-clicked and emits the folder ID into the event.detail */
@Event() dnnRmFolderDoubleClicked: EventEmitter<number>;

componentWillLoad() {
document.addEventListener("click", this.dismissContextMenu.bind(this));
}
Expand Down Expand Up @@ -79,6 +82,12 @@ export class DnnRmItemsListview {
return;
}

private handleDoubleClick(item: Item): void {
if (item.isFolder) {
this.dnnRmFolderDoubleClicked.emit(item.itemId);
}
}

render() {
return (
<Host>
Expand All @@ -102,6 +111,7 @@ export class DnnRmItemsListview {
onKeyDown={e => this.handleRowKeyDown(e, item)}
onClick={() => selectionUtilities.toggleItemSelected(item)}
onContextMenu={e => this.handleContextMenu(e, item)}
onDblClick={() => this.handleDoubleClick(item)}
>
<td class="radio">
{selectionUtilities.isItemSelected(item) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
| `currentItems` _(required)_ | -- | The list of current items. | `GetFolderContentResponse` | `undefined` |


## Events

| Event | Description | Type |
| -------------------------- | ----------------------------------------------------------------------------------- | --------------------- |
| `dnnRmFolderDoubleClicked` | Fires when a folder is double-clicked and emits the folder ID into the event.detail | `CustomEvent<number>` |


## Dependencies

### Used by
Expand Down