Skip to content

Commit

Permalink
Datetime field imrpovements (superdesk#4732)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc authored Jan 23, 2025
1 parent f3a916e commit a55623a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 47 deletions.
58 changes: 29 additions & 29 deletions package-lock.json

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

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"sass-loader": "6.0.6",
"shortid": "2.2.8",
"style-loader": "0.20.2",
"superdesk-ui-framework": "4.0.4",
"superdesk-ui-framework": "4.0.11",
"ts-loader": "3.5.0",
"typescript": "4.9.5",
"uuid": "8.3.1",
Expand Down Expand Up @@ -168,5 +168,8 @@
"lint-fix": "eslint --fix --parser=@typescript-eslint/parser --ext .js --ext .jsx --ext .ts --ext .tsx scripts e2e/client tasks",
"server": "grunt server",
"dev": "npm run server"
},
"volta": {
"node": "14.21.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class Difference extends React.PureComponent<IProps> {
<DifferenceGeneric
items1={value1 == null ? [] : [value1]}
items2={value2 == null ? [] : [value2]}
getId={(item) => item}
getId={(item) => item.getDate().toString()}
template={({item}) => <span>{item}</span>}
/>
);
Expand Down
11 changes: 2 additions & 9 deletions scripts/apps/authoring-react/fields/datetime/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,8 @@ export class Editor extends React.PureComponent<IProps> {
text: gettext('Date time'),
hidden: true,
}}
onChange={(value) => {
this.props.onChange(value);
}}
value={(() => {
const {value} = this.props;
const parsedVal = value != null && (value.length > 0) ? new Date(value) : null;

return parsedVal;
})()}
onChange={this.props.onChange}
value={this.props.value}
disabled={this.props.config.readOnly}
width={this.props.config.width}
/>
Expand Down
7 changes: 1 addition & 6 deletions scripts/apps/authoring-react/fields/datetime/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ export class Preview extends React.PureComponent<IProps> {
label={gettext('Date time (AUTHORING-REACT)')}
onChange={noop}
preview={true}
value={(() => {
const {value} = this.props;
const parsedVal = value != null && (value.length > 0) ? new Date(value) : null;

return parsedVal;
})()}
value={this.props.value}
disabled={this.props.config.readOnly}
width={this.props.config.width}
/>
Expand Down
2 changes: 1 addition & 1 deletion scripts/core/superdesk-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ declare module 'superdesk-api' {

// AUTHORING-REACT FIELD TYPES - datetime

export type IDateTimeValueOperational = string; // ISO 8601, 13:59:01.123
export type IDateTimeValueOperational = Date | null;
export type IDateTimeValueStorage = IDateTimeValueOperational;
export interface IDateTimeFieldConfig extends ICommonFieldConfig {
allowSeconds?: boolean;
Expand Down

0 comments on commit a55623a

Please sign in to comment.