Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
petrjasek committed Jan 13, 2025
1 parent a939213 commit 40e5cef
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 41 deletions.
20 changes: 20 additions & 0 deletions client/components/fields/editor/PlanningDateTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -12,6 +13,21 @@ interface IProps extends IEditorFieldProps {
}

export class EditorFieldPlanningDateTime extends React.PureComponent<IProps> {
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;

Check failure on line 24 in client/components/fields/editor/PlanningDateTime.tsx

View workflow job for this annotation

GitHub Actions / client (14.x)

Assignment to function parameter 'value'
this.props.onChange(fieldOrValues, value);
} else {
this.props.onChange(fieldOrValues);
}
}

render() {
const {gettext} = superdeskApi.localization;
const {
Expand All @@ -29,6 +45,10 @@ export class EditorFieldPlanningDateTime extends React.PureComponent<IProps> {
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}
/>
);
}
Expand Down
1 change: 1 addition & 0 deletions client/components/fields/editor/base/dateTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface IProps extends IEditorFieldProps {
singleValue?: boolean;
onToBeConfirmed?(field: string): void;
dateOnly?: boolean;
hideTime?: boolean;
}

export class EditorFieldDateTime extends React.PureComponent<IProps> {
Expand Down
68 changes: 27 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions server/planning/planning/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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"]
Expand Down

0 comments on commit 40e5cef

Please sign in to comment.