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

refactor(bootstrap 5): date field types, textareas and some fixes #772

Merged
merged 42 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5b19f98
fix: no list if not iterable
theus77 Feb 17, 2024
eecd6ce
fix: not parsable date shows in red
theus77 Feb 17, 2024
d30ec9e
fix: keep not parsable data
theus77 Feb 17, 2024
0149984
ref: DateTime documentation
theus77 Feb 17, 2024
cd828d2
fix: test date is a date
theus77 Feb 17, 2024
9b3b187
fix: keep wronf string on view revision
theus77 Feb 17, 2024
5347743
fix: create invalid feedback message
theus77 Feb 17, 2024
7f5f9f3
fix: create invalid feedback message
theus77 Feb 17, 2024
dfbe151
chore: clean old code
theus77 Feb 17, 2024
a6d00f7
ref: html_classes
theus77 Feb 17, 2024
7bc2d75
fix: avoid bootstrap to be loaded multiple time (popper was broken)
theus77 Feb 17, 2024
bbcfca9
fix: dropdown-item
theus77 Feb 17, 2024
18ea142
fix: has-error only for containers
theus77 Feb 17, 2024
c93ae43
ref: border in red for containers with errors
theus77 Feb 17, 2024
cba840a
fix: has-error only for containers
theus77 Feb 17, 2024
327d232
fix: autohide toasts
theus77 Feb 17, 2024
eb03410
ref: DateFieldType
theus77 Feb 17, 2024
66f5938
ref: DateFieldType (is-invalid)
theus77 Feb 17, 2024
d484256
fix: not defined error
theus77 Feb 17, 2024
453704a
chore: docs
theus77 Feb 17, 2024
d186d78
chore: deps
theus77 Feb 17, 2024
b18a3af
chore:
theus77 Feb 17, 2024
b4cda3a
chore: docs
theus77 Feb 17, 2024
bf9afef
feat: parseFormat
theus77 Feb 17, 2024
4487c06
feat: parseFormat
theus77 Feb 17, 2024
0252123
feat: parseFormat
theus77 Feb 17, 2024
daaee7d
ref: date range
theus77 Feb 17, 2024
34332d1
ref: TimeFieldType
theus77 Feb 17, 2024
2ef6a0a
chore:
theus77 Feb 17, 2024
ef71f60
chore: eslint
theus77 Feb 17, 2024
34e8365
ref: textarea
theus77 Feb 17, 2024
bf83ed7
ref: glyphicon glyphicon-open replaced by fa fa-upload
theus77 Feb 17, 2024
8434399
ref: dropdown-item
theus77 Feb 17, 2024
fdb29da
ref: date and/or time FieldType
theus77 Feb 17, 2024
485aa9c
chore: cleaning
theus77 Feb 17, 2024
bad9ce5
ref: toggle button with alt text
theus77 Feb 19, 2024
82cd524
ref: toggle button with alt text
theus77 Feb 19, 2024
4dab5e8
ref: collection
theus77 Feb 19, 2024
b86e4e2
fix: detail.target
theus77 Feb 19, 2024
bd06da1
ref: searchForm
theus77 Feb 19, 2024
9d7ea45
fix: body.dataSet from document (not target)
theus77 Feb 19, 2024
62004a2
fix: closeModalNotification and intAjaxModalLinks
theus77 Feb 19, 2024
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
7 changes: 0 additions & 7 deletions EMS/admin-ui-bundle/_to_be_ref/js/core.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
window.ems_wysiwyg_type_filters = JSON.parse(document.querySelector("BODY").getAttribute('data-wysiwyg-type-filters'));

require('admin-lte/plugins/timepicker/bootstrap-timepicker');
require('chart.js');
require('fastclick');
require('flot');
Expand All @@ -11,12 +10,8 @@ require('jquery-sparkline');
require('moment');
require('pace');
require('raphael');
require('select2/dist/js/select2.full');
require('slimscroll');
require('bootstrap-datepicker');
require('daterangepicker');
require('fullcalendar');
require('jquery-match-height');

//Fix issue CK editor in bootstrap model
//https://ckeditor.com/old/forums/Support/Issue-with-Twitter-Bootstrap#comment-127719
Expand All @@ -31,5 +26,3 @@ $.fn.modal.Constructor.prototype.enforceFocus = function() {
})
};

require('./initEms');

112 changes: 0 additions & 112 deletions EMS/admin-ui-bundle/_to_be_ref/js/editRevisionEventListeners.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,4 @@
import EmsListeners from "./EmsListeners";
import {CKEditorConfig} from "./CKEditorConfig";

let ckconfig = false;

function editRevisionEventListeners(target, onChangeCallback = null){
new EmsListeners(target.get(0), onChangeCallback);

if (false === ckconfig) {
ckconfig = new CKEditorConfig().getConfig()
}

target.find('.remove-content-button').on('click', function(e) {
// prevent the link from creating a "#" on the URL
e.preventDefault();

const panel = $(this).closest('.collection-item-panel');
panel.find('input._ems_internal_deleted').val('deleted');
panel.hide();

if (onChangeCallback) {
onChangeCallback();
}
});

target.find('.add-content-button').on('click', function(e) {
// prevent the link from creating a "#" on the URL
e.preventDefault();

const panel = $(this).closest('.collection-panel');
const index = panel.data('index');
const prototype = panel.data('prototype');
const prototypeName = new RegExp(panel.data('prototype-name'), "g");
const prototypeLabel = new RegExp(panel.data('prototype-label'), "g");

// Replace '__label__name__$fieldId__' in the prototype's HTML to
// Replace '__name__$fieldId__' in the prototype's HTML to
// instead be a number based on how many items we have
const newForm = $(prototype.replace(prototypeLabel, (index+1)).replace(prototypeName, index));
// increase the index with one for the next item
panel.data('index', (index + 1));

editRevisionEventListeners(newForm);

panel.children('.panel-body').children('.collection-panel-container').append(newForm);

if (onChangeCallback) {
onChangeCallback();
}
});

target.find('.ems-sortable > div').sortable({
handle: ".ems-handle"
});

target.find(".ckeditor_ems").each(function(){

Expand Down Expand Up @@ -177,65 +124,6 @@ function editRevisionEventListeners(target, onChangeCallback = null){
});
}
});

target.find(".timepicker").each(function(){

const settings = {
showMeridian: $( this ).data('show-meridian'),
explicitMode: $( this ).data('explicit-mode'),
minuteStep: $( this ).data('minute-step'),
disableMousewheel: true,
defaultTime: false
};

$( this ).unbind( "change" );

if ($(this).not('.ignore-ems-update')) {
if (onChangeCallback) {
$( this ).timepicker(settings).on('changeTime.timepicker', onChangeCallback);
}
} else {
$( this ).timepicker(settings);
}
});


target.find('.datepicker').each(function( ) {

$(this).unbind('change');
const params = {
format: $(this).attr('data-date-format'),
todayBtn: true,
weekStart: $(this).attr('data-week-start'),
daysOfWeekHighlighted: $(this).attr('data-days-of-week-highlighted'),
daysOfWeekDisabled: $(this).attr('data-days-of-week-disabled'),
todayHighlight: $(this).attr('data-today-highlight')
};

if($(this).attr('data-multidate') && $(this).attr('data-multidate') !== 'false'){
params.multidate = true;
}

$(this).datepicker(params);

if (onChangeCallback) {
$(this).not(".ignore-ems-update").on('dp.change', onChangeCallback);
}
});

target.find('.ems_daterangepicker').each(function( ) {

const options = $(this).data('display-option');
$(this).unbind('change');

if ($(this).not('.ignore-ems-update')) {
if (onChangeCallback) {
$(this).daterangepicker(options, function() { onChangeCallback(); });
}
} else {
$(this).daterangepicker(options);
}
});
}

export {editRevisionEventListeners};
88 changes: 0 additions & 88 deletions EMS/admin-ui-bundle/_to_be_ref/js/initEms.js

This file was deleted.

7 changes: 7 additions & 0 deletions EMS/admin-ui-bundle/assets/css/core/components/form.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
form {
div.has-error {
border-color: var(--bs-form-invalid-border-color);
border-style: solid;
border-width: 1px;
}
}
30 changes: 28 additions & 2 deletions EMS/admin-ui-bundle/assets/js/core/components/modal.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
'use strict'
import $ from 'jquery'
import queryString from '../helpers/queryString'
import { Modal as BSModal } from 'bootstrap'
import ajaxModal from '../../../js/core/helpers/ajaxModal'

export default class Modal {
constructor () {
this.autoOpenModal()
this.closeModalNotification()
this.intAjaxModalLinks()
}

autoOpenModal () {
const queryStringObject = queryString()
if (queryStringObject.open) {
const modalElement = document.getElementById(`content_type_structure_fieldType${queryStringObject.open}`)
const modal = BSModal.getOrCreateInstance(modalElement)
const modal = window.bootstrap.Modal.getOrCreateInstance(modalElement)
modal.show()
}
}

closeModalNotification () {
$('#modal-notification-close-button').on('click', function () {
$('#modal-notifications .modal-body').empty()
$('#modal-notifications').modal('hide')
})
}

intAjaxModalLinks () {
const ajaxModalLinks = document.querySelectorAll('a[data-ajax-modal-url]');
[].forEach.call(ajaxModalLinks, function (link) {
link.onclick = (event) => {
ajaxModal.load({
url: event.target.dataset.ajaxModalUrl,
size: event.target.dataset.ajaxModalSize
}, (json) => {
if (Object.prototype.hasOwnProperty.call(json, 'success') && json.success === true) {
location.reload()
}
})
}
})
}
}
11 changes: 7 additions & 4 deletions EMS/admin-ui-bundle/assets/js/core/components/notifications.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Toast, Modal } from 'bootstrap'

class Notifications {
constructor () {
this.counter = 0
const toasts = document.querySelectorAll('.toast')
for (let i = 0; i < toasts.length; ++i) {
const toast = new window.bootstrap.Toast(toasts[i])
toast.show()
}
}

startActivity () {
Expand Down Expand Up @@ -75,7 +78,7 @@ class Notifications {
const toaster = document.getElementById('toaster')
toaster.insertAdjacentElement('beforeend', div)

const toast = new Toast(div, {
const toast = new window.bootstrap.Toast(div, {
animation: true,
autohide: autoHide,
delay: 5000
Expand All @@ -85,7 +88,7 @@ class Notifications {

outOfSync () {
const outOfSync = document.getElementById('data-out-of-sync')
const modal = new Modal(outOfSync, {
const modal = new window.bootstrap.Modal(outOfSync, {
keyboard: false,
backdrop: 'static'
})
Expand Down
8 changes: 5 additions & 3 deletions EMS/admin-ui-bundle/assets/js/core/core.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Button from './plugins/button'
import Choice from './plugins/choice'
import CodeEditor from './plugins/codeEditor'
import CollapsibleCollection from './plugins/collapsibleCollection'
import Collection from './plugins/Collection'
import Datatable from './plugins/datatable'
import Datetime from './plugins/datetime'
import File from './plugins/file'
Expand All @@ -14,6 +14,7 @@ import JsonMenuNested from './plugins/jsonMenuNested'
import MediaLibrary from './plugins/mediaLibrary'
import NestedSortable from './plugins/nestedSortable'
import ObjectPicker from './plugins/objectPicker'
import SearchForm from './plugins/searchForm'
import Select from './plugins/select'
import SortableList from './plugins/sortableList'
import SymfonyCollection from './plugins/symfonyCollection'
Expand All @@ -36,7 +37,7 @@ class Core {
new Button(),
new Choice(),
new CodeEditor(),
new CollapsibleCollection(),
new Collection(),
new Datatable(),
new Datetime(),
new File(),
Expand All @@ -49,14 +50,15 @@ class Core {
new MediaLibrary(),
new NestedSortable(),
new ObjectPicker(),
new SearchForm(),
new Select(),
new SortableList(),
new SymfonyCollection(),
new Text(),
new Tooltip(),
new WYSIWYG()
]
document.addEventListener(EMS_ADDED_DOM_EVENT, (event) => this.load(event.target))
document.addEventListener(EMS_ADDED_DOM_EVENT, (event) => this.load(event.detail.target))
this.coreReady()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
export const EMS_ADDED_DOM_EVENT = 'emsAddedDomEvent'
export class AddedDomEvent {
constructor (target) {
this._event = new CustomEvent(EMS_ADDED_DOM_EVENT, { target })
this._event = new CustomEvent(EMS_ADDED_DOM_EVENT, {
detail: {
target
}
})
this._target = target
}

Expand Down
3 changes: 1 addition & 2 deletions EMS/admin-ui-bundle/assets/js/core/helpers/ajaxModal.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import $ from 'jquery'
import { AddedDomEvent } from '../events/addedDomEvent'
import { tooltipDataLinks } from './tooltip'
import { Modal } from 'bootstrap'

class AjaxModal {
constructor (selector) {
this.selector = selector
this.$modal = $(selector)
this.bsModal = new Modal(document.querySelector(selector))
this.bsModal = new window.bootstrap.Modal(document.querySelector(selector))

this.modal = document.querySelector(this.selector)
if (this.modal) {
Expand Down
Loading
Loading