Guest User

Untitled

a guest
Jan 17th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.68 KB | None | 0 0
  1. /* tslint:disable:no-unused-variable */
  2. import * as React from 'react';
  3. /* tslint:enable:no-unused-variable */
  4. import { TextField } from 'office-ui-fabric-react/lib/TextField';
  5. import {
  6. CheckboxVisibility,
  7. DetailsList,
  8. DetailsListLayoutMode,
  9. IColumn,ConstrainMode
  10.  
  11. } from 'office-ui-fabric-react/lib/DetailsList';
  12. import { Link } from 'office-ui-fabric-react/lib/Link'
  13. import { autobind } from 'office-ui-fabric-react/lib/Utilities';
  14. import pnp from "sp-pnp-js";
  15. import { Web } from "sp-pnp-js";
  16. import { Item, Items } from 'sp-pnp-js/lib/sharepoint/items';
  17.  
  18.  
  19. let _items: {
  20. key: number,
  21. name: string,
  22. value: number,
  23. Title : string,
  24. Id :number,
  25. Category :string,
  26. Subcategory :string,
  27. description :string,
  28. Status :string,
  29. CreatedBy :string,
  30. CreatedDate :string,
  31. Approvers :string,
  32. ApproveRejectedBy :string,
  33. ApproverComment :string,
  34. ApproveRejectedDate :string,
  35. ViewLink :string,
  36. }[] = [];
  37.  
  38. let _columns = [
  39.  
  40. {
  41. key: 'column13',
  42. name: 'View Link',
  43. fieldName: 'ViewLink',
  44. minWidth: 50,
  45. maxWidth: 60,
  46. isResizable: true,
  47. onRender : item =>(
  48. <Link data-selection-invoke={ true } href={item.ViewLink }>
  49. View
  50. </Link>
  51. )
  52. },
  53. {
  54. key: 'column2',
  55. name: 'ID',
  56. fieldName: 'Id',
  57. minWidth: 25,
  58. maxWidth: 40,
  59. isResizable: true
  60. },
  61. {
  62. key: 'column1',
  63. name: 'Title',
  64. fieldName: 'name',
  65. minWidth: 100,
  66. maxWidth: 200,
  67. isResizable: true
  68. },
  69. {
  70. key: 'column3',
  71. name: 'Category',
  72. fieldName: 'Category',
  73. minWidth: 70,
  74. maxWidth: 100,
  75. isResizable: true
  76. },
  77. {
  78. key: 'column4',
  79. name: 'Sub Category',
  80. fieldName: 'Subcategory',
  81. minWidth: 70,
  82. maxWidth: 100,
  83. isResizable: true
  84. },
  85. {
  86. key: 'column5',
  87. name: 'Description',
  88. fieldName: 'description',
  89. minWidth: 100,
  90. maxWidth: 200,
  91. isResizable: true
  92. },
  93. {
  94. key: 'column6',
  95. name: 'Status',
  96. fieldName: 'Status',
  97. minWidth: 70,
  98. maxWidth: 100,
  99. isResizable: true
  100. },
  101. {
  102. key: 'column7',
  103. name: 'Created By',
  104. fieldName: 'CreatedBy',
  105. minWidth: 100,
  106. maxWidth: 200,
  107. isResizable: true
  108. },
  109. {
  110. key: 'column8',
  111. name: 'Created Date',
  112. fieldName: 'CreatedDate',
  113. minWidth: 70,
  114. maxWidth: 100,
  115. isResizable: true,
  116. },
  117. {
  118. key: 'column9',
  119. name: 'Approvers',
  120. fieldName: 'Approvers',
  121. minWidth: 100,
  122. maxWidth: 200,
  123. isResizable: true
  124. },
  125. {
  126. key: 'column10',
  127. name: 'Approve/Rejected By',
  128. fieldName: 'ApproveRejectedBy',
  129. minWidth: 100,
  130. maxWidth: 200,
  131. isResizable: true
  132. },
  133. {
  134. key: 'column11',
  135. name: 'Approver Comment',
  136. fieldName: 'ApproverComment',
  137. minWidth: 100,
  138. maxWidth: 200,
  139. isResizable: true
  140. },
  141. {
  142. key: 'column12',
  143. name: 'Approve/Rejected Date',
  144. fieldName: 'ApproveRejectedDate',
  145. minWidth: 70,
  146. maxWidth: 100,
  147. isResizable: true
  148. },
  149. ];
  150. export default class AllItemsView extends React.Component<{},{items: {}[];}>
  151. {
  152. private _selection: Selection;
  153. constructor(props: {}) {
  154. super(props);
  155.  
  156. pnp.sp.web.lists.getByTitle('list').items.orderBy('ID', false).get().then(
  157. response => {
  158. response.map(item =>{
  159. _items.push({
  160. key: item.ID,
  161. name: item.Title,
  162. value: item.ID,
  163. Title : item.Title,
  164. Id :item.ID,
  165. Category :item.Category,
  166. Subcategory :item.Sub_x0020_Category,
  167. description :item.Feedback_x0020_Description,
  168. Status :item.Status,
  169. CreatedBy :item.CreatedByDisplay,
  170. CreatedDate :(item.Created) ?new Date(item.Created).toLocaleDateString("en-GB") :'',
  171. Approvers :item.ApproversDispay,
  172. ApproveRejectedBy :item.ApprovedByDisplay,
  173. ApproverComment :item.Approver_x0020_Comments,
  174. ApproveRejectedDate : (item.ApproveRejectedDate) ? new Date(item.ApproveRejectedDate).toLocaleDateString("en-GB"): '',
  175. ViewLink :"https://bajajelect.sharepoint.com/teams/ConnectApp/SitePages/ViewRequestAllFields.aspx?ApproverId=" + item.ID
  176. })
  177. })
  178. }
  179. )
  180. this.state = {
  181. items: _items
  182. };
  183. }
  184. public render() {
  185.  
  186. let { items } = this.state;
  187.  
  188. console.log();
  189. return (
  190. <div style = {{wordWrap : 'true'}}>
  191. <DetailsList
  192. constrainMode = {ConstrainMode.horizontalConstrained}
  193. items={ items }
  194. columns={ _columns }
  195. layoutMode={ DetailsListLayoutMode.fixedColumns }
  196. onItemInvoked={ this._onItemInvoked }
  197. checkboxVisibility ={CheckboxVisibility.hidden}
  198. />
  199. </div>
  200. );
  201. }
  202. private _onItemInvoked(item: any): void {
  203. window.location.href = item.ViewLink;
  204. }
  205. }
Add Comment
Please, Sign In to add comment