-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
108 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace markhuot\keystone\actions; | ||
|
||
use markhuot\keystone\models\Component; | ||
|
||
class GetParentFromPath | ||
{ | ||
public function handle(int $elementId, int $fieldId, ?string $path): ?Component | ||
{ | ||
$parentId = last(explode('/', $path)); | ||
|
||
return $parentId ? Component::findOne([ | ||
'elementId' => $elementId, | ||
'fieldId' => $fieldId, | ||
'id' => $parentId, | ||
]) : null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace markhuot\keystone\enums; | ||
|
||
enum MoveComponentPosition: string | ||
{ | ||
case BEFOREEND = 'beforeEnd'; | ||
case BEFORE = 'before'; | ||
case AFTER = 'after'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
<div contenteditable data-id='{{ component.getQueryCondition()|json_encode }}'> | ||
{{ value }} | ||
</div> | ||
<span contenteditable data-id='{{ component.getQueryCondition()|merge({handle: field.handle})|json_encode }}'>{{ value }}</span> | ||
|
||
{% if craft.app.getRequest().isPreview() %} | ||
{% js %} | ||
document.addEventListener('input', event => { | ||
const params = JSON.parse(event.target.dataset.id); | ||
fetch("{{ actionUrl('keystone/components/update') }}", { | ||
method: 'post', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json', | ||
'X-CSRF-Token': '{{ craft.app.request.csrfToken }}', | ||
}, | ||
body: JSON.stringify({...params, fields: { {{ field.handle }}: event.target.innerHTML}}), | ||
}); | ||
{% js %} | ||
document.addEventListener('input', event => { | ||
const params = JSON.parse(event.target.dataset.id); | ||
fetch("{{ actionUrl('keystone/components/update') }}", { | ||
method: 'post', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json', | ||
'X-CSRF-Token': '{{ craft.app.request.csrfToken }}', | ||
}, | ||
body: JSON.stringify({...params, fields: { {{ field.handle }}: event.target.innerHTML}}), | ||
}); | ||
{% endjs %} | ||
{% endif %} | ||
}); | ||
{% endjs %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters