From 40e5cef8fe76fd35ea83a1c12e33774df0f06643 Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Mon, 13 Jan 2025 12:08:44 +0100 Subject: [PATCH] save --- .../fields/editor/PlanningDateTime.tsx | 20 ++++++ .../fields/editor/base/dateTime.tsx | 1 + package-lock.json | 68 ++++++++----------- server/planning/planning/planning.py | 4 ++ 4 files changed, 52 insertions(+), 41 deletions(-) diff --git a/client/components/fields/editor/PlanningDateTime.tsx b/client/components/fields/editor/PlanningDateTime.tsx index f177c3e34..fea9eed54 100644 --- a/client/components/fields/editor/PlanningDateTime.tsx +++ b/client/components/fields/editor/PlanningDateTime.tsx @@ -3,6 +3,7 @@ import * as React from 'react'; import {superdeskApi} from '../../../superdeskApi'; import {IEditorFieldProps, IPlanningItem} from '../../../interfaces'; import {EditorFieldDateTime} from './base/dateTime'; +import {assertNever} from 'core/helpers/typescript-helpers'; interface IProps extends IEditorFieldProps { item: IPlanningItem; @@ -12,6 +13,21 @@ interface IProps extends IEditorFieldProps { } export class EditorFieldPlanningDateTime extends React.PureComponent { + constructor(props: IProps) { + super(props); + + this.onChange = this.onChange.bind(this); + } + + onChange(fieldOrValues: string | { [key: string]: any }, value?: any) { + if (typeof fieldOrValues === 'string') { + value = value?.isValid() ? value.format('YYYY-MM-DD') : null; + this.props.onChange(fieldOrValues, value); + } else { + this.props.onChange(fieldOrValues); + } + } + render() { const {gettext} = superdeskApi.localization; const { @@ -29,6 +45,10 @@ export class EditorFieldPlanningDateTime extends React.PureComponent { label={label ?? gettext('Planning Date')} showToBeConfirmed={true} toBeConfirmed={this.props.item?._time_to_be_confirmed == true} + singleValue={true} + dateOnly={true} // todo: use app config + hideTime={true} + onChange={this.onChange} /> ); } diff --git a/client/components/fields/editor/base/dateTime.tsx b/client/components/fields/editor/base/dateTime.tsx index 2100abb08..3d9024a30 100644 --- a/client/components/fields/editor/base/dateTime.tsx +++ b/client/components/fields/editor/base/dateTime.tsx @@ -14,6 +14,7 @@ interface IProps extends IEditorFieldProps { singleValue?: boolean; onToBeConfirmed?(field: string): void; dateOnly?: boolean; + hideTime?: boolean; } export class EditorFieldDateTime extends React.PureComponent { diff --git a/package-lock.json b/package-lock.json index fd3c153b4..c1f6391db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4124,6 +4124,27 @@ "unpipe": "~1.0.0" } }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, "path-to-regexp": { "version": "0.1.10", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", @@ -7719,6 +7740,12 @@ "trim-newlines": "^1.0.0" } }, + "merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "dev": true + }, "merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -14099,47 +14126,6 @@ "is-weakset": "^2.0.3" } }, - "which-builtin-type": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/which-builtin-type/-/which-builtin-type-1.2.0.tgz", - "integrity": "sha512-I+qLGQ/vucCby4tf5HsLmGueEla4ZhwTBSqaooS+Y0BuxN4Cp+okmGuV+8mXZ84KDI9BA+oklo+RzKg0ONdSUA==", - "dev": true, - "requires": { - "call-bind": "^1.0.7", - "function.prototype.name": "^1.1.6", - "has-tostringtag": "^1.0.2", - "is-async-function": "^2.0.0", - "is-date-object": "^1.0.5", - "is-finalizationregistry": "^1.1.0", - "is-generator-function": "^1.0.10", - "is-regex": "^1.1.4", - "is-weakref": "^1.0.2", - "isarray": "^2.0.5", - "which-boxed-primitive": "^1.0.2", - "which-collection": "^1.0.2", - "which-typed-array": "^1.1.15" - }, - "dependencies": { - "isarray": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", - "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", - "dev": true - } - } - }, - "which-collection": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.2.tgz", - "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", - "dev": true, - "requires": { - "is-map": "^2.0.3", - "is-set": "^2.0.3", - "is-weakmap": "^2.0.2", - "is-weakset": "^2.0.3" - } - }, "which-module": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", diff --git a/server/planning/planning/planning.py b/server/planning/planning/planning.py index c22889f4c..2ebf56cde 100644 --- a/server/planning/planning/planning.py +++ b/server/planning/planning/planning.py @@ -136,6 +136,7 @@ def generate_related_assignments(self, docs): doc.pop("_planning_schedule", None) doc.pop("_updates_schedule", None) sync_assignment_details_to_coverages(doc) + print("FETCHED", doc) def on_fetched(self, docs): self.generate_related_assignments(docs.get(config.ITEMS)) @@ -162,6 +163,9 @@ def on_create(self, docs): history_service = get_resource_service("planning_history") generated_planning_items = [] for doc in docs: + if doc.get("planning_date") and isinstance(doc["planning_date"], datetime): + doc["planning_date"] = doc["planning_date"].date().isoformat() + print("DOC", doc) if "guid" not in doc: doc["guid"] = generate_guid(type=GUID_NEWSML) doc[config.ID_FIELD] = doc["guid"]