-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* IBX-6398: UDW as standalone package * UDW as GH package * UDW as GH package * IBX-6398: UDW as GH package * IBX-6398: UDW as GH package * IBX-6398: UDW as GH package * IBX-6398: UDW as GH package * IBX-6398: UDW as GH package * IBX-6398: UDW as GH package * IBX-6398: UDW as GH package * IBX-6398: UDW as GH package * Prettier * IBX-6398: UDW as GH package * UDW as GH package * IBX-6398: UDW as GH package * UDW as GH package * UDW as GH package * UDW as GH package * Added ApplicationConfigRestResolver * [PHPStan] Regenerated baseline * UDW as GH package * UDW as GH package * UDW as GH package * UDW as GH package * UDW as GH package * UDW as GH package * UDW as GH package * UDW as GH package * UDW as GH package * UDW as GH package * After CR * UDW as GH package * Fixed fulltextCriterion * IBX-1464: Added `versionNo` param in the `ezimage` edit form template (#2113) --------- Co-authored-by: Tomasz Kryszan <tomasz.kryszan@ez.no> Co-authored-by: Bartek Wajda <bartlomiej.wajda@ibexa.co>
- Loading branch information
1 parent
a4f9a3f
commit 15704ef
Showing
83 changed files
with
1,845 additions
and
1,401 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
194 changes: 100 additions & 94 deletions
194
src/bundle/Resources/public/js/scripts/core/date.time.picker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,124 @@ | ||
(function (global, doc, ibexa, flatpickr) { | ||
const { convertDateToTimezone, formatShortDateTime } = ibexa.helpers.timezone; | ||
const userTimezone = ibexa.adminUiConfig.timezone; | ||
const DEFAULT_CONFIG = { | ||
enableTime: true, | ||
time_24hr: true, | ||
formatDate: (date) => formatShortDateTime(date, null), | ||
}; | ||
|
||
class DateTimePicker { | ||
constructor(config) { | ||
this.container = config.container; | ||
this.fieldWrapper = this.container.querySelector('.ibexa-date-time-picker'); | ||
this.inputField = this.fieldWrapper.querySelector('.ibexa-date-time-picker__input'); | ||
this.actionsWrapper = this.fieldWrapper.querySelector('.ibexa-input-text-wrapper__actions'); | ||
this.calendarBtn = this.actionsWrapper.querySelector('.ibexa-input-text-wrapper__action-btn--calendar'); | ||
this.clearBtn = this.fieldWrapper.querySelector('.ibexa-input-text-wrapper__action-btn--clear'); | ||
this.customOnChange = config.onChange; | ||
|
||
this.init = this.init.bind(this); | ||
this.onChange = this.onChange.bind(this); | ||
this.onInput = this.onInput.bind(this); | ||
this.clear = this.clear.bind(this); | ||
|
||
this.flatpickrConfig = { | ||
...DEFAULT_CONFIG, | ||
inline: this.fieldWrapper.classList.contains('ibexa-date-time-picker--inline-datetime-popup'), | ||
onChange: this.onChange, | ||
ignoredFocusElements: [this.actionsWrapper], | ||
...(config.flatpickrConfig ?? {}), | ||
}; | ||
|
||
ibexa.helpers.objectInstances.setInstance(this.container, this); | ||
} | ||
import { getAdminUiConfig, getFlatpickr } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper'; | ||
import { convertDateToTimezone, formatShortDateTime } from '../helpers/timezone.helper'; | ||
import { setInstance } from '../helpers/object.instances'; | ||
|
||
const { ibexa } = window; | ||
|
||
const DEFAULT_CONFIG = { | ||
enableTime: true, | ||
time_24hr: true, | ||
formatDate: (date) => formatShortDateTime(date, null), | ||
}; | ||
|
||
class DateTimePicker { | ||
constructor(config) { | ||
this.container = config.container; | ||
this.fieldWrapper = this.container.querySelector('.ibexa-date-time-picker'); | ||
this.inputField = this.fieldWrapper.querySelector('.ibexa-date-time-picker__input'); | ||
this.actionsWrapper = this.fieldWrapper.querySelector('.ibexa-input-text-wrapper__actions'); | ||
this.calendarBtn = this.actionsWrapper.querySelector('.ibexa-input-text-wrapper__action-btn--calendar'); | ||
this.clearBtn = this.fieldWrapper.querySelector('.ibexa-input-text-wrapper__action-btn--clear'); | ||
this.customOnChange = config.onChange; | ||
|
||
this.init = this.init.bind(this); | ||
this.onChange = this.onChange.bind(this); | ||
this.onInput = this.onInput.bind(this); | ||
this.clear = this.clear.bind(this); | ||
|
||
this.flatpickrConfig = { | ||
...DEFAULT_CONFIG, | ||
inline: this.fieldWrapper.classList.contains('ibexa-date-time-picker--inline-datetime-popup'), | ||
onChange: this.onChange, | ||
ignoredFocusElements: [this.actionsWrapper], | ||
...(config.flatpickrConfig ?? {}), | ||
}; | ||
|
||
setInstance(this.container, this); | ||
} | ||
|
||
clear() { | ||
this.flatpickrInstance.clear(); | ||
} | ||
clear() { | ||
this.flatpickrInstance.clear(); | ||
} | ||
|
||
onChange(dates) { | ||
const isDateSelected = !!dates[0]; | ||
const otherArguments = { inputField: this.inputField, dates }; | ||
onChange(dates) { | ||
const isDateSelected = !!dates[0]; | ||
const otherArguments = { inputField: this.inputField, dates }; | ||
|
||
if (!isDateSelected) { | ||
this.inputField.dataset.timestamp = ''; | ||
if (!isDateSelected) { | ||
this.inputField.dataset.timestamp = ''; | ||
|
||
this.customOnChange([''], otherArguments); | ||
this.customOnChange([''], otherArguments); | ||
|
||
return; | ||
} | ||
return; | ||
} | ||
|
||
const timestamps = dates.map((date) => { | ||
const selectedDateWithUserTimezone = convertDateToTimezone(date, userTimezone, true); | ||
const timestamp = Math.floor(selectedDateWithUserTimezone.valueOf() / 1000); | ||
const timestamps = dates.map((date) => { | ||
const { timezone } = getAdminUiConfig(); | ||
const selectedDateWithUserTimezone = convertDateToTimezone(date, timezone, true); | ||
const timestamp = Math.floor(selectedDateWithUserTimezone.valueOf() / 1000); | ||
|
||
return timestamp; | ||
}); | ||
return timestamp; | ||
}); | ||
|
||
[this.inputField.dataset.timestamp] = timestamps; | ||
[this.inputField.dataset.timestamp] = timestamps; | ||
|
||
this.customOnChange(timestamps, otherArguments); | ||
} | ||
this.customOnChange(timestamps, otherArguments); | ||
} | ||
|
||
onInput(event) { | ||
event.preventDefault(); | ||
onInput(event) { | ||
event.preventDefault(); | ||
|
||
if (event.target.value === '' && this.inputField.dataset.timestamp !== '') { | ||
this.clear(); | ||
} | ||
if (event.target.value === '' && this.inputField.dataset.timestamp !== '') { | ||
this.clear(); | ||
} | ||
} | ||
|
||
onKeyUp(isMinute, event) { | ||
const inputValue = event.target.value; | ||
|
||
if (inputValue.length === 0) { | ||
return; | ||
} | ||
onKeyUp(isMinute, event) { | ||
const inputValue = event.target.value; | ||
|
||
const value = parseInt(inputValue, 10); | ||
if (inputValue.length === 0) { | ||
return; | ||
} | ||
|
||
if (typeof value === 'number' && value >= 0) { | ||
const flatpickrDate = this.flatpickrInstance.selectedDates[0]; | ||
const value = parseInt(inputValue, 10); | ||
|
||
if (isMinute) { | ||
flatpickrDate.setMinutes(value); | ||
} else { | ||
flatpickrDate.setHours(value); | ||
} | ||
if (typeof value === 'number' && value >= 0) { | ||
const flatpickrDate = this.flatpickrInstance.selectedDates[0]; | ||
|
||
if (this.flatpickrConfig.minDate.getTime() > flatpickrDate.getTime()) { | ||
return; | ||
} | ||
if (isMinute) { | ||
flatpickrDate.setMinutes(value); | ||
} else { | ||
flatpickrDate.setHours(value); | ||
} | ||
|
||
this.flatpickrInstance.setDate(flatpickrDate, true); | ||
if (this.flatpickrConfig.minDate.getTime() > flatpickrDate.getTime()) { | ||
return; | ||
} | ||
|
||
this.flatpickrInstance.setDate(flatpickrDate, true); | ||
} | ||
} | ||
|
||
init() { | ||
this.flatpickrInstance = flatpickr(this.inputField, this.flatpickrConfig); | ||
|
||
this.inputField.addEventListener('input', this.onInput, false); | ||
this.calendarBtn.addEventListener( | ||
'click', | ||
() => { | ||
this.flatpickrInstance.open(); | ||
}, | ||
false, | ||
); | ||
|
||
if (this.flatpickrInstance.config.enableTime) { | ||
this.flatpickrInstance.minuteElement.addEventListener('keyup', this.onKeyUp.bind(this, true), false); | ||
this.flatpickrInstance.hourElement.addEventListener('keyup', this.onKeyUp.bind(this, false), false); | ||
} | ||
init() { | ||
const flatpickr = getFlatpickr(); | ||
this.flatpickrInstance = flatpickr(this.inputField, this.flatpickrConfig); | ||
|
||
this.inputField.addEventListener('input', this.onInput, false); | ||
this.calendarBtn.addEventListener( | ||
'click', | ||
() => { | ||
this.flatpickrInstance.open(); | ||
}, | ||
false, | ||
); | ||
|
||
if (this.flatpickrInstance.config.enableTime) { | ||
this.flatpickrInstance.minuteElement.addEventListener('keyup', this.onKeyUp.bind(this, true), false); | ||
this.flatpickrInstance.hourElement.addEventListener('keyup', this.onKeyUp.bind(this, false), false); | ||
} | ||
} | ||
} | ||
|
||
ibexa?.addConfig('core.DateTimePicker', DateTimePicker); | ||
|
||
ibexa.addConfig('core.DateTimePicker', DateTimePicker); | ||
})(window, window.document, window.ibexa, window.flatpickr); | ||
export { DateTimePicker }; |
41 changes: 41 additions & 0 deletions
41
src/bundle/Resources/public/js/scripts/helpers/config.loader.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as contentType from './content.type.helper'; | ||
import * as cookies from './cookies.helper'; | ||
import * as formError from './form.error.helper'; | ||
import * as formValidation from './form.validation.helper'; | ||
import * as highlight from './highlight.helper'; | ||
import * as icon from './icon.helper'; | ||
import * as location from './location.helper'; | ||
import * as middleEllipsis from './middle.ellipsis'; | ||
import * as notification from './notification.helper'; | ||
import * as objectInstances from './object.instances'; | ||
import * as pagination from './pagination.helper'; | ||
import * as request from './request.helper'; | ||
import * as system from './system.helper'; | ||
import * as table from './table.helper'; | ||
import * as tagViewSelect from './tag.view.select.helper'; | ||
import * as text from './text.helper'; | ||
import * as timezone from './timezone.helper'; | ||
import * as tooltips from './tooltips.helper'; | ||
import * as user from './user.helper'; | ||
|
||
(function (ibexa) { | ||
ibexa.addConfig('helpers.contentType', contentType); | ||
ibexa.addConfig('helpers.cookies', cookies); | ||
ibexa.addConfig('helpers.formError', formError); | ||
ibexa.addConfig('helpers.formValidation', formValidation); | ||
ibexa.addConfig('helpers.highlight', highlight); | ||
ibexa.addConfig('helpers.icon', icon); | ||
ibexa.addConfig('helpers.location', location); | ||
ibexa.addConfig('helpers.ellipsis.middle', middleEllipsis); | ||
ibexa.addConfig('helpers.notification', notification); | ||
ibexa.addConfig('helpers.objectInstances', objectInstances); | ||
ibexa.addConfig('helpers.pagination', pagination); | ||
ibexa.addConfig('helpers.request', request); | ||
ibexa.addConfig('helpers.system', system); | ||
ibexa.addConfig('helpers.table', table); | ||
ibexa.addConfig('helpers.tagViewSelect', tagViewSelect); | ||
ibexa.addConfig('helpers.text', text); | ||
ibexa.addConfig('helpers.timezone', timezone); | ||
ibexa.addConfig('helpers.tooltips', tooltips); | ||
ibexa.addConfig('helpers.user', user); | ||
})(window.ibexa); |
Oops, something went wrong.