cleanup
This commit is contained in:
parent
31a14fa9ef
commit
5e34ee7cb7
|
@ -132,19 +132,18 @@ export default class PropertyBagDisplay extends React.Component<IPropertyBagDisp
|
|||
|
||||
<tbody>
|
||||
{this.state.workingStorage.DisplayProps.map((dp, i) => {
|
||||
return (<tr>
|
||||
return (<tr key={dp.managedPropertyName}>
|
||||
<td>{dp.managedPropertyName}</td>
|
||||
<td>{this.state.workingStorage[dp.managedPropertyName]}</td>
|
||||
<td>{dp.crawledPropertyName}</td>
|
||||
<td>
|
||||
<TextField
|
||||
data-crawledPropertyName={dp.crawledPropertyName}
|
||||
value={dp.value}
|
||||
onChange={(event: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>, newValue?: string) => {
|
||||
const selectedProperty = dp.crawledPropertyName;
|
||||
const temp: DisplayProp = _.find(this.state.workingStorage.DisplayProps, p => { return p.crawledPropertyName === selectedProperty; });
|
||||
dp.value = newValue;
|
||||
this.setState(this.state);
|
||||
debugger;
|
||||
const ws = _.clone(this.state.workingStorage);
|
||||
_.find(ws.DisplayProps, p => { return p.crawledPropertyName === dp.crawledPropertyName; }).value = newValue;
|
||||
this.setState((current) => ({ ...current, workingStorage: ws }));
|
||||
}}
|
||||
/>
|
||||
</td>
|
||||
|
@ -328,9 +327,6 @@ export default class PropertyBagDisplay extends React.Component<IPropertyBagDisp
|
|||
* @memberOf PropertyBagDisplay
|
||||
*/
|
||||
public componentDidMount(): void {
|
||||
// this.state.columns = this.setupColumns();
|
||||
// this.state.managedToCrawedMapping = [];
|
||||
// this.state.managedPropNames = [];
|
||||
let initState = {
|
||||
|
||||
columns: this.setupColumns(),
|
||||
|
@ -382,7 +378,6 @@ export default class PropertyBagDisplay extends React.Component<IPropertyBagDisp
|
|||
initState.sites.push(obj);
|
||||
}
|
||||
debugger;
|
||||
//initState.errorMessages.push(new md.Message("Items Recieved"));
|
||||
this.setState({ ...initState });
|
||||
}).catch(err => {
|
||||
debugger;
|
||||
|
@ -400,7 +395,6 @@ export default class PropertyBagDisplay extends React.Component<IPropertyBagDisp
|
|||
* @memberOf PropertyBagDisplay
|
||||
*/
|
||||
public onActiveItemChanged(item?: any, index?: number): void {
|
||||
//this.state.selectedIndex = index;
|
||||
this.setState((current) => ({ ...current, selectedIndex: index }));
|
||||
}
|
||||
|
||||
|
@ -425,15 +419,15 @@ export default class PropertyBagDisplay extends React.Component<IPropertyBagDisp
|
|||
if (this.state.workingStorage.forceCrawl) {
|
||||
utils.forceCrawl(this.state.workingStorage.Url);
|
||||
}
|
||||
|
||||
debugger;
|
||||
this.setState((current) => ({ ...current, workingStorage: null, isediting: false }));
|
||||
|
||||
this.setState(this.state);
|
||||
}).catch((err) => {
|
||||
debugger;
|
||||
this.state.workingStorage.errorMessages.push(new md.Message(err));
|
||||
this.setState(this.state);
|
||||
console.log(err);
|
||||
const temp = _.clone(this.state.workingStorage);
|
||||
temp.errorMessages.push(new md.Message(err));
|
||||
this.setState(current => ({ ...current, workingStorage: temp }))
|
||||
});
|
||||
}
|
||||
/**
|
||||
|
@ -444,8 +438,6 @@ export default class PropertyBagDisplay extends React.Component<IPropertyBagDisp
|
|||
* @memberOf PropertyBagDisplay
|
||||
*/
|
||||
public onCancel(e?: MouseEvent): void {
|
||||
// this.state.isediting = false;
|
||||
// this.state.workingStorage = null;
|
||||
this.setState((current) => ({ ...current, workingStorage: null, isediting: false }));
|
||||
}
|
||||
/**
|
||||
|
@ -457,24 +449,10 @@ export default class PropertyBagDisplay extends React.Component<IPropertyBagDisp
|
|||
* @memberOf PropertyBagDisplay
|
||||
*/
|
||||
|
||||
public onForceCrawlChange(newValue: boolean) {
|
||||
this.state.workingStorage.forceCrawl = newValue;
|
||||
this.setState(this.state);
|
||||
}
|
||||
/**
|
||||
* Called when the value of a property i schanged in the display.
|
||||
* Saves the new value in workingStarage,
|
||||
*
|
||||
* @param {React.FormEvent<HTMLInputElement>} event
|
||||
*
|
||||
* @memberOf PropertyBagDisplay
|
||||
*/
|
||||
public onPropertyValueChanged(event: React.FormEvent<HTMLInputElement>, newValue: string) {
|
||||
const selectedProperty = newValue;//event.currentTarget.attributes["data-crawledpropertyname"].value;
|
||||
const dp: DisplayProp = _.find(this.state.workingStorage.DisplayProps, p => { return p.crawledPropertyName === selectedProperty; });
|
||||
dp.value = event.currentTarget.value;
|
||||
this.setState(this.state);
|
||||
public onForceCrawlChange(newValue: boolean): void {
|
||||
this.setState(current => ({ ...current, workingStorage: ({ ...current.workingStorage, forceCrawl: newValue }) }));
|
||||
}
|
||||
|
||||
public createSearcheableOnChangedHandler = (managedPropertyName) => (value) => {
|
||||
const dp: DisplayProp = _.find(this.state.workingStorage.DisplayProps, p => { return p.crawledPropertyName === managedPropertyName; });
|
||||
dp.searchable = value;
|
||||
|
@ -495,23 +473,21 @@ export default class PropertyBagDisplay extends React.Component<IPropertyBagDisp
|
|||
console.log("in onEditItemClicked");
|
||||
const selectedSite = this.state.sites[this.state.selectedIndex];
|
||||
const web = new Web(selectedSite.Url);
|
||||
let context = this;
|
||||
// let context = this;
|
||||
web.select("Title", "AllProperties").expand("AllProperties").get().then((r) => {
|
||||
console.log(context.context);
|
||||
const crawledProps: Array<string> = context.props.propertiesToDisplay.map(item => {
|
||||
const crawledProps: Array<string> = this.props.propertiesToDisplay.map(item => {
|
||||
return item.split("|")[0];
|
||||
});
|
||||
let temp = _.clone(selectedSite);
|
||||
temp.searchableProps = utils.decodeSearchableProps(r.AllProperties["vti_x005f_indexedpropertykeys"]);
|
||||
// temp.DisplayProps = utils.SelectProperties(r.AllProperties, crawledProps, context.state.workingStorage.searchableProps);
|
||||
temp.DisplayProps = utils.SelectProperties(r.AllProperties, crawledProps, temp.searchableProps);
|
||||
temp.errorMessages = new Array<md.Message>();
|
||||
// now add in the managed Prop
|
||||
for (const dp of temp.DisplayProps) {
|
||||
dp.managedPropertyName =
|
||||
_.find(context.state.managedToCrawedMapping, mtc => { return mtc.crawledPropertyName === dp.crawledPropertyName; }).managedPropertyName;
|
||||
_.find(this.state.managedToCrawedMapping, mtc => { return mtc.crawledPropertyName === dp.crawledPropertyName; }).managedPropertyName;
|
||||
}
|
||||
context.setState((current) => ({
|
||||
this.setState((current) => ({
|
||||
...current,
|
||||
workingStorage: temp, isediting: true
|
||||
|
||||
|
|
|
@ -80,22 +80,16 @@ export default class PropertyBagEditor extends React.Component<IPropertyBagEdito
|
|||
debugger;
|
||||
const sp = utils.decodeSearchableProps(r.AllProperties.vti_x005f_indexedpropertykeys);
|
||||
const dp = utils.SelectProperties(r.AllProperties, this.props.propertiesToEdit, sp);
|
||||
// this.state.searchableProps = sp;
|
||||
// this.state.displayProps = dp;
|
||||
|
||||
this.setState((current) => ({ ...current, searchableProps: sp, displayProps: dp }))
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/** event hadlers */
|
||||
public stopediting() {
|
||||
//this.state.isediting = false;
|
||||
|
||||
this.setState((current) => ({ ...current, isediting: false }))
|
||||
}
|
||||
public onActiveItemChanged(item?: any, index?: number) {
|
||||
//this.state.selectedIndex = index;
|
||||
this.setState((current) => ({ ...current, selectedIndex: index }))
|
||||
}
|
||||
/**
|
||||
|
@ -107,10 +101,6 @@ export default class PropertyBagEditor extends React.Component<IPropertyBagEdito
|
|||
* @memberOf PropertyBagEditor
|
||||
*/
|
||||
public onSearchableValueChanged(e: Event, newValue: boolean) {
|
||||
|
||||
//this.state.workingStorage.searchable = newValue;
|
||||
//this.setState(this.state);
|
||||
//this.state.workingStorage.searchable = newValue;
|
||||
debugger;
|
||||
this.setState((current) => ({ ...current, workingStorage: ({ ...current.workingStorage, searchable: newValue }) }));
|
||||
}
|
||||
|
@ -124,7 +114,6 @@ export default class PropertyBagEditor extends React.Component<IPropertyBagEdito
|
|||
*/
|
||||
public onPropertyValueChanged(event) {
|
||||
debugger;
|
||||
//this.state.workingStorage.value = event.target.value;
|
||||
this.setState((current) => ({
|
||||
...current,
|
||||
workingStorage: ({
|
||||
|
@ -143,9 +132,6 @@ export default class PropertyBagEditor extends React.Component<IPropertyBagEdito
|
|||
* @memberOf PropertyBagEditor
|
||||
*/
|
||||
public onEditItemClicked(e?: MouseEvent): void {
|
||||
//this.state.isediting = true;
|
||||
//this.state.workingStorage = _.clone(this.state.displayProps[this.state.selectedIndex]);
|
||||
//this.setState(this.state);
|
||||
this.setState((current) => ({ ...current, isediting: true, workingStorage: _.clone(current.displayProps[current.selectedIndex]) }))
|
||||
}
|
||||
/**
|
||||
|
@ -161,10 +147,8 @@ export default class PropertyBagEditor extends React.Component<IPropertyBagEdito
|
|||
.then(value => {
|
||||
this.changeSearchable(this.state.workingStorage.crawledPropertyName, this.state.workingStorage.searchable)
|
||||
.then(s => {
|
||||
//this.state.displayProps[this.state.selectedIndex] = this.state.workingStorage;
|
||||
const temp = _.clone(this.state.displayProps);// this.state.workingStorage = null;
|
||||
temp[this.state.selectedIndex] = this.state.workingStorage;// this.state.isediting = false;
|
||||
// this.setState(this.state);
|
||||
this.setState((current) => ({ ...current, isediting: false, workingStorage: null, displayProps: temp }))
|
||||
});
|
||||
});
|
||||
|
@ -177,9 +161,6 @@ export default class PropertyBagEditor extends React.Component<IPropertyBagEdito
|
|||
* @memberOf PropertyBagEditor
|
||||
*/
|
||||
public onCancel(e?: MouseEvent): void {
|
||||
// this.state.isediting = false;
|
||||
// this.state.workingStorage = null;
|
||||
// this.setState(this.state);
|
||||
this.setState((current) => ({ ...current, isediting: false, workingStorage: null }))
|
||||
}
|
||||
|
||||
|
@ -196,7 +177,6 @@ export default class PropertyBagEditor extends React.Component<IPropertyBagEdito
|
|||
public changeSearchable(propname: string, newValue: boolean): Promise<any> {
|
||||
if (newValue) {//make prop searchable
|
||||
if (_.indexOf(this.state.searchableProps, propname) === -1) {// wasa not searchable, mpw it is
|
||||
//this.state.searchableProps.push(propname);
|
||||
const temp = _.clone(this.state.searchableProps);
|
||||
temp.push(propname);
|
||||
this.setState(current => ({ ...current, searchableProps: temp }));
|
||||
|
|
|
@ -8,9 +8,8 @@ import { Label } from "office-ui-fabric-react/lib/Label";
|
|||
import MessageDisplay, * as md from "../../shared/MessageDisplay";
|
||||
import utils from "../../shared/utils";
|
||||
import { IPropertyBagFilteredSiteListProps } from "./IPropertyBagFilteredSiteListProps";
|
||||
|
||||
import { IContextualMenuItem, } from "office-ui-fabric-react/lib/ContextualMenu";
|
||||
import { DetailsList } from "office-ui-fabric-react";
|
||||
|
||||
export interface IPropertyBagFilteredSiteListState {
|
||||
errorMessages: Array<md.Message>;
|
||||
sites: Array<Site>;
|
||||
|
@ -83,10 +82,6 @@ export default class PropertyBagFilteredSiteList extends React.Component<IProper
|
|||
* @memberOf PropertyBagFilteredSiteList
|
||||
*/
|
||||
public removeMessage(messageId: string) {
|
||||
// _.remove(this.state.errorMessages, {
|
||||
// Id: messageId
|
||||
// });
|
||||
// this.setState(this.state);
|
||||
const messages = this.state.errorMessages;
|
||||
_.remove(messages, {
|
||||
Id: messageId
|
||||
|
@ -94,27 +89,7 @@ export default class PropertyBagFilteredSiteList extends React.Component<IProper
|
|||
this.setState((current) => ({ ...current, errorMessages: messages }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the list of user filters.
|
||||
* A user filter is created for each UserFilter name specified in the props.
|
||||
*
|
||||
* @param {Array<string>} userFilterNames
|
||||
*
|
||||
* @memberOf PropertyBagFilteredSiteList
|
||||
*/
|
||||
// public setupUserFilters(userFilterNames: Array<string>): void {
|
||||
|
||||
// // this.state.userFilters = [];
|
||||
// // for (const userFilterName of userFilterNames) {
|
||||
// // this.state.userFilters.push(new UserFilter(userFilterName));
|
||||
// // }
|
||||
// let userFilters = [];
|
||||
// for (const userFilterName of userFilterNames) {
|
||||
// userFilters.push(new UserFilter(userFilterName));
|
||||
// }
|
||||
// this.setState((current) => ({ ...current, userFilters: userFilters }));
|
||||
|
||||
// }
|
||||
|
||||
/**
|
||||
* Adds values to All the UserFilters for a given SearchResults.
|
||||
|
@ -193,19 +168,6 @@ export default class PropertyBagFilteredSiteList extends React.Component<IProper
|
|||
|
||||
};
|
||||
pnp.sp.search(q).then((results: SearchResults) => {
|
||||
// this.state.sites = [];
|
||||
// debugger;
|
||||
// this.setupUserFilters(userFilterNameArray);
|
||||
// for (const r of results.PrimarySearchResults) {
|
||||
// const index = this.state.sites.push(new Site(r.Title, r.Description, r.SPSiteUrl));
|
||||
|
||||
// for (const mp of this.props.userFilters) {
|
||||
// this.state.sites[index-1][mp] = r[mp];
|
||||
// }
|
||||
// this.extractUserFilterValues(r);
|
||||
// }
|
||||
// this.filterSites();
|
||||
// this.setState(this.state);
|
||||
let sites = [];
|
||||
debugger;
|
||||
let userFilters: UserFilter[] = [];
|
||||
|
@ -243,20 +205,7 @@ export default class PropertyBagFilteredSiteList extends React.Component<IProper
|
|||
|
||||
this.getSites(this.props.siteTemplatesToInclude, this.props.filters, this.props.showQueryText, this.props.userFilters, this.props.showSiteDescriptions);
|
||||
}
|
||||
/**
|
||||
* Called whe Properties are changed in the PropertyPane
|
||||
* Gets the sites and builds the userFilters using the new Properties
|
||||
*
|
||||
*
|
||||
* @param {IPropertyBagFilteredSiteListProps} nextProps
|
||||
* @param {*} nextContext
|
||||
*
|
||||
* @memberOf PropertyBagFilteredSiteList
|
||||
*/
|
||||
// public component(nextProps: IPropertyBagFilteredSiteListProps, nextContext: any): void {
|
||||
// debugger;
|
||||
// this.getSites(nextProps.siteTemplatesToInclude, nextProps.filters, nextProps.showQueryText, nextProps.userFilters, nextProps.showSiteDescriptions);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Called by the Render method.
|
||||
* Displayes the Site Description if requested in the PropertyPane.
|
||||
|
@ -395,8 +344,6 @@ export default class PropertyBagFilteredSiteList extends React.Component<IProper
|
|||
*/
|
||||
public filterOnMetadata(ev?: React.MouseEvent<HTMLElement>, item?: IContextualMenuItem) {
|
||||
const newFilters = this.ToggleAppliedUserFilter(this.state.appliedUserFilters, item);
|
||||
// this.filterSites();
|
||||
// this.setState(this.state);
|
||||
this.setState((current) => ({ ...current, appliedUserFilters: newFilters, filteredSites: this.filterSites(newFilters, current.sites) }));
|
||||
}
|
||||
|
||||
|
|
|
@ -90,11 +90,6 @@ export default class PropertyBagGlobalNav extends React.Component<IPropertyBagGl
|
|||
|
||||
};
|
||||
pnp.sp.search(q).then((results: SearchResults) => {
|
||||
// this.state.menuitems = [];
|
||||
// for (const r of results.PrimarySearchResults) {
|
||||
// this.addMenuItem(r);
|
||||
// }
|
||||
// this.setState(this.state);
|
||||
let menuitems = [];
|
||||
for (const r of results.PrimarySearchResults) {
|
||||
this.addMenuItem(menuitems, r);
|
||||
|
@ -106,11 +101,13 @@ export default class PropertyBagGlobalNav extends React.Component<IPropertyBagGl
|
|||
|
||||
}).catch(err => {
|
||||
debugger;
|
||||
this.state.errorMessages.push(new md.Message(err));
|
||||
this.setState(this.state);
|
||||
|
||||
const em = this.state.errorMessages;
|
||||
em.push(new md.Message(err));
|
||||
this.setState(current => ({ ...current, errorMessages: em }));
|
||||
});
|
||||
}
|
||||
/** react lifecycle */
|
||||
|
||||
public componentDidMount(): void {
|
||||
|
||||
this.getSites(this.props.siteTemplatesToInclude, this.props.filters, this.props.managedProperties);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"skipLibCheck": true,
|
||||
"inlineSources": false,
|
||||
"strictNullChecks": false,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedLocals": true,
|
||||
"target": "es5",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "esnext",
|
||||
|
|
Loading…
Reference in New Issue