forked from decidim/decidim
-
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
1 parent
86ea930
commit 9197173
Showing
5 changed files
with
104 additions
and
59 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
87 changes: 50 additions & 37 deletions
87
decidim-admin/app/views/decidim/admin/share_tokens/index.html.erb
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,45 +1,58 @@ | ||
<% add_decidim_page_title(t(".title", name: resource_title)) %> | ||
<div class="card share_tokens"> | ||
<div class="item_show__header"> | ||
<h2 class="item_show__header-title"> | ||
<div class="card-divider"> | ||
<h2 class="card-title"> | ||
<%= t(".title", name: resource_title) %> | ||
<a class="button button__sm button__secondary" href="<%= share_tokens_path(:new) %>"><%= icon "add-line" %><%= t(".new_share_token_button") %></a> | ||
<%= link_to t(".new_share_token_button"), share_tokens_path(:new), class: "button tiny button--title new" %> | ||
</h2> | ||
</div> | ||
<div class="mb-4"> | ||
<p class="help-text whitespace-pre-line"><%= t(".share_tokens_help", clipboard: icon("clipboard-line", class: "inline-block mb-1")).html_safe %></p> | ||
</div> | ||
<% if @share_tokens.any? %> | ||
<div class="table-scroll"> | ||
<table class="table-list"> | ||
<thead> | ||
<tr> | ||
<th><%= sort_link(query, :token, t("models.share_token.fields.token", scope: "decidim.admin"), default_order: :desc) %></th> | ||
<th><%= sort_link(query, :expires_at, t("models.share_token.fields.expires_at", scope: "decidim.admin"), default_order: :desc) %></th> | ||
<th><%= sort_link(query, :registered_only, t("models.share_token.fields.registered_only", scope: "decidim.admin"), default_order: :desc) %></th> | ||
<th><%= sort_link(query, :times_used, t("models.share_token.fields.times_used", scope: "decidim.admin"), default_order: :desc) %></th> | ||
<th><%= t("models.share_token.fields.actions", scope: "decidim.admin") %></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @share_tokens.each do |share_token| %> | ||
<div class="card-section"> | ||
<div> | ||
<p class="help-text whitespace-pre-line"><%= t(".share_tokens_help", clipboard: icon("clipboard", class: "inline-block mb-1")).html_safe %></p> | ||
</div> | ||
<% if @share_tokens.any? %> | ||
<div class="card-section"> | ||
<div class="table-scroll"> | ||
<table class="table-list"> | ||
<thead> | ||
<tr> | ||
<td id="js-token-<%= share_token.id %>"><%= share_token.token %></td> | ||
<td><%= share_token.expires_at.present? ? ("<span class=\"text-#{share_token.expired? ? "warning" : ""}\">#{l(share_token.expires_at, format: :decidim_short)}</span>".html_safe) : content_tag(:em, t(".never")) %></td> | ||
<td><%= t("booleans.#{share_token.registered_only.present?}") %></td> | ||
<td><%= share_token.times_used %></td> | ||
<td class="table-list__actions"> | ||
<%= icon_link_to "pencil-line", share_tokens_path(:edit, id: share_token ), t("actions.edit", scope: "decidim.admin.share_tokens"), class: "action-icon--edit" %> | ||
<%= icon_link_to "clipboard-line", "#", t("actions.copy_link", scope: "decidim.admin.share_tokens"), class: "action-icon--copy", data: { "clipboard-copy" => "#js-token-#{share_token.id}", "clipboard-content" => share_token.url,"clipboard-copy-label" => t(".copied"),"clipboard-copy-message" => t(".copy_message") } %> | ||
<%= icon_link_to "eye-line", share_token.url, t("actions.preview", scope: "decidim.admin.share_tokens"), class: "action-icon--preview", target: :blank %> | ||
<%= icon_link_to "delete-bin-line", share_tokens_path(:destroy, id: share_token ), t("actions.destroy", scope: "decidim.admin.share_tokens"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin.share_tokens") } %> | ||
</td> | ||
<th><%= sort_link(query, :token, t("models.share_token.fields.token", scope: "decidim.admin"), default_order: :desc) %></th> | ||
<th><%= sort_link(query, :expires_at, t("models.share_token.fields.expires_at", scope: "decidim.admin"), default_order: :desc) %></th> | ||
<th><%= sort_link(query, :registered_only, t("models.share_token.fields.registered_only", scope: "decidim.admin"), default_order: :desc) %></th> | ||
<th><%= sort_link(query, :times_used, t("models.share_token.fields.times_used", scope: "decidim.admin"), default_order: :desc) %></th> | ||
<th><%= t("models.share_token.fields.actions", scope: "decidim.admin") %></th> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
<% else %> | ||
<p><%= t(".empty", new_token_link: link_to(t(".create_new_token"), share_tokens_path(:new) , class: "button button__text-secondary")).html_safe %></p> | ||
<% end %> | ||
</thead> | ||
<tbody> | ||
<% @share_tokens.each do |share_token| %> | ||
<tr> | ||
<td id="js-token-<%= share_token.id %>"><%= share_token.token %></td> | ||
<td><%= share_token.expires_at.present? ? ("<span class=\"text-#{share_token.expired? ? "warning" : ""}\">#{l(share_token.expires_at, format: :decidim_short)}</span>".html_safe) : content_tag(:em, t(".never")) %></td> | ||
<td><%= t("booleans.#{share_token.registered_only.present?}") %></td> | ||
<td><%= share_token.times_used %></td> | ||
<td class="table-list__actions"> | ||
<%= icon_link_to "pencil", share_tokens_path(:edit, id: share_token ), t("actions.edit", scope: "decidim.admin.share_tokens"), class: "action-icon--edit" %> | ||
<%= icon_link_to "clipboard", | ||
"#", | ||
t("actions.copy_link", scope: "decidim.admin.share_tokens"), | ||
class: "action-icon--copy", | ||
data: { | ||
"clipboard-copy" => "#js-token-#{share_token.id}", | ||
"clipboard-content" => share_token.url, | ||
"clipboard-copy-label" => t(".copied"), | ||
"clipboard-copy-message" => t(".copy_message") } %> | ||
<%= icon_link_to "eye", share_token.url, t("actions.preview", scope: "decidim.admin.share_tokens"), class: "action-icon--preview", target: :blank %> | ||
<%= icon_link_to "trash", share_tokens_path(:destroy, id: share_token ), t("actions.destroy", scope: "decidim.admin.share_tokens"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin.share_tokens") } %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<% else %> | ||
<p><%= t(".empty", new_token_link: link_to(t(".create_new_token"), share_tokens_path(:new) , class: "")).html_safe %></p> | ||
<% end %> | ||
</div> | ||
</div> | ||
<%= decidim_paginate @share_tokens %> |
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
2 changes: 1 addition & 1 deletion
2
decidim-core/db/migrate/20240717093514_add_registered_only_to_decidim_share_tokens.rb
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