Skip to content

Commit 081e193

Browse files
Merge pull request #126 from microsoft/feature
1. Added Password field support
2 parents c074707 + d84787e commit 081e193

5 files changed

Lines changed: 64 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fluentui-editable-grid",
3-
"version": "1.11.2",
3+
"version": "1.12.0",
44
"license": "MIT",
55
"description": "Wrapper over the existing DetailsList that makes in-place editability work like a dream(among many other new features)",
66
"main": "dist/index.js",

src/Examples/gridconsumer/gridconfig.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
import React from "react";
45
import { NumberAndDateOperators, StringOperators } from "../../libs/types/cellstyleruletype";
56
import { IColumnConfig } from "../../libs/types/columnconfigtype";
67
import { EditControlType } from "../../libs/types/editcontroltype";
@@ -50,6 +51,20 @@ export const GridColumnConfig : IColumnConfig[] =
5051
includeColumnInSearch: true,
5152
applyColumnFilter: true
5253
},
54+
{
55+
key: 'password',
56+
name: 'Password',
57+
text: 'Password',
58+
editable: true,
59+
dataType: 'string',
60+
minWidth: 100,
61+
maxWidth: 100,
62+
isResizable: true,
63+
includeColumnInExport: true,
64+
includeColumnInSearch: true,
65+
applyColumnFilter: true,
66+
inputType: EditControlType.Password
67+
},
5368
{
5469
key: 'age',
5570
name: 'Age',
@@ -192,6 +207,7 @@ export interface GridItemsType {
192207
id: number;
193208
customerhovercol: string;
194209
name: string;
210+
password: string;
195211
age: number;
196212
designation: string;
197213
salary: number;

src/Examples/gridconsumer/gridconsumer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ const Consumer = () => {
151151
id: i,
152152
customerhovercol: 'Hover Me',
153153
name: 'Name'+ GetRandomInt(1, 10),
154+
password: "somepassword",
154155
age: GetRandomInt(20,40),
155156
designation: 'Designation' + GetRandomInt(1, 15),
156157
salary: GetRandomInt(35000, 75000),
@@ -224,7 +225,7 @@ const Consumer = () => {
224225
};
225226

226227
const onCheckboxChange = (ev?: React.FormEvent<HTMLElement | HTMLInputElement>, checked?: boolean): void => {
227-
setGridConfigOptions({...gridConfigOptions, [(ev.target as Element).id]: !gridConfigOptions[(ev.target as Element).id] })
228+
setGridConfigOptions({...gridConfigOptions, [(ev!.target as Element).id]: !gridConfigOptions[(ev!.target as Element).id] })
228229
};
229230

230231
return (
@@ -350,7 +351,7 @@ const Consumer = () => {
350351
<TeachingBubble
351352
target={teachingBubblePropsConfig?.config.target}
352353
primaryButtonProps={teachingBubblePropsConfig?.id < teachingBubbleConfig.length - 1 ? nextBubbleProps : closeButtonProps}
353-
secondaryButtonProps={teachingBubblePropsConfig?.id > 0 ? previousBubbleProps : null}
354+
secondaryButtonProps={teachingBubblePropsConfig?.id > 0 ? previousBubbleProps : undefined}
354355
onDismiss={toggleTeachingBubbleVisible}
355356
footerContent={teachingBubblePropsConfig?.config.footerContent}
356357
headline={teachingBubblePropsConfig?.config.headline}

src/libs/editablegrid/editablegrid.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,37 @@ const EditableGrid = (props: Props) => {
12521252
(RenderLinkSpan(props, index, rowNum, column, item, EditCellValue))
12531253
)
12541254
}</span>
1255+
case EditControlType.Password:
1256+
return <span>{
1257+
(ShouldRenderSpan())
1258+
?
1259+
(column?.hoverComponentOptions?.enable ?
1260+
(<HoverCard
1261+
type={HoverCardType.plain}
1262+
plainCardProps={{
1263+
onRenderPlainCard: () => onRenderPlainCard(column, rowNum!, item),
1264+
}}
1265+
instantOpenOnClick
1266+
>
1267+
{RenderPasswordFieldSpan(props, index, rowNum, column, item, EditCellValue)}
1268+
</HoverCard>)
1269+
:
1270+
(RenderPasswordFieldSpan(props, index, rowNum, column, item, EditCellValue))
1271+
)
1272+
:
1273+
(<TextField
1274+
errorMessage={activateCellEdit[rowNum!]['properties'][column.key].error}
1275+
label={item.text}
1276+
ariaLabel={column.key}
1277+
styles={textFieldStyles}
1278+
onChange={(ev, text) => onCellValueChange(ev, text!, item, rowNum!, column.key, column)}
1279+
autoFocus={!props.enableDefaultEditMode && !editMode && !(activateCellEdit?.[Number(item['_grid_row_id_'])!]?.['isActivated'])}
1280+
value={activateCellEdit[rowNum!]['properties'][column.key].value}
1281+
onKeyDown={(event) => onKeyDownEvent(event, column, rowNum!, false)}
1282+
maxLength={column.maxLength != null ? column.maxLength : 1000}
1283+
type="password"
1284+
canRevealPassword
1285+
/>)}</span>
12551286
default:
12561287
return <span>{
12571288
(ShouldRenderSpan())
@@ -1633,6 +1664,17 @@ const EditableGrid = (props: Props) => {
16331664
const RenderTextFieldSpan = (props: Props, index: number, rowNum: number, column: IColumnConfig, item: any, EditCellValue: (key: string, rowNum: number, activateCurrentCell: boolean) => void): React.ReactNode => {
16341665
return RenderSpan(props, index, rowNum, column, item, HandleCellOnClick, EditCellValue, HandleCellOnDoubleClick);
16351666
}
1667+
1668+
const RenderPasswordFieldSpan = (props: Props, index: number, rowNum: number, column: IColumnConfig, item: any, EditCellValue: (key: string, rowNum: number, activateCurrentCell: boolean) => void): React.ReactNode => {
1669+
return <span
1670+
id={`id-${props.id}-col-${index}-row-${rowNum}`}
1671+
className={GetDynamicSpanStyles(column, item[column.key])}
1672+
onClick={HandleCellOnClick(props, column, EditCellValue, rowNum)}
1673+
onDoubleClick={HandleCellOnDoubleClick(props, column, EditCellValue, rowNum)}
1674+
>
1675+
{item[column.key].replace(/./g, '*')}
1676+
</span>;
1677+
}
16361678

16371679
const RenderPickerSpan = (props: Props, index: number, rowNum: number, column: IColumnConfig, item: any, EditCellValue: (key: string, rowNum: number, activateCurrentCell: boolean) => void): React.ReactNode => {
16381680
return RenderSpan(props, index, rowNum, column, item, HandleCellOnClick, EditCellValue, HandleCellOnDoubleClick);

src/libs/types/editcontroltype.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ export enum EditControlType {
99
MultilineTextField,
1010
DateTime,
1111
Picker,
12-
Link
12+
Link,
13+
Password
1314
}

0 commit comments

Comments
 (0)