From 2020a9c420750e92aeec8e879e80b61a9178717c Mon Sep 17 00:00:00 2001 From: Tomasz Rondio Date: Fri, 30 Oct 2020 15:55:07 +0100 Subject: [PATCH] ui framework version bump. Datepicker implementation --- .../components/Analytics/FiltersPanel.js | 9 +- .../Analytics/__snapshots__/Analytics.js.snap | 60 ++++++++--- .../__snapshots__/FiltersPanel.js.snap | 60 ++++++++--- .../Automatic/__snapshots__/Automatic.js.snap | 100 +++++++++++++----- .../__snapshots__/FilterPanel.js.snap | 100 +++++++++++++----- .../Output/__snapshots__/FilterPane.js.snap | 68 ++++++++---- .../Output/__snapshots__/Output.js.snap | 68 ++++++++---- client/components/Analytics/FiltersPanel.jsx | 48 ++++++--- .../ContentLists/Automatic/FilterPanel.jsx | 83 ++++++++++----- client/components/Output/FilterPane.jsx | 59 +++++++---- .../website-management/route-form.html | 11 +- package.json | 2 +- 12 files changed, 484 insertions(+), 184 deletions(-) diff --git a/client/__tests__/components/Analytics/FiltersPanel.js b/client/__tests__/components/Analytics/FiltersPanel.js index 1179879d..18dba15c 100644 --- a/client/__tests__/components/Analytics/FiltersPanel.js +++ b/client/__tests__/components/Analytics/FiltersPanel.js @@ -78,18 +78,11 @@ describe("Analytics/FiltersPanel", () => { /> ); - const input = container.querySelector('input[name="published_before"]'); - fireEvent.change(input, { target: { value: "2020-02-02" } }); - const filterButton = getByText("Run Report"); fireEvent.click(filterButton); expect(setFilters).toHaveBeenCalled(); - - let newFilters = { ...filters }; - newFilters.published_before = "2020-02-02"; - - expect(setFilters).toHaveBeenCalledWith(newFilters); + expect(setFilters).toHaveBeenCalledWith(filters); }); it("clears filters", () => { diff --git a/client/__tests__/components/Analytics/__snapshots__/Analytics.js.snap b/client/__tests__/components/Analytics/__snapshots__/Analytics.js.snap index 78819167..f64a91ac 100644 --- a/client/__tests__/components/Analytics/__snapshots__/Analytics.js.snap +++ b/client/__tests__/components/Analytics/__snapshots__/Analytics.js.snap @@ -323,12 +323,30 @@ exports[`Analytics/Analytics renders correctly 1`] = ` > From - + + + +
To - + + + +
diff --git a/client/__tests__/components/Analytics/__snapshots__/FiltersPanel.js.snap b/client/__tests__/components/Analytics/__snapshots__/FiltersPanel.js.snap index 27aaa061..fb17924f 100644 --- a/client/__tests__/components/Analytics/__snapshots__/FiltersPanel.js.snap +++ b/client/__tests__/components/Analytics/__snapshots__/FiltersPanel.js.snap @@ -132,12 +132,30 @@ exports[`Analytics/FiltersPanel renders correctly 1`] = ` > From - + + + +
To - + + + +
diff --git a/client/__tests__/components/ContentLists/Automatic/__snapshots__/Automatic.js.snap b/client/__tests__/components/ContentLists/Automatic/__snapshots__/Automatic.js.snap index c6c5b3d0..6a4a0cc0 100644 --- a/client/__tests__/components/ContentLists/Automatic/__snapshots__/Automatic.js.snap +++ b/client/__tests__/components/ContentLists/Automatic/__snapshots__/Automatic.js.snap @@ -134,52 +134,102 @@ exports[`ContentLists/Automatic/Automatic renders properly 1`] = ` - + + + +
- + + + +
-
-
- + + + +
- Published date + Publish date - + + + +
- + + + +
-
-
- + + + +
- + + + +
-
-
- + + + +
- + + + +
-
-
- + + + +
- { + let stringDate = moment(date).format("YYYY-MM-DD"); + + this.handleInputChange({ + target: { + name: "published_after", + value: stringDate, + }, + }); + }} />
- { + let stringDate = moment(date).format("YYYY-MM-DD"); + this.handleInputChange({ + target: { + name: "published_before", + value: stringDate, + }, + }); + }} />
diff --git a/client/components/ContentLists/Automatic/FilterPanel.jsx b/client/components/ContentLists/Automatic/FilterPanel.jsx index 195c415c..855c1bc1 100644 --- a/client/components/ContentLists/Automatic/FilterPanel.jsx +++ b/client/components/ContentLists/Automatic/FilterPanel.jsx @@ -1,8 +1,10 @@ import React from "react"; import PropTypes from "prop-types"; import _ from "lodash"; +import moment from "moment"; import { Button, IconButton, Dropdown } from "superdesk-ui-framework/react"; import MultiSelect from "../../UI/MultiSelect"; +import { DatePicker } from "superdesk-ui-framework/react"; class FilterPanel extends React.Component { constructor(props) { @@ -430,53 +432,82 @@ class FilterPanel extends React.Component {
- - Publish date + { + let stringDate = moment(date).format("YYYY-MM-DD"); + + this.handleInputChange({ + target: { + name: "published_at", + value: stringDate, + }, + }); + }} />
-
+
- { + let stringDate = moment(date).format("YYYY-MM-DD"); + + this.handleInputChange({ + target: { + name: "published_after", + value: stringDate, + }, + }); + }} />
-
-
-
+ +
- { + let stringDate = moment(date).format("YYYY-MM-DD"); + + this.handleInputChange({ + target: { + name: "published_before", + value: stringDate, + }, + }); + }} />
diff --git a/client/components/Output/FilterPane.jsx b/client/components/Output/FilterPane.jsx index a9b130ac..97fc209c 100644 --- a/client/components/Output/FilterPane.jsx +++ b/client/components/Output/FilterPane.jsx @@ -1,8 +1,8 @@ import React from "react"; import PropTypes from "prop-types"; import classNames from "classnames"; - -import { Button, IconButton } from "superdesk-ui-framework/react"; +import moment from "moment"; +import { Button, IconButton, DatePicker } from "superdesk-ui-framework/react"; import MultiSelect from "../UI/MultiSelect"; import Store from "./Store"; @@ -245,38 +245,57 @@ class FilterPane extends React.Component {
-
+
- { + let stringDate = moment(date).format("YYYY-MM-DD"); + + this.handleInputChange({ + target: { + name: "published_after", + value: stringDate, + }, + }); + }} />
-
-
-
+ +
- { + let stringDate = moment(date).format("YYYY-MM-DD"); + + this.handleInputChange({ + target: { + name: "published_before", + value: stringDate, + }, + }); + }} />
diff --git a/client/views/settings/website-management/route-form.html b/client/views/settings/website-management/route-form.html index 3c4ad22c..a02e43cf 100644 --- a/client/views/settings/website-management/route-form.html +++ b/client/views/settings/website-management/route-form.html @@ -50,11 +50,12 @@
- +