Skip to content

Commit 70ca786

Browse files
committed
feat(dotcms): Add UVE integration and edit controller for content management
1 parent 8988f48 commit 70ca786

4 files changed

Lines changed: 47 additions & 1 deletion

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Controller } from '@hotwired/stimulus';
2+
import { getUVEState, editContentlet } from '@dotcms/uve';
3+
import { UVE_MODE } from "@dotcms/types";
4+
5+
6+
export default class extends Controller {
7+
static values = {
8+
contentlet: Object
9+
}
10+
11+
connect() {
12+
const isEditing = getUVEState()?.mode === UVE_MODE.EDIT;
13+
14+
if (!isEditing) {
15+
this.element.style.display = 'none';
16+
}
17+
}
18+
19+
edit() {
20+
editContentlet(this.contentletValue);
21+
}
22+
}

examples/dotcms-symfony/package-lock.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/dotcms-symfony/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@
1919
"dev": "encore dev",
2020
"watch": "encore dev --watch",
2121
"build": "encore production --progress"
22+
},
23+
"dependencies": {
24+
"@dotcms/types": "^1.0.0",
25+
"@dotcms/uve": "^1.0.0"
2226
}
2327
}

examples/dotcms-symfony/templates/blog-detail.html.twig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
<div style="max-width: 70ch; margin: 0 auto;">
2222

2323
<header>
24-
<button data-contentlet="{{ pageAsset.urlContentMap|json_encode }}">Edit</button>
24+
<button
25+
{{ stimulus_controller('dotcms-edit', { contentlet: pageAsset.urlContentMap|json_encode }) }}
26+
data-action="dotcms-edit#edit"
27+
>
28+
Edit
29+
</button>
2530
<h1>{{ pageAsset.urlContentMap.title }}</h1>
2631
{% if pageAsset.urlContentMap.publishDate is defined %}
2732
{% set publishDate = pageAsset.urlContentMap.publishDate // 1000 %}

0 commit comments

Comments
 (0)