Skip to content

Commit a13153a

Browse files
committed
[WIP] feat(reversibility): add export uid to content tree
1 parent d95544f commit a13153a

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

app/services/decidim/content/tree_generator.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class TreeGenerator
66
include Decidim::TranslatableAttributes
77
include Decidim::Content::MetadataGenerator
88
include Decidim::Content::LocationGenerator
9+
include Decidim::Content::UidTools
910

1011
SUPPORTED_PARTICIPATORY_SPACES = [
1112
{
@@ -101,7 +102,7 @@ def build_tree
101102
def to_csv
102103
rows = flatten_hash_for_csv(hash)
103104

104-
forced_headers = [:kind, :group, :sub_group, :space, :class, :component_type, :name, :private, :published, :item_count, :stats, :url, :admin_url, :gid]
105+
forced_headers = [:kind, :group, :sub_group, :space, :class, :component_type, :name, :private, :published, :item_count, :stats, :url, :admin_url, :gid, :uid]
105106
rejected_headers = [:manifest, :components, :component_count, :hashtag]
106107

107108
headers_row_hash = rows.each_with_object([]) do |row, keys|
@@ -225,6 +226,7 @@ def shared_hash(instance:, kind:, manifest:, icon: nil)
225226
manifest:,
226227
class: instance.class.name,
227228
gid: instance.to_global_id.to_s,
229+
uid: uid(instance),
228230
name: name_attribute(instance) ||
229231
"-- #{instance.class.name}(ID:#{instance.id}) --"
230232
}

app/views/decidim/admin/content/tree/_article.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</span>
2121
<span class="item-name">
2222
<%= item[:name] %>
23-
<% if item[:item_count].to_i.positive? %>
23+
<% if item[:kind] != "component" && item[:item_count].to_i.positive? %>
2424
<span class="item-count"><%= item[:item_count] %></span>
2525
<% end %>
2626
</span>
@@ -45,6 +45,9 @@
4545
<% end %>
4646
</div>
4747
<div class="actions px-4">
48+
<% if item.dig(:uid).present? %>
49+
<span class="label info font-mono"><pre class="!text-xs"><%= item[:uid] %></pre></span>
50+
<% end %>
4851
<% button_cell_attributes = { button_classes: "button button__xs button__transparent-secondary", html_options: { target: "_blank", data: { "external-link": false } } } %>
4952
<% if item[:path].present? %>
5053
<%= cell("decidim/button", { text: "View", icon: "eye-line", path: item[:path] }, button_cell_attributes) %>

0 commit comments

Comments
 (0)