Skip to content
Snippets Groups Projects
Commit b89c210a authored by Michael Lee's avatar Michael Lee
Browse files

Merge branch 'dropzonejs' into lee5151

parents f2811519 f9628157
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "34d6f8d40b4e8320b4d8293429038bea",
"content-hash": "9f914adbdb471a59f52866743ae07f2e",
"packages": [
{
"name": "alchemy/zippy",
......@@ -3467,17 +3467,17 @@
},
{
"name": "drupal/dropzonejs",
"version": "2.7.0",
"version": "2.8.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/dropzonejs.git",
"reference": "8.x-2.7"
"reference": "8.x-2.8"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/dropzonejs-8.x-2.7.zip",
"reference": "8.x-2.7",
"shasum": "10e2de01919d70c211ab7daad92bb19b02da71ce"
"url": "https://ftp.drupal.org/files/projects/dropzonejs-8.x-2.8.zip",
"reference": "8.x-2.8",
"shasum": "d330143503eef258e0b87a384d2d9ad8dcf03380"
},
"require": {
"drupal/core": "^9.3 || ^10"
......@@ -3491,8 +3491,8 @@
"type": "drupal-module",
"extra": {
"drupal": {
"version": "8.x-2.7",
"datestamp": "1663761775",
"version": "8.x-2.8",
"datestamp": "1676965468",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
......
......@@ -3586,18 +3586,18 @@
},
{
"name": "drupal/dropzonejs",
"version": "2.7.0",
"version_normalized": "2.7.0.0",
"version": "2.8.0",
"version_normalized": "2.8.0.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/dropzonejs.git",
"reference": "8.x-2.7"
"reference": "8.x-2.8"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/dropzonejs-8.x-2.7.zip",
"reference": "8.x-2.7",
"shasum": "10e2de01919d70c211ab7daad92bb19b02da71ce"
"url": "https://ftp.drupal.org/files/projects/dropzonejs-8.x-2.8.zip",
"reference": "8.x-2.8",
"shasum": "d330143503eef258e0b87a384d2d9ad8dcf03380"
},
"require": {
"drupal/core": "^9.3 || ^10"
......@@ -3611,8 +3611,8 @@
"type": "drupal-module",
"extra": {
"drupal": {
"version": "8.x-2.7",
"datestamp": "1663761775",
"version": "8.x-2.8",
"datestamp": "1676965468",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
......
......@@ -671,9 +671,9 @@
'dev_requirement' => false,
),
'drupal/dropzonejs' => array(
'pretty_version' => '2.7.0',
'version' => '2.7.0.0',
'reference' => '8.x-2.7',
'pretty_version' => '2.8.0',
'version' => '2.8.0.0',
'reference' => '8.x-2.8',
'type' => 'drupal-module',
'install_path' => __DIR__ . '/../../web/modules/dropzonejs',
'aliases' => array(),
......
......@@ -6,7 +6,7 @@ package: Media
dependencies:
- drupal:file
# Information added by Drupal.org packaging script on 2022-09-21
version: '8.x-2.7'
# Information added by Drupal.org packaging script on 2023-02-21
version: '8.x-2.8'
project: 'dropzonejs'
datestamp: 1663761777
datestamp: 1676965469
......@@ -44,6 +44,7 @@ function dropzonejs_theme() {
* - element: A render element representing the file.
*/
function template_preprocess_dropzonejs(array &$variables) {
$translation = \Drupal::translation();
$element = $variables['element'];
$variables['attributes'] = [];
......@@ -53,10 +54,14 @@ function template_preprocess_dropzonejs(array &$variables) {
if (!empty($element['#attributes']['class'])) {
$variables['attributes']['class'] = (array) $element['#attributes']['class'];
}
$cardinality = 0;
if (isset($element['#max_files'])) {
$cardinality = $element['#max_files'];
}
$variables['dropzone_description'] = $element['#dropzone_description'];
$variables['or_text'] = t('or');
$variables['select_files_button_text'] = t('Select files');
$variables['select_files_button_text'] = $translation->formatPlural($cardinality, 'Select file', 'Select files');
$variables['uploaded_files'] = $element['uploaded_files'];
}
......
......@@ -9,7 +9,7 @@ dependencies:
- entity_browser:entity_browser
# Information added by Drupal.org packaging script on 2022-09-21
version: '8.x-2.7'
# Information added by Drupal.org packaging script on 2023-02-21
version: '8.x-2.8'
project: 'dropzonejs'
datestamp: 1663761777
datestamp: 1676965469
......@@ -156,6 +156,8 @@ public static function preRenderDropzoneJs(array $element) {
array_unshift($element['#attached']['library'], 'dropzonejs/exif-js');
}
$element['#attached']['library'][] = 'dropzonejs/widget';
static::setAttributes($element, ['dropzone-enable']);
return $element;
}
......
......@@ -32,6 +32,13 @@ public static function create(ContainerInterface $container) {
return $form;
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return $this->getBaseFormId() . '_dropzonejs';
}
/**
* Set the upload service.
*
......@@ -55,11 +62,14 @@ protected function buildInputElement(array $form, FormStateInterface $form_state
$process = (array) $this->elementInfo->getInfoProperty('dropzonejs', '#process', []);
$form['container']['upload']['#type'] = 'dropzonejs';
$form['container']['upload']['#process'] = array_merge(['::validateUploadElement'], $process);
$translation = \Drupal::translation();
$cardinality = $slots < 1 ? 0 : $slots;
$dropzone_description = $translation->formatPlural($cardinality, 'Drop file here to upload it', 'Drop files here to upload them');
$dropzone_specific_properties = [
'#max_files' => $slots < 1 ? 0 : $slots,
'#max_filesize' => $settings['max_filesize'],
'#extensions' => $settings['file_extensions'],
'#dropzone_description' => $this->t('Drop files here to upload them'),
'#dropzone_description' => $dropzone_description,
];
$form['container']['upload'] += $dropzone_specific_properties;
......
......@@ -7,7 +7,7 @@ dependencies:
- dropzonejs:dropzonejs
- dropzonejs:dropzonejs_eb_widget
# Information added by Drupal.org packaging script on 2022-09-21
version: '8.x-2.7'
# Information added by Drupal.org packaging script on 2023-02-21
version: '8.x-2.8'
project: 'dropzonejs'
datestamp: 1663761777
datestamp: 1676965469
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment