adt-js-components 1.0.4 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/DateInput/index.js +10 -7
- package/src/SubmitForm/index.js +9 -7
package/package.json
CHANGED
package/src/DateInput/index.js
CHANGED
|
@@ -9,7 +9,9 @@ const locale = document.querySelector('html').getAttribute('lang');
|
|
|
9
9
|
function initTime(input, options) {
|
|
10
10
|
$(input).timepicker({
|
|
11
11
|
scrollDefault: 'now',
|
|
12
|
-
timeFormat: options.format
|
|
12
|
+
timeFormat: options.format,
|
|
13
|
+
minTime: options.minTime,
|
|
14
|
+
maxTime: options.maxTime
|
|
13
15
|
});
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -19,19 +21,20 @@ function initDate(input, options) {
|
|
|
19
21
|
enableTime: options.type === 'datetime' || options.type === 'datetime-local',
|
|
20
22
|
time_24hr: true,
|
|
21
23
|
locale: require(`flatpickr/dist/l10n/${locale}.js`).default[locale],
|
|
22
|
-
defaultDate: options.value,
|
|
23
|
-
minDate: options.minDate
|
|
24
|
+
defaultDate: options.value ? new Date(options.value) : null,
|
|
25
|
+
minDate: options.minDate ? new Date(options.minDate) : null,
|
|
26
|
+
maxDate: options.maxDate ? new Date(options.maxDate) : null
|
|
24
27
|
});
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
function run(options) {
|
|
28
31
|
$.nette.ext('live').after(function($el) {
|
|
29
32
|
$el.find('[data-adt-date-input]').each(function() {
|
|
30
|
-
|
|
33
|
+
const data = $(this).data('adt-date-input');
|
|
34
|
+
|
|
35
|
+
const options = $(this).data('adt-date-input');
|
|
31
36
|
options.type = $(this).attr('type');
|
|
32
|
-
|
|
33
|
-
options.minDate = $(this).data('min-date') !== undefined ? $(this).data('min-date') : null;
|
|
34
|
-
|
|
37
|
+
|
|
35
38
|
$(this).attr('type', 'text');
|
|
36
39
|
if (options.type === 'time') {
|
|
37
40
|
initTime(this, options);
|
package/src/SubmitForm/index.js
CHANGED
|
@@ -6,15 +6,17 @@ function run(options) {
|
|
|
6
6
|
if (settings.nette && settings.nette.form && settings.nette.form.attr('data-adt-submit-form') !== undefined) {
|
|
7
7
|
settings.nette.form.data('enabledButtons', settings.nette.form.find('button:enabled'));
|
|
8
8
|
settings.nette.form.find('button').prop('disabled', true);
|
|
9
|
-
settings.nette.el.
|
|
10
|
-
settings.nette.
|
|
9
|
+
settings.nette.el.css('width', settings.nette.el.outerWidth());
|
|
10
|
+
settings.nette.el.data('originalContent', settings.nette.el.html());
|
|
11
|
+
settings.nette.el.html('<span class="spinner-border spinner-border-sm"></span>');
|
|
12
|
+
settings.nette.form.find('.alert-danger').remove();
|
|
11
13
|
settings.nette.form.find('.is-invalid').removeClass('is-invalid');
|
|
12
14
|
}
|
|
13
15
|
},
|
|
14
16
|
success: function (payload, status, xhr, settings) {
|
|
15
17
|
// if there is no redirect, we will enable buttons
|
|
16
18
|
if (!payload.redirect && settings.nette && settings.nette.form && settings.nette.form.attr('data-adt-submit-form') !== undefined) {
|
|
17
|
-
settings.nette.el.
|
|
19
|
+
settings.nette.el.html(settings.nette.el.data('originalContent'));
|
|
18
20
|
settings.nette.form.data('enabledButtons').each(function () {
|
|
19
21
|
$(this).prop('disabled', false);
|
|
20
22
|
});
|
|
@@ -22,9 +24,9 @@ function run(options) {
|
|
|
22
24
|
},
|
|
23
25
|
error: function (xhr, status, error, settings) {
|
|
24
26
|
if (settings.nette && settings.nette.form && settings.nette.form.attr('data-adt-submit-form') !== undefined) {
|
|
25
|
-
settings.nette.form.
|
|
27
|
+
settings.nette.form.prepend('<div class="alert alert-danger">' + xhr.responseText + '</div>');
|
|
26
28
|
|
|
27
|
-
settings.nette.el.
|
|
29
|
+
settings.nette.el.html(settings.nette.el.data('originalContent'));
|
|
28
30
|
settings.nette.form.data('enabledButtons').each(function () {
|
|
29
31
|
$(this).prop('disabled', false);
|
|
30
32
|
});
|
|
@@ -32,8 +34,8 @@ function run(options) {
|
|
|
32
34
|
},
|
|
33
35
|
complete: function (xhr, status, settings) {
|
|
34
36
|
// if there are errors we will scroll to first of them
|
|
35
|
-
if (settings.nette && settings.nette.form && settings.nette.form.attr('data-adt-submit-form') !== undefined && settings.nette.form.find('.
|
|
36
|
-
const $error = settings.nette.form.find('.
|
|
37
|
+
if (settings.nette && settings.nette.form && settings.nette.form.attr('data-adt-submit-form') !== undefined && settings.nette.form.find('.alert-danger').length > 0) {
|
|
38
|
+
const $error = settings.nette.form.find('.alert-danger:first');
|
|
37
39
|
|
|
38
40
|
// we have to find first scrollable element (it can be document or modal for example)
|
|
39
41
|
let scrollParent = Scrollparent($error[0]);
|