change: replace date controller of Scheduler.
feature: `ui.formatDate` supports formatter. fix: issue about boolean sort.
This commit is contained in:
@ -1,18 +1,8 @@
|
||||
import { Grid, GridColumn, createElement, setTooltip, createIcon, createCheckbox, createRadiobox, showAlert, showConfirm, Popup, Dropdown, validation } from "../ui";
|
||||
import { r as lang, nullOrEmpty, formatUrl, escapeEmoji, isEmail, isPhone } from "../utility";
|
||||
import { createElement, createCheckbox, createRadiobox, Dropdown, validation, toDateValue } from "../ui";
|
||||
import { r as lang } from "../utility";
|
||||
|
||||
let r = lang;
|
||||
|
||||
function datepicker(element) {
|
||||
if (typeof $?.fn?.datepicker === 'function') {
|
||||
$(element).datepicker({
|
||||
autoHide: true,
|
||||
format: 'm/dd/yyyy'
|
||||
});
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
export default class ScheduleItem {
|
||||
_var = {};
|
||||
|
||||
@ -79,7 +69,8 @@ export default class ScheduleItem {
|
||||
|
||||
getDateString(s) {
|
||||
const d = this.getDateTime(s);
|
||||
return String(d.getMonth() + 1).padStart(2, '0') + '/' + String(d.getDate()).padStart(2, '0') + '/' + String(d.getFullYear());
|
||||
// return String(d.getMonth() + 1).padStart(2, '0') + '/' + String(d.getDate()).padStart(2, '0') + '/' + String(d.getFullYear());
|
||||
return toDateValue(d, true);
|
||||
}
|
||||
|
||||
setParameters(p) {
|
||||
@ -101,15 +92,8 @@ export default class ScheduleItem {
|
||||
this._var.container.querySelector('.schedule-id-6>input').checked = schedule.Saturday;
|
||||
this._var.container.querySelector('.schedule-id-7>input').checked = schedule.Sunday;
|
||||
this._var.container.querySelector('.schedule-id-dayofmonth').value = String(schedule.DayOfMonth);
|
||||
const start = this.getDateString(schedule.StartDate);
|
||||
const end = this.getDateString(schedule.EndDate);
|
||||
if (typeof $?.fn?.datepicker === 'function') {
|
||||
$(this._var.container.querySelector('.schedule-id-duration-start')).datepicker('setDate', new Date(start));
|
||||
$(this._var.container.querySelector('.schedule-id-duration-end')).datepicker('setDate', new Date(end));
|
||||
} else {
|
||||
this._var.container.querySelector('.schedule-id-duration-start').value = start;
|
||||
this._var.container.querySelector('.schedule-id-duration-end').value = end;
|
||||
}
|
||||
this._var.container.querySelector('.schedule-id-duration-start').value = this.getDateString(schedule.StartDate);
|
||||
this._var.container.querySelector('.schedule-id-duration-end').value = this.getDateString(schedule.EndDate);
|
||||
}
|
||||
|
||||
create() {
|
||||
@ -222,20 +206,10 @@ export default class ScheduleItem {
|
||||
createElement('legend', legend => legend.innerText = 'Duration'),
|
||||
createElement('div', 'schedule-item-line schedule-item-line-duration',
|
||||
createElement('span', span => span.innerText = 'Start date'),
|
||||
datepicker(
|
||||
validation(
|
||||
createElement('input', i => { i.type = 'text', i.className = 'ui-input schedule-id-duration-start', i.maxLength = 10 }),
|
||||
/^([0]?[1-9]|[1][0-2])\/([0]?[1-9]|[12][0-9]|[3][01])\/[0-9]{4}$/
|
||||
)
|
||||
),
|
||||
createElement('input', i => { i.type = 'date', i.className = 'ui-input schedule-id-duration-start', i.maxLength = 10 }),
|
||||
createElement('div', 'schedule-item-placeholder'),
|
||||
createElement('span', span => span.innerText = 'End date'),
|
||||
datepicker(
|
||||
validation(
|
||||
createElement('input', i => { i.type = 'text', i.className = 'ui-input schedule-id-duration-end', i.maxLength = 10 }),
|
||||
/^([0]?[1-9]|[1][0-2])\/([0]?[1-9]|[12][0-9]|[3][01])\/[0-9]{4}$/
|
||||
)
|
||||
)
|
||||
createElement('input', i => { i.type = 'date', i.className = 'ui-input schedule-id-duration-end', i.maxLength = 10 })
|
||||
),
|
||||
createElement('div', 'schedule-item-line',
|
||||
createCheckbox({ className: 'schedule-id-enabled', checked: true, label: 'Enabled' })
|
||||
|
Reference in New Issue
Block a user