Skip to content

Commit a5fd408

Browse files
convert BackwardsCopyTemplateRowPage date to text
1 parent 4563a9d commit a5fd408

File tree

2 files changed

+7
-27
lines changed

2 files changed

+7
-27
lines changed

i18n/ante/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
"deputy.ante.backwardsCopy.entry.title.placeholder": "Article, journal, or medium name",
163163
"deputy.ante.backwardsCopy.entry.title.label": "Publication name",
164164
"deputy.ante.backwardsCopy.entry.title.help": "The publication title. This is the title of the medium that copied from Wikipedia",
165+
"deputy.ante.backwardsCopy.entry.date.placeholder": "12 Feburary 2022",
165166
"deputy.ante.backwardsCopy.entry.date.label": "Publishing date",
166167
"deputy.ante.backwardsCopy.entry.date.help": "This is the date on which the article was first published.",
167168
"deputy.ante.backwardsCopy.entry.author.placeholder": "Add author",

src/modules/ante/ui/pages/BackwardsCopyTemplateRowPage.tsx

+6-27
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,6 @@ function initBackwardsCopyTemplateRowPage() {
172172
}` :
173173
this.backwardsCopyTemplateRow.year
174174
);
175-
const parsedDate =
176-
( rowDate == null || rowDate.trim().length === 0 ) ?
177-
undefined : (
178-
!isNaN( new Date( rowDate.trim() + ' UTC' ).getTime() ) ?
179-
( new Date( rowDate.trim() + ' UTC' ) ) : (
180-
!isNaN( new Date( rowDate.trim() ).getTime() ) ?
181-
new Date( rowDate.trim() ) : null
182-
)
183-
);
184175

185176
// TODO: l10n
186177
const authorRegex = /(.+?, (?:[A-Z]\.\s?)*)(?:(?:&|[&;]|[,;] (?:&|[&;])?)\s*|$)/g;
@@ -199,13 +190,11 @@ function initBackwardsCopyTemplateRowPage() {
199190
value: this.backwardsCopyTemplateRow.title ??
200191
this.backwardsCopyTemplateRow.articlename
201192
} ),
202-
date: new mw.widgets.datetime.DateTimeInputWidget( {
203-
$overlay: this.parent.$overlay,
204-
required: true,
205-
calendar: null,
206-
icon: 'calendar',
207-
clearable: true,
208-
value: parsedDate
193+
date: new OO.ui.TextInputWidget( {
194+
placeholder: mw.message(
195+
'deputy.ante.backwardsCopy.entry.date.placeholder'
196+
).text(),
197+
value: rowDate
209198
} ),
210199
author: new OO.ui.TagMultiselectWidget( {
211200
allowArbitrary: true,
@@ -294,17 +283,7 @@ function initBackwardsCopyTemplateRowPage() {
294283
} else {
295284
// Attach the change listener
296285
input.on( 'change', ( value: string ) => {
297-
if ( input instanceof mw.widgets.datetime.DateTimeInputWidget ) {
298-
this.backwardsCopyTemplateRow[ field ] =
299-
new Date( value ).toLocaleDateString( 'en-GB', {
300-
year: 'numeric', month: 'long', day: 'numeric'
301-
} );
302-
if ( value.length > 0 ) {
303-
fields[ field ].setWarnings( [] );
304-
}
305-
} else {
306-
this.backwardsCopyTemplateRow[ field ] = value;
307-
}
286+
this.backwardsCopyTemplateRow[ field ] = value;
308287
this.backwardsCopyTemplateRow.parent.save();
309288
} );
310289
}

0 commit comments

Comments
 (0)