Skip to content

Commit de74d21

Browse files
committed
code review changes
1 parent 75977d6 commit de74d21

6 files changed

Lines changed: 78 additions & 50 deletions

File tree

packages/components/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@labkey/components",
3-
"version": "6.46.1-fb-issue53071.2",
3+
"version": "6.46.1-fb-issue53071.3",
44
"description": "Components, models, actions, and utility functions for LabKey applications and pages",
55
"sideEffects": false,
66
"files": [

packages/components/src/internal/components/forms/QueryInfoForm.test.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,35 +205,43 @@ describe('getUpdatedFields', () => {
205205
test('without ::enabled', () => {
206206
expect(getUpdatedFields(MIXTURE_QUERY_INFO, formData).toJS()).toEqual({
207207
expirationTime: '22:20:00.000',
208-
extraTestColumn: 'abc'
208+
extraTestColumn: 'abc',
209209
});
210210
});
211211

212212
test('without ::enabled, with additionalFields', () => {
213213
expect(getUpdatedFields(MIXTURE_QUERY_INFO, formData, ['numItems']).toJS()).toEqual({
214214
expirationTime: '22:20:00.000',
215215
extraTestColumn: 'abc',
216-
numItems: 10
216+
numItems: 10,
217217
});
218218
});
219219

220220
test('with ::enabled=false', () => {
221-
expect(getUpdatedFields(MIXTURE_QUERY_INFO, {
222-
...formData,
223-
'extraTestColumn::enabled': false
224-
}).toJS()).toEqual({
221+
expect(
222+
getUpdatedFields(MIXTURE_QUERY_INFO, {
223+
...formData,
224+
'extraTestColumn::enabled': false,
225+
}).toJS()
226+
).toEqual({
225227
expirationTime: '22:20:00.000',
226228
});
227229
});
228230

229231
test('with ::enabled=false, with additionalFields', () => {
230-
expect(getUpdatedFields(MIXTURE_QUERY_INFO, {
231-
...formData,
232-
'extraTestColumn::enabled': false
233-
}, ['numItems', 'extraTestColumn']).toJS()).toEqual({
232+
expect(
233+
getUpdatedFields(
234+
MIXTURE_QUERY_INFO,
235+
{
236+
...formData,
237+
'extraTestColumn::enabled': false,
238+
},
239+
['numItems', 'extraTestColumn']
240+
).toJS()
241+
).toEqual({
234242
expirationTime: '22:20:00.000',
235243
extraTestColumn: 'abc',
236-
numItems: 10
244+
numItems: 10,
237245
});
238246
});
239247
});

packages/components/src/internal/components/forms/QueryInfoForm.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,7 @@ export class QueryInfoForm extends PureComponent<QueryInfoFormProps, State> {
191191
if (onFormChangeWithData) {
192192
const row = this.formRef?.['current']?.['getModel']?.();
193193
if (row) {
194-
const updatedRow = getUpdatedFields(queryInfo, row, [
195-
'numItems',
196-
'creationType',
197-
]);
194+
const updatedRow = getUpdatedFields(queryInfo, row, ['numItems', 'creationType']);
198195
onFormChangeWithData(updatedRow);
199196
}
200197
}

packages/components/src/internal/util/Date.test.ts

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ import {
3939
getNonStandardDateTimeFormatWarning,
4040
getNonStandardFormatWarning,
4141
getParsedRelativeDateStr,
42-
getPickerDateAndTimeFormat, getPickerFormatWithPrecision, getPickerTimeFormatWithPrecision,
42+
getPickerDateAndTimeFormat,
43+
getPickerFormatWithPrecision,
44+
getPickerTimeFormatWithPrecision,
4345
isDateBetween,
4446
isDateTimeInPast,
4547
isRelativeDateFilterValue,
@@ -457,7 +459,6 @@ describe('Date Utilities', () => {
457459
dateFormat: 'HH:mm:ss.SSS',
458460
timeFormat: 'HH:mm:ss.SSS',
459461
});
460-
461462
});
462463

463464
test('datePlaceholder without col.rangeURI', () => {
@@ -499,7 +500,6 @@ describe('Date Utilities', () => {
499500
timeFormat: undefined,
500501
});
501502

502-
503503
const timeCol = new QueryColumn({ shortCaption: 'TimeCol', rangeURI: undefined });
504504
expect(getColDateFormat(timeCol, 'Time')).toBe('HH:mm');
505505

@@ -522,7 +522,6 @@ describe('Date Utilities', () => {
522522
dateFormat: 'yyyy-MM-dd HH:mm:ss.SSS',
523523
timeFormat: 'HH:mm:ss.SSS',
524524
});
525-
526525
});
527526

528527
test('queryColumn.format', () => {
@@ -793,9 +792,9 @@ describe('Date Utilities', () => {
793792

794793
describe('getPickerTimeFormatWithPrecision', () => {
795794
test('invalid', () => {
796-
expect(getPickerTimeFormatWithPrecision(undefined)).toBe('')
797-
expect(getPickerTimeFormatWithPrecision(null)).toBe('')
798-
expect(getPickerTimeFormatWithPrecision('')).toBe('')
795+
expect(getPickerTimeFormatWithPrecision(undefined)).toBe('');
796+
expect(getPickerTimeFormatWithPrecision(null)).toBe('');
797+
expect(getPickerTimeFormatWithPrecision('')).toBe('');
799798
expect(getPickerTimeFormatWithPrecision('null')).toBe('null');
800799
});
801800

@@ -815,7 +814,7 @@ describe('Date Utilities', () => {
815814
});
816815

817816
test('am/pm', () => {
818-
expect(getPickerTimeFormatWithPrecision('hh:mm:ss.SSS a')).toBe('hh:mm:ss.SSS a')
817+
expect(getPickerTimeFormatWithPrecision('hh:mm:ss.SSS a')).toBe('hh:mm:ss.SSS a');
819818
expect(getPickerTimeFormatWithPrecision('hh:mm:ss.SSS a', true, false, false)).toBe('hh:mm:ss.SSS a');
820819
expect(getPickerTimeFormatWithPrecision('hh:mm:ss.SSS a', false, true, false)).toBe('hh:mm:ss.SSS a');
821820
expect(getPickerTimeFormatWithPrecision('hh:mm:ss.SSS a', false, false, true)).toBe('hh:mm:ss.SSS a');
@@ -832,38 +831,62 @@ describe('Date Utilities', () => {
832831

833832
describe('getPickerFormatWithPrecision', () => {
834833
test('invalid', () => {
835-
expect(getPickerFormatWithPrecision(undefined)).toBe('')
836-
expect(getPickerFormatWithPrecision(null)).toBe('')
837-
expect(getPickerFormatWithPrecision('')).toBe('')
834+
expect(getPickerFormatWithPrecision(undefined)).toBe('');
835+
expect(getPickerFormatWithPrecision(null)).toBe('');
836+
expect(getPickerFormatWithPrecision('')).toBe('');
838837
expect(getPickerFormatWithPrecision('null')).toBe('null');
839838
});
840839

841840
test('Date only', () => {
842-
expect(getPickerFormatWithPrecision('yyyy-MM-dd')).toBe('yyyy-MM-dd')
843-
expect(getPickerFormatWithPrecision('MMMM dd yyyy')).toBe('MMMM dd yyyy')
841+
expect(getPickerFormatWithPrecision('yyyy-MM-dd')).toBe('yyyy-MM-dd');
842+
expect(getPickerFormatWithPrecision('MMMM dd yyyy')).toBe('MMMM dd yyyy');
844843
});
845844

846845
test('Datetime', () => {
847846
expect(getPickerFormatWithPrecision('yyyy-MM-dd HH:mm:ss.SSS')).toBe('yyyy-MM-dd HH:mm:ss.SSS');
848847
expect(getPickerFormatWithPrecision('MMMM dd yyyy HH:mm:ss.SSS')).toBe('MMMM dd yyyy HH:mm:ss.SSS');
849-
expect(getPickerFormatWithPrecision('yyyy-MM-dd HH:mm:ss.SSS', true, false, false)).toBe('yyyy-MM-dd HH:mm:ss.SSS');
850-
expect(getPickerFormatWithPrecision('MMMM dd yyyy HH:mm:ss.SSS', true, false, false)).toBe('MMMM dd yyyy HH:mm:ss.SSS');
848+
expect(getPickerFormatWithPrecision('yyyy-MM-dd HH:mm:ss.SSS', true, false, false)).toBe(
849+
'yyyy-MM-dd HH:mm:ss.SSS'
850+
);
851+
expect(getPickerFormatWithPrecision('MMMM dd yyyy HH:mm:ss.SSS', true, false, false)).toBe(
852+
'MMMM dd yyyy HH:mm:ss.SSS'
853+
);
851854
expect(getPickerFormatWithPrecision('yyyy-MM-dd HH:mm:ss')).toBe('yyyy-MM-dd HH:mm:ss');
852855
expect(getPickerFormatWithPrecision('MMMM dd yyyy HH:mm:ss')).toBe('MMMM dd yyyy HH:mm:ss');
853-
expect(getPickerFormatWithPrecision('yyyy-MM-dd HH:mm:ss', false, false, true)).toBe('yyyy-MM-dd HH:mm:ss.SSS');
854-
expect(getPickerFormatWithPrecision('MMMM dd yyyy HH:mm:ss', false, false, true)).toBe('MMMM dd yyyy HH:mm:ss.SSS');
856+
expect(getPickerFormatWithPrecision('yyyy-MM-dd HH:mm:ss', false, false, true)).toBe(
857+
'yyyy-MM-dd HH:mm:ss.SSS'
858+
);
859+
expect(getPickerFormatWithPrecision('MMMM dd yyyy HH:mm:ss', false, false, true)).toBe(
860+
'MMMM dd yyyy HH:mm:ss.SSS'
861+
);
855862
expect(getPickerFormatWithPrecision('yyyy-MM-dd HH:mm', false, true, false)).toBe('yyyy-MM-dd HH:mm:ss');
856-
expect(getPickerFormatWithPrecision('MMMM dd yyyy HH:mm', false, true, false)).toBe('MMMM dd yyyy HH:mm:ss');
857-
expect(getPickerFormatWithPrecision('yyyy-MM-dd HH:mm', false, false, true)).toBe('yyyy-MM-dd HH:mm:ss.SSS');
858-
expect(getPickerFormatWithPrecision('MMMM dd yyyy HH:mm', false, false, true)).toBe('MMMM dd yyyy HH:mm:ss.SSS');
859-
expect(getPickerFormatWithPrecision('MMMM dd yyyy hh:mm:ss.SSS a')).toBe('MMMM dd yyyy hh:mm:ss.SSS a')
860-
expect(getPickerFormatWithPrecision('yyyy-MM-dd hh:mm:ss.SSS a', true, false, false)).toBe('yyyy-MM-dd hh:mm:ss.SSS a');
861-
expect(getPickerFormatWithPrecision('yyyy-MM-dd hh:mm:ss a', false, false, true)).toBe('yyyy-MM-dd hh:mm:ss.SSS a');
862-
expect(getPickerFormatWithPrecision('MMMM dd yyyy hh:mm:ss a', false, false, true)).toBe('MMMM dd yyyy hh:mm:ss.SSS a');
863+
expect(getPickerFormatWithPrecision('MMMM dd yyyy HH:mm', false, true, false)).toBe(
864+
'MMMM dd yyyy HH:mm:ss'
865+
);
866+
expect(getPickerFormatWithPrecision('yyyy-MM-dd HH:mm', false, false, true)).toBe(
867+
'yyyy-MM-dd HH:mm:ss.SSS'
868+
);
869+
expect(getPickerFormatWithPrecision('MMMM dd yyyy HH:mm', false, false, true)).toBe(
870+
'MMMM dd yyyy HH:mm:ss.SSS'
871+
);
872+
expect(getPickerFormatWithPrecision('MMMM dd yyyy hh:mm:ss.SSS a')).toBe('MMMM dd yyyy hh:mm:ss.SSS a');
873+
expect(getPickerFormatWithPrecision('yyyy-MM-dd hh:mm:ss.SSS a', true, false, false)).toBe(
874+
'yyyy-MM-dd hh:mm:ss.SSS a'
875+
);
876+
expect(getPickerFormatWithPrecision('yyyy-MM-dd hh:mm:ss a', false, false, true)).toBe(
877+
'yyyy-MM-dd hh:mm:ss.SSS a'
878+
);
879+
expect(getPickerFormatWithPrecision('MMMM dd yyyy hh:mm:ss a', false, false, true)).toBe(
880+
'MMMM dd yyyy hh:mm:ss.SSS a'
881+
);
863882
expect(getPickerFormatWithPrecision('MMMM dd yyyy hh:mm a')).toBe('MMMM dd yyyy hh:mm a');
864883
expect(getPickerFormatWithPrecision('yyyy-MM-dd hh:mm a', true, false, false)).toBe('yyyy-MM-dd hh:mm a');
865-
expect(getPickerFormatWithPrecision('yyyy-MM-dd hh:mm a', false, true, false)).toBe('yyyy-MM-dd hh:mm:ss a');
866-
expect(getPickerFormatWithPrecision('MMMM dd yyyy hh:mm a', false, false, true)).toBe('MMMM dd yyyy hh:mm:ss.SSS a');
884+
expect(getPickerFormatWithPrecision('yyyy-MM-dd hh:mm a', false, true, false)).toBe(
885+
'yyyy-MM-dd hh:mm:ss a'
886+
);
887+
expect(getPickerFormatWithPrecision('MMMM dd yyyy hh:mm a', false, false, true)).toBe(
888+
'MMMM dd yyyy hh:mm:ss.SSS a'
889+
);
867890
});
868891
});
869892

packages/components/src/internal/util/Date.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function isDateTimeCol(col: QueryColumn): boolean {
9999
return false;
100100
}
101101

102-
function _toAmPm(rawTimeFormat: string, toAMPM: boolean) : string {
102+
function _toAmPm(rawTimeFormat: string, toAMPM: boolean): string {
103103
if (!toAMPM) return rawTimeFormat;
104104

105105
if (rawTimeFormat.indexOf(' a') > -1) return rawTimeFormat;
@@ -112,9 +112,8 @@ export function getPickerTimeFormatWithPrecision(
112112
showMinute?: boolean,
113113
showSeconds?: boolean,
114114
showMilliSeconds?: boolean
115-
) : string {
116-
if (!timeFormat)
117-
return '';
115+
): string {
116+
if (!timeFormat) return '';
118117

119118
const useAmPm = timeFormat.indexOf(' a') > -1;
120119
if (timeFormat.indexOf('.SSS') > -1) return timeFormat;
@@ -141,7 +140,7 @@ export function getPickerFormatWithPrecision(
141140
showMinute?: boolean,
142141
showSeconds?: boolean,
143142
showMilliSeconds?: boolean
144-
) : string {
143+
): string {
145144
const parts = splitDateTimeFormat(rawDateTimeFormat);
146145
if (parts.length === 1) return parts[0];
147146
if (!parts[1]) return parts[0];
@@ -505,7 +504,8 @@ export function parseTime(time: string | Date): Date {
505504
if (isValid(date)) return date;
506505
}
507506

508-
return null;}
507+
return null;
508+
}
509509

510510
function safeParse(dateStr: string, formatStr: string, referenceDate: number | Date, options?: any): Date {
511511
try {

0 commit comments

Comments
 (0)