Last active
July 13, 2017 11:35
-
-
Save ypcode/311be02229f9fa4732a0d84946d9b97c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
import { | |
BaseClientSideWebPart, | |
IPropertyPaneConfiguration, | |
PropertyPaneTextField, | |
PropertyPaneDropdown | |
} from '@microsoft/sp-webpart-base'; | |
import { escape } from '@microsoft/sp-lodash-subset'; | |
// ... | |
import { ITask } from "./models/ITask"; | |
import { IListInfo } from "./models/IListInfo"; | |
import { IFieldInfo } from "./models/IFieldInfo"; | |
// ... | |
export default class KanbanBoardWebPart extends BaseClientSideWebPart<IKanbanBoardWebPartProps> { | |
private statuses: string[] = []; | |
private tasks: ITask[] = []; | |
private availableLists: IListInfo[] = []; | |
// ... | |
private _getAvailableFieldsFromCurrentList(): IFieldInfo[] { | |
if (!this.properties.tasksListId) | |
return []; | |
let filteredListInfo = this.availableLists.filter(l => l.Id == this.properties.tasksListId); | |
if (filteredListInfo.length != 1) | |
return []; | |
return filteredListInfo[0].Fields.filter(f => f.TypeAsString == "Choice"); | |
} | |
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration { | |
return { | |
pages: [ | |
{ | |
header: { | |
description: "Settings" | |
}, | |
groups: [ | |
{ | |
groupName: "Tasks source configuration", | |
groupFields: [ | |
PropertyPaneDropdown('tasksListId', { | |
label: "Source Task list", | |
options: this.availableLists.map(l => ({ | |
key: l.Id, | |
text: l.Title | |
})) | |
}), | |
PropertyPaneDropdown('statusFieldName', { | |
label: "Status field Internal name", | |
options: this._getAvailableFieldsFromCurrentList().map(f => ({ | |
key: f.InternalName, | |
text: f.Title | |
})) | |
}) | |
] | |
} | |
] | |
} | |
] | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment