Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
E
ephoto_dam
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
ephoto_dam
Commits
dd955abf
Commit
dd955abf
authored
Aug 23, 2020
by
ephoto_dam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ephoto Dam Field in progress
parent
75608d37
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
94 additions
and
48 deletions
+94
-48
modules/ephoto_dam_field/ephoto_dam_field.module
modules/ephoto_dam_field/ephoto_dam_field.module
+22
-1
modules/ephoto_dam_field/js/ephoto_dam_field.js
modules/ephoto_dam_field/js/ephoto_dam_field.js
+68
-38
modules/ephoto_dam_field/src/Plugin/Field/FieldWidget/EphotoDamFieldWidget.php
...eld/src/Plugin/Field/FieldWidget/EphotoDamFieldWidget.php
+4
-9
No files found.
modules/ephoto_dam_field/ephoto_dam_field.module
View file @
dd955abf
...
...
@@ -5,9 +5,30 @@
* Module ephoto_dam_field.
*/
use
Drupal\Component\Serialization\Json
;
use
\
Drupal\Core\Render\Markup
;
/**
* Hook : implements hook_field_widget_form_alter().
*/
function
ephoto_dam_field_field_widget_form_alter
(
&
$element
,
&
$form_state
,
$context
)
{
$field_definition
=
$context
[
'items'
]
->
getFieldDefinition
();
if
(
$field_definition
->
getType
()
===
'ephoto_dam_field'
)
{
$settings
=
$field_definition
->
getSettings
();
$settings_encoded
=
str_replace
(
'"'
,
"'"
,
Json
::
encode
(
$settings
));
$element
[
'#attached'
][
'library'
][]
=
'ephoto_dam_field/edit'
;
// I do not like it
// It would be nice to put the settings AFTER the ".libraries", which would make it possible to call directly EphotoDamField.load($settings_encoded)
$element
[
'#attached'
][
'html_head'
][]
=
[
[
'#tag'
=>
'script'
,
'#value'
=>
Markup
::
create
(
'EphotoDamFieldSettings='
.
$settings_encoded
.
';'
),
'#weight'
=>
200
],
'ephoto_dam_field_js_settings'
];
}
}
modules/ephoto_dam_field/js/ephoto_dam_field.js
View file @
dd955abf
...
...
@@ -27,6 +27,9 @@
*/
connected
:
false
,
/**
* Enable version support
*/
enableVersionSupport
:
function
(
el
)
{
if
(
el
.
checked
)
{
$
(
'
.ephoto-dam-field-version-field
'
).
removeClass
(
'
ephoto-dam-field-hidden
'
);
...
...
@@ -43,16 +46,22 @@
}
},
select
:
function
(
settings
)
{
this
.
settings
=
settings
;
/**
* Load Ephoto Dam Api
*/
load
:
function
()
{
this
.
settings
=
EphotoDamFieldSettings
;
$
.
getScript
(
settings
.
url
+
'
api/apiJS.js
'
,
this
.
initApi
.
bind
(
this
));
},
/**
* Init Ephoto Dam Api
*/
initApi
:
function
()
{
var
self
=
this
;
if
(
!
ePhoto
)
{
if
(
!
ePhoto
)
{
console
.
log
(
Drupal
.
t
(
'
Error loading the Ephoto Dam API
'
));
return
;
}
...
...
@@ -68,6 +77,10 @@
this
.
ephoto
.
connect
();
//this.ephoto.File.setMode('embed');
//this.ephoto.File.enableDCore();
this
.
ephoto
.
callOnConnect
(
function
()
{
//var today = expires = new Date();
...
...
@@ -79,13 +92,30 @@
});
this
.
ephoto
.
File
.
callOnFileReceived
(
this
.
insert
.
bind
(
this
));
},
/**
*
*/
selectVersionUrls
:
function
()
{
this
.
ephoto
.
File
.
get
();
},
/**
*
*/
selectUrl
:
function
(
delta
)
{
this
.
ephoto
.
File
.
get
();
},
/**
*
*/
insert
:
function
()
{
}
}
EphotoDamField
.
load
();
})(
jQuery
);
modules/ephoto_dam_field/src/Plugin/Field/FieldWidget/EphotoDamFieldWidget.php
View file @
dd955abf
...
...
@@ -26,13 +26,8 @@ class EphotoDamFieldWidget extends WidgetBase {
* {@inheritdoc}
*/
public
function
formElement
(
FieldItemListInterface
$items
,
$delta
,
array
$element
,
array
&
$form
,
FormStateInterface
$form_state
)
{
$settings
=
$this
->
getFieldSettings
();
$settings
[
'delta'
]
=
$delta
;
$settings_encoded
=
str_replace
(
'"'
,
"'"
,
Json
::
encode
(
$settings
));
$is_default_values_form
=
$this
->
isDefaultValueWidget
(
$form_state
);
$version_support
=
$
settings
[
'version_support'
]
;
$version_support
=
$
this
->
getFieldSetting
(
'version_support'
)
;
if
(
self
::
$first
)
{
$classes
=
[
'ephoto-dam-field-button'
,
'ephoto-dam-field-version-button'
];
...
...
@@ -44,9 +39,9 @@ class EphotoDamFieldWidget extends WidgetBase {
'#disabled'
=>
$is_default_values_form
,
'#attributes'
=>
[
'class'
=>
$classes
,
'onclick'
=>
'EphotoDamField.select
('
.
$settings_encoded
.
'
);return false'
,
'onclick'
=>
'EphotoDamField.select
VersionUrls(
);return false'
,
'class'
=>
$classes
,
]
]
,
];
self
::
$first
=
false
;
...
...
@@ -89,7 +84,7 @@ class EphotoDamFieldWidget extends WidgetBase {
'#disabled'
=>
$is_default_values_form
,
'#attributes'
=>
[
'class'
=>
$classes
,
'onclick'
=>
'EphotoDamField.select
('
.
$settings_encoded
.
');return false'
,
'onclick'
=>
'EphotoDamField.select
Url('
.
$delta
.
');return false'
,
'class'
=>
$classes
]
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment