Commit af1f864f authored by Arnaud Bour's avatar Arnaud Bour

Ephoto Dam Field in progress

parent 4d55a75d
......@@ -33,6 +33,16 @@
padding-right:0
}
.ephoto-dam-field-legend-field {
width:50em !important;
resize:none;
box-shadow:none !important;
border:0 !important;
background:none !important;
padding:0 !important;
border-bottom:1px solid #888 !important
}
.ephoto-dam-field-button {
border-radius:2em !important;
margin:0.5em 0 0 0 !important;
......@@ -44,6 +54,7 @@
.ephoto-dam-field-file-button {
margin:1.8em 0 0 0 !important;
display:inline-block !important
}
.ephoto-dam-field-hidden {
......
......@@ -62,8 +62,6 @@
* Load Ephoto Dam Api
*/
load: function() {
console.log(this.settings);
if (this.settings && this.settings.server_url) {
$.getScript(this.settings.server_url + '/api/apiJS.js', this.init.bind(this));
}
......
......@@ -23,6 +23,16 @@ use Drupal\Core\TypedData\TraversableTypedDataInterface;
*/
class EphotoDamField extends FieldItemBase {
/**
* Default settings
*
* @const
*/
private const DEFAULT_SETTINGS = [
'version_support' => false,
'captions_format' => '[dc:rights]'
];
/**
* {@inheritdoc}
*/
......@@ -91,7 +101,7 @@ class EphotoDamField extends FieldItemBase {
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$form = [];
$form['version_support'] = [
'#title' => t('Version support'),
'#description' => t('An url will be automatically associated with each version with the same label in Ephoto Dam') . '.',
......@@ -103,6 +113,14 @@ class EphotoDamField extends FieldItemBase {
]
];
$form['captions_format'] = [
'#title' => t('Captions format'),
'#type' => 'textarea',
'#default_value' => $this->getSetting('captions_format'),
'#description' => t('Please format the captions'),
'#rows' => 1
];
return $form;
}
......@@ -110,8 +128,6 @@ class EphotoDamField extends FieldItemBase {
* {@inheritdoc}
*/
public static function defaultFieldSettings() {
return [
'version_support' => false
];
return self::DEFAULT_SETTINGS;
}
}
......@@ -42,6 +42,21 @@ class EphotoDamFieldWidget extends WidgetBase {
],
];
if (!$is_default_values_form && $version_support) {
$element['legend'] = [
'#type' => 'textarea',
'#title' => t('Legend'),
'#default_value' => isset($items[$delta]->legend) ? $items[$delta]->legend : null,
'#rows' => 1,
'#maxlength' => 256,
'#attributes' => [
'class' => ['ephoto-dam-field-legend-field'],
'readonly' => 'readonly',
'onclick' => 'this.focus();this.select()'
]
];
}
self::$_first = false;
}
......@@ -122,6 +137,21 @@ class EphotoDamFieldWidget extends WidgetBase {
]
];
if (!$is_default_values_form && !$version_support) {
$element['legend'] = [
'#type' => 'textarea',
'#title' => t('Legend') . ' ' . ($delta + 1),
'#default_value' => isset($items[$delta]->legend) ? $items[$delta]->legend : null,
'#rows' => 1,
'#maxlength' => 256,
'#attributes' => [
'class' => ['ephoto-dam-field-legend-field'],
'readonly' => 'readonly',
'onclick' => 'this.focus();this.select()'
]
];
}
if (!$is_default_values_form) {
$element['image_size']['#attributes']['readonly'] = 'readonly';
$element['version']['#attributes']['readonly'] = 'readonly';
......
#edit-editor-settings-plugins-ephoto-dam-url {
width:350px
}
#edit-editor-settings-plugins-ephoto-dam-captions-format {
width:350px;
height:50px;
resize:none
width:30em;
height:4em
}
.cke_widget_ephoto_dam > .cke_widget_element {
......
......@@ -39,7 +39,7 @@ class ConfigurationForm extends ConfigFormBase {
'#default_value' => $config->get('server_url'),
'#required' => true,
'#attributes' => ['placeholder' => $this->t('https://ephoto.mycompany.com/')],
'#size' => 50,
'#size' => 75,
];
return parent::buildForm($form, $form_state);
......
......@@ -75,14 +75,14 @@ class EphotoDam extends CKEditorPluginBase implements CKEditorPluginConfigurable
'#type' => 'checkbox',
'#default_value' => $settings->captions,
'#description' => $this->t('Display the caption under images, videos and documents'),
'#required' => false,
'#required' => false
];
$form['captions_format'] = [
'#title' => $this->t('Captions format'),
'#type' => 'textarea',
'#default_value' => $settings->captions_format,
'#required' => false,
'#required' => false
];
$form['zoom'] = [
......@@ -90,7 +90,7 @@ class EphotoDam extends CKEditorPluginBase implements CKEditorPluginConfigurable
'#type' => 'checkbox',
'#default_value' => $settings->zoom,
'#description' => $this->t('View large images by clicking on them'),
'#required' => false,
'#required' => false
];
$form['images_size'] = [
......@@ -101,7 +101,7 @@ class EphotoDam extends CKEditorPluginBase implements CKEditorPluginConfigurable
'#required' => true,
'#field_suffix' => 'px',
'#attributes' => ['min' => 0, 'max' => 6000],
'#size' => 20,
'#size' => 20
];
$form['videos_size'] = [
......@@ -112,7 +112,7 @@ class EphotoDam extends CKEditorPluginBase implements CKEditorPluginConfigurable
'#required' => true,
'#field_suffix' => 'px',
'#attributes' => ['min' => 0, 'max' => 6000],
'#size' => 20,
'#size' => 20
];
$form['documents_size'] = [
......@@ -123,7 +123,7 @@ class EphotoDam extends CKEditorPluginBase implements CKEditorPluginConfigurable
'#required' => true,
'#field_suffix' => 'px',
'#attributes' => ['min' => 0, 'max' => 6000],
'#size' => 20,
'#size' => 20
];
return $form;
......
......@@ -128,4 +128,7 @@ msgid "The \"Size\" field must respect one of the following patterns: \"x{height
msgstr "Le champ \"Taille\" doit respecter un des paternes suivant : \"x{hauteur}\", \"{longueur}x\", \"{longueur}x{hauteur}\" ou \"{longueur/hauteur(auto)}\". Exemples: \"x500\", \"500x\", \"500x500\" ou \"500\"."
msgid "The version of Ephoto Dam is not compatible with this feature"
msgstr "La version d'Ephoto Dam n'est pas compatible avec cette fonctionnalité"
\ No newline at end of file
msgstr "La version d'Ephoto Dam n'est pas compatible avec cette fonctionnalité"
msgid "Legend"
msgstr "Légende"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment