Skip to content

Commit

Permalink
Fixes issues with single folder in document template dialog "Hent dok…
Browse files Browse the repository at this point in the history
…umentmal" (#376)
  • Loading branch information
olemp authored Feb 9, 2021
1 parent 9db3784 commit 3e9ec42
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 83 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

Every change is marked with Pull Request ID.

## 1.2.4 - TBA
## 1.2.5 - TBA

## Fixed

- Fixes issues with single folder in "Hent dokumentmal" #376

## 1.2.4 - 30.11.2020

## Added

Expand Down
4 changes: 2 additions & 2 deletions SharePointFramework/PortfolioWebParts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"object-assign": "4.1.1",
"object-get": "2.1.0",
"office-ui-fabric-react": "6.214.0",
"pp365-shared": "file:../@Shared",
"pp365-projectwebparts": "file:../ProjectWebParts",
"pp365-shared": "1.2.6",
"pp365-projectwebparts": "1.2.6",
"react": "16.8.5",
"react-calendar-timeline": "0.26.6",
"react-dom": "16.8.5",
Expand Down
2 changes: 1 addition & 1 deletion SharePointFramework/ProjectExtensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@uifabric/utilities": "6.45.1",
"msgraph-helper": "0.8.3",
"office-ui-fabric-react": "6.214.0",
"pp365-shared": "file:../@Shared",
"pp365-shared": "1.2.6",
"react": "16.8.5",
"react-dom": "16.8.5",
"react-markdown": "4.2.2",
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { SPDataAdapter } from 'data'
import { Icon } from 'office-ui-fabric-react/lib/Icon'
import { TextField } from 'office-ui-fabric-react/lib/TextField'
import * as strings from 'ProjectExtensionsStrings'
import * as React from 'react'
import React, { useState, useEffect, FormEvent } from 'react'
import styles from './DocumentTemplateItem.module.scss'
import { IDocumentTemplateItemProps } from './IDocumentTemplateItemProps'
import { IDocumentTemplateItemProps } from './types'

// tslint:disable-next-line: naming-convention
export const DocumentTemplateItem = (props: IDocumentTemplateItemProps) => {
const nameId = getId('name')
const titleId = getId('title')
let changeTimeout: number
const [isExpanded, setIsExpanded] = React.useState(false)
const [isExpanded, setIsExpanded] = useState(false)

/**
* On input change
Expand All @@ -22,9 +22,9 @@ export const DocumentTemplateItem = (props: IDocumentTemplateItemProps) => {
* @param {number} resolveDelay Resolve delay
*/
function onInputChange(
event: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>,
event: FormEvent<HTMLInputElement | HTMLTextAreaElement>,
newValue: string,
resolveDelay = 400
resolveDelay: number = 400
) {
clearTimeout(changeTimeout)
changeTimeout = setTimeout(async () => {
Expand All @@ -49,7 +49,7 @@ export const DocumentTemplateItem = (props: IDocumentTemplateItemProps) => {
}, resolveDelay)
}

React.useEffect(() => {
useEffect(() => {
SPDataAdapter.isFilenameValid(props.folderServerRelativeUrl, props.model.name).then(
(errorMessage) => {
if (errorMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ export interface IDocumentTemplateItemProps {
*/
folderServerRelativeUrl: string
}

export interface IDocumentTemplateItemState {
/**
* Is expanded
*/
isExpanded: boolean
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { stringIsNullOrEmpty, TypedHash } from '@pnp/common'
import { ISPLibraryFolder } from 'data/SPDataAdapter/ISPLibraryFolder'
import { DefaultButton, PrimaryButton } from 'office-ui-fabric-react/lib/Button'
import { DialogFooter } from 'office-ui-fabric-react/lib/Dialog'
import { Dropdown, IDropdownOption } from 'office-ui-fabric-react/lib/Dropdown'
import * as strings from 'ProjectExtensionsStrings'
import * as React from 'react'
import React, { useState } from 'react'
import { InfoMessage } from '../../InfoMessage'
import { DocumentTemplateDialogScreen } from '../DocumentTemplateDialogScreen'
import { DocumentTemplateDialogScreen } from '../types'
import styles from './DocumentTemplateDialogScreenEditCopy.module.scss'
import { DocumentTemplateItem } from './DocumentTemplateItem'
import { IDocumentTemplateDialogScreenEditCopyProps } from './IDocumentTemplateDialogScreenEditCopyProps'
import { ISPLibraryFolder } from 'data/SPDataAdapter/ISPLibraryFolder'
import { IDocumentTemplateDialogScreenEditCopyProps } from './types'

// tslint:disable-next-line: naming-convention
export const DocumentTemplateDialogScreenEditCopy = (
props: IDocumentTemplateDialogScreenEditCopyProps
) => {
const [templates, setTemplates] = React.useState([...props.selectedTemplates])
const [selectedLibrary, setLibrary] = React.useState<ISPLibraryFolder>(props.libraries[0])
const [selectedFolder, setFolder] = React.useState<ISPLibraryFolder>(null)
const [templates, setTemplates] = useState([...props.selectedTemplates])
const [selectedLibrary, setLibrary] = useState<ISPLibraryFolder>(props.libraries[0])
const [selectedFolder, setFolder] = useState<ISPLibraryFolder>(null)

/**
* On input changed
Expand Down Expand Up @@ -45,23 +45,19 @@ export const DocumentTemplateDialogScreenEditCopy = (
/**
* On library changed
*
* @param {any} _event Event
* @param {IDropdownOption} option Option
* @param {number} _index Index
*/
function onLibraryChanged(_event: React.FormEvent<HTMLDivElement>, option: IDropdownOption) {
function onLibraryChanged(option: IDropdownOption) {
setLibrary(option.data)
setFolder(null)
}

/**
* On folder changed
*
* @param {any} _event Event
* @param {IDropdownOption} option Option
* @param {number} _index Index
*/
function onFolderChanged(_event: React.FormEvent<HTMLDivElement>, option: IDropdownOption) {
function onFolderChanged(option: IDropdownOption) {
setFolder(option.data)
}

Expand Down Expand Up @@ -93,25 +89,28 @@ export const DocumentTemplateDialogScreenEditCopy = (
disabled={props.libraries.length === 1}
label={strings.DocumentLibraryDropdownLabel}
defaultSelectedKey={selectedLibrary.Id}
onChange={onLibraryChanged}
onChange={(_, option) => onLibraryChanged(option)}
options={props.libraries.map((lib) => ({ key: lib.Id, text: lib.Title, data: lib }))}
/>
</div>
<div>
<Dropdown
disabled={selectedLibrary.Folders.length < 2}
disabled={selectedLibrary.Folders.length < 1}
label={strings.FolderDropdownLabel}
placeholder={
selectedLibrary.Folders.length === 0 &&
`Det finnes ingen mapper i ${selectedLibrary.Title}.`
}
defaultSelectedKey={selectedFolder && selectedFolder.Id}
options={selectedLibrary.Folders.map((fld) => ({
key: fld.Id,
text: fld.Title,
data: fld
}))}
onChange={onFolderChanged}
defaultSelectedKey={selectedFolder ? selectedFolder.Id : '-'}
options={[
{
key: '-',
text: strings.DocumentTemplateDialogScreenEditCopyRootLevelText,
data: null
},
...selectedLibrary.Folders.map((fld) => ({
key: fld.Id,
text: fld.Title,
data: fld
}))
]}
onChange={(_, option) => onFolderChanged(option)}
/>
</div>
<DialogFooter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DocumentTemplateDialogScreen } from '..'
import { IDocumentLibrary, TemplateFile } from '../../../models'
import { DocumentTemplateDialogScreen } from '../DocumentTemplateDialogScreen'

export interface IDocumentTemplateDialogScreenEditCopyProps {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import {
SelectionMode
} from 'office-ui-fabric-react/lib/DetailsList'
import { MarqueeSelection } from 'office-ui-fabric-react/lib/MarqueeSelection'
import * as strings from 'ProjectExtensionsStrings'
import * as React from 'react'
import { format } from 'office-ui-fabric-react/lib/Utilities'
import * as strings from 'ProjectExtensionsStrings'
import React, { Component, ReactElement } from 'react'
import { InfoMessage } from '../../InfoMessage'
import {
DocumentTemplateDialogScreenSelectDefaultProps,
IDocumentTemplateDialogScreenSelectProps
} from './IDocumentTemplateDialogScreenSelectProps'
} from './types'

export class DocumentTemplateDialogScreenSelect extends React.Component<
export class DocumentTemplateDialogScreenSelect extends Component<
IDocumentTemplateDialogScreenSelectProps,
{}
> {
public static defaultProps = DocumentTemplateDialogScreenSelectDefaultProps

public render(): React.ReactElement<IDocumentTemplateDialogScreenSelectProps> {
public render(): ReactElement<IDocumentTemplateDialogScreenSelectProps> {
return (
<>
<InfoMessage
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,26 @@ import { MessageBarType } from 'office-ui-fabric-react/lib/MessageBar'
import { ProgressIndicator } from 'office-ui-fabric-react/lib/ProgressIndicator'
import { format } from 'office-ui-fabric-react/lib/Utilities'
import * as strings from 'ProjectExtensionsStrings'
import * as React from 'react'
import React, { useState } from 'react'
import { SPDataAdapter } from '../../data'
import { TemplateFile } from '../../models/index'
import { BaseDialog } from '../@BaseDialog/index'
import { InfoMessage } from '../InfoMessage'
import styles from './DocumentTemplateDialog.module.scss'
import { DocumentTemplateDialogScreen } from './DocumentTemplateDialogScreen'
import { DocumentTemplateDialogScreenEditCopy } from './DocumentTemplateDialogScreenEditCopy'
import { DocumentTemplateDialogScreenSelect } from './DocumentTemplateDialogScreenSelect'
import { IDocumentTemplateDialogProps } from './IDocumentTemplateDialogProps'
import { DocumentTemplateDialogScreen, IDocumentTemplateDialogProps } from './types'

// tslint:disable-next-line: naming-convention
export const DocumentTemplateDialog = (props: IDocumentTemplateDialogProps) => {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
const selection = new Selection({ onSelectionChanged })

const [selected, setSelected] = React.useState([])
const [progress, setProgress] = React.useState(null)
const [screen, setScreen] = React.useState(DocumentTemplateDialogScreen.Select)
const [isBlocking, setIsBlocking] = React.useState(false)
const [uploaded, setUploaded] = React.useState([])
const [selected, setSelected] = useState([])
const [progress, setProgress] = useState(null)
const [screen, setScreen] = useState(DocumentTemplateDialogScreen.Select)
const [isBlocking, setIsBlocking] = useState(false)
const [uploaded, setUploaded] = useState([])

function onSelectionChanged() {
setSelected(selection.getSelection() as TemplateFile[])
Expand Down Expand Up @@ -147,5 +146,5 @@ export const DocumentTemplateDialog = (props: IDocumentTemplateDialogProps) => {
)
}

export * from './IDocumentTemplateDialogDismissProps'
export * from './types'
export { IDocumentTemplateDialogProps }
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { TemplateFile, IDocumentLibrary } from '../../models'
import { IDocumentTemplateDialogDismissProps } from './IDocumentTemplateDialogDismissProps'

export interface IDocumentTemplateDialogDismissProps {
reload?: boolean
}

export interface IDocumentTemplateDialogProps {
/**
Expand Down Expand Up @@ -27,3 +30,25 @@ export interface IDocumentTemplateDialogProps {
*/
onDismiss: (props: IDocumentTemplateDialogDismissProps) => void
}

export enum DocumentTemplateDialogScreen {
/**
* Select screen
*/
Select,

/**
* Edit copy screen
*/
EditCopy,

/**
* Copy progess screen
*/
CopyProgress,

/**
* Summary scren
*/
Summary
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare interface IProjectExtensionsStrings {
DocumentTemplateDialogScreenEditCopyRootLevelText: string
ApplyExtensionText: string;
ProcessListItemText: string;
ProcessFileText: string;
Expand Down
3 changes: 2 additions & 1 deletion SharePointFramework/ProjectExtensions/src/loc/nb-no.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ define([], function () {
UnknownErrorText: 'Ukjent feil',
TemplateListContentConfigText: 'Den valgte prosjektmalen inneholder konfigurasjon for standardinnhold.',
FolderDropdownLabel:'Velg mappe',
DocumentLibraryDropdownLabel: 'Velg dokumentbibliotek'
DocumentLibraryDropdownLabel: 'Velg dokumentbibliotek',
DocumentTemplateDialogScreenEditCopyRootLevelText: 'Øverste nivå'
}
});

0 comments on commit 3e9ec42

Please sign in to comment.