Include tags in item export and restore them on import#1567
Merged
Conversation
The export endpoint (api/item) now emits each item's assigned tag titles, excluding the root/default dashboard tag. On import, those titles are resolved back to local tags - reusing an existing tag or creating a missing one - instead of dropping every imported item onto the default dashboard. Tags round-trip by title so a config can be moved between instances without having to reassign each item to its section by hand. Resolves #1555
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Resolves #1555.
Exporting a Heimdall config and re-importing it into another instance loses every item's tag/section assignment — all items land back on the default dashboard. Two causes:
GET api/item) only emittedtitle, colour, url, description, appid, appdescription— no tags.itemImport.js) hard-codedtags: [0]for every item.Change
ItemRestController::index): each exported item now includes atagsarray of its assigned tag titles, excluding the root/default dashboard tag (id 0). Existing fields are unchanged;parentsis eager-loaded to avoid N+1.ItemRestController::store): incomingtagstitles are resolved to local tag ids before the item is stored — an existing tag with that title is reused, a missing one is created (same shape asTagController::store). Resolution is idempotent, so many items sharing a tag only ever create it once. Empty/omitted tags default to[0]. The normal web-form path (ItemController::store) is untouched.resources/assets/js/itemImport.js+ recompiledpublic/js/app.js): forwards the item's exported tags instead of hard-coding[0].Tags round-trip by title, so a config can be moved between instances without reassigning each item by hand.
Tests
ItemExportTest::test_returns_exactly_the_defined_fieldsfor the newtagskey.ItemExportTest::test_exports_assigned_tag_titles_excluding_the_root_tag.tests/Feature/ItemImportTest.php: creating+assigning a tag from a title, reusing an existing tag for the same title, and root-only imports creating no stray tags.Full suite green (38 passing, 1 pre-existing skip).
phpcsclean on the changed controller.