Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-6398: UDW as standalone as GH package #1010

Merged
merged 34 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9679015
IBX-6398: UDW as standalone package
lucasOsti Nov 3, 2023
e7e6628
UDW as GH package
lucasOsti Nov 14, 2023
2852d10
UDW as GH package
lucasOsti Nov 14, 2023
244d9aa
IBX-6398: UDW as GH package
lucasOsti Nov 16, 2023
605cf29
IBX-6398: UDW as GH package
lucasOsti Nov 16, 2023
ba1b1b8
IBX-6398: UDW as GH package
lucasOsti Nov 16, 2023
6853333
IBX-6398: UDW as GH package
lucasOsti Nov 24, 2023
c7621ff
IBX-6398: UDW as GH package
lucasOsti Nov 25, 2023
a7daee5
IBX-6398: UDW as GH package
lucasOsti Nov 25, 2023
960ce41
IBX-6398: UDW as GH package
lucasOsti Nov 25, 2023
be0d6b4
IBX-6398: UDW as GH package
lucasOsti Nov 27, 2023
5d88471
Prettier
lucasOsti Nov 27, 2023
8a996f9
IBX-6398: UDW as GH package
lucasOsti Nov 27, 2023
de1b307
UDW as GH package
lucasOsti Nov 30, 2023
810a364
IBX-6398: UDW as GH package
lucasOsti Nov 30, 2023
9fc2db6
UDW as GH package
lucasOsti Dec 1, 2023
af9dd96
UDW as GH package
lucasOsti Dec 4, 2023
15361d5
UDW as GH package
lucasOsti Dec 5, 2023
6c6b840
Added ApplicationConfigRestResolver
ciastektk Dec 4, 2023
6b995af
[PHPStan] Regenerated baseline
ciastektk Dec 4, 2023
3039dcf
UDW as GH package
lucasOsti Dec 5, 2023
87dcd58
UDW as GH package
lucasOsti Dec 5, 2023
c6ed09e
UDW as GH package
lucasOsti Dec 5, 2023
aced7a8
UDW as GH package
lucasOsti Dec 6, 2023
6dba3df
UDW as GH package
lucasOsti Dec 7, 2023
81d8680
UDW as GH package
lucasOsti Dec 7, 2023
fc4dca9
UDW as GH package
lucasOsti Dec 7, 2023
afdd7ed
UDW as GH package
lucasOsti Dec 7, 2023
d46625f
UDW as GH package
lucasOsti Dec 7, 2023
72a74ad
UDW as GH package
lucasOsti Dec 7, 2023
a86da4b
After CR
lucasOsti Dec 7, 2023
1b7a7c9
UDW as GH package
lucasOsti Dec 8, 2023
0a70372
Fixed fulltextCriterion
lucasOsti Dec 8, 2023
e4aba74
IBX-1464: Added `versionNo` param in the `ezimage` edit form template…
barw4 Dec 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -223,7 +223,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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need IIFE? I think given we have modules this is not needed.

ibexa.addConfig('helpers.contentType', contentType);
ibexa.addConfig('helpers.cookies', cookies);
ibexa.addConfig('helpers.formError', formError);
Comment on lines +22 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, why we have config.loader.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I create config.loader.js file wherever something was added to window.ibexa via the addConfig method

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
Loading