Skip to content

Commit

Permalink
Merge branch '4.0-dev' into 27149-batchSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
HLeithner committed Jan 1, 2020
2 parents aa3adec + f8d21d8 commit b5c7136
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 101 deletions.
14 changes: 13 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ steps:
- name: javascript-cs
depends_on: [ npm ]
image: joomlaprojects/docker-images:systemtests
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- export DISPLAY=:0
- Xvfb -screen 0 1024x768x24 -ac +extension GLX +render -noreset > /dev/null 2>&1 &
Expand All @@ -181,6 +183,8 @@ steps:
- name: javascript-tests
depends_on: [ npm ]
image: joomlaprojects/docker-images:systemtests
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- export DISPLAY=:0
- Xvfb -screen 0 1024x768x24 -ac +extension GLX +render -noreset > /dev/null 2>&1 &
Expand All @@ -191,24 +195,32 @@ steps:
- name: system-tests-mysql
depends_on: [ javascript-tests ]
image: joomlaprojects/docker-images:systemtests
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/Codeception/drone-system-run.sh "$(pwd)" mysql

- name: system-tests-mysql8
depends_on: [ system-tests-mysql ]
image: joomlaprojects/docker-images:systemtests
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/Codeception/drone-system-run.sh "$(pwd)" mysql8

- name: system-tests-postgres
depends_on: [ system-tests-mysql8 ]
image: joomlaprojects/docker-images:systemtests
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/Codeception/drone-system-run.sh "$(pwd)" postgres

- name: api-tests
depends_on: [ system-tests-postgres ]
image: joomlaprojects/docker-images:systemtests
environment:
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
commands:
- bash tests/Codeception/drone-api-run.sh "$(pwd)"

Expand Down Expand Up @@ -297,6 +309,6 @@ services:

---
kind: signature
hmac: 9269cc571ec30d3d18ba3bb5f7dc132c36608b54ec777ae6d9c6dde224255fc8
hmac: bf9ea2d23f5b94fc80c2cb5fbd9b8c5f7b1423319c01a904b0b499233eb873f6

...
2 changes: 1 addition & 1 deletion administrator/components/com_csp/services/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Joomla\DI\ServiceProviderInterface;

/**
* The cache service provider.
* The com_csp service provider.
*
* @since 4.0.0
*/
Expand Down
149 changes: 69 additions & 80 deletions build/media_source/system/js/fields/joomla-field-subform.w-c.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,41 @@
return false;
});

/**
* Helper to find a closest parent element
*
* @param {HTMLElement} element
* @param {String} selector
*
* @returns {HTMLElement|null}
*/
function closest(element, selector) {
let parent;

// Traverse parents
while (element) {
parent = element.parentElement;
if (parent && parent[matchesFn](selector)) {
return parent;
}

// eslint-disable-next-line no-param-reassign
element = parent;
}

return null;
}

/**
* Helper for testing whether a selection modifier is pressed
* @param {Event} event
*
* @returns {boolean|*}
*/
function hasModifier(event) {
return (event.ctrlKey || event.metaKey || event.shiftKey);
}

class JoomlaFieldSubform extends HTMLElement {
// Attribute getters
get buttonAdd() { return this.getAttribute('button-add'); }
Expand Down Expand Up @@ -67,6 +102,10 @@
}
}

// Keep track of row index, this is important to avoid a name duplication
// Note: php side should reset the indexes each time, eg: $value = array_values($value);
this.lastRowIndex = this.getRows().length - 1;

// Template for the repeating group
this.template = '';

Expand Down Expand Up @@ -125,16 +164,12 @@
}

/**
* Search for existing rows
* @returns {HTMLElement[]}
*/
* Search for existing rows
* @returns {HTMLElement[]}
*/
getRows() {
const rows = this.containerWithRows.children;


const matchesFn = document.body.msMatchesSelector ? 'msMatchesSelector' : 'matches';


const result = [];

// Filter out the rows
Expand All @@ -148,8 +183,8 @@
}

/**
* Prepare a row template
*/
* Prepare a row template
*/
prepareTemplate() {
const tmplElement = [].slice.call(this.children).filter(el => el.classList.contains('subform-repeatable-template-section'));

Expand All @@ -163,10 +198,10 @@
}

/**
* Add new row
* @param {HTMLElement} after
* @returns {HTMLElement}
*/
* Add new row
* @param {HTMLElement} after
* @returns {HTMLElement}
*/
addRow(after) {
// Count how much we already have
const count = this.getRows().length;
Expand Down Expand Up @@ -217,9 +252,9 @@
}

/**
* Remove the row
* @param {HTMLElement} row
*/
* Remove the row
* @param {HTMLElement} row
*/
removeRow(row) {
// Count how much we have
const count = this.getRows().length;
Expand All @@ -241,55 +276,40 @@
}

/**
* Fix names ind id`s for field that in the row
* @param {HTMLElement} row
* @param {Number} count
*/
* Fix names ind id`s for field that in the row
* @param {HTMLElement} row
* @param {Number} count
*/
fixUniqueAttributes(row, count) {
count = count || 0;

const group = row.getAttribute('data-group');
// current group name

const group = row.getAttribute('data-group'); // current group name
const basename = row.getAttribute('data-base-name');
const countnew = Math.max(this.lastRowIndex, count);
const groupnew = basename + countnew; // new group name

const groupnew = basename + count; // new group name

this.lastRowIndex = countnew + 1;
row.setAttribute('data-group', groupnew);

// Fix inputs that have a "name" attribute
let haveName = row.querySelectorAll('[name]');


const ids = {}; // Collect id for fix checkboxes and radio

// Filter out nested
haveName = [].slice.call(haveName).filter(el => closest(el, 'joomla-field-subform') === this);

for (let i = 0, l = haveName.length; i < l; i++) {
const $el = haveName[i];


const name = $el.getAttribute('name');


const id = name
.replace(/(\[\]$)/g, '')
.replace(/(\]\[)/g, '__')
.replace(/\[/g, '_')
.replace(/\]/g, '')
.replace(/\W/g, '_');
// id from name

const nameNew = name.replace(`[${group}][`, `[${groupnew}][`);
// New name

let idNew = id.replace(group, groupnew);
// Count new id

let countMulti = 0;
// count for multiple radio/checkboxes

.replace(/\W/g, '_'); // id from name
const nameNew = name.replace(`[${group}][`, `[${groupnew}][`); // New name
let idNew = id.replace(group, groupnew); // Count new id
let countMulti = 0; // count for multiple radio/checkboxes
let forOldAttr = id; // Fix "for" in the labels

if ($el.type === 'checkbox' && name.match(/\[\]$/)) { // <input type="checkbox" name="name[]"> fix
Expand Down Expand Up @@ -359,10 +379,10 @@
}

/**
* Use of HTML Drag and Drop API
* https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API
* https://www.sitepoint.com/accessible-drag-drop/
*/
* Use of HTML Drag and Drop API
* https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API
* https://www.sitepoint.com/accessible-drag-drop/
*/
setUpDragSort() {
const that = this; // Self reference
let item = null; // Storing the selected item
Expand All @@ -381,7 +401,7 @@
// Helper method to test whether Handler was clicked
function getMoveHandler(element) {
return !element.form // This need to test whether the element is :input
&& element[matchesFn](that.buttonMove) ? element : closest(element, that.buttonMove);
&& element[matchesFn](that.buttonMove) ? element : closest(element, that.buttonMove);
}

// Helper method to mover row to selected position
Expand Down Expand Up @@ -477,7 +497,7 @@
// - "esc" to cancel selection
this.addEventListener('keydown', (event) => {
if ((event.keyCode !== KEYCODE.ESC && event.keyCode !== KEYCODE.SPACE && event.keyCode !== KEYCODE.ENTER)
|| event.target.form || !event.target[matchesFn](that.repeatableElement)) {
|| event.target.form || !event.target[matchesFn](that.repeatableElement)) {
return;
}

Expand Down Expand Up @@ -587,36 +607,5 @@

customElements.define('joomla-field-subform', JoomlaFieldSubform);

/**
* Helper to find a closest parent element
*
* @param {HTMLElement} element
* @param {String} selector
*
* @returns {HTMLElement|null}
*/
function closest(element, selector) {
let parent;

// Traverse parents
while (element) {
parent = element.parentElement;
if (parent && parent[matchesFn](selector)) {
return parent;
}
element = parent;
}

return null;
}

/**
* Helper for testing whether a selection modifier is pressed
* @param {Event} event
*
* @returns {boolean|*}
*/
function hasModifier(event) {
return (event.ctrlKey || event.metaKey || event.shiftKey);
}
}(customElements));
4 changes: 2 additions & 2 deletions installation/language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ INSTL_DATABASE="Database Configuration"
INSTL_DATABASE_ERROR_POSTGRESQL_QUERY="PostgreSQL database query failed."
INSTL_DATABASE_HOST_DESC="Enter the host name, usually \"localhost\" or a name provided by your host."
INSTL_DATABASE_HOST_LABEL="Host Name"
INSTL_DATABASE_HOST_IS_NOT_LOCALHOST_CREATE_FILE="We were not able to create the file. Please manually create a file named \"%1$s\" and upload it to the \"%2$s\" folder of your Joomla site."
INSTL_DATABASE_HOST_IS_NOT_LOCALHOST_DELETE_FILE="To confirm that you are the owner of this website please delete the file named \"%1$s\" we have created in the \"%2$s\" folder of your Joomla site."
INSTL_DATABASE_HOST_IS_NOT_LOCALHOST_CREATE_FILE="We were not able to create the file. Please manually create a file named \"%1$s\" and upload it to the \"%2$s\" folder of your Joomla site. Then select \"%3$s\" to continue."
INSTL_DATABASE_HOST_IS_NOT_LOCALHOST_DELETE_FILE="To confirm that you are the owner of this website please delete the file named \"%1$s\" we have created in the \"%2$s\" folder of your Joomla site. Then select \"%3$s\" to continue."
INSTL_DATABASE_HOST_IS_NOT_LOCALHOST_GENERAL_MESSAGE="You are trying to use a database host which is not on your local server. For security reasons, you need to verify the ownership of your web hosting account. <a href=\"%s\">Please read the documentation</a> for more information."
INSTL_DATABASE_NAME_DESC="Enter the database name."
INSTL_DATABASE_NAME_LABEL="Database Name"
Expand Down
4 changes: 2 additions & 2 deletions installation/language/en-US/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ INSTL_DATABASE="Database Configuration"
INSTL_DATABASE_ERROR_POSTGRESQL_QUERY="PostgreSQL database query failed."
INSTL_DATABASE_HOST_DESC="Enter the host name, usually \"localhost\" or a name provided by your host."
INSTL_DATABASE_HOST_LABEL="Host Name"
INSTL_DATABASE_HOST_IS_NOT_LOCALHOST_CREATE_FILE="We were not able to create the file. Please manually create a file named \"%1$s\" and upload it to the \"%2$s\" folder of your Joomla site."
INSTL_DATABASE_HOST_IS_NOT_LOCALHOST_DELETE_FILE="To confirm that you are the owner of this website please delete the file named \"%1$s\" we have created in the \"%2$s\" folder of your Joomla site."
INSTL_DATABASE_HOST_IS_NOT_LOCALHOST_CREATE_FILE="We were not able to create the file. Please manually create a file named \"%1$s\" and upload it to the \"%2$s\" folder of your Joomla site. Then select \"%3$s\" to continue."
INSTL_DATABASE_HOST_IS_NOT_LOCALHOST_DELETE_FILE="To confirm that you are the owner of this website please delete the file named \"%1$s\" we have created in the \"%2$s\" folder of your Joomla site. Then select \"%3$s\" to continue."
INSTL_DATABASE_HOST_IS_NOT_LOCALHOST_GENERAL_MESSAGE="You are trying to use a database host which is not on your local server. For security reasons, you need to verify the ownership of your web hosting account. <a href=\"%s\">Please read the documentation</a> for more information."
INSTL_DATABASE_NAME_DESC="Enter the database name."
INSTL_DATABASE_NAME_LABEL="Database Name"
Expand Down

0 comments on commit b5c7136

Please sign in to comment.