Skip to content

Commit

Permalink
Merge pull request #69 from valadas/edit-folder
Browse files Browse the repository at this point in the history
Added folder editing capability
  • Loading branch information
valadas authored Mar 30, 2022
2 parents 04cba65 + 1561210 commit bb137ad
Show file tree
Hide file tree
Showing 38 changed files with 1,367 additions and 273 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,22 @@
<data name="MappedPath.Text" xml:space="preserve">
<value>Mapped Path</value>
</data>
<data name="Edit.Text" xml:space="preserve">
<value>Edit</value>
</data>
<data name="RolePermissions.Text" xml:space="preserve">
<value>Role Permissions</value>
</data>
<data name="UserPermissions.Text" xml:space="preserve">
<value>User Permissions</value>
</data>
<data name="FolderId.Text" xml:space="preserve">
<value>Folder ID</value>
</data>
<data name="General.Text" xml:space="preserve">
<value>General</value>
</data>
<data name="Permissions.Text" xml:space="preserve">
<value>Permissions</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void SaveFileDetails(IFileInfo file, FileDetailsRequest fileDetails)
public void SaveFolderDetails(IFolderInfo folder, FolderDetailsRequest folderDetails)
{
this.assetManager.RenameFolder(folderDetails.FolderId, folderDetails.FolderName);
folder.FolderPermissions.Clear();
folder.FolderPermissions.Clear();
folder.FolderPermissions.AddRange(folderDetails.Permissions.RolePermissions.ToPermissionInfos(folderDetails.FolderId));
folder.FolderPermissions.AddRange(folderDetails.Permissions.UserPermissions.ToPermissionInfos(folderDetails.FolderId));
FolderManager.Instance.UpdateFolder(folder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public static ArrayList ToPermissionInfos(this IList<UserPermission> permissions
AllowAccess = p.AllowAccess,
FolderID = folderId,
PermissionID = p.PermissionId,
RoleID = Null.NullInteger,
RoleID = int.Parse(Globals.glbRoleNothing),
UserID = permission.UserId,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
<Compile Include="Services\Dto\MoveFolderRequest.cs" />
<Compile Include="Services\Dto\Permission.cs" />
<Compile Include="Services\Dto\Permissions.cs" />
<Compile Include="Services\Dto\RoleGroupDto.cs" />
<Compile Include="Services\Dto\RolePermission.cs" />
<Compile Include="Services\Dto\ThumbnailDownloadRequest.cs" />
<Compile Include="Services\Dto\UserPermission.cs" />
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"license": "MIT",
"devDependencies": {
"@dnncommunity/dnn-elements": "0.14.1",
"@dnncommunity/dnn-elements": "^0.15.0-beta.21",
"@stencil/sass": "^1.5.2",
"@stencil/store": "^1.5.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
* It contains typing information for all components that exist in this project.
*/
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
import { GetFolderContentResponse, Item } from "./services/ItemsClient";
import { FolderTreeItem } from "./services/InternalServicesClient";
import { GetFolderContentResponse } from "./services/ItemsClient";
export namespace Components {
interface DnnActionCreateFolder {
"parentFolderId": number;
}
interface DnnActionEditItem {
"item": Item;
}
interface DnnResourceManager {
/**
* The ID of the module.
Expand All @@ -19,7 +22,13 @@ export namespace Components {
}
interface DnnRmActionsBar {
}
interface DnnRmCreateFolder {
}
interface DnnRmEditFolder {
/**
* The ID of the folder to edit.
*/
"folderId": number;
}
interface DnnRmFilesPane {
/**
Expand All @@ -29,9 +38,9 @@ export namespace Components {
}
interface DnnRmFolderContextMenu {
/**
* The ID of the folder onto which the context menu was triggered on.
* The item that triggered this menu.
*/
"clickedFolderId": number;
"item": Item;
}
interface DnnRmFolderList {
}
Expand All @@ -44,6 +53,10 @@ export namespace Components {
* The basic information about the folder
*/
"folder": FolderTreeItem;
/**
* The ID of the parent folder.
*/
"parentFolderId": number;
}
interface DnnRmItemsCardview {
/**
Expand Down Expand Up @@ -73,6 +86,12 @@ declare global {
prototype: HTMLDnnActionCreateFolderElement;
new (): HTMLDnnActionCreateFolderElement;
};
interface HTMLDnnActionEditItemElement extends Components.DnnActionEditItem, HTMLStencilElement {
}
var HTMLDnnActionEditItemElement: {
prototype: HTMLDnnActionEditItemElement;
new (): HTMLDnnActionEditItemElement;
};
interface HTMLDnnResourceManagerElement extends Components.DnnResourceManager, HTMLStencilElement {
}
var HTMLDnnResourceManagerElement: {
Expand All @@ -85,6 +104,12 @@ declare global {
prototype: HTMLDnnRmActionsBarElement;
new (): HTMLDnnRmActionsBarElement;
};
interface HTMLDnnRmCreateFolderElement extends Components.DnnRmCreateFolder, HTMLStencilElement {
}
var HTMLDnnRmCreateFolderElement: {
prototype: HTMLDnnRmCreateFolderElement;
new (): HTMLDnnRmCreateFolderElement;
};
interface HTMLDnnRmEditFolderElement extends Components.DnnRmEditFolder, HTMLStencilElement {
}
var HTMLDnnRmEditFolderElement: {
Expand Down Expand Up @@ -153,8 +178,10 @@ declare global {
};
interface HTMLElementTagNameMap {
"dnn-action-create-folder": HTMLDnnActionCreateFolderElement;
"dnn-action-edit-item": HTMLDnnActionEditItemElement;
"dnn-resource-manager": HTMLDnnResourceManagerElement;
"dnn-rm-actions-bar": HTMLDnnRmActionsBarElement;
"dnn-rm-create-folder": HTMLDnnRmCreateFolderElement;
"dnn-rm-edit-folder": HTMLDnnRmEditFolderElement;
"dnn-rm-files-pane": HTMLDnnRmFilesPaneElement;
"dnn-rm-folder-context-menu": HTMLDnnRmFolderContextMenuElement;
Expand All @@ -172,6 +199,9 @@ declare namespace LocalJSX {
interface DnnActionCreateFolder {
"parentFolderId"?: number;
}
interface DnnActionEditItem {
"item": Item;
}
interface DnnResourceManager {
/**
* The ID of the module.
Expand All @@ -180,7 +210,17 @@ declare namespace LocalJSX {
}
interface DnnRmActionsBar {
}
interface DnnRmCreateFolder {
/**
* Fires when there is a possibility that some folders have changed. Can be used to force parts of the UI to refresh.
*/
"onDnnRmFoldersChanged"?: (event: CustomEvent<void>) => void;
}
interface DnnRmEditFolder {
/**
* The ID of the folder to edit.
*/
"folderId": number;
/**
* Fires when there is a possibility that some folders have changed. Can be used to force parts of the UI to refresh.
*/
Expand All @@ -194,9 +234,9 @@ declare namespace LocalJSX {
}
interface DnnRmFolderContextMenu {
/**
* The ID of the folder onto which the context menu was triggered on.
* The item that triggered this menu.
*/
"clickedFolderId": number;
"item": Item;
}
interface DnnRmFolderList {
}
Expand All @@ -213,6 +253,10 @@ declare namespace LocalJSX {
* Fires when a context menu is opened for this item. Emits the folder ID.
*/
"onDnnRmcontextMenuOpened"?: (event: CustomEvent<number>) => void;
/**
* The ID of the parent folder.
*/
"parentFolderId": number;
}
interface DnnRmItemsCardview {
/**
Expand All @@ -236,8 +280,10 @@ declare namespace LocalJSX {
}
interface IntrinsicElements {
"dnn-action-create-folder": DnnActionCreateFolder;
"dnn-action-edit-item": DnnActionEditItem;
"dnn-resource-manager": DnnResourceManager;
"dnn-rm-actions-bar": DnnRmActionsBar;
"dnn-rm-create-folder": DnnRmCreateFolder;
"dnn-rm-edit-folder": DnnRmEditFolder;
"dnn-rm-files-pane": DnnRmFilesPane;
"dnn-rm-folder-context-menu": DnnRmFolderContextMenu;
Expand All @@ -256,8 +302,10 @@ declare module "@stencil/core" {
export namespace JSX {
interface IntrinsicElements {
"dnn-action-create-folder": LocalJSX.DnnActionCreateFolder & JSXBase.HTMLAttributes<HTMLDnnActionCreateFolderElement>;
"dnn-action-edit-item": LocalJSX.DnnActionEditItem & JSXBase.HTMLAttributes<HTMLDnnActionEditItemElement>;
"dnn-resource-manager": LocalJSX.DnnResourceManager & JSXBase.HTMLAttributes<HTMLDnnResourceManagerElement>;
"dnn-rm-actions-bar": LocalJSX.DnnRmActionsBar & JSXBase.HTMLAttributes<HTMLDnnRmActionsBarElement>;
"dnn-rm-create-folder": LocalJSX.DnnRmCreateFolder & JSXBase.HTMLAttributes<HTMLDnnRmCreateFolderElement>;
"dnn-rm-edit-folder": LocalJSX.DnnRmEditFolder & JSXBase.HTMLAttributes<HTMLDnnRmEditFolderElement>;
"dnn-rm-files-pane": LocalJSX.DnnRmFilesPane & JSXBase.HTMLAttributes<HTMLDnnRmFilesPaneElement>;
"dnn-rm-folder-context-menu": LocalJSX.DnnRmFolderContextMenu & JSXBase.HTMLAttributes<HTMLDnnRmFolderContextMenuElement>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class DnnActionCreateFolder {
const modal = document.createElement("dnn-modal");
modal.backdropDismiss = false;
modal.showCloseButton = false;
const editor = document.createElement("dnn-rm-edit-folder");
const editor = document.createElement("dnn-rm-create-folder");
modal.appendChild(editor);
document.body.appendChild(modal);
modal.show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
### Depends on

- dnn-modal
- [dnn-rm-edit-folder](../../dnn-rm-edit-folder)
- [dnn-rm-create-folder](../../dnn-rm-create-folder)

### Graph
```mermaid
graph TD;
dnn-action-create-folder --> dnn-modal
dnn-action-create-folder --> dnn-rm-edit-folder
dnn-rm-edit-folder --> dnn-button
dnn-action-create-folder --> dnn-rm-create-folder
dnn-rm-create-folder --> dnn-button
dnn-button --> dnn-modal
dnn-button --> dnn-button
dnn-rm-actions-bar --> dnn-action-create-folder
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Component, Host, h, Prop } from '@stencil/core';
import { Item } from '../../../services/ItemsClient';
import state from "../../../store/store";

@Component({
tag: 'dnn-action-edit-item',
styleUrl: '../dnn-action.scss',
shadow: true,
})
export class DnnActionEditItem {

@Prop() item!: Item;

private handleClick(): void {
this.showModal();
}

private showModal(){
const modal = document.createElement("dnn-modal");
modal.backdropDismiss = false;
modal.showCloseButton = false;
// We also need to show a different model depending if we have a file or folder
if (this.item.isFolder){
const editor = document.createElement("dnn-rm-edit-folder") as HTMLDnnRmEditFolderElement;
editor.folderId = this.item.itemId;
modal.appendChild(editor);
}
document.body.appendChild(modal);
modal.show();
}

render() {
return (
<Host>
<button onClick={() => this.handleClick()}>
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M14.06 9.02l.92.92L5.92 19H5v-.92l9.06-9.06M17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29zm-3.6 3.19L3 17.25V21h3.75L17.81 9.94l-3.75-3.75z"/></svg>
<span>{state.localization.Edit}</span>
</button>
</Host>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# dnn-action-edit-item



<!-- Auto Generated Below -->


## Properties

| Property | Attribute | Description | Type | Default |
| ------------------- | --------- | ----------- | ------ | ----------- |
| `item` _(required)_ | -- | | `Item` | `undefined` |


## Dependencies

### Used by

- [dnn-rm-actions-bar](../../dnn-rm-actions-bar)
- [dnn-rm-folder-context-menu](../../context-menus/dnn-rm-folder-context-menu)

### Depends on

- dnn-modal
- [dnn-rm-edit-folder](../../dnn-rm-edit-folder)

### Graph
```mermaid
graph TD;
dnn-action-edit-item --> dnn-modal
dnn-action-edit-item --> dnn-rm-edit-folder
dnn-rm-edit-folder --> dnn-tabs
dnn-rm-edit-folder --> dnn-tab
dnn-rm-edit-folder --> dnn-permissions-grid
dnn-rm-edit-folder --> dnn-button
dnn-permissions-grid --> dnn-checkbox
dnn-permissions-grid --> dnn-button
dnn-permissions-grid --> dnn-searchbox
dnn-permissions-grid --> dnn-collapsible
dnn-button --> dnn-modal
dnn-button --> dnn-button
dnn-rm-actions-bar --> dnn-action-edit-item
dnn-rm-folder-context-menu --> dnn-action-edit-item
style dnn-action-edit-item fill:#f9f,stroke:#333,stroke-width:4px
```

----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
Loading

0 comments on commit bb137ad

Please sign in to comment.