Add clone support for scene and automation cards, update sync clock descriptions
- Scene clone: opens capture modal with prefilled name/description/targets instead of server-side duplication; removed backend clone endpoint - Automation clone: opens editor with prefilled conditions, scene, logic, deactivation mode (webhook tokens stripped for uniqueness) - Updated sync clock i18n descriptions to reflect speed-only-on-clock model - Added entity card clone pattern documentation to server/CLAUDE.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -130,6 +130,31 @@ After restarting the server with new code:
|
||||
|
||||
## Frontend UI Patterns
|
||||
|
||||
### Entity Cards
|
||||
|
||||
All entity cards (devices, targets, CSS sources, streams, scenes, automations, etc.) **must support clone functionality**. Clone buttons use the `ICON_CLONE` (📋) icon in `.card-actions`.
|
||||
|
||||
**Clone pattern**: Clone must open the entity's add/create modal with fields prefilled from the cloned item. It must **never** silently create a duplicate — the user should review and confirm.
|
||||
|
||||
Implementation:
|
||||
|
||||
1. Export a `cloneMyEntity(id)` function that fetches (or finds in cache) the entity data
|
||||
2. Call the add/create modal function, passing the entity data as `cloneData`
|
||||
3. In the modal opener, detect clone mode (no ID + cloneData present) and prefill all fields
|
||||
4. Append `' (Copy)'` to the name
|
||||
5. Set the modal title to the "add" variant (not "edit")
|
||||
6. The save action creates a new entity (POST), not an update (PUT)
|
||||
|
||||
```javascript
|
||||
export async function cloneMyEntity(id) {
|
||||
const entity = myCache.data.find(e => e.id === id);
|
||||
if (!entity) return;
|
||||
showMyEditor(null, entity); // null id = create mode, entity = cloneData
|
||||
}
|
||||
```
|
||||
|
||||
Register the clone function in `app.js` window exports so inline `onclick` handlers can call it.
|
||||
|
||||
### Modal Dialogs
|
||||
|
||||
**IMPORTANT**: All modal dialogs must follow these standards for consistent UX:
|
||||
|
||||
Reference in New Issue
Block a user