Commit 793c8f74 authored by ephoto_dam's avatar ephoto_dam

Ephoto Dam Field in progress

parent d95110b4
......@@ -86,13 +86,7 @@
this.ephoto.connect();
if (this.settings.version_support === '1') {
this.ephoto.File.callOnFileReceived(this.getVersionUrls.bind(this));
}
else {
this.ephoto.File.callOnFileReceived(this.getFileUrl.bind(this));
}
this.ephoto.File.callOnFileReceived(this.getUrl.bind(this));
this.ephoto.File.setMode('manual');
......@@ -123,18 +117,11 @@
this.ephoto.File.get();
},
/**
*
*/
getVersionUrls: function() {
console.log('get version urls!');
},
/**
*
*/
select: function(delta) {
selectFile: function(delta) {
this.fieldSelected = this._getFieldValues()[delta];
if (!this.fieldSelected) {
......@@ -156,17 +143,18 @@
/**
*
*/
getFileUrl: function() {
console.log('get file url!');
getUrl: function() {
var self = this;
var version_support = this.settings.version_support === '1';
if (!this._fieldSelected) {
if (!this.fieldSelected) {
alert(Drupal.t('Field selection error'));
return;
}
this.ephoto.File.store(function(url) {
this._fieldSelected.value = url;
this._fieldSelected = null;
this.ephoto.File.store(function(url) {
self.fieldSelected.input.val(url);
self.fieldSelected = null;
});
},
......@@ -176,11 +164,13 @@
_getFieldValues: function() {
var fields = [];
var sizes = $('.ephoto-dam-field-imagesize-field').toArray();
var inputs = $('.ephoto-dam-field-value-field').toArray();
$('.ephoto-dam-field-version-field').map(function(index, el) {
fields.push({
'name' : $(el).val(),
'size' : $(sizes[index]).val()
'size' : $(sizes[index]).val(),
'input' : $(inputs[index])
});
});
......
......@@ -63,16 +63,16 @@ class EphotoDamField extends FieldItemBase {
*/
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties['value'] = DataDefinition::create('string')
->setLabel(t('Url'))
->setRequired(true);
->setLabel(t('Url'));
//->setRequired(true);
$properties['image_size'] = DataDefinition::create('integer')
->setLabel(t('Image size'))
->setRequired(true);
->setLabel(t('Image size'));
//->setRequired(true);
$properties['version'] = DataDefinition::create('string')
->setLabel(t('Version'))
->setRequired(true);
->setLabel(t('Version'));
//->setRequired(true);
return $properties;
}
......@@ -92,6 +92,8 @@ class EphotoDamField extends FieldItemBase {
* {@inheritdoc}
*/
public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
$form = [];
$form['server_url'] = [
'#title' => $this->t('Server URL'),
'#type' => 'url',
......
......@@ -38,7 +38,7 @@ class EphotoDamFieldWidget extends WidgetBase {
'#disabled' => $is_default_values_form,
'#attributes' => [
'class' => $classes,
'onclick' => 'Drupal.ephotoDamField.selectVersionUrls();return false',
'onclick' => 'Drupal.ephotoDamField.selectVersions();return false',
'class' => $classes,
],
];
......@@ -61,7 +61,7 @@ class EphotoDamFieldWidget extends WidgetBase {
$element['image_size'] = [
'#type' => 'number',
'#title' => ' ',
'#default_value' => isset($items[$delta]->image_size) ? $items[$delta]->image_size : 0,
'#default_value' => isset($items[$delta]->image_size) ? $items[$delta]->image_size : null,
'#disabled' => !$is_default_values_form,
'#size' => 12,
'#maxlength' => 60,
......@@ -69,7 +69,6 @@ class EphotoDamFieldWidget extends WidgetBase {
'#attributes' => [
'class' => ['form-url', 'ephoto-dam-field-imagesize-field'],
'placeholder' => $this->t('Image size'),
'min' => 20,
'max' => 1600
]
];
......@@ -99,7 +98,7 @@ class EphotoDamFieldWidget extends WidgetBase {
'#disabled' => $is_default_values_form,
'#attributes' => [
'class' => $classes,
'onclick' => 'Drupal.ephotoDamField.selectUrl(' . $delta . ');return false',
'onclick' => 'Drupal.ephotoDamField.selectFile(' . $delta . ');return false',
'class' => $classes
]
];
......
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