Skip to content
This repository has been archived by the owner on Oct 6, 2019. It is now read-only.

Added small and large icons to pages editor #111

Merged
merged 1 commit into from
Nov 6, 2018
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 @@ -797,6 +797,25 @@ protected virtual void UpdateTabInfoFromPageSettings(TabInfo tab, PageSettings p
}
}
}

// icons
if (pageSettings.IconFile != null && pageSettings.IconFile.fileId > 0)
{
tab.IconFile = FileManager.Instance.GetFile(pageSettings.IconFile.fileId).RelativePath;
}
else
{
tab.IconFile = null;
}
if (pageSettings.IconFileLarge != null && pageSettings.IconFileLarge.fileId > 0)
{
tab.IconFileLarge = FileManager.Instance.GetFile(pageSettings.IconFileLarge.fileId).RelativePath;
}
else
{
tab.IconFileLarge = null;
}

}

private string GetContainerSrc(PageSettings pageSettings)
Expand Down Expand Up @@ -1047,6 +1066,30 @@ public PageSettings GetPageSettings(int pageId, PortalSettings requestPortalSett
page.PrimaryAliasId = GetPrimaryAliasId(portalSettings.PortalId, portalSettings.CultureCode);
page.Locales = GetLocales(portalSettings.PortalId);
page.HasParent = tab.ParentId > -1;

// icons
var iconFile = string.IsNullOrEmpty(tab.IconFile) ? null : FileManager.Instance.GetFile(tab.PortalID, tab.IconFileRaw);
if (iconFile != null) {
page.IconFile = new FileDto
{
fileId = iconFile.FileId,
fileName = iconFile.FileName,
folderId = iconFile.FolderId,
folderPath = iconFile.Folder
};
}
var iconFileLarge = string.IsNullOrEmpty(tab.IconFileLarge) ? null : FileManager.Instance.GetFile(tab.PortalID, tab.IconFileLargeRaw);
if (iconFileLarge != null)
{
page.IconFileLarge = new FileDto
{
fileId = iconFileLarge.FileId,
fileName = iconFileLarge.FileName,
folderId = iconFileLarge.FolderId,
folderPath = iconFileLarge.Folder
};
}

return page;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<Compile Include="Services\Dto\DnnPageDto.cs" />
<Compile Include="Services\Dto\DnnPagesRequest.cs" />
<Compile Include="Services\Dto\DnnPagesDto.cs" />
<Compile Include="Services\Dto\FileDto.cs" />
<Compile Include="Services\Dto\ModuleCopyType.cs" />
<Compile Include="Services\Dto\ModuleItem.cs" />
<Compile Include="Services\Dto\PageFolderTemplate.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,8 @@ module.exports = [
"flyout",
"Flyout",
"interactor",
"cloneDeep"
"cloneDeep",
"bmp",
"xml",
"filesystem"
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {connect} from "react-redux";
import PageStandard from "./PageStandard/PageStandard";
import PageUrl from "./PageUrl/PageUrl";
import PageDetailsFooter from "./PageDetailsFooter/PageDetailsFooter";
import PageIcons from "./PageIcons/PageIcons";

class PageDetail extends Component {

Expand All @@ -27,6 +28,7 @@ class PageDetail extends Component {
return (
<div>
<DetailComponent onChangeField={this.props.onChangeField} errors={this.props.errors} onSelectParentPageId={this.props.onSelectParentPageId}/>
<PageIcons components={this.props.components} onChangeField={this.props.onChangeField} errors={this.props.errors} page={this.props.page} />
<PageDetailsFooter components={this.props.components} onChangeField={this.props.onChangeField} errors={this.props.errors} />
</div>
);
Expand All @@ -43,7 +45,7 @@ PageDetail.propTypes = {

const mapStateToProps = (state) => {
return {
page: state.pages.selectedPage
page: state.pages.selectedPage
};
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import React, {Component} from "react";
import PropTypes from "prop-types";
import FileUpload from 'dnn-file-upload';
import GridSystem from "dnn-grid-system";
import GridCell from "dnn-grid-cell";
import Label from 'dnn-label';
import Localization from '../../../localization';
import util from '../../../utils';
import styles from './styles.less';

export default class PageIcons extends Component {
constructor(props) {
super(props);
}

onChangeIcon(key, fileInfo) {
const {onChangeField} = this.props;
onChangeField(key, fileInfo);
}

render() {
const {props} = this;
util.utilities = util.getUtilities();
return (
<div className={styles.pageIcons}>
<GridSystem>
<GridCell className="left-column">
<Label
tooltipMessage={Localization.get("IconFile.Help")}
label={Localization.get("IconFile")}
/>
<FileUpload
utils={util}
onSelectFile={this.onChangeIcon.bind(this, 'iconFile')}
selectedFile={props.page.iconFile}
folderName={props.page.iconFile ? props.page.iconFile.folderName: null}
fileFormats={["image/png", "image/jpg", "image/jpeg", "image/bmp", "image/gif", "image/svg+xml"]}
browseActionText={Localization.get("BrowseAction")} // Press {save|[ENTER]} to save, or {cancel|[ESC]} to cancel
browseButtonText={Localization.get("BrowseButton")} // Browse Filesystem
defaultText={Localization.get("DragOver")} // Drag and Drop a File
fileText={Localization.get("File")} // File
folderText={Localization.get("Folder")} // Folder
imageText={Localization.get("DefaultImageTitle")} // Image
linkButtonText={Localization.get("LinkButton")} // Enter URL Link
linkInputActionText={Localization.get("LinkInputAction")} // Press {save|[ENTER]} to save, or {cancel|[ESC]} to cancel
linkInputPlaceholderText={Localization.get("LinkInputPlaceholder")} // http://example.com/imagename.jpg
linkInputTitleText={Localization.get("LinkInputTitle")} // URL Link
notSpecifiedText={Localization.get("NoneSpecified")} // <None Specified>
searchFilesPlaceHolderText={Localization.get("SearchFilesPlaceHolder")} // Search Files...
searchFoldersPlaceHolderText={Localization.get("SearchFoldersPlaceholder")} // Search Folders...
uploadButtonText={Localization.get("UploadButton")} // Upload a File
uploadCompleteText={Localization.get("UploadComplete")} // Upload Complete
uploadingText={Localization.get("Uploading")} // Uploading...
uploadFailedText={Localization.get("UploadFailed")} // Upload Failed
wrongFormatText={Localization.get("WrongFormat")} // wrong format
/>
</GridCell>
<GridCell className="right-column">
<Label
tooltipMessage={Localization.get("IconFileLarge.Help")}
label={Localization.get("IconFileLarge")}
/>
<FileUpload
utils={util}
onSelectFile={this.onChangeIcon.bind(this, 'iconFileLarge')}
selectedFile={props.page.iconFileLarge}
folderName={props.page.iconFileLarge ? props.page.iconFileLarge.folderName : null}
fileFormats={["image/png", "image/jpg", "image/jpeg", "image/bmp", "image/gif", "image/svg+xml"]}
browseActionText={Localization.get("BrowseAction")} // Press {save|[ENTER]} to save, or {cancel|[ESC]} to cancel
browseButtonText={Localization.get("BrowseButton")} // Browse Filesystem
defaultText={Localization.get("DragOver")} // Drag and Drop a File
fileText={Localization.get("File")} // File
folderText={Localization.get("Folder")} // Folder
imageText={Localization.get("DefaultImageTitle")} // Image
linkButtonText={Localization.get("LinkButton")} // Enter URL Link
linkInputActionText={Localization.get("LinkInputAction")} // Press {save|[ENTER]} to save, or {cancel|[ESC]} to cancel
linkInputPlaceholderText={Localization.get("LinkInputPlaceholder")} // http://example.com/imagename.jpg
linkInputTitleText={Localization.get("LinkInputTitle")} // URL Link
notSpecifiedText={Localization.get("NoneSpecified")} // <None Specified>
searchFilesPlaceHolderText={Localization.get("SearchFilesPlaceHolder")} // Search Files...
searchFoldersPlaceHolderText={Localization.get("SearchFoldersPlaceholder")} // Search Folders...
uploadButtonText={Localization.get("UploadButton")} // Upload a File
uploadCompleteText={Localization.get("UploadComplete")} // Upload Complete
uploadingText={Localization.get("Uploading")} // Uploading...
uploadFailedText={Localization.get("UploadFailed")} // Upload Failed
wrongFormatText={Localization.get("WrongFormat")} // wrong format
/>
</GridCell>
</GridSystem>
</div>
);
}
}

PageIcons.propTypes = {
page: PropTypes.object.isRequired,
errors: PropTypes.object.isRequired,
onChangeField: PropTypes.func.isRequired,
components: PropTypes.func.isRequired
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@import "../../../less/globals.less";
@import "~dnn-global-styles/index";
:local(.pageIcons) {
.dnn-file-upload{
width:100%;
.file-upload-container{
.drop-down{
margin-bottom: 7px;
}
}
}
.dnn-grid-system {
margin-top:15px;
margin-bottom:15px;
.left-column{
padding-right:15px;
}
.right-column{
padding-left:15px;
}
}
.dnn-label{
padding-bottom:10px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ const PageService = function () {
page.hasParent = parentPage && typeof parentPage !== "function" && parentPage.id || page.hasParent;
page.hierarchy = parentPage && typeof parentPage !== "function" && parentPage.id && parentPage.name || page.hierarchy;
page.parentId = parentPage && typeof parentPage !== "function" && parentPage.id || page.parentId;
page.iconFile = null;
page.iconFileLarge = null;
return page;
});
};
Expand Down
17 changes: 17 additions & 0 deletions Extensions/Content/Dnn.PersonaBar.Pages/Services/Dto/FileDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Dnn.PersonaBar.Pages.Services.Dto
{
[JsonObject]
public class FileDto
{
public int fileId { get; set; }
public string fileName { get; set; }
public int folderId { get; set; }
public string folderPath { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,11 @@ public class PageSettings

[DataMember(Name = "isspecial")]
public bool IsSpecial { get; set; }

[DataMember(Name = "iconFile")]
public FileDto IconFile { get; set; }

[DataMember(Name = "iconFileLarge")]
public FileDto IconFileLarge { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1690,4 +1690,16 @@
<data name="EditContent.Text" xml:space="preserve">
<value>Edit Content</value>
</data>
<data name="IconFile.Help" xml:space="preserve">
<value>The page icon is an image that may be used by your theme or menu system for each page</value>
</data>
<data name="IconFile.Text" xml:space="preserve">
<value>Small Icon</value>
</data>
<data name="IconFileLarge.Help" xml:space="preserve">
<value>The page icon is an image that may be used by your theme or menu system for each page</value>
</data>
<data name="IconFileLarge.Text" xml:space="preserve">
<value>Large Icon</value>
</data>
</root>