Assume lock/unlock times when those are empty
This makes it so the form will, in the absence of data in the time inputs, behave as it did before g/350203 when those weren't a thing fixes RCX-2185 flag=none Test plan: - Go to course or user files - Upload a file if you have none - Click the publish status icon - Select schedule availability - Ignore the date fields and only fill the date ones - Save and check the availability was properly saved Change-Id: Ic9ce7fda4ad0a7bd67476d9e2a56df3648f95d72 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/355274 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Eric Saupe <eric.saupe@instructure.com> QA-Review: Eric Saupe <eric.saupe@instructure.com> Product-Review: Luis Oliveira <luis.oliveira@instructure.com>
This commit is contained in:
parent
f59d0f6201
commit
3acadfb29b
|
@ -120,8 +120,18 @@ class RestrictedRadioButtons extends React.Component {
|
|||
}
|
||||
|
||||
extractFormValues = () => {
|
||||
const unlock_at_datetime = $(this.unlock_at_time).val() && $(this.unlock_at).data('unfudged-date') ? mergeTimeAndDate($(this.unlock_at_time).val(), $(this.unlock_at).data('unfudged-date')) : ''
|
||||
const lock_at_datetime = $(this.lock_at_time).val() && $(this.lock_at).data('unfudged-date') ? mergeTimeAndDate($(this.lock_at_time).val(), $(this.lock_at).data('unfudged-date')) : ''
|
||||
let unlock_at_datetime = ''
|
||||
let lock_at_datetime = ''
|
||||
|
||||
if (this.state.selectedOption === 'date_range') {
|
||||
unlock_at_datetime = $(this.unlock_at).data('unfudged-date') || ''
|
||||
if ($(this.unlock_at_time).val()) { unlock_at_datetime = mergeTimeAndDate($(this.unlock_at_time).val(), $(this.unlock_at).data('unfudged-date')) || '' }
|
||||
|
||||
|
||||
lock_at_datetime = $(this.lock_at).data('unfudged-date') || ''
|
||||
if ($(this.lock_at_time).val()) { lock_at_datetime = mergeTimeAndDate($(this.lock_at_time).val(), $(this.lock_at).data('unfudged-date')) || '' }
|
||||
}
|
||||
|
||||
const opts = {
|
||||
hidden: this.state.selectedOption === 'link_only',
|
||||
unlock_at:
|
||||
|
|
|
@ -176,6 +176,26 @@ test('returns the correct object to restrict an item based on dates', function (
|
|||
)
|
||||
})
|
||||
|
||||
test('returns the correct object to restrict an item based on dates in the absence of times', function () {
|
||||
Simulate.change(this.restrictedRadioButtons.dateRange)
|
||||
this.restrictedRadioButtons.dateRange.checked = true
|
||||
const startDate = new Date(2016, 5, 1)
|
||||
const endDate = new Date(2016, 5, 4)
|
||||
$(this.restrictedRadioButtons.unlock_at).data('unfudged-date', startDate)
|
||||
$(this.restrictedRadioButtons.lock_at).data('unfudged-date', endDate)
|
||||
const expectedObject = {
|
||||
hidden: false,
|
||||
unlock_at: $(this.restrictedRadioButtons.unlock_at).data('unfudged-date'),
|
||||
lock_at: $(this.restrictedRadioButtons.lock_at).data('unfudged-date'),
|
||||
locked: false,
|
||||
}
|
||||
deepEqual(
|
||||
this.restrictedRadioButtons.extractFormValues(),
|
||||
expectedObject,
|
||||
'returns the correct object'
|
||||
)
|
||||
})
|
||||
|
||||
QUnit.module('RestrictedRadioButtons Multiple Items', {
|
||||
setup() {
|
||||
const props = {
|
||||
|
|
Loading…
Reference in New Issue