@mwater/visualization 5.5.0 → 5.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/lib/ColorComponent.js +2 -2
  2. package/lib/MWaterContextComponent.d.ts +1 -1
  3. package/lib/MWaterGlobalFiltersComponent.d.ts +2 -2
  4. package/lib/MWaterGlobalFiltersComponent.js +11 -20
  5. package/lib/MWaterLoaderComponent.d.ts +4 -13
  6. package/lib/MWaterLoaderComponent.js +2 -11
  7. package/lib/TranslationsTabComponent.d.ts +34 -0
  8. package/lib/TranslationsTabComponent.js +256 -0
  9. package/lib/UndoStack.d.ts +2 -1
  10. package/lib/UndoStack.js +12 -6
  11. package/lib/dashboards/DashboardComponent.js +6 -5
  12. package/lib/dashboards/DashboardDesign.d.ts +1 -1
  13. package/lib/dashboards/ServerDashboardDataSource.d.ts +0 -1
  14. package/lib/dashboards/ServerDashboardDataSource.js +0 -25
  15. package/lib/dashboards/SettingsModalComponent.js +9 -233
  16. package/lib/datagrids/DatagridComponent.js +27 -2
  17. package/lib/datagrids/DatagridDesignerComponent.d.ts +2 -3
  18. package/lib/datagrids/DatagridDesignerComponent.js +108 -120
  19. package/lib/datagrids/DatagridViewComponent.js +33 -6
  20. package/lib/datagrids/OrderBysDesignerComponent.d.ts +7 -7
  21. package/lib/datagrids/OrderBysDesignerComponent.js +19 -28
  22. package/lib/index.css +45 -2
  23. package/lib/index.d.ts +5 -5
  24. package/lib/index.js +2 -3
  25. package/lib/layouts/blocks/BlocksDisplayComponent.d.ts +8 -1
  26. package/lib/layouts/blocks/BlocksDisplayComponent.js +46 -4
  27. package/lib/maps/BufferLayer.d.ts +0 -13
  28. package/lib/maps/BufferLayer.js +24 -237
  29. package/lib/maps/BufferLayerDesign.d.ts +1 -1
  30. package/lib/maps/BufferLayerDesignerComponent.d.ts +1 -1
  31. package/lib/maps/BufferLayerDesignerComponent.js +2 -7
  32. package/lib/maps/ChoroplethLayer.d.ts +1 -16
  33. package/lib/maps/ChoroplethLayer.js +25 -358
  34. package/lib/maps/ChoroplethLayerDesign.d.ts +5 -2
  35. package/lib/maps/ChoroplethLayerDesigner.d.ts +10 -32
  36. package/lib/maps/ChoroplethLayerDesigner.js +58 -89
  37. package/lib/maps/ClusterLayer.d.ts +0 -9
  38. package/lib/maps/ClusterLayer.js +0 -250
  39. package/lib/maps/DirectMapDataSource.js +1 -48
  40. package/lib/maps/EditHoverOver.d.ts +4 -3
  41. package/lib/maps/EditHoverOver.js +3 -3
  42. package/lib/maps/GridLayer.d.ts +0 -15
  43. package/lib/maps/GridLayer.js +0 -212
  44. package/lib/maps/HoverContent.js +1 -1
  45. package/lib/maps/Layer.d.ts +1 -26
  46. package/lib/maps/Layer.js +0 -13
  47. package/lib/maps/LeafletMapComponent.js +10 -19
  48. package/lib/maps/MapComponent.d.ts +19 -35
  49. package/lib/maps/MapComponent.js +135 -77
  50. package/lib/maps/MapControlComponent.d.ts +4 -5
  51. package/lib/maps/MapControlComponent.js +5 -12
  52. package/lib/maps/MapDesign.d.ts +8 -0
  53. package/lib/maps/MapDesignerComponent.d.ts +2 -0
  54. package/lib/maps/MapDesignerComponent.js +7 -2
  55. package/lib/maps/MapLayerDataSource.d.ts +0 -4
  56. package/lib/maps/MapLayerViewDesignerComponent.d.ts +3 -1
  57. package/lib/maps/MapLayerViewDesignerComponent.js +5 -1
  58. package/lib/maps/MapLayersDesignerComponent.d.ts +2 -0
  59. package/lib/maps/MapLayersDesignerComponent.js +2 -1
  60. package/lib/maps/MapTranslationsTab.d.ts +15 -0
  61. package/lib/maps/MapTranslationsTab.js +47 -0
  62. package/lib/maps/MapUtils.d.ts +11 -0
  63. package/lib/maps/MapUtils.js +57 -1
  64. package/lib/maps/MapViewComponent.d.ts +1 -1
  65. package/lib/maps/MapViewComponent.js +1 -8
  66. package/lib/maps/MarkersLayer.d.ts +1 -14
  67. package/lib/maps/MarkersLayer.js +89 -254
  68. package/lib/maps/MarkersLayerDesign.d.ts +5 -1
  69. package/lib/maps/MarkersLayerDesignerComponent.d.ts +32 -57
  70. package/lib/maps/MarkersLayerDesignerComponent.js +158 -134
  71. package/lib/maps/ServerMapDataSource.d.ts +0 -1
  72. package/lib/maps/ServerMapDataSource.js +0 -25
  73. package/lib/maps/SwitchableTileUrlLayer.d.ts +0 -2
  74. package/lib/maps/SwitchableTileUrlLayer.js +0 -9
  75. package/lib/maps/TileUrlLayer.d.ts +0 -1
  76. package/lib/maps/TileUrlLayer.js +0 -5
  77. package/lib/maps/VectorMapViewComponent.js +13 -10
  78. package/lib/maps/symbols/font-awesome/asterisk.png +0 -0
  79. package/lib/maps/symbols/font-awesome/ban.png +0 -0
  80. package/lib/maps/symbols/font-awesome/beer.png +0 -0
  81. package/lib/maps/symbols/font-awesome/bell.png +0 -0
  82. package/lib/maps/symbols/font-awesome/bolt.png +0 -0
  83. package/lib/maps/symbols/font-awesome/building.png +0 -0
  84. package/lib/maps/symbols/font-awesome/bullseye.png +0 -0
  85. package/lib/maps/symbols/font-awesome/bus.png +0 -0
  86. package/lib/maps/symbols/font-awesome/caret-up.png +0 -0
  87. package/lib/maps/symbols/font-awesome/certificate.png +0 -0
  88. package/lib/maps/symbols/font-awesome/check-circle.png +0 -0
  89. package/lib/maps/symbols/font-awesome/check.png +0 -0
  90. package/lib/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
  91. package/lib/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
  92. package/lib/maps/symbols/font-awesome/cloud-rain.png +0 -0
  93. package/lib/maps/symbols/font-awesome/cloud.png +0 -0
  94. package/lib/maps/symbols/font-awesome/comment.png +0 -0
  95. package/lib/maps/symbols/font-awesome/crosshairs.png +0 -0
  96. package/lib/maps/symbols/font-awesome/dot-circle-o.png +0 -0
  97. package/lib/maps/symbols/font-awesome/exclamation-circle.png +0 -0
  98. package/lib/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
  99. package/lib/maps/symbols/font-awesome/female.png +0 -0
  100. package/lib/maps/symbols/font-awesome/file.png +0 -0
  101. package/lib/maps/symbols/font-awesome/flag.png +0 -0
  102. package/lib/maps/symbols/font-awesome/flask.png +0 -0
  103. package/lib/maps/symbols/font-awesome/h-square.png +0 -0
  104. package/lib/maps/symbols/font-awesome/home.png +0 -0
  105. package/lib/maps/symbols/font-awesome/info-circle.png +0 -0
  106. package/lib/maps/symbols/font-awesome/male.png +0 -0
  107. package/lib/maps/symbols/font-awesome/medkit.png +0 -0
  108. package/lib/maps/symbols/font-awesome/mobile.png +0 -0
  109. package/lib/maps/symbols/font-awesome/plus-circle.png +0 -0
  110. package/lib/maps/symbols/font-awesome/plus-square.png +0 -0
  111. package/lib/maps/symbols/font-awesome/plus.png +0 -0
  112. package/lib/maps/symbols/font-awesome/square.png +0 -0
  113. package/lib/maps/symbols/font-awesome/star.png +0 -0
  114. package/lib/maps/symbols/font-awesome/thumbs-down.png +0 -0
  115. package/lib/maps/symbols/font-awesome/thumbs-up.png +0 -0
  116. package/lib/maps/symbols/font-awesome/ticket.png +0 -0
  117. package/lib/maps/symbols/font-awesome/times-circle.png +0 -0
  118. package/lib/maps/symbols/font-awesome/times.png +0 -0
  119. package/lib/maps/symbols/font-awesome/tint.png +0 -0
  120. package/lib/maps/symbols/font-awesome/tree.png +0 -0
  121. package/lib/maps/symbols/font-awesome/university.png +0 -0
  122. package/lib/maps/symbols/font-awesome/usd.png +0 -0
  123. package/lib/maps/symbols/font-awesome/user.png +0 -0
  124. package/lib/maps/symbols/font-awesome/users.png +0 -0
  125. package/lib/maps/symbols/font-awesome/wheelchair.png +0 -0
  126. package/lib/maps/symbols/sdf-ize.sh +93 -0
  127. package/lib/maps/vectorMaps.d.ts +6 -6
  128. package/lib/maps/vectorMaps.js +33 -45
  129. package/lib/mwater_table_selection/IndicatorsListComponent.d.ts +4 -2
  130. package/lib/mwater_table_selection/IndicatorsListComponent.js +103 -34
  131. package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.d.ts +18 -0
  132. package/lib/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.js +80 -0
  133. package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.d.ts +26 -0
  134. package/lib/mwater_table_selection/MWaterCompleteTableSelectComponent.js +237 -51
  135. package/lib/mwater_table_selection/MWaterTableSelectComponent.d.ts +2 -2
  136. package/lib/mwater_table_selection/MWaterTableSelectComponent.js +9 -4
  137. package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.d.ts +19 -0
  138. package/lib/mwater_table_selection/MWaterWorkflowsSelectComponent.js +111 -0
  139. package/lib/quickfilter/QuickfiltersComponent.d.ts +3 -102
  140. package/lib/quickfilter/QuickfiltersComponent.js +53 -110
  141. package/lib/quickfilter/TextLiteralComponent.d.ts +23 -47
  142. package/lib/quickfilter/TextLiteralComponent.js +85 -82
  143. package/lib/widgets/MapWidget.js +6 -3
  144. package/lib/widgets/text/ExprItemEditorComponent.d.ts +3 -8
  145. package/lib/widgets/text/ExprItemEditorComponent.js +36 -33
  146. package/lib/widgets/text/ExprUpdateModalComponent.d.ts +1 -0
  147. package/package.json +3 -4
  148. package/src/ColorComponent.tsx +2 -2
  149. package/src/MWaterContextComponent.tsx +1 -1
  150. package/src/{MWaterGlobalFiltersComponent.ts → MWaterGlobalFiltersComponent.tsx} +32 -33
  151. package/src/{MWaterLoaderComponent.ts → MWaterLoaderComponent.tsx} +17 -18
  152. package/src/TranslationsTabComponent.tsx +429 -0
  153. package/src/UndoStack.ts +14 -6
  154. package/src/dashboards/DashboardComponent.tsx +6 -5
  155. package/src/dashboards/DashboardDesign.ts +1 -1
  156. package/src/dashboards/ServerDashboardDataSource.ts +0 -31
  157. package/src/dashboards/SettingsModalComponent.tsx +27 -383
  158. package/src/datagrids/DatagridComponent.tsx +36 -2
  159. package/src/datagrids/DatagridDesignerComponent.tsx +241 -229
  160. package/src/datagrids/DatagridViewComponent.tsx +44 -7
  161. package/src/datagrids/OrderBysDesignerComponent.tsx +61 -70
  162. package/src/index.css +45 -2
  163. package/src/index.ts +5 -11
  164. package/src/layouts/blocks/BlocksDisplayComponent.tsx +60 -5
  165. package/src/maps/BufferLayer.ts +30 -263
  166. package/src/maps/BufferLayerDesign.ts +1 -1
  167. package/src/maps/BufferLayerDesignerComponent.tsx +2 -7
  168. package/src/maps/ChoroplethLayer.ts +30 -394
  169. package/src/maps/ChoroplethLayerDesign.ts +5 -2
  170. package/src/maps/ChoroplethLayerDesigner.tsx +169 -165
  171. package/src/maps/ClusterLayer.ts +0 -274
  172. package/src/maps/DirectMapDataSource.ts +2 -61
  173. package/src/maps/EditHoverOver.tsx +9 -5
  174. package/src/maps/GridLayer.ts +0 -224
  175. package/src/maps/HoverContent.tsx +1 -1
  176. package/src/maps/Layer.ts +1 -35
  177. package/src/maps/LeafletMapComponent.tsx +10 -19
  178. package/src/maps/MapComponent.tsx +448 -0
  179. package/src/maps/MapControlComponent.tsx +41 -0
  180. package/src/maps/MapDesign.ts +6 -0
  181. package/src/maps/MapDesignerComponent.tsx +18 -1
  182. package/src/maps/MapLayerDataSource.ts +0 -5
  183. package/src/maps/MapLayerViewDesignerComponent.ts +9 -2
  184. package/src/maps/MapLayersDesignerComponent.ts +4 -1
  185. package/src/maps/MapTranslationsTab.tsx +53 -0
  186. package/src/maps/MapUtils.ts +61 -1
  187. package/src/maps/MapViewComponent.tsx +2 -8
  188. package/src/maps/MarkersLayer.ts +101 -275
  189. package/src/maps/MarkersLayerDesign.ts +7 -1
  190. package/src/maps/MarkersLayerDesignerComponent.tsx +436 -0
  191. package/src/maps/ServerMapDataSource.ts +0 -31
  192. package/src/maps/SwitchableTileUrlLayer.tsx +0 -11
  193. package/src/maps/TileUrlLayer.tsx +0 -6
  194. package/src/maps/VectorMapViewComponent.tsx +15 -15
  195. package/src/maps/symbols/font-awesome/asterisk.png +0 -0
  196. package/src/maps/symbols/font-awesome/ban.png +0 -0
  197. package/src/maps/symbols/font-awesome/beer.png +0 -0
  198. package/src/maps/symbols/font-awesome/bell.png +0 -0
  199. package/src/maps/symbols/font-awesome/bolt.png +0 -0
  200. package/src/maps/symbols/font-awesome/building.png +0 -0
  201. package/src/maps/symbols/font-awesome/bullseye.png +0 -0
  202. package/src/maps/symbols/font-awesome/bus.png +0 -0
  203. package/src/maps/symbols/font-awesome/caret-up.png +0 -0
  204. package/src/maps/symbols/font-awesome/certificate.png +0 -0
  205. package/src/maps/symbols/font-awesome/check-circle.png +0 -0
  206. package/src/maps/symbols/font-awesome/check.png +0 -0
  207. package/src/maps/symbols/font-awesome/chevron-circle-down.png +0 -0
  208. package/src/maps/symbols/font-awesome/chevron-circle-up.png +0 -0
  209. package/src/maps/symbols/font-awesome/cloud-rain.png +0 -0
  210. package/src/maps/symbols/font-awesome/cloud.png +0 -0
  211. package/src/maps/symbols/font-awesome/comment.png +0 -0
  212. package/src/maps/symbols/font-awesome/crosshairs.png +0 -0
  213. package/src/maps/symbols/font-awesome/dot-circle-o.png +0 -0
  214. package/src/maps/symbols/font-awesome/exclamation-circle.png +0 -0
  215. package/src/maps/symbols/font-awesome/exclamation-triangle.png +0 -0
  216. package/src/maps/symbols/font-awesome/female.png +0 -0
  217. package/src/maps/symbols/font-awesome/file.png +0 -0
  218. package/src/maps/symbols/font-awesome/flag.png +0 -0
  219. package/src/maps/symbols/font-awesome/flask.png +0 -0
  220. package/src/maps/symbols/font-awesome/h-square.png +0 -0
  221. package/src/maps/symbols/font-awesome/home.png +0 -0
  222. package/src/maps/symbols/font-awesome/info-circle.png +0 -0
  223. package/src/maps/symbols/font-awesome/male.png +0 -0
  224. package/src/maps/symbols/font-awesome/medkit.png +0 -0
  225. package/src/maps/symbols/font-awesome/mobile.png +0 -0
  226. package/src/maps/symbols/font-awesome/plus-circle.png +0 -0
  227. package/src/maps/symbols/font-awesome/plus-square.png +0 -0
  228. package/src/maps/symbols/font-awesome/plus.png +0 -0
  229. package/src/maps/symbols/font-awesome/square.png +0 -0
  230. package/src/maps/symbols/font-awesome/star.png +0 -0
  231. package/src/maps/symbols/font-awesome/thumbs-down.png +0 -0
  232. package/src/maps/symbols/font-awesome/thumbs-up.png +0 -0
  233. package/src/maps/symbols/font-awesome/ticket.png +0 -0
  234. package/src/maps/symbols/font-awesome/times-circle.png +0 -0
  235. package/src/maps/symbols/font-awesome/times.png +0 -0
  236. package/src/maps/symbols/font-awesome/tint.png +0 -0
  237. package/src/maps/symbols/font-awesome/tree.png +0 -0
  238. package/src/maps/symbols/font-awesome/university.png +0 -0
  239. package/src/maps/symbols/font-awesome/usd.png +0 -0
  240. package/src/maps/symbols/font-awesome/user.png +0 -0
  241. package/src/maps/symbols/font-awesome/users.png +0 -0
  242. package/src/maps/symbols/font-awesome/wheelchair.png +0 -0
  243. package/src/maps/symbols/sdf-ize.sh +93 -0
  244. package/src/maps/vectorMaps.tsx +32 -53
  245. package/src/mwater_table_selection/IndicatorsListComponent.tsx +165 -37
  246. package/src/mwater_table_selection/MWaterCalculatedDataSourcesListComponent.tsx +111 -0
  247. package/src/mwater_table_selection/MWaterCompleteTableSelectComponent.tsx +373 -37
  248. package/src/mwater_table_selection/MWaterTableSelectComponent.tsx +12 -8
  249. package/src/mwater_table_selection/MWaterWorkflowsSelectComponent.tsx +159 -0
  250. package/src/quickfilter/{QuickfiltersComponent.ts → QuickfiltersComponent.tsx} +165 -158
  251. package/src/quickfilter/TextLiteralComponent.tsx +197 -0
  252. package/src/widgets/MapWidget.tsx +11 -1
  253. package/src/widgets/text/ExprItemEditorComponent.tsx +83 -77
  254. package/src/widgets/text/ExprUpdateModalComponent.tsx +1 -0
  255. package/test/UndoStackTests.ts +52 -1
  256. package/.storybook/config.js +0 -7
  257. package/.storybook/head.html +0 -3
  258. package/.storybook/webpack.config.js +0 -15
  259. package/src/maps/BingLayer.ts +0 -146
  260. package/src/maps/MapComponent.ts +0 -312
  261. package/src/maps/MapControlComponent.ts +0 -46
  262. package/src/maps/MarkersLayerDesignerComponent.ts +0 -374
  263. package/src/maps/RasterMapViewComponent.ts +0 -345
  264. package/src/quickfilter/TextLiteralComponent.ts +0 -165
  265. package/stories/UpdateableComponent.js +0 -29
  266. package/stories/consoles.js +0 -202
  267. package/stories/dashboards.js +0 -217
  268. package/stories/datagridDesign.js +0 -114
  269. package/stories/datagrids.js +0 -69
  270. package/stories/dates.js +0 -80
  271. package/stories/exprcomponent.js +0 -43
  272. package/stories/index.js +0 -18
  273. package/stories/leaflet.js +0 -59
  274. package/stories/maps.js +0 -24
  275. package/stories/pivotChart.js +0 -235
@@ -1,165 +0,0 @@
1
- import _ from "lodash"
2
- import React from "react"
3
- const R = React.createElement
4
- import { default as AsyncReactSelect } from "react-select/async"
5
- import { ExprCompiler, Schema } from "@mwater/expressions"
6
- import { ExprUtils } from "@mwater/expressions"
7
- import { JsonQLFilter } from "../JsonQLFilter"
8
- import { QuickfiltersDataSource } from "./QuickfiltersDataSource"
9
-
10
- export interface TextLiteralComponentProps {
11
- value?: any
12
- onChange?: any
13
- schema: Schema
14
- /** See QuickfiltersDataSource */
15
- quickfiltersDataSource: QuickfiltersDataSource
16
- expr: any
17
- index: number
18
- /** true to display multiple values */
19
- multi?: boolean
20
-
21
- /** Filters to add to restrict quick filter data to */
22
- filters?: JsonQLFilter[]
23
- }
24
-
25
- /** Displays a combo box that allows selecting single or multiple text values from an expression
26
- * The expression can be type `text` or `text[]`
27
- */
28
- export default class TextLiteralComponent extends React.Component<TextLiteralComponentProps> {
29
- handleSingleChange = (val: any) => {
30
- const value = val ? val.value || null : null // Blank is null
31
- return this.props.onChange(value)
32
- }
33
-
34
- handleMultipleChange = (val: any) => {
35
- const value = val ? _.pluck(val, "value") : []
36
-
37
- if (value.length > 0) {
38
- return this.props.onChange(value)
39
- } else {
40
- return this.props.onChange(null)
41
- }
42
- }
43
-
44
- getOptions = (input: any, cb: any) => {
45
- // Determine type of expression
46
- const filters = (this.props.filters || []).slice()
47
-
48
- const exprUtils = new ExprUtils(this.props.schema)
49
- const exprType = exprUtils.getExprType(this.props.expr)
50
-
51
- // Create query to get matches
52
- const exprCompiler = new ExprCompiler(this.props.schema)
53
-
54
- if(!this.props.expr.table) {
55
- return
56
- }
57
-
58
- // Add filter for input (simple if just text)
59
- if (exprType === "text") {
60
- if (input) {
61
- filters.push({
62
- table: this.props.expr.table,
63
- jsonql: {
64
- type: "op",
65
- op: "~*",
66
- exprs: [
67
- exprCompiler.compileExpr({ expr: this.props.expr, tableAlias: "{alias}" }),
68
- escapeRegex(input) // Don't use _.escapeRegExp as adds weird backslashes that postgres doesn't like
69
- ]
70
- }
71
- })
72
- }
73
- } else if (exprType === "text[]") {
74
- // Special filter for text[]
75
- if (input) {
76
- filters.push({
77
- table: "values",
78
- jsonql: {
79
- type: "op",
80
- op: "~*",
81
- exprs: [
82
- { type: "field", tableAlias: "{alias}", column: "value" },
83
- "^" + escapeRegex(input) // Don't use _.escapeRegExp as adds weird backslashes that postgres doesn't like
84
- ]
85
- }
86
- })
87
- }
88
- } else {
89
- return
90
- }
91
-
92
- // Execute query
93
- this.props.quickfiltersDataSource.getValues(
94
- this.props.index,
95
- this.props.expr,
96
- filters,
97
- null,
98
- 250,
99
- (err: any, values: any) => {
100
- if (err) {
101
- return
102
- }
103
-
104
- // Filter null and blank
105
- values = _.filter(values, (value) => value)
106
-
107
- return cb(
108
- _.map(values, (value) => ({
109
- value,
110
- label: value
111
- }))
112
- )
113
- }
114
- )
115
- }
116
-
117
- renderSingle() {
118
- const currentValue = this.props.value ? { value: this.props.value, label: this.props.value } : null
119
-
120
- return R(AsyncReactSelect, {
121
- key: JSON.stringify(this.props.filters), // Include to force a change when filters change
122
- placeholder: T`All`,
123
- value: currentValue,
124
- loadOptions: this.getOptions,
125
- onChange: this.props.onChange ? this.handleSingleChange : undefined,
126
- isClearable: true,
127
- defaultOptions: true,
128
- isDisabled: this.props.onChange == null,
129
- noOptionsMessage: () => T`Type to search`,
130
- styles: {
131
- // Keep menu above fixed data table headers
132
- menu: (style) => _.extend({}, style, { zIndex: 2000 })
133
- }
134
- })
135
- }
136
-
137
- renderMultiple() {
138
- const currentValue = this.props.value ? _.map(this.props.value, (v) => ({ value: v, label: v })) : null
139
-
140
- return R(AsyncReactSelect, {
141
- placeholder: T`All`,
142
- value: currentValue,
143
- key: JSON.stringify(this.props.filters), // Include to force a change when filters change
144
- isMulti: true,
145
- loadOptions: this.getOptions,
146
- defaultOptions: true,
147
- onChange: this.props.onChange ? this.handleMultipleChange : undefined,
148
- isClearable: true,
149
- isDisabled: this.props.onChange == null,
150
- noOptionsMessage: () => T`Type to search`,
151
- styles: {
152
- // Keep menu above fixed data table headers
153
- menu: (style) => _.extend({}, style, { zIndex: 2000 })
154
- }
155
- })
156
- }
157
-
158
- render() {
159
- return R("div", { style: { width: "100%" } }, this.props.multi ? this.renderMultiple() : this.renderSingle())
160
- }
161
- }
162
-
163
- function escapeRegex(s: any) {
164
- return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&")
165
- }
@@ -1,29 +0,0 @@
1
- // TODO: This file was created by bulk-decaffeinate.
2
- // Sanity-check the conversion and remove this comment.
3
- let UpdateableComponent;
4
- import _ from 'lodash';
5
- import React from 'react';
6
-
7
- // Convenience wrapper that allows updating state
8
- export default UpdateableComponent = class UpdateableComponent extends React.Component {
9
- constructor(props) {
10
- super(props);
11
- this.state = _.clone(this.props || {});
12
- }
13
-
14
- // Creates update function
15
- update = name => {
16
- return value => {
17
- const upt = {};
18
- upt[name] = value;
19
- this.setState(upt);
20
- return console.log(JSON.stringify(upt, null, 2));
21
- };
22
- };
23
- // action("update")(upt)
24
-
25
- render() {
26
- return this.props.children(this.state, this.update);
27
- }
28
- };
29
-
@@ -1,202 +0,0 @@
1
- // TODO: This file was created by bulk-decaffeinate.
2
- // Sanity-check the conversion and remove this comment.
3
- import PropTypes from 'prop-types';
4
- import _ from 'lodash';
5
- import React from 'react';
6
- const H = React.DOM;
7
- const R = React.createElement;
8
-
9
- import uuid from 'uuid';
10
- import { storiesOf } from '@kadira/storybook';
11
- import ConsoleComponent from '../src/consoles/ConsoleComponent';
12
- import DirectConsoleDataSource from '../src/consoles/DirectConsoleDataSource';
13
- import MWaterLoaderComponent from '../src/MWaterLoaderComponent';
14
- import UpdateableComponent from './UpdateableComponent';
15
-
16
- storiesOf('console', module)
17
- .add('simple console', () => {
18
- return R(ConsoleTest);
19
- });
20
-
21
- // .add 'table dashboard', =>
22
- // R DashboardTest, design: tableDashboardDesign
23
-
24
- // .add 'popup', =>
25
- // R DashboardPopupTest
26
-
27
-
28
- class ConsoleTest extends React.Component {
29
- static initClass() {
30
- this.propTypes =
31
- {design: PropTypes.object};
32
- }
33
-
34
- render() {
35
- return R(UpdateableComponent,
36
- {design: this.props.design || { tabs: [{ id: uuid(), type: "blank", name: "New Tab" }], popups: [] }},
37
- (state, update) => {
38
- const apiUrl = "https://api.mwater.co/v3/";
39
- return R(MWaterLoaderComponent, {
40
- apiUrl,
41
- client: null,
42
- user: null
43
- // onExtraTablesChange: (extraTables) => @setState(extraTables: extraTables)
44
- // extraTables: @state.extraTables
45
- }, (error, config) => {
46
- if (error) {
47
- alert("Error: " + error.message);
48
- return null;
49
- }
50
-
51
- const consoleDataSource = new DirectConsoleDataSource({
52
- apiUrl,
53
- client: null,
54
- schema: config.schema,
55
- dataSource: config.dataSource,
56
- design: state.design
57
- });
58
-
59
- return H.div({style: { height: 800 }},
60
- React.createElement(ConsoleComponent, {
61
- schema: config.schema,
62
- dataSource: config.dataSource,
63
- consoleDataSource,
64
- design: state.design,
65
- onDesignChange: update("design"),
66
- activeTabId: state.activeTabId,
67
- onActiveTabIdChange: update("activeTabId"),
68
- titleElem: "Sample"
69
- })
70
- );
71
- });
72
- });
73
- }
74
- }
75
- ConsoleTest.initClass();
76
-
77
-
78
- // class DashboardPopupTest extends React.Component
79
- // render: ->
80
- // R UpdateableComponent,
81
- // popup: { name: "Untitled", design: { items: { id: "root", type: "root", blocks: [] }, layout: "blocks" } }
82
- // (state, update) =>
83
- // apiUrl = "https://api.mwater.co/v3/"
84
- // R MWaterLoaderComponent, {
85
- // apiUrl: apiUrl
86
- // client: null
87
- // user: null
88
- // # onExtraTablesChange: (extraTables) => @setState(extraTables: extraTables)
89
- // # extraTables: @state.extraTables
90
- // }, (error, config) =>
91
- // if error
92
- // alert("Error: " + error.message)
93
- // return null
94
-
95
- // dashboardDataSource = new DirectDashboardDataSource({
96
- // apiUrl: apiUrl
97
- // client: null
98
- // design: state.popup.design
99
- // schema: config.schema
100
- // dataSource: config.dataSource
101
- // })
102
-
103
- // return H.div null,
104
- // R DashboardPopupComponent,
105
- // ref: (comp) => @popupComponent = comp
106
- // schema: config.schema
107
- // dataSource: config.dataSource
108
- // dashboardDataSource: dashboardDataSource
109
- // popup: state.popup
110
- // onPopupChange: update("popup")
111
-
112
- // H.button
113
- // type: "button"
114
- // onClick: => @popupComponent.show()
115
- // className: "btn btn-default",
116
- // "Show"
117
-
118
-
119
- // ModalWindowComponent = require 'react-library/lib/ModalWindowComponent'
120
- // ui = require 'react-library/lib/bootstrap'
121
- // update = require 'react-library/lib/update'
122
-
123
- // class DashboardPopupComponent extends React.Component
124
- // @propTypes:
125
- // popup: PropTypes.object.isRequired
126
- // onPopupChange: PropTypes.func # If not set, readonly
127
- // schema: PropTypes.object.isRequired
128
- // dataSource: PropTypes.object.isRequired
129
- // dashboardDataSource: PropTypes.object.isRequired # dashboard data source
130
-
131
- // onRowClick: PropTypes.func # Called with (tableId, rowId) when item is clicked
132
- // namedStrings: PropTypes.object # Optional lookup of string name to value. Used for {{branding}} and other replacement strings in text widget
133
-
134
- // # Filters to add to the dashboard
135
- // filters: PropTypes.arrayOf(PropTypes.shape({
136
- // table: PropTypes.string.isRequired # id table to filter
137
- // jsonql: PropTypes.object.isRequired # jsonql filter with {alias} for tableAlias
138
- // }))
139
-
140
- // constructor: ->
141
- // super
142
-
143
- // @state = {
144
- // open: false
145
- // }
146
-
147
- // # Updates with the specified changes
148
- // update: => update(@props.popup, @props.onPopupChange, arguments)
149
-
150
- // show: ->
151
- // @setState(open: true)
152
-
153
- // render: ->
154
- // R ModalWindowComponent,
155
- // onRequestClose: => @setState(open: false)
156
- // isOpen: @state.open,
157
- // R DashboardComponent, {
158
- // schema: @props.schema
159
- // dataSource: @props.dataSource
160
- // dashboardDataSource: @props.dashboardDataSource
161
- // design: @props.popup.design
162
- // onDesignChange: @update("design")
163
- // # titleElem: H.span style: { fontSize: 20, cursor: "pointer" },
164
- // # H.span className: "text-muted", onClick: (=> @setState(open: false)),
165
- // # R ui.Icon, id: "fa-arrow-left"
166
- // }
167
-
168
-
169
- // tableDashboardDesign = {
170
- // "items": {
171
- // "id": "root",
172
- // "type": "root",
173
- // "blocks": [
174
- // {
175
- // "type": "widget",
176
- // "aspectRatio": 1.4,
177
- // "widgetType": "TableChart",
178
- // "design": {
179
- // "version": 1,
180
- // "columns": [
181
- // {
182
- // "id": "f1532afb-c0ea-48de-8e4e-931b147eeb6f",
183
- // "textAxis": {
184
- // "expr": {
185
- // "type": "field",
186
- // "table": "entities.place_of_worship",
187
- // "column": "name"
188
- // }
189
- // }
190
- // }
191
- // ],
192
- // "orderings": [],
193
- // "table": "entities.place_of_worship"
194
- // },
195
- // "id": "193bbc40-9177-4547-8b83-c2b5441f72c3"
196
- // }
197
- // ]
198
- // },
199
- // "layout": "blocks"
200
- // }
201
-
202
-
@@ -1,217 +0,0 @@
1
- // TODO: This file was created by bulk-decaffeinate.
2
- // Sanity-check the conversion and remove this comment.
3
- import PropTypes from 'prop-types';
4
- import _ from 'lodash';
5
- import React from 'react';
6
- const H = React.DOM;
7
- const R = React.createElement;
8
-
9
- import { storiesOf } from '@kadira/storybook';
10
- import DashboardComponent from '../src/dashboards/DashboardComponent';
11
- import DirectDashboardDataSource from '../src/dashboards/DirectDashboardDataSource';
12
- import MWaterLoaderComponent from '../src/MWaterLoaderComponent';
13
- import UpdateableComponent from './UpdateableComponent';
14
-
15
- storiesOf('dashboard', module)
16
- .add('empty dashboard', () => {
17
- return R(DashboardTest);
18
- }).add('table dashboard', () => {
19
- return R(DashboardTest, {design: tableDashboardDesign});
20
- }).add('popup', () => {
21
- return R(DashboardPopupTest);
22
- });
23
-
24
-
25
- var tableDashboardDesign = {
26
- "items": {
27
- "id": "root",
28
- "type": "root",
29
- "blocks": [
30
- {
31
- "type": "widget",
32
- "aspectRatio": 1.4,
33
- "widgetType": "TableChart",
34
- "design": {
35
- "version": 1,
36
- "columns": [
37
- {
38
- "id": "f1532afb-c0ea-48de-8e4e-931b147eeb6f",
39
- "textAxis": {
40
- "expr": {
41
- "type": "field",
42
- "table": "entities.place_of_worship",
43
- "column": "name"
44
- }
45
- }
46
- }
47
- ],
48
- "orderings": [],
49
- "table": "entities.place_of_worship"
50
- },
51
- "id": "193bbc40-9177-4547-8b83-c2b5441f72c3"
52
- }
53
- ]
54
- },
55
- "layout": "blocks"
56
- };
57
-
58
-
59
- class DashboardTest extends React.Component {
60
- static initClass() {
61
- this.propTypes =
62
- {design: PropTypes.object};
63
- }
64
-
65
- render() {
66
- return R(UpdateableComponent,
67
- {design: this.props.design || { items: { id: "root", type: "root", blocks: [] }, layout: "blocks" }},
68
- (state, update) => {
69
- const apiUrl = "https://api.mwater.co/v3/";
70
- return R(MWaterLoaderComponent, {
71
- apiUrl,
72
- client: null,
73
- user: null,
74
- onExtraTablesChange: update("extraTables"),
75
- extraTables: state.extraTables
76
- }, (error, config) => {
77
- if (error) {
78
- alert("Error: " + error.message);
79
- return null;
80
- }
81
-
82
- const dashboardDataSource = new DirectDashboardDataSource({
83
- apiUrl,
84
- client: null,
85
- design: state.design,
86
- schema: config.schema,
87
- dataSource: config.dataSource
88
- });
89
-
90
- return H.div({style: { height: 800 }},
91
- React.createElement(DashboardComponent, {
92
- schema: config.schema,
93
- dataSource: config.dataSource,
94
- dashboardDataSource,
95
- design: state.design,
96
- onDesignChange: update("design"),
97
- titleElem: "Sample"
98
- // quickfilterLocks: [{ expr: { type: "field", table: "entities.water_point", column: "type" }, value: "Protected dug well" }]
99
- })
100
- );
101
- });
102
- });
103
- }
104
- }
105
- DashboardTest.initClass();
106
-
107
-
108
- class DashboardPopupTest extends React.Component {
109
- render() {
110
- return R(UpdateableComponent,
111
- {popup: { name: "Untitled", design: { items: { id: "root", type: "root", blocks: [] }, layout: "blocks" } }},
112
- (state, update) => {
113
- const apiUrl = "https://api.mwater.co/v3/";
114
- return R(MWaterLoaderComponent, {
115
- apiUrl,
116
- client: null,
117
- user: null
118
- // onExtraTablesChange: (extraTables) => @setState(extraTables: extraTables)
119
- // extraTables: @state.extraTables
120
- }, (error, config) => {
121
- if (error) {
122
- alert("Error: " + error.message);
123
- return null;
124
- }
125
-
126
- const dashboardDataSource = new DirectDashboardDataSource({
127
- apiUrl,
128
- client: null,
129
- design: state.popup.design,
130
- schema: config.schema,
131
- dataSource: config.dataSource
132
- });
133
-
134
- return H.div(null,
135
- R(DashboardPopupComponent, {
136
- ref: comp => { return this.popupComponent = comp; },
137
- schema: config.schema,
138
- dataSource: config.dataSource,
139
- dashboardDataSource,
140
- popup: state.popup,
141
- onPopupChange: update("popup")
142
- }
143
- ),
144
-
145
- H.button({
146
- type: "button",
147
- onClick: () => this.popupComponent.show(),
148
- className: "btn btn-default"
149
- },
150
- "Show")
151
- );
152
- });
153
- });
154
- }
155
- }
156
-
157
-
158
- const ModalWindowComponent = require("@mwater/react-library/lib/ModalWindowComponent");
159
- const ui = require("@mwater/react-library/lib/bootstrap");
160
- const update = require("@mwater/react-library/lib/update");
161
-
162
- class DashboardPopupComponent extends React.Component {
163
- static initClass() {
164
- this.propTypes = {
165
- popup: PropTypes.object.isRequired,
166
- onPopupChange: PropTypes.func, // If not set, readonly
167
- schema: PropTypes.object.isRequired,
168
- dataSource: PropTypes.object.isRequired,
169
- dashboardDataSource: PropTypes.object.isRequired, // dashboard data source
170
-
171
- onRowClick: PropTypes.func, // Called with (tableId, rowId) when item is clicked
172
- namedStrings: PropTypes.object, // Optional lookup of string name to value. Used for {{branding}} and other replacement strings in text widget
173
-
174
- // Filters to add to the dashboard
175
- filters: PropTypes.arrayOf(PropTypes.shape({
176
- table: PropTypes.string.isRequired, // id table to filter
177
- jsonql: PropTypes.object.isRequired // jsonql filter with {alias} for tableAlias
178
- }))
179
- };
180
- }
181
-
182
- constructor(props) {
183
- this.update = this.update.bind(this);
184
- super(props);
185
-
186
- this.state = {
187
- open: false
188
- };
189
- }
190
-
191
- // Updates with the specified changes
192
- update() { return update(this.props.popup, this.props.onPopupChange, arguments); }
193
-
194
- show() {
195
- return this.setState({open: true});
196
- }
197
-
198
- render() {
199
- return R(ModalWindowComponent, {
200
- onRequestClose: () => this.setState({open: false}),
201
- isOpen: this.state.open
202
- },
203
- R(DashboardComponent, {
204
- schema: this.props.schema,
205
- dataSource: this.props.dataSource,
206
- dashboardDataSource: this.props.dashboardDataSource,
207
- design: this.props.popup.design,
208
- onDesignChange: this.update("design")
209
- // titleElem: H.span style: { fontSize: 20, cursor: "pointer" },
210
- // H.span className: "text-muted", onClick: (=> @setState(open: false)),
211
- // R ui.Icon, id: "fa-arrow-left"
212
- }));
213
- }
214
- }
215
- DashboardPopupComponent.initClass();
216
-
217
-