Skip to content

Commit

Permalink
convert BackwardsCopyTemplateRowPage date to text
Browse files Browse the repository at this point in the history
  • Loading branch information
ChlodAlejandro committed Aug 20, 2022
1 parent 4563a9d commit a5fd408
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 27 deletions.
1 change: 1 addition & 0 deletions i18n/ante/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
"deputy.ante.backwardsCopy.entry.title.placeholder": "Article, journal, or medium name",
"deputy.ante.backwardsCopy.entry.title.label": "Publication name",
"deputy.ante.backwardsCopy.entry.title.help": "The publication title. This is the title of the medium that copied from Wikipedia",
"deputy.ante.backwardsCopy.entry.date.placeholder": "12 Feburary 2022",
"deputy.ante.backwardsCopy.entry.date.label": "Publishing date",
"deputy.ante.backwardsCopy.entry.date.help": "This is the date on which the article was first published.",
"deputy.ante.backwardsCopy.entry.author.placeholder": "Add author",
Expand Down
33 changes: 6 additions & 27 deletions src/modules/ante/ui/pages/BackwardsCopyTemplateRowPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,6 @@ function initBackwardsCopyTemplateRowPage() {
}` :
this.backwardsCopyTemplateRow.year
);
const parsedDate =
( rowDate == null || rowDate.trim().length === 0 ) ?
undefined : (
!isNaN( new Date( rowDate.trim() + ' UTC' ).getTime() ) ?
( new Date( rowDate.trim() + ' UTC' ) ) : (
!isNaN( new Date( rowDate.trim() ).getTime() ) ?
new Date( rowDate.trim() ) : null
)
);

// TODO: l10n
const authorRegex = /(.+?, (?:[A-Z]\.\s?)*)(?:(?:&|[&;]|[,;] (?:&|[&;])?)\s*|$)/g;
Expand All @@ -199,13 +190,11 @@ function initBackwardsCopyTemplateRowPage() {
value: this.backwardsCopyTemplateRow.title ??
this.backwardsCopyTemplateRow.articlename
} ),
date: new mw.widgets.datetime.DateTimeInputWidget( {
$overlay: this.parent.$overlay,
required: true,
calendar: null,
icon: 'calendar',
clearable: true,
value: parsedDate
date: new OO.ui.TextInputWidget( {
placeholder: mw.message(
'deputy.ante.backwardsCopy.entry.date.placeholder'
).text(),
value: rowDate
} ),
author: new OO.ui.TagMultiselectWidget( {
allowArbitrary: true,
Expand Down Expand Up @@ -294,17 +283,7 @@ function initBackwardsCopyTemplateRowPage() {
} else {
// Attach the change listener
input.on( 'change', ( value: string ) => {
if ( input instanceof mw.widgets.datetime.DateTimeInputWidget ) {
this.backwardsCopyTemplateRow[ field ] =
new Date( value ).toLocaleDateString( 'en-GB', {
year: 'numeric', month: 'long', day: 'numeric'
} );
if ( value.length > 0 ) {
fields[ field ].setWarnings( [] );
}
} else {
this.backwardsCopyTemplateRow[ field ] = value;
}
this.backwardsCopyTemplateRow[ field ] = value;
this.backwardsCopyTemplateRow.parent.save();
} );
}
Expand Down

0 comments on commit a5fd408

Please sign in to comment.