|
1 | 1 | import { CustomDataProvider } from '@dhis2/app-runtime' |
2 | | -import { storiesOf } from '@storybook/react' |
3 | 2 | import React from 'react' |
4 | 3 | import CalculationModal from '../components/DataDimension/Calculation/CalculationModal.js' |
5 | 4 |
|
@@ -221,102 +220,120 @@ const calculationWithOperand = { |
221 | 220 | expression: '#{cYeuwXTCPkU}*10-#{fbfJHSPpUQD.pq2XI5kz2BY}', |
222 | 221 | } |
223 | 222 |
|
224 | | -storiesOf('CalculationModal', module) |
225 | | - .add('Default', () => { |
226 | | - return ( |
227 | | - <CustomDataProvider |
228 | | - data={{ |
229 | | - dataElements: DATA_ELEMENTS, |
230 | | - dataElementGroups: DATA_ELEMENT_GROUPS, |
231 | | - dataElementOperands: DATA_ELEMENT_OPERANDS, |
232 | | - }} |
233 | | - > |
234 | | - <CalculationModal |
235 | | - displayNameProp="name" |
236 | | - onClose={Function.prototype} |
237 | | - onDelete={Function.prototype} |
238 | | - onSave={Function.prototype} |
239 | | - /> |
240 | | - </CustomDataProvider> |
241 | | - ) |
242 | | - }) |
243 | | - .add('With calculation', () => { |
244 | | - return ( |
245 | | - <CustomDataProvider |
246 | | - data={{ |
247 | | - dataElements: DATA_ELEMENTS, |
248 | | - dataElementGroups: DATA_ELEMENT_GROUPS, |
249 | | - dataElementOperands: DATA_ELEMENT_OPERANDS, |
250 | | - }} |
251 | | - > |
252 | | - <CalculationModal |
253 | | - calculation={calculation} |
254 | | - displayNameProp="name" |
255 | | - onClose={Function.prototype} |
256 | | - onDelete={Function.prototype} |
257 | | - onSave={Function.prototype} |
258 | | - /> |
259 | | - </CustomDataProvider> |
260 | | - ) |
261 | | - }) |
262 | | - .add('With calculation containing operand', () => { |
263 | | - return ( |
264 | | - <CustomDataProvider |
265 | | - data={{ |
266 | | - dataElements: DATA_ELEMENTS, |
267 | | - dataElementGroups: DATA_ELEMENT_GROUPS, |
268 | | - dataElementOperands: DATA_ELEMENT_OPERANDS, |
269 | | - }} |
270 | | - > |
271 | | - <CalculationModal |
272 | | - calculation={calculationWithOperand} |
273 | | - displayNameProp="name" |
274 | | - onClose={Function.prototype} |
275 | | - onDelete={Function.prototype} |
276 | | - onSave={Function.prototype} |
277 | | - /> |
278 | | - </CustomDataProvider> |
279 | | - ) |
280 | | - }) |
281 | | - .add('No available data', () => { |
282 | | - return ( |
283 | | - <CustomDataProvider |
284 | | - data={{ |
285 | | - dataElements: { |
286 | | - pager: { |
287 | | - page: 1, |
288 | | - total: 0, |
289 | | - pageSize: 50, |
290 | | - pageCount: 1, |
291 | | - }, |
292 | | - dataElements: [], |
| 223 | +export default { |
| 224 | + title: 'CalculationModal', |
| 225 | +} |
| 226 | + |
| 227 | +export const Default = () => { |
| 228 | + return ( |
| 229 | + <CustomDataProvider |
| 230 | + data={{ |
| 231 | + dataElements: DATA_ELEMENTS, |
| 232 | + dataElementGroups: DATA_ELEMENT_GROUPS, |
| 233 | + dataElementOperands: DATA_ELEMENT_OPERANDS, |
| 234 | + }} |
| 235 | + > |
| 236 | + <CalculationModal |
| 237 | + displayNameProp="name" |
| 238 | + onClose={Function.prototype} |
| 239 | + onDelete={Function.prototype} |
| 240 | + onSave={Function.prototype} |
| 241 | + /> |
| 242 | + </CustomDataProvider> |
| 243 | + ) |
| 244 | +} |
| 245 | + |
| 246 | +export const WithCalculation = () => { |
| 247 | + return ( |
| 248 | + <CustomDataProvider |
| 249 | + data={{ |
| 250 | + dataElements: DATA_ELEMENTS, |
| 251 | + dataElementGroups: DATA_ELEMENT_GROUPS, |
| 252 | + dataElementOperands: DATA_ELEMENT_OPERANDS, |
| 253 | + }} |
| 254 | + > |
| 255 | + <CalculationModal |
| 256 | + calculation={calculation} |
| 257 | + displayNameProp="name" |
| 258 | + onClose={Function.prototype} |
| 259 | + onDelete={Function.prototype} |
| 260 | + onSave={Function.prototype} |
| 261 | + /> |
| 262 | + </CustomDataProvider> |
| 263 | + ) |
| 264 | +} |
| 265 | + |
| 266 | +WithCalculation.story = { |
| 267 | + name: 'With calculation', |
| 268 | +} |
| 269 | + |
| 270 | +export const WithCalculationContainingOperand = () => { |
| 271 | + return ( |
| 272 | + <CustomDataProvider |
| 273 | + data={{ |
| 274 | + dataElements: DATA_ELEMENTS, |
| 275 | + dataElementGroups: DATA_ELEMENT_GROUPS, |
| 276 | + dataElementOperands: DATA_ELEMENT_OPERANDS, |
| 277 | + }} |
| 278 | + > |
| 279 | + <CalculationModal |
| 280 | + calculation={calculationWithOperand} |
| 281 | + displayNameProp="name" |
| 282 | + onClose={Function.prototype} |
| 283 | + onDelete={Function.prototype} |
| 284 | + onSave={Function.prototype} |
| 285 | + /> |
| 286 | + </CustomDataProvider> |
| 287 | + ) |
| 288 | +} |
| 289 | + |
| 290 | +WithCalculationContainingOperand.story = { |
| 291 | + name: 'With calculation containing operand', |
| 292 | +} |
| 293 | + |
| 294 | +export const NoAvailableData = () => { |
| 295 | + return ( |
| 296 | + <CustomDataProvider |
| 297 | + data={{ |
| 298 | + dataElements: { |
| 299 | + pager: { |
| 300 | + page: 1, |
| 301 | + total: 0, |
| 302 | + pageSize: 50, |
| 303 | + pageCount: 1, |
293 | 304 | }, |
294 | | - dataElementGroups: { |
295 | | - pager: { |
296 | | - page: 1, |
297 | | - total: 0, |
298 | | - pageSize: 50, |
299 | | - pageCount: 1, |
300 | | - }, |
301 | | - dataElementGroups: [], |
| 305 | + dataElements: [], |
| 306 | + }, |
| 307 | + dataElementGroups: { |
| 308 | + pager: { |
| 309 | + page: 1, |
| 310 | + total: 0, |
| 311 | + pageSize: 50, |
| 312 | + pageCount: 1, |
302 | 313 | }, |
303 | | - dataElementOperands: { |
304 | | - pager: { |
305 | | - page: 1, |
306 | | - total: 0, |
307 | | - pageSize: 50, |
308 | | - pageCount: 1, |
309 | | - }, |
310 | | - dataElementOperands: [], |
| 314 | + dataElementGroups: [], |
| 315 | + }, |
| 316 | + dataElementOperands: { |
| 317 | + pager: { |
| 318 | + page: 1, |
| 319 | + total: 0, |
| 320 | + pageSize: 50, |
| 321 | + pageCount: 1, |
311 | 322 | }, |
312 | | - }} |
313 | | - > |
314 | | - <CalculationModal |
315 | | - displayNameProp="name" |
316 | | - onClose={Function.prototype} |
317 | | - onDelete={Function.prototype} |
318 | | - onSave={Function.prototype} |
319 | | - /> |
320 | | - </CustomDataProvider> |
321 | | - ) |
322 | | - }) |
| 323 | + dataElementOperands: [], |
| 324 | + }, |
| 325 | + }} |
| 326 | + > |
| 327 | + <CalculationModal |
| 328 | + displayNameProp="name" |
| 329 | + onClose={Function.prototype} |
| 330 | + onDelete={Function.prototype} |
| 331 | + onSave={Function.prototype} |
| 332 | + /> |
| 333 | + </CustomDataProvider> |
| 334 | + ) |
| 335 | +} |
| 336 | + |
| 337 | +NoAvailableData.story = { |
| 338 | + name: 'No available data', |
| 339 | +} |
0 commit comments