Skip to content

Commit

Permalink
IBX-6398: UDW as standalone as GH package (#1010)
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
3 people authored Dec 14, 2023
1 parent a4f9a3f commit 15704ef
Show file tree
Hide file tree
Showing 83 changed files with 1,845 additions and 1,401 deletions.
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8430,6 +8430,11 @@ parameters:
count: 1
path: src/lib/REST/Input/Parser/Operation.php

-
message: "#^Cannot call method resolve\\(\\) on Ibexa\\\\Contracts\\\\AdminUi\\\\REST\\\\ApplicationConfigRestResolverInterface\\|null\\.$#"
count: 1
path: src/lib/REST/Output/ValueObjectVisitor/ApplicationConfigVisitor.php

-
message: "#^Method Ibexa\\\\AdminUi\\\\REST\\\\Output\\\\ValueObjectVisitor\\\\BulkOperationResponse\\:\\:visit\\(\\) has no return type specified\\.$#"
count: 1
Expand Down
1 change: 0 additions & 1 deletion src/bundle/Resources/config/services/controllers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ services:
parent: Ibexa\Contracts\AdminUi\Controller\Controller
autowire: true


Ibexa\Bundle\AdminUi\Controller\ApplicationConfigController:
parent: Ibexa\Rest\Server\Controller
autowire: true
Expand Down
1 change: 1 addition & 0 deletions src/bundle/Resources/encore/ibexa.config.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ const path = require('path');
module.exports = (Encore) => {
Encore.addAliases({
'@ibexa-admin-ui': path.resolve('./vendor/ibexa/admin-ui'),
'@ibexa-admin-ui-modules': path.resolve('./vendor/ibexa/admin-ui/src/bundle/ui-dev/src/modules'),
});
};
22 changes: 3 additions & 19 deletions src/bundle/Resources/encore/ibexa.js.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,7 @@ const fs = require('fs');
const translationsPath = path.resolve('./public/assets/translations/');
const fieldTypesPath = path.resolve(__dirname, '../public/js/scripts/fieldType/');
const layout = [
path.resolve(__dirname, '../public/js/scripts/helpers/icon.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/location.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/text.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/request.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/notification.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/timezone.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/content.type.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/user.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/tooltips.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/table.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/cookies.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/tag.view.select.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/pagination.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/object.instances.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/middle.ellipsis.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/form.validation.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/form.error.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/system.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/highlight.helper.js'),
path.resolve(__dirname, '../public/js/scripts/helpers/config.loader.js'),
path.resolve(__dirname, '../public/js/scripts/admin.format.date.js'),
path.resolve(__dirname, '../public/js/scripts/core/draggable.js'),
path.resolve(__dirname, '../public/js/scripts/core/dropdown.js'),
Expand Down Expand Up @@ -219,6 +201,7 @@ module.exports = (Encore) => {
path.resolve(__dirname, '../public/js/scripts/admin.settings.datetimeformat.update.js'),
])
.addEntry('ibexa-admin-ui-udw-js', [
path.resolve(__dirname, '../../ui-dev/src/modules/universal-discovery/config.loader.js'),
path.resolve(__dirname, '../../ui-dev/src/modules/universal-discovery/universal.discovery.module.js'),
])
.addEntry('ibexa-admin-ui-udw-tabs-js', [
Expand Down Expand Up @@ -251,6 +234,7 @@ module.exports = (Encore) => {
.addEntry('ibexa-admin-ui-subitems-js', [path.resolve(__dirname, '../../ui-dev/src/modules/sub-items/sub.items.module.js')])
.addEntry('ibexa-admin-ui-content-tree-js', [
path.resolve(__dirname, '../../ui-dev/src/modules/content-tree/content.tree.module.js'),
path.resolve(__dirname, '../../ui-dev/src/modules/content-tree/config.loader.js'),
])
.addEntry('ibexa-admin-ui-url-management-js', [
path.resolve(__dirname, '../public/js/scripts/button.state.toggle.js'),
Expand Down
194 changes: 100 additions & 94 deletions src/bundle/Resources/public/js/scripts/core/date.time.picker.js
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 src/bundle/Resources/public/js/scripts/helpers/config.loader.js
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);
Loading

0 comments on commit 15704ef

Please sign in to comment.