File

src/ui/file-picker/file-picker-dialog/file-picker-dialog.component.ts

Implements

OnInit OnDestroy

Metadata

Index

Properties
Methods
Inputs

Inputs

allowCreateFolder
Type : boolean
fileMustExist
Type : boolean
folderScope
Type : string
selectionMode
Type : "file" | "folder"

Methods

cancel
cancel()

Cancel file selection

Returns : void
createFolder
createFolder(explorerFile?: ExplorerFileComponent)

Create a folder

Parameters :
Name Type Optional
explorerFile ExplorerFileComponent Yes
Returns : void
handleFilePatternChange
handleFilePatternChange(filePattern: FilePattern)

Handle the file pattern change

Parameters :
Name Type Optional Description
filePattern FilePattern No
  • The file pattern change event
Returns : void
handleNodeClick
handleNodeClick(node: SmartFilePickerFile)

Handle the node click

Parameters :
Name Type Optional Description
node SmartFilePickerFile No
  • The node
Returns : void
handleSelectionFromExplorerFile
handleSelectionFromExplorerFile(node: SmartFilePickerFile)

Handle the selection from the explorer file

Parameters :
Name Type Optional Description
node SmartFilePickerFile No
  • The node
Returns : void
selectFolder
selectFolder(node: SmartFilePickerFile, refresh: unknown)

Select the root folder

Parameters :
Name Type Optional Default value Description
node SmartFilePickerFile No
  • The root folder node
refresh unknown No false
  • Whether to refresh the folder
Returns : void
setSelection
setSelection(node: SmartFilePickerFile | null)

Sets the current file/folder selection

Parameters :
Name Type Optional Description
node SmartFilePickerFile | null No
  • The node
Returns : void
submit
submit()

Submit file selection

Returns : void
updateValidSelection
updateValidSelection()

Update the valid selection

Returns : void

Properties

explorerToolbarPath
Type : ElementRef<HTMLDivElement>
Decorators :
@ViewChild('explorerToolbarPath')
getFiles
Type : unknown
Default value : () => {...}

Get the files of a folder

Parameters :
Name Description
node
  • The folder node
getSubfolders
Type : unknown
Default value : () => {...}

Get the subfolders of a folder

Parameters :
Name Description
node
  • The folder node
handleKeyDown
Type : unknown
Default value : () => {...}

Handle the keydown event and navigate up the folder tree on arrow up

Parameters :
Name Description
event
  • The keyboard event
hasChildren
Type : unknown
Default value : () => {...}

Check if the node has children

Parameters :
Name Description
node
  • The node
<!--
**************************************************************************
* Copyright © 2006-2026 by Consultingwerk Ltd. ("CW") -                  *
* www.consultingwerk.com and other contributors as listed                *
* below. All Rights Reserved.                                            *
*                                                                        *
*  Software is distributed on an "AS IS", WITHOUT WARRANTY OF ANY        *
*   KIND, either express or implied.                                     *
*                                                                        *
*  Contributors:                                                         *
*                                                                        *
**************************************************************************

--------------------------------------------------------------------------
    File        : file-picker-dialog.component.html
    Purpose     : Template for file picker dialog.
    Author(s)   : Radu Nicoara
    Created     : Apr 07, 2025
--------------------------------------------------------------------------
-->
<div class="file-picker-dialog h-100 w-100 overflow-hidden">
	<div class="explorer-toolbar">
		<button
			kendoButton
			class="file-picker-dialog-explorer-toolbar-button"
			iconClass="fa-solid fa-folder-plus"
			[fillMode]="'outline'"
			[size]="'small'"
			(click)="createFolder()"
		></button>
		<button
			kendoButton
			class="file-picker-dialog-explorer-toolbar-button"
			iconClass="fa-solid fa-arrow-up"
			[fillMode]="'outline'"
			[size]="'small'"
			[disabled]="!selectedRootFolder?.parent"
			(click)="
				handleNodeClick(
					$safeNavigationMigration(selectedRootFolder?.parent)
				)
			"
		></button>
		<div class="explorer-toolbar-path" #explorerToolbarPath>
			@for (node of path; track $index) {
			<div class="explorer-toolbar-path-node">
				<explorer-file
					[node]="node"
					[displayIcon]="false"
					(click)="handleNodeClick(node)"
				></explorer-file>
			</div>
			@if ($index < path.length - 1) {
			<span class="mx-2 text-select-disabled">/</span>
			} }
		</div>
	</div>
	<kendo-splitter [orientation]="'horizontal'" class="explorer-splitter">
		<kendo-splitter-pane [size]="'20%'">
			<div class="file-picker-dialog-root-folders">
				<kendo-treeview
					kendoTreeViewExpandable
					kendoTreeViewSelectable
					selectBy="path"
					[(selectedKeys)]="selectedTreeKeys"
					class="h-100 w-100 ps-2 file-tree"
					[nodes]="rootFolders | async"
					[textField]="['displayText', 'displayText']"
					[hasChildren]="hasChildren"
					[children]="getSubfolders"
					(nodeClick)="handleNodeClick($event.item.dataItem)"
					(expand)="getSubfolders($event.dataItem)"
				>
					<ng-template kendoTreeViewNodeTemplate let-node>
						<explorer-file [node]="node"></explorer-file>
					</ng-template>
				</kendo-treeview>
			</div>
		</kendo-splitter-pane>
		<kendo-splitter-pane>
			<div
				class="d-flex flex-column h-100 w-100 p-2 file-picker-dialog-explorer-files-container"
			>
				<div class="file-picker-dialog-explorer-files">
					@for (node of selectedRootFolder?.subfiles; track $index) {
					<explorer-file
						[ngClass]="{
							selected:
								currentSelectionPath ===
								node.getStringPathFromRoot()
						}"
						#filePickerExplorerFile
						[node]="node"
						(dblClick)="handleNodeClick(node)"
						(onSave)="createFolder(filePickerExplorerFile)"
						(click)="handleSelectionFromExplorerFile(node)"
					>
					</explorer-file>
					}
				</div>
			</div>
		</kendo-splitter-pane>
	</kendo-splitter>
	<div class="d-flex flex-column file-picker-dialog-explorer-files-bottom">
		<div
			class="d-flex flex-row justify-content-between w-100 align-items-center file-info-container"
		>
			<div
				class="d-flex flex-row file-picker-dialog-explorer-files-bottom-file-name align-items-center"
			>
				<label>File name:</label>
				<kendo-textbox
					class="flex-1"
					[style.height]="'100%'"
					[readonly]="selectionMode === 'folder' || fileMustExist"
					[(value)]="currentSelectionPath"
					[disabled]="!selectedRootFolder"
				>
				</kendo-textbox>
			</div>
			@if (selectionMode === 'file') {
			<div [style.minWidth]="'150px'">
				<kendo-dropdownlist
					[ngModel]="selectedFilePattern"
					size="small"
					(ngModelChange)="handleFilePatternChange($event)"
					[data]="filePatterns"
					[valueField]="'pattern'"
					[textField]="'description'"
				>
				</kendo-dropdownlist>
			</div>
			}
		</div>
	</div>
	<div
		class="d-flex flex-row justify-content-end w-100 pb-2 file-picker-dialog-explorer-files-bottom-buttons"
	>
		<button
			kendoButton
			class="file-picker-dialog-explorer-files-bottom-toolbar-button"
			[disabled]="!hasValidSelection"
			iconClass="fa-solid fa-folder-open"
			themeColor="primary"
			[size]="'small'"
			(click)="submit()"
			[disabled]="!hasValidSelection"
		>
			<span>Open</span>
		</button>
		<button
			kendoButton
			class="file-picker-dialog-explorer-files-bottom-toolbar-button"
			iconClass="fa-solid fa-xmark"
			(click)="cancel()"
			[size]="'small'"
		>
			<span>Cancel</span>
		</button>
	</div>
</div>

./file-picker-dialog.component.scss

/**********************************************************************
 * Copyright © 2006-2026 by Consultingwerk Ltd. ("CW") -              *
 * www.consultingwerk.com and other contributors as listed            *
 * below. All Rights Reserved.                                        *
 *                                                                    *
 *  Software is distributed on an "AS IS", WITHOUT WARRANTY OF ANY    *
 *   KIND, either express or implied.                                 *
 *                                                                    *
 *  Contributors:                                                     *
 *                                                                    *
 **********************************************************************/
/*------------------------------------------------------------------------
    File        : file-picker-dialog.component.scss
    Purpose     : Styles for file picker dialog.
    Author(s)   : Radu Nicoara
    Created     : Apr 07, 2025
  ----------------------------------------------------------------------*/

:host {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
}

.file-picker-dialog {
	display: flex;
	flex-direction: column;
	gap: 5px;
	height: 100%;
    
    .explorer-splitter {
        flex: 1;
        min-height: 0;
		border-radius: 5px;
    }
}

.file-picker-dialog-explorer-files {
	display: flex;
	flex-flow: column wrap;
	gap: 5px;
	align-items: flex-start;
	height: 100%;
    width: 100%;
	overflow-x: auto;
	overflow-y: hidden;
}

.file-picker-dialog-explorer-files-bottom {
	padding-top: 5px;
	padding-left: 5px;
}

.file-picker-dialog-explorer-files-container, .file-picker-dialog-explorer-files-bottom-buttons, .file-picker-dialog-explorer-files-bottom {
	gap: 5px;
}

.file-info-container {
	gap: 10px;
}

.explorer-file-dialog-root-folder {
	display: flex;
	align-items: center;
	gap: 5px;
}

.file-picker-dialog-root-folders {
	height: 100%;
	width: 100%;
	overflow-y: auto;
}

.file-picker-dialog-explorer-files-bottom-file-name {
	flex: 1;
	align-items: center;
	gap: 5px;
	label {
		white-space: nowrap;
	}
}

.explorer-toolbar {
	display: flex;
	align-items: center;
    flex-direction: row;
	gap: 5px;
}

.explorer-toolbar-path {
	display: flex;
    flex-direction: row;
    flex: 1;
	align-items: center;
	gap: 5px;
    border: 1px solid lightgray;
    border-radius: 5px;
    padding: 5px;
    height: 100%;
	overflow-x: auto;
	scrollbar-width: none !important;

    .explorer-toolbar-path-node {
        &:hover {
            background-color: lightgray;	
			border-radius: 5px;
            cursor: pointer !important;
        }
        padding-left: 2px;
        padding-right: 2px;

		::ng-deep .explorer-file {
			cursor: pointer !important;
		}
    }
}

.file-picker-dialog-explorer-toolbar-button {
    border: 1px solid lightgray;
}

.file-picker-dialog-explorer-files-container {
    height: 100%;
    overflow: hidden;
    min-height: 0;
}

::ng-deep .text-select-disabled {
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
}

::ng-deep .file-tree {
	.k-treeview-leaf {
		padding-left: 0px !important;
		padding-bottom: 5px !important;
	}
}

::ng-deep explorer-file.selected {
	border: 1px solid lightgray;
	border-radius: 5px;
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""