diff --git a/.gitignore b/.gitignore index aceb6077f..94b93dbe7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ .idea .vscode +.streerc .rdbg* # Ignore all logfiles and tempfiles. diff --git a/app/assets/images/SD_icon.png b/app/assets/images/SD_icon.png index 38fd92c51..3d6b19080 100644 Binary files a/app/assets/images/SD_icon.png and b/app/assets/images/SD_icon.png differ diff --git a/app/components/admin/box_table_row_component.html.erb b/app/components/admin/box_table_row_component.html.erb deleted file mode 100644 index cb3aab948..000000000 --- a/app/components/admin/box_table_row_component.html.erb +++ /dev/null @@ -1,23 +0,0 @@ - - - <%= link_to @box.name, admin_tenant_box_path(Current.tenant, @box) %> - - - <%= @box.uri %> - - <% - case @box_action - when 'add' %> - - <%= form_with model: [:admin, BoxMembership.new(box: @box, user: @user)], class: "contents" do |form| %> - <%= form.hidden_field :box_id %> - <%= form.hidden_field :user_id %> - <%= form.submit 'Add to box' ,class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> - - <% end %> -<% else %> - - <%= link_to 'Edit this box', edit_admin_tenant_box_path(Current.tenant, @box), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %> - -<% end %> - diff --git a/app/components/admin/box_table_row_component.rb b/app/components/admin/box_table_row_component.rb deleted file mode 100644 index 6668cea8b..000000000 --- a/app/components/admin/box_table_row_component.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class Admin::BoxTableRowComponent < ViewComponent::Base - with_collection_parameter :box - - def initialize(box:, user: "", box_action: "") - @box = box - @user = user - @box_action = box_action - end -end diff --git a/app/components/admin/boxes/box_form_component.html.erb b/app/components/admin/boxes/box_form_component.html.erb new file mode 100644 index 000000000..6c78fcda0 --- /dev/null +++ b/app/components/admin/boxes/box_form_component.html.erb @@ -0,0 +1,43 @@ +<%= tag.turbo_frame id: 'modal' do %> + +<% end %> diff --git a/app/components/admin/boxes/box_form_component.rb b/app/components/admin/boxes/box_form_component.rb new file mode 100644 index 000000000..d8a2c724c --- /dev/null +++ b/app/components/admin/boxes/box_form_component.rb @@ -0,0 +1,6 @@ +class Admin::Boxes::BoxFormComponent < ViewComponent::Base + def initialize(box:, action:) + @box = box + @action = action + end +end diff --git a/app/components/admin/boxes/box_rename_component.html.erb b/app/components/admin/boxes/box_rename_component.html.erb new file mode 100644 index 000000000..de0de8125 --- /dev/null +++ b/app/components/admin/boxes/box_rename_component.html.erb @@ -0,0 +1,28 @@ +
+ + +
diff --git a/app/components/admin/boxes/box_rename_component.rb b/app/components/admin/boxes/box_rename_component.rb new file mode 100644 index 000000000..2e51070d0 --- /dev/null +++ b/app/components/admin/boxes/box_rename_component.rb @@ -0,0 +1,5 @@ +class Admin::Boxes::BoxRenameComponent < ViewComponent::Base + def initialize(box) + @box = box + end +end diff --git a/app/components/admin/boxes/boxes_list_component.html.erb b/app/components/admin/boxes/boxes_list_component.html.erb new file mode 100644 index 000000000..f423ac2f8 --- /dev/null +++ b/app/components/admin/boxes/boxes_list_component.html.erb @@ -0,0 +1,15 @@ +
+
+
+
Pripojené schránky
+ <%= link_to new_admin_tenant_box_path, class:"px-3.5 py-2.5 bg-blue-600 rounded-md justify-center items-center gap-2.5 flex" do %> +

Pripojiť schránku

+ <% end %> +
+
+ <% @boxes.each do |box| %> + <%= render Admin::Boxes::BoxesListRowComponent.new(box) %> + <% end %> +
+
+
diff --git a/app/components/admin/boxes/boxes_list_component.rb b/app/components/admin/boxes/boxes_list_component.rb new file mode 100644 index 000000000..b481b555b --- /dev/null +++ b/app/components/admin/boxes/boxes_list_component.rb @@ -0,0 +1,5 @@ +class Admin::Boxes::BoxesListComponent < ViewComponent::Base + def initialize(boxes) + @boxes = boxes + end +end diff --git a/app/components/admin/boxes/boxes_list_row_component.html.erb b/app/components/admin/boxes/boxes_list_row_component.html.erb new file mode 100644 index 000000000..385005ce3 --- /dev/null +++ b/app/components/admin/boxes/boxes_list_row_component.html.erb @@ -0,0 +1,23 @@ +
+
+
+

<%= @box.short_name || @box.name[0] %>

+
+
+
+
+ <%= render Admin::Boxes::BoxRenameComponent.new(@box) %> +
+
+ <%= @box.uri %> +
+
+
+ <%= link_to edit_admin_tenant_box_path(@box.tenant, @box), data: { turbo_frame: :modal } do %> + <%= render Common::EditButtonComponent.new %> + <% end %> + <%= button_to admin_tenant_box_path(@box.tenant, @box), method: :delete do %> + <%= render Common::DeleteButtonComponent.new %> + <% end %> +
+
diff --git a/app/components/admin/boxes/boxes_list_row_component.rb b/app/components/admin/boxes/boxes_list_row_component.rb new file mode 100644 index 000000000..c00a2bbe4 --- /dev/null +++ b/app/components/admin/boxes/boxes_list_row_component.rb @@ -0,0 +1,5 @@ +class Admin::Boxes::BoxesListRowComponent < ViewComponent::Base + def initialize(box) + @box = box + end +end diff --git a/app/components/admin/group_membership_table_row_component.html.erb b/app/components/admin/group_membership_table_row_component.html.erb deleted file mode 100644 index dcbc9a204..000000000 --- a/app/components/admin/group_membership_table_row_component.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - - - <%= link_to @group_membership.group.name, admin_tenant_group_path(Current.tenant, @group_membership.group) %> - - - <%= @group_membership.group.group_type %> - - - <% if @group_membership.group_membership_modifiable? %> - <%= button_to 'Remove from group', admin_group_membership_path(@group_membership), - method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium cursor-pointer" %> - <% end %> - - diff --git a/app/components/admin/group_membership_table_row_component.rb b/app/components/admin/group_membership_table_row_component.rb deleted file mode 100644 index 8687b529a..000000000 --- a/app/components/admin/group_membership_table_row_component.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class Admin::GroupMembershipTableRowComponent < ViewComponent::Base - with_collection_parameter :group_membership - - def initialize(group_membership:) - @group_membership = group_membership - end - -end \ No newline at end of file diff --git a/app/components/admin/group_table_row_component.html.erb b/app/components/admin/group_table_row_component.html.erb deleted file mode 100644 index 29ab61eeb..000000000 --- a/app/components/admin/group_table_row_component.html.erb +++ /dev/null @@ -1,25 +0,0 @@ - - - <%= link_to @group.name, admin_tenant_group_path(Current.tenant, @group) %> - - - <%= @group.group_type %> - - <% - case @group_action - when 'add' %> - <% if @group.is_modifiable? %> - - <%= form_with model: [:admin, GroupMembership.new(group: @group, user: @user)], class: "contents" do |form| %> - <%= form.hidden_field :group_id %> - <%= form.hidden_field :user_id %> - <%= form.submit 'Add to group' ,class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> - <% end %> - - <% end %> -<% else %> - - <%= link_to 'Edit this group', edit_admin_tenant_group_path(Current.tenant, @group), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %> - -<% end %> - diff --git a/app/components/admin/group_table_row_component.rb b/app/components/admin/group_table_row_component.rb deleted file mode 100644 index 98d775760..000000000 --- a/app/components/admin/group_table_row_component.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class Admin::GroupTableRowComponent < ViewComponent::Base - with_collection_parameter :group - - def initialize(group:, user: '', group_action: '') - @group = group - @user = user - @group_action = group_action - end -end diff --git a/app/components/admin/groups/group_form_component.html.erb b/app/components/admin/groups/group_form_component.html.erb index fe8489239..30dfb470d 100644 --- a/app/components/admin/groups/group_form_component.html.erb +++ b/app/components/admin/groups/group_form_component.html.erb @@ -8,20 +8,20 @@

<%= @group.name %>

Používatelia v skupine

- <%= link_to admin_tenant_groups_path(Current.tenant), data: { turbo_frame: "_top" } do %> - <%= render Common::CloseButtonComponent.new %> - <% end %> + <%= render Common::CloseButtonComponent.new(link_to: admin_tenant_groups_path(Current.tenant)) %>
- <% if @step.in? [:new, :edit] %> - <%= form_with url: search_non_members_admin_tenant_group_path(Current.tenant, @group), class:"flex justify-start items-center self-stretch flex-grow-0 flex-shrink-0 gap-4 p-6 border-t-0 border-r-0 border-b border-l-0 border-gray-200" do |form| %> + <% if !@readonly %> + <%= form_with url: search_non_members_admin_tenant_group_path(Current.tenant, @group), + data: { controller: 'debounce', debounce_target: 'form'}, + class:"flex justify-start items-center self-stretch flex-grow-0 flex-shrink-0 gap-4 p-6 border-t-0 border-r-0 border-b border-l-0 border-gray-200" do |form| %>
<%= render Icons::SearchComponent.new %>
<%= tag.turbo_frame id:'user-search-results' %> <%= form.search_field :name_search, value: params[:name_search], placeholder: "Vyhľadaj používateľa pre pridanie do skupiny", - oninput: "this.form.requestSubmit()", + data: { action: 'input->debounce#debounce' }, onreset: "this.form.requestSubmit()", class: "block w-full flex-1 border-0 bg-transparent py-1.5 pl-1 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6" %>
@@ -29,8 +29,8 @@ <% end %>
<% @group.group_memberships.each do |group_membership| %> -
- <% if @step.in? [:new, :edit] %> +
+ <% if !@readonly %> <%= render Admin::Groups::MembersListRowComponent.new(group_membership) %> <% else %> <%= render Admin::Groups::MembersListRowViewOnlyComponent.new(group_membership) %> diff --git a/app/components/admin/groups/group_form_component.rb b/app/components/admin/groups/group_form_component.rb index c60482959..62fb5f33d 100644 --- a/app/components/admin/groups/group_form_component.rb +++ b/app/components/admin/groups/group_form_component.rb @@ -1,6 +1,6 @@ class Admin::Groups::GroupFormComponent < ViewComponent::Base - def initialize(group:, step:) + def initialize(group:, readonly: false) @group = group - @step = step + @readonly = readonly end end diff --git a/app/components/admin/groups/groups_list_component.html.erb b/app/components/admin/groups/groups_list_component.html.erb index fca46084b..01a3d7f01 100644 --- a/app/components/admin/groups/groups_list_component.html.erb +++ b/app/components/admin/groups/groups_list_component.html.erb @@ -34,9 +34,9 @@
Pridať používateľov
Existujúci používatelia môžu byť rozdelení do skupín, napríklad podľa zodpovednosti
-
-
Nastaviť používateľov
-
+ <%= link_to admin_tenant_users_path, class:"px-3.5 py-2.5 bg-white rounded-md border border-gray-300 justify-center items-center gap-2.5 flex" do %> +

Nastaviť používateľov

+ <% end %>
@@ -46,9 +46,9 @@
Určiť prístup skupín k správam
Jednotlivé skupiny používateľov (ako aj samotný používatelia) môžu mať rozdielny prístup k správam
-
-
Nastaviť prístup
-
+ <%= link_to admin_tenant_tag_groups_path, class:"px-3.5 py-2.5 bg-white rounded-md border border-gray-300 justify-center items-center gap-2.5 flex" do %> +

Nastaviť prístup

+ <% end %>
diff --git a/app/components/admin/groups/groups_list_row_component.html.erb b/app/components/admin/groups/groups_list_row_component.html.erb index 2b9bdfea8..1a5bb6fce 100644 --- a/app/components/admin/groups/groups_list_row_component.html.erb +++ b/app/components/admin/groups/groups_list_row_component.html.erb @@ -18,14 +18,14 @@
<% if @group.is_modifiable? %> - <%= link_to edit_members_admin_tenant_group_path(@group.tenant, @group), data: { turbo_frame: :modal } do %> + <%= link_to edit_members_admin_tenant_group_path(@group.tenant, @group) do %> <%= render Common::EditButtonComponent.new %> <% end %> - <%= button_to admin_tenant_group_path(@group.tenant, @group), method: :delete, data: { turbo_frame: :modal } do %> + <%= button_to admin_tenant_group_path(@group.tenant, @group), method: :delete do %> <%= render Common::DeleteButtonComponent.new %> <% end %> <% else %> - <%= link_to admin_tenant_group_path(@group.tenant, @group), data: { turbo_frame: :modal } do %> + <%= link_to show_members_admin_tenant_group_path(@group.tenant, @group) do %> <%= render Common::ShowButtonComponent.new %> <% end %> <% end %> diff --git a/app/components/admin/groups/hidden_group_form_component.html.erb b/app/components/admin/groups/hidden_group_form_component.html.erb deleted file mode 100644 index 95371a224..000000000 --- a/app/components/admin/groups/hidden_group_form_component.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<%= @form.hidden_field :id %> -<%= @form.hidden_field :tenant_id %> -<%= @form.fields_for :group_memberships do |membership_form| %> - <%= membership_form.hidden_field :group_id %> - <%= membership_form.hidden_field :user_id %> - <%= membership_form.hidden_field :id if membership_form.object.id %> - <%= membership_form.hidden_field :delete_record if membership_form.object.delete_record %> -<% end %> diff --git a/app/components/admin/groups/hidden_group_form_component.rb b/app/components/admin/groups/hidden_group_form_component.rb deleted file mode 100644 index a2d2cc551..000000000 --- a/app/components/admin/groups/hidden_group_form_component.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Admin::Groups::HiddenGroupFormComponent < ViewComponent::Base - def initialize(form:) - @form = form - end -end diff --git a/app/components/admin/groups/member_add_popup_component.html.erb b/app/components/admin/groups/member_add_popup_component.html.erb index d6b9d9b5f..7b3e1d59b 100644 --- a/app/components/admin/groups/member_add_popup_component.html.erb +++ b/app/components/admin/groups/member_add_popup_component.html.erb @@ -5,9 +5,7 @@

Pridaj používateľa do skupiny

- <%= link_to edit_members_admin_tenant_group_path(Current.tenant, @group), data: { turbo_frame: "modal" } do %> - <%= render Common::CloseButtonComponent.new %> - <% end %> + <%= render Common::CloseButtonComponent.new(link_to: edit_members_admin_tenant_group_path(Current.tenant, @group), target_frame: 'modal') %>
diff --git a/app/components/admin/groups/members_list_row_component.html.erb b/app/components/admin/groups/members_list_row_component.html.erb index 96ca57e0e..8f5723a84 100644 --- a/app/components/admin/groups/members_list_row_component.html.erb +++ b/app/components/admin/groups/members_list_row_component.html.erb @@ -1,4 +1,3 @@ -
@@ -6,6 +5,6 @@
<%= @user.name %>
<%= @user.email %>
-<%= button_to admin_group_membership_path(@group_membership), method: :delete do %> +<%= button_to admin_tenant_group_group_membership_path(Current.tenant, @group_membership.group, @group_membership), method: :delete do %> <%= render Common::DeleteButtonComponent.new %> <% end %> diff --git a/app/components/admin/groups/new_group_form_component.html.erb b/app/components/admin/groups/new_group_form_component.html.erb index f6ca64b8c..4a334b5d2 100644 --- a/app/components/admin/groups/new_group_form_component.html.erb +++ b/app/components/admin/groups/new_group_form_component.html.erb @@ -8,9 +8,7 @@

Nová skupina

Názov skupiny

- <%= link_to admin_tenant_groups_path(Current.tenant), data: { turbo_frame: "_top" } do %> - <%= render Common::CloseButtonComponent.new %> - <% end %> + <%= render Common::CloseButtonComponent.new(link_to: admin_tenant_groups_path(Current.tenant)) %> <%= form_with model:[:admin, Current.tenant, @group] do |form| %>
diff --git a/app/components/admin/groups/user_add_component.html.erb b/app/components/admin/groups/user_add_component.html.erb index 18b53e32d..5ef208dab 100644 --- a/app/components/admin/groups/user_add_component.html.erb +++ b/app/components/admin/groups/user_add_component.html.erb @@ -6,7 +6,7 @@
<%= @user.name %>
<%= @user.email %>
- <%= button_to controller: :group_memberships, method: :post, action: :create, group_membership: { group_id: @group.id, user_id: @user.id } do %> + <%= button_to admin_tenant_group_group_memberships_path(Current.tenant, @group, group_membership: { group_id: @group.id, user_id: @user.id }), method: :post, data: { turbo_frame: "modal" } do %> <%= render Common::AddButtonComponent.new %> <% end %> diff --git a/app/components/admin/permissions/group_form_component.html.erb b/app/components/admin/permissions/group_form_component.html.erb new file mode 100644 index 000000000..78709f4ef --- /dev/null +++ b/app/components/admin/permissions/group_form_component.html.erb @@ -0,0 +1,44 @@ +<%= tag.turbo_frame id: 'modal' do %> + +<% end %> diff --git a/app/components/admin/permissions/group_form_component.rb b/app/components/admin/permissions/group_form_component.rb new file mode 100644 index 000000000..2a45069b2 --- /dev/null +++ b/app/components/admin/permissions/group_form_component.rb @@ -0,0 +1,5 @@ +class Admin::Permissions::GroupFormComponent < ViewComponent::Base + def initialize(group:) + @group = group + end +end diff --git a/app/components/admin/permissions/group_rename_component.html.erb b/app/components/admin/permissions/group_rename_component.html.erb new file mode 100644 index 000000000..30c1e6b8f --- /dev/null +++ b/app/components/admin/permissions/group_rename_component.html.erb @@ -0,0 +1,28 @@ +
+ + +
diff --git a/app/components/admin/permissions/group_rename_component.rb b/app/components/admin/permissions/group_rename_component.rb new file mode 100644 index 000000000..6b8d012f4 --- /dev/null +++ b/app/components/admin/permissions/group_rename_component.rb @@ -0,0 +1,5 @@ +class Admin::Groups::GroupRenameComponent < ViewComponent::Base + def initialize(group) + @group = group + end +end diff --git a/app/components/admin/permissions/groups_list_component.html.erb b/app/components/admin/permissions/groups_list_component.html.erb new file mode 100644 index 000000000..05ed96ab7 --- /dev/null +++ b/app/components/admin/permissions/groups_list_component.html.erb @@ -0,0 +1,48 @@ +
+
+
+
Skupiny
+
+
+ <%= render Admin::Permissions::GroupsListRowComponent.with_collection(@groups) %> +
+
+
+
+
+ <%= render Icons::InfoComponent.new %> +
+
+
Pridať používateľov
+
Existujúci používatelia môžu byť rozdelení do skupín, napríklad podľa zodpovednosti
+
+ <%= link_to admin_tenant_users_path, class:"px-3.5 py-2.5 bg-white rounded-md border border-gray-300 justify-center items-center gap-2.5 flex" do %> +

Nastaviť používateľov

+ <% end %> +
+
+
+ <%= render Icons::InfoComponent.new %> +
+
+
Pridať skupiny
+
Používatelia môžu patriť do skupín, napríklad podľa zodpovednosti
+
+ <%= link_to admin_tenant_groups_path, class:"px-3.5 py-2.5 bg-white rounded-md border border-gray-300 justify-center items-center gap-2.5 flex" do %> +

Nastaviť skupiny

+ <% end %> +
+
+
+ <%= render Icons::InfoComponent.new %> +
+
+
Pridať štítky
+
Štítky môžu byť použité na limitovanie prístupu k správam pre jednotlivých používateľov/skupiny
+
+ <%= link_to admin_tenant_tags_path(Current.tenant), class:"px-3.5 py-2.5 bg-white rounded-md border border-gray-300 justify-center items-center gap-2.5 flex" do %> +

Nastaviť štítky

+ <% end %> +
+
+
diff --git a/app/components/admin/permissions/groups_list_component.rb b/app/components/admin/permissions/groups_list_component.rb new file mode 100644 index 000000000..20bc03135 --- /dev/null +++ b/app/components/admin/permissions/groups_list_component.rb @@ -0,0 +1,5 @@ +class Admin::Permissions::GroupsListComponent < ViewComponent::Base + def initialize(groups) + @groups = groups + end +end diff --git a/app/components/admin/permissions/groups_list_row_component.html.erb b/app/components/admin/permissions/groups_list_row_component.html.erb new file mode 100644 index 000000000..02f273c62 --- /dev/null +++ b/app/components/admin/permissions/groups_list_row_component.html.erb @@ -0,0 +1,29 @@ +
+
+
+ <%= @group.name[0] %> +
+
+
+ <% if @group.is_modifiable? %> + <%= render Admin::Groups::GroupRenameComponent.new(@group) if @group.is_modifiable? %> + <% else %> + <%= @group.name %> + <% end %> +
+
+ <%= t :user, count: @group.users.count %> +
+
+
+
+ <%= render Admin::Permissions::TagComponent.with_collection(@group.tags) %> +
+
+
+
+ <%= link_to edit_permissions_admin_tenant_group_path(@group.tenant, @group), data: { turbo_frame: :modal } do %> + <%= render Common::EditButtonComponent.new %> + <% end %> +
+
diff --git a/app/components/admin/permissions/groups_list_row_component.rb b/app/components/admin/permissions/groups_list_row_component.rb new file mode 100644 index 000000000..8bf098a08 --- /dev/null +++ b/app/components/admin/permissions/groups_list_row_component.rb @@ -0,0 +1,6 @@ +class Admin::Permissions::GroupsListRowComponent < ViewComponent::Base + with_collection_parameter :group + def initialize(group:) + @group = group + end +end diff --git a/app/components/admin/permissions/members_list_row_view_only_component.html.erb b/app/components/admin/permissions/members_list_row_view_only_component.html.erb new file mode 100644 index 000000000..75ac7e9d3 --- /dev/null +++ b/app/components/admin/permissions/members_list_row_view_only_component.html.erb @@ -0,0 +1,7 @@ +
+ +
+
+
<%= @user.name %>
+
<%= @user.email %>
+
diff --git a/app/components/admin/permissions/members_list_row_view_only_component.rb b/app/components/admin/permissions/members_list_row_view_only_component.rb new file mode 100644 index 000000000..2cf57fcc7 --- /dev/null +++ b/app/components/admin/permissions/members_list_row_view_only_component.rb @@ -0,0 +1,6 @@ +class Admin::Groups::MembersListRowViewOnlyComponent < ViewComponent::Base + def initialize(group_membership) + @group_membership = group_membership + @user = @group_membership.user + end +end diff --git a/app/components/admin/permissions/new_group_form_component.html.erb b/app/components/admin/permissions/new_group_form_component.html.erb new file mode 100644 index 000000000..4a334b5d2 --- /dev/null +++ b/app/components/admin/permissions/new_group_form_component.html.erb @@ -0,0 +1,33 @@ +<%= tag.turbo_frame id: 'modal' do %> + +<% end %> diff --git a/app/components/admin/permissions/new_group_form_component.rb b/app/components/admin/permissions/new_group_form_component.rb new file mode 100644 index 000000000..9f60f975c --- /dev/null +++ b/app/components/admin/permissions/new_group_form_component.rb @@ -0,0 +1,5 @@ +class Admin::Groups::NewGroupFormComponent < ViewComponent::Base + def initialize(group) + @group = group + end +end diff --git a/app/components/admin/permissions/permission_add_component.html.erb b/app/components/admin/permissions/permission_add_component.html.erb new file mode 100644 index 000000000..c6f00b054 --- /dev/null +++ b/app/components/admin/permissions/permission_add_component.html.erb @@ -0,0 +1,8 @@ +<%= button_to admin_tenant_tag_groups_path(@group.tenant, tag_group: { group_id: @group.id, tag_id: @tag.id }), data: { turbo_frame: "modal" } do %> +
+

<%= @tag.name %>

+ + + +
+<% end %> diff --git a/app/components/admin/permissions/permission_add_component.rb b/app/components/admin/permissions/permission_add_component.rb new file mode 100644 index 000000000..f6a0829ca --- /dev/null +++ b/app/components/admin/permissions/permission_add_component.rb @@ -0,0 +1,6 @@ +class Admin::Permissions::PermissionAddComponent < ViewComponent::Base + def initialize(tag:, group:) + @tag = tag + @group = group + end +end diff --git a/app/components/admin/permissions/permissions_add_popup_component.html.erb b/app/components/admin/permissions/permissions_add_popup_component.html.erb new file mode 100644 index 000000000..b56f7f86c --- /dev/null +++ b/app/components/admin/permissions/permissions_add_popup_component.html.erb @@ -0,0 +1,21 @@ + diff --git a/app/components/admin/permissions/permissions_add_popup_component.rb b/app/components/admin/permissions/permissions_add_popup_component.rb new file mode 100644 index 000000000..722b81aa3 --- /dev/null +++ b/app/components/admin/permissions/permissions_add_popup_component.rb @@ -0,0 +1,6 @@ +class Admin::Permissions::PermissionsAddPopupComponent < ViewComponent::Base + def initialize(tags:, group:) + @group = group + @tags = tags + end +end diff --git a/app/components/admin/permissions/permissions_list_row_component.html.erb b/app/components/admin/permissions/permissions_list_row_component.html.erb new file mode 100644 index 000000000..85b2d947c --- /dev/null +++ b/app/components/admin/permissions/permissions_list_row_component.html.erb @@ -0,0 +1,4 @@ +<%= render Admin::Permissions::TagComponent.new(tag: @tag_group.tag) %> +<%= button_to admin_tenant_tag_group_path(Current.tenant, @tag_group), method: :delete do %> + <%= render Common::DeleteButtonComponent.new %> +<% end %> diff --git a/app/components/admin/permissions/permissions_list_row_component.rb b/app/components/admin/permissions/permissions_list_row_component.rb new file mode 100644 index 000000000..db2f01265 --- /dev/null +++ b/app/components/admin/permissions/permissions_list_row_component.rb @@ -0,0 +1,6 @@ +class Admin::Permissions::PermissionsListRowComponent < ViewComponent::Base + def initialize(tag_group) + @tag_group = tag_group + @tag = @tag_group.tag + end +end diff --git a/app/components/admin/permissions/tag_component.html.erb b/app/components/admin/permissions/tag_component.html.erb new file mode 100644 index 000000000..af3629573 --- /dev/null +++ b/app/components/admin/permissions/tag_component.html.erb @@ -0,0 +1,7 @@ + +
+

<%= @tag.name %>

+ + + +
diff --git a/app/components/admin/permissions/tag_component.rb b/app/components/admin/permissions/tag_component.rb new file mode 100644 index 000000000..b0981a643 --- /dev/null +++ b/app/components/admin/permissions/tag_component.rb @@ -0,0 +1,5 @@ +class Admin::Permissions::TagComponent < ViewComponent::Base + def initialize(tag:) + @tag = tag + end +end diff --git a/app/components/admin/tag_group_table_row_component.html.erb b/app/components/admin/tag_group_table_row_component.html.erb deleted file mode 100644 index 25ac5897f..000000000 --- a/app/components/admin/tag_group_table_row_component.html.erb +++ /dev/null @@ -1,12 +0,0 @@ - - - <%= link_to @tag_group.tag.name, admin_tenant_tag_path(Current.tenant, @tag_group.tag) %> - - - <%= @tag_group.tag.visible %> - - - <%= button_to 'Unassign tag', admin_tag_group_path(@tag_group), - method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium cursor-pointer" %> - - diff --git a/app/components/admin/tag_group_table_row_component.rb b/app/components/admin/tag_group_table_row_component.rb deleted file mode 100644 index 51d873708..000000000 --- a/app/components/admin/tag_group_table_row_component.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class Admin::TagGroupTableRowComponent < ViewComponent::Base - with_collection_parameter :tag_group - - def initialize(tag_group:) - @tag_group = tag_group - end - -end diff --git a/app/components/admin/tag_table_row_component.html.erb b/app/components/admin/tag_table_row_component.html.erb deleted file mode 100644 index ff8997bba..000000000 --- a/app/components/admin/tag_table_row_component.html.erb +++ /dev/null @@ -1,23 +0,0 @@ - - - <%= link_to @tag.name, admin_tenant_tag_path(Current.tenant, @tag) %> - - - <%= @tag.visible %> - - <% - case @tag_action - when 'add' %> - - <%= form_with model: [:admin, TagGroup.new(tag_id: @tag.id, group_id: @group.id)], class: "contents" do |form| %> - <%= form.hidden_field :tag_id %> - <%= form.hidden_field :group_id %> - <%= form.submit 'Assign tag' ,class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> - <% end %> - -<% else %> - - <%= link_to 'Edit this tag', edit_admin_tenant_tag_path(Current.tenant, @tag), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %> - -<% end %> - diff --git a/app/components/admin/tag_table_row_component.rb b/app/components/admin/tag_table_row_component.rb deleted file mode 100644 index 2dddc1de5..000000000 --- a/app/components/admin/tag_table_row_component.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -class Admin::TagTableRowComponent < ViewComponent::Base - with_collection_parameter :tag - - def initialize(tag:, group: "", tag_action: "") - @tag = tag - @group = group - @tag_action = tag_action - end -end diff --git a/app/components/admin/tag_user_table_row_component.html.erb b/app/components/admin/tag_user_table_row_component.html.erb deleted file mode 100644 index b49b47ee7..000000000 --- a/app/components/admin/tag_user_table_row_component.html.erb +++ /dev/null @@ -1,12 +0,0 @@ - - - <%= link_to @tag_user.tag.name, admin_tenant_tag_path(Current.tenant, @tag_user.tag) %> - - - <%= @tag_user.tag.visible %> - - - <%#= button_to 'Unassign tag', admin_tag_user_path(@tag_user), - method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium cursor-pointer" %> - - diff --git a/app/components/admin/tag_user_table_row_component.rb b/app/components/admin/tag_user_table_row_component.rb deleted file mode 100644 index 8c4b44346..000000000 --- a/app/components/admin/tag_user_table_row_component.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -class Admin::TagUserTableRowComponent < ViewComponent::Base - with_collection_parameter :tag_user - - def initialize(tag_user:) - @tag_user = tag_user - end - -end \ No newline at end of file diff --git a/app/components/admin/tags/external_tags_component.html.erb b/app/components/admin/tags/external_tags_component.html.erb new file mode 100644 index 000000000..779ad420d --- /dev/null +++ b/app/components/admin/tags/external_tags_component.html.erb @@ -0,0 +1,19 @@ +
+
+
+

Zobraziť štítky zo štátnej schránky

+
+
+ <% @tags.each do |tag| %> +
+
+
+
+

<%= tag.name %>

+
+
+ <%= render Admin::Tags::VisibilityToggleComponent.new(tag) %> +
+
+ <% end %> +
diff --git a/app/components/admin/tags/external_tags_component.rb b/app/components/admin/tags/external_tags_component.rb new file mode 100644 index 000000000..251d5412b --- /dev/null +++ b/app/components/admin/tags/external_tags_component.rb @@ -0,0 +1,5 @@ +class Admin::Tags::ExternalTagsComponent < ViewComponent::Base + def initialize(tags) + @tags = tags + end +end diff --git a/app/components/admin/tags/tag_form_component.html.erb b/app/components/admin/tags/tag_form_component.html.erb new file mode 100644 index 000000000..c0d0e8e0e --- /dev/null +++ b/app/components/admin/tags/tag_form_component.html.erb @@ -0,0 +1,33 @@ +<%= tag.turbo_frame id: 'modal' do %> + +<% end %> diff --git a/app/components/admin/tags/tag_form_component.rb b/app/components/admin/tags/tag_form_component.rb new file mode 100644 index 000000000..cbad0d5a4 --- /dev/null +++ b/app/components/admin/tags/tag_form_component.rb @@ -0,0 +1,6 @@ +class Admin::Tags::TagFormComponent < ViewComponent::Base + def initialize(tag:, action:) + @tag = tag + @actio = action + end +end diff --git a/app/components/admin/tags/tag_rename_component.html.erb b/app/components/admin/tags/tag_rename_component.html.erb new file mode 100644 index 000000000..4a5e3bddb --- /dev/null +++ b/app/components/admin/tags/tag_rename_component.html.erb @@ -0,0 +1,28 @@ +
+ + +
diff --git a/app/components/admin/tags/tag_rename_component.rb b/app/components/admin/tags/tag_rename_component.rb new file mode 100644 index 000000000..f8cc372b5 --- /dev/null +++ b/app/components/admin/tags/tag_rename_component.rb @@ -0,0 +1,5 @@ +class Admin::Tags::TagRenameComponent < ViewComponent::Base + def initialize(tag) + @tag = tag + end +end diff --git a/app/components/admin/tags/tags_list_component.html.erb b/app/components/admin/tags/tags_list_component.html.erb new file mode 100644 index 000000000..8d87ffbc6 --- /dev/null +++ b/app/components/admin/tags/tags_list_component.html.erb @@ -0,0 +1,40 @@ +
+
+
+
Štítky
+ <%= link_to new_admin_tenant_tag_path, class:"px-3.5 py-2.5 bg-blue-600 rounded-md justify-center items-center gap-2.5 flex" do %> +

Vytvoriť štítok

+ <% end %> +
+
+ <%= render Admin::Tags::TagsListRowComponent.with_collection(@internal_tags) %> +
+
+ <%= render Admin::Tags::ExternalTagsComponent.new(@external_tags) %> +
+
+
+ <%= render Icons::InfoComponent.new %> +
+
+
Nataviť prístup na základe štítkov
+
Jednotlivý používatelia alebo skupiny používateľov môžu mať rozdielny prístup k správam
+
+ <%= link_to admin_tenant_tag_groups_path, class:"px-3.5 py-2.5 bg-white rounded-md border border-gray-300 justify-center items-center gap-2.5 flex" do %> +

Nastaviť prístup

+ <% end %> +
+
+
+ <%= render Icons::InfoComponent.new %> +
+
+
Zautomatizovať pridávanie štítkov
+
V prípade jasne zadaných pravidiel je možné automaticky k novým správam prideliť štítky
+
+ <%= link_to settings_automation_rules_path, class:"px-3.5 py-2.5 bg-white rounded-md border border-gray-300 justify-center items-center gap-2.5 flex" do %> +

Nastaviť pravidlá

+ <% end %> +
+
+
diff --git a/app/components/admin/tags/tags_list_component.rb b/app/components/admin/tags/tags_list_component.rb new file mode 100644 index 000000000..d52127bdb --- /dev/null +++ b/app/components/admin/tags/tags_list_component.rb @@ -0,0 +1,6 @@ +class Admin::Tags::TagsListComponent < ViewComponent::Base + def initialize(tags) + @external_tags = tags.where(external: true).order(:name) + @internal_tags = tags.where(external: false).order(:name) + end +end diff --git a/app/components/admin/tags/tags_list_row_component.html.erb b/app/components/admin/tags/tags_list_row_component.html.erb new file mode 100644 index 000000000..e3ba0cb85 --- /dev/null +++ b/app/components/admin/tags/tags_list_row_component.html.erb @@ -0,0 +1,15 @@ +
+
+
+ <%= render Admin::Tags::TagRenameComponent.new(@tag) %> +
+
+
+ <%= link_to edit_admin_tenant_tag_path(@tag.tenant, @tag) do %> + <%= render Common::EditButtonComponent.new %> + <% end %> + <%= button_to admin_tenant_tag_path(@tag.tenant, @tag), method: :delete do %> + <%= render Common::DeleteButtonComponent.new %> + <% end %> +
+
diff --git a/app/components/admin/tags/tags_list_row_component.rb b/app/components/admin/tags/tags_list_row_component.rb new file mode 100644 index 000000000..a3aa8ae33 --- /dev/null +++ b/app/components/admin/tags/tags_list_row_component.rb @@ -0,0 +1,6 @@ +class Admin::Tags::TagsListRowComponent < ViewComponent::Base + with_collection_parameter :tag + def initialize(tag:) + @tag = tag + end +end diff --git a/app/components/admin/tags/visibility_toggle_component.html.erb b/app/components/admin/tags/visibility_toggle_component.html.erb new file mode 100644 index 000000000..ce4e9ec6c --- /dev/null +++ b/app/components/admin/tags/visibility_toggle_component.html.erb @@ -0,0 +1,9 @@ +<%= tag.turbo_frame id:"@tag-form-visible-#{tag.id}" do %> + <%= form_with model:[:admin, Current.tenant, @tag], method: :patch do |form| %> + <%= form.hidden_field :visible, value:!@tag.visible %> + <%= form.button class:"#{@tag.visible ? "bg-indigo-600" : "bg-gray-200"} relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2", role: :switch, aria: { checked: :false}, data: @dialog do %> + Use setting + + <% end %> + <% end %> +<% end %> diff --git a/app/components/admin/tags/visibility_toggle_component.rb b/app/components/admin/tags/visibility_toggle_component.rb new file mode 100644 index 000000000..bcc9279d0 --- /dev/null +++ b/app/components/admin/tags/visibility_toggle_component.rb @@ -0,0 +1,8 @@ +class Admin::Tags::VisibilityToggleComponent < ViewComponent::Base + def initialize(tag) + @tag = tag + @dialog = { + turbo_confirm: 'Naozaj zrušiť viditeľnosť štítku? Používateľom nebude zobrazovaný v zozname štítkov, a nedostanú sa k príslušným správam', + } if @tag.visible + end +end diff --git a/app/components/admin/tenants/tenant_form_component.html.erb b/app/components/admin/tenants/tenant_form_component.html.erb new file mode 100644 index 000000000..c88006d45 --- /dev/null +++ b/app/components/admin/tenants/tenant_form_component.html.erb @@ -0,0 +1,33 @@ +<%= tag.turbo_frame id: 'modal' do %> + +<% end %> diff --git a/app/components/admin/tenants/tenant_form_component.rb b/app/components/admin/tenants/tenant_form_component.rb new file mode 100644 index 000000000..409ab7be2 --- /dev/null +++ b/app/components/admin/tenants/tenant_form_component.rb @@ -0,0 +1,6 @@ +class Admin::Tenants::TenantFormComponent < ViewComponent::Base + def initialize(tenant:, action:) + @tenant = tenant + @action = action + end +end diff --git a/app/components/admin/tenants/tenant_rename_component.html.erb b/app/components/admin/tenants/tenant_rename_component.html.erb new file mode 100644 index 000000000..641f4984d --- /dev/null +++ b/app/components/admin/tenants/tenant_rename_component.html.erb @@ -0,0 +1,28 @@ +
+ + +
diff --git a/app/components/admin/tenants/tenant_rename_component.rb b/app/components/admin/tenants/tenant_rename_component.rb new file mode 100644 index 000000000..23762b681 --- /dev/null +++ b/app/components/admin/tenants/tenant_rename_component.rb @@ -0,0 +1,5 @@ +class Admin::Tenants::TenantRenameComponent < ViewComponent::Base + def initialize(tenant) + @tenant = tenant + end +end diff --git a/app/components/admin/tenants/tenants_list_component.html.erb b/app/components/admin/tenants/tenants_list_component.html.erb new file mode 100644 index 000000000..fb32fd8a7 --- /dev/null +++ b/app/components/admin/tenants/tenants_list_component.html.erb @@ -0,0 +1,15 @@ +
+
+
+
Tenanti / Organizácie
+ <%= link_to new_admin_tenant_path, class:"px-3.5 py-2.5 bg-blue-600 rounded-md justify-center items-center gap-2.5 flex" do %> +

Vytvoriť nového tenanta

+ <% end %> +
+
+ <% @tenants.each do |tenant| %> + <%= render Admin::Tenants::TenantsListRowComponent.new(tenant) %> + <% end %> +
+
+
diff --git a/app/components/admin/tenants/tenants_list_component.rb b/app/components/admin/tenants/tenants_list_component.rb new file mode 100644 index 000000000..04f98374a --- /dev/null +++ b/app/components/admin/tenants/tenants_list_component.rb @@ -0,0 +1,5 @@ +class Admin::Tenants::TenantsListComponent < ViewComponent::Base + def initialize(tenants) + @tenants = tenants + end +end diff --git a/app/components/admin/tenants/tenants_list_row_component.html.erb b/app/components/admin/tenants/tenants_list_row_component.html.erb new file mode 100644 index 000000000..8ce6252a7 --- /dev/null +++ b/app/components/admin/tenants/tenants_list_row_component.html.erb @@ -0,0 +1,18 @@ +
+
+ <%= @tenant.name[0] %> +
+
+
+ <%= render Admin::Tenants::TenantRenameComponent.new(@tenant) %> +
+
+
+ <%= link_to edit_admin_tenant_path(@tenant) do %> + <%= render Common::EditButtonComponent.new %> + <% end %> + <%= button_to admin_tenant_path(@tenant), method: :delete do %> + <%= render Common::DeleteButtonComponent.new %> + <% end %> +
+
diff --git a/app/components/admin/tenants/tenants_list_row_component.rb b/app/components/admin/tenants/tenants_list_row_component.rb new file mode 100644 index 000000000..236e80d42 --- /dev/null +++ b/app/components/admin/tenants/tenants_list_row_component.rb @@ -0,0 +1,5 @@ +class Admin::Tenants::TenantsListRowComponent < ViewComponent::Base + def initialize(tenant) + @tenant = tenant + end +end diff --git a/app/components/admin/user_table_row_component.html.erb b/app/components/admin/user_table_row_component.html.erb deleted file mode 100644 index 2f191e27f..000000000 --- a/app/components/admin/user_table_row_component.html.erb +++ /dev/null @@ -1,7 +0,0 @@ - - <%= link_to @user.name, admin_tenant_user_path(Current.tenant, @user) %> - <%= @user.email %> - - <%= link_to 'Edit this user', edit_admin_tenant_user_path(Current.tenant, @user), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %> - - diff --git a/app/components/admin/user_table_row_component.rb b/app/components/admin/user_table_row_component.rb deleted file mode 100644 index 306dd04c1..000000000 --- a/app/components/admin/user_table_row_component.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -class Admin::UserTableRowComponent < ViewComponent::Base - with_collection_parameter :user - def initialize(user:) - @user = user - end -end diff --git a/app/components/admin/users/user_form_component.html.erb b/app/components/admin/users/user_form_component.html.erb new file mode 100644 index 000000000..3a197437a --- /dev/null +++ b/app/components/admin/users/user_form_component.html.erb @@ -0,0 +1,38 @@ +<%= tag.turbo_frame id: 'modal' do %> + +<% end %> diff --git a/app/components/admin/users/user_form_component.rb b/app/components/admin/users/user_form_component.rb new file mode 100644 index 000000000..85c06503f --- /dev/null +++ b/app/components/admin/users/user_form_component.rb @@ -0,0 +1,6 @@ +class Admin::Users::UserFormComponent < ViewComponent::Base + def initialize(user:, action:) + @user = user + @action = action + end +end diff --git a/app/components/admin/users/user_rename_component.html.erb b/app/components/admin/users/user_rename_component.html.erb new file mode 100644 index 000000000..ded43bb8f --- /dev/null +++ b/app/components/admin/users/user_rename_component.html.erb @@ -0,0 +1,28 @@ +
+ + +
diff --git a/app/components/admin/users/user_rename_component.rb b/app/components/admin/users/user_rename_component.rb new file mode 100644 index 000000000..bf315a750 --- /dev/null +++ b/app/components/admin/users/user_rename_component.rb @@ -0,0 +1,5 @@ +class Admin::Users::UserRenameComponent < ViewComponent::Base + def initialize(user) + @user = user + end +end diff --git a/app/components/admin/users/users_list_component.html.erb b/app/components/admin/users/users_list_component.html.erb new file mode 100644 index 000000000..615aa3d81 --- /dev/null +++ b/app/components/admin/users/users_list_component.html.erb @@ -0,0 +1,41 @@ +
+
+
+
Používatelia
+ <%= link_to new_admin_tenant_user_path, class:"px-3.5 py-2.5 bg-blue-600 rounded-md justify-center items-center gap-2.5 flex" do %> +

Vytvoriť používateľa

+ <% end %> +
+
+ <% @users.each do |user| %> + <%= render Admin::Users::UsersListRowComponent.new(user) %> + <% end %> +
+
+
+
+
+ <%= render Icons::InfoComponent.new %> +
+
+
Pridať používateľov do skupín
+
Používatelia môžu byť rozdelení do skupín, napríklad podľa zodpovednosti
+
+ <%= link_to admin_tenant_groups_path, class:"px-3.5 py-2.5 bg-white rounded-md border border-gray-300 justify-center items-center gap-2.5 flex" do %> +

Nastaviť skupiny

+ <% end %> +
+
+
+ <%= render Icons::InfoComponent.new %> +
+
+
Určiť prístup skupín k správam
+
Jednotlivé skupiny používateľov (ako aj samotný používatelia) môžu mať rozdielny prístup k správam
+
+
+
Nastaviť prístup
+
+
+
+
diff --git a/app/components/admin/users/users_list_component.rb b/app/components/admin/users/users_list_component.rb new file mode 100644 index 000000000..2c64582fc --- /dev/null +++ b/app/components/admin/users/users_list_component.rb @@ -0,0 +1,5 @@ +class Admin::Users::UsersListComponent < ViewComponent::Base + def initialize(users) + @users = users + end +end diff --git a/app/components/admin/users/users_list_row_component.html.erb b/app/components/admin/users/users_list_row_component.html.erb new file mode 100644 index 000000000..c7c16cc9b --- /dev/null +++ b/app/components/admin/users/users_list_row_component.html.erb @@ -0,0 +1,21 @@ +
+
+ <%= @user.name[0] %> +
+
+
+ <%= render Admin::Users::UserRenameComponent.new(@user) %> +
+
+ <%= @user.email %> +
+
+
+ <%= link_to edit_admin_tenant_user_path(@user.tenant, @user) do %> + <%= render Common::EditButtonComponent.new %> + <% end %> + <%= button_to admin_tenant_user_path(@user.tenant, @user), method: :delete do %> + <%= render Common::DeleteButtonComponent.new %> + <% end %> +
+
diff --git a/app/components/admin/users/users_list_row_component.rb b/app/components/admin/users/users_list_row_component.rb new file mode 100644 index 000000000..d3de3797f --- /dev/null +++ b/app/components/admin/users/users_list_row_component.rb @@ -0,0 +1,5 @@ +class Admin::Users::UsersListRowComponent < ViewComponent::Base + def initialize(user) + @user = user + end +end diff --git a/app/components/common/close_button_component.html.erb b/app/components/common/close_button_component.html.erb index 1fa3f4068..c808abec5 100644 --- a/app/components/common/close_button_component.html.erb +++ b/app/components/common/close_button_component.html.erb @@ -1,6 +1,8 @@ -
- - - - -
+<%= link_to @link_to, data: { turbo_frame: @target_frame } do %> +
+ + + + +
+<% end %> diff --git a/app/components/common/close_button_component.rb b/app/components/common/close_button_component.rb index b01c7e811..5a5f48884 100644 --- a/app/components/common/close_button_component.rb +++ b/app/components/common/close_button_component.rb @@ -1,4 +1,8 @@ module Common class CloseButtonComponent < ViewComponent::Base + def initialize(link_to:, target_frame: '_top') + @link_to = link_to + @target_frame = target_frame + end end end diff --git a/app/components/common/tag_selector_component.html.erb b/app/components/common/tag_selector_component.html.erb index 464ed477a..48b3e727b 100644 --- a/app/components/common/tag_selector_component.html.erb +++ b/app/components/common/tag_selector_component.html.erb @@ -18,6 +18,6 @@ diff --git a/app/components/common/tag_selector_component.rb b/app/components/common/tag_selector_component.rb index 87ce3c457..56e9ff734 100644 --- a/app/components/common/tag_selector_component.rb +++ b/app/components/common/tag_selector_component.rb @@ -1,7 +1,8 @@ module Common class TagSelectorComponent < ViewComponent::Base - def initialize(object) + def initialize(object, available_tags) @object = object + @available_tags = available_tags end end end diff --git a/app/components/common/tag_selector_popup_component.html.erb b/app/components/common/tag_selector_popup_component.html.erb index 046e87a8a..ebc32135d 100644 --- a/app/components/common/tag_selector_popup_component.html.erb +++ b/app/components/common/tag_selector_popup_component.html.erb @@ -1,7 +1,8 @@ -
-
- - + -
-
- - - -
-
- <% @tags.each do |tag|%> -
- <% if @object.class.name == 'MessageThread' %> - <%= form_with model: [MessageThreadsTag.new(message_thread: @object, tag: tag)], class: "contents" do |form| %> - <%= form.hidden_field :message_thread_id %> - <%= form.hidden_field :tag_id %> - <%= form.submit "#{tag.name}" ,class:"text-sm text-left text-blue-600 hover:cursor-pointer" %> - <% end %> - <% else %> - <%= form_with model: [MessagesTag.new(message: @object, tag: tag)], class: "contents" do |form| %> - <%= form.hidden_field :message_id %> - <%= form.hidden_field :tag_id %> - <%= form.submit "#{tag.name}", class:"text-sm text-left text-blue-600 hover:cursor-pointer" %> +
+
+ + + +
+
+ <% @tags.each do |tag|%> +
+ <% if @object.class.name == 'MessageThread' %> + <%= form_with model: [MessageThreadsTag.new(message_thread: @object, tag: tag)], class: "contents" do |form| %> + <%= form.hidden_field :message_thread_id %> + <%= form.hidden_field :tag_id %> + <%= form.submit "#{tag.name}" ,class:"text-sm text-left text-blue-600 hover:cursor-pointer" %> + <% end %> + <% else %> + <%= form_with model: [MessagesTag.new(message: @object, tag: tag)], class: "contents" do |form| %> + <%= form.hidden_field :message_id %> + <%= form.hidden_field :tag_id %> + <%= form.submit "#{tag.name}", class:"text-sm text-left text-blue-600 hover:cursor-pointer" %> + <% end %> <% end %> - <% end %> -
- <% end %> +
+ <% end %> +
- +<% end %> diff --git a/app/components/common/tag_selector_popup_component.rb b/app/components/common/tag_selector_popup_component.rb index f150a7910..24ad5ca82 100644 --- a/app/components/common/tag_selector_popup_component.rb +++ b/app/components/common/tag_selector_popup_component.rb @@ -1,8 +1,8 @@ module Common class TagSelectorPopupComponent < ViewComponent::Base - def initialize(object) + def initialize(object, available_tags) @object = object - @tags = Current.tenant.tags.where.not(id: object.tags.ids) + @tags = available_tags end end end diff --git a/app/components/icons/closed_lock_component.html.erb b/app/components/icons/closed_lock_component.html.erb new file mode 100644 index 000000000..9373862ff --- /dev/null +++ b/app/components/icons/closed_lock_component.html.erb @@ -0,0 +1,3 @@ + + + diff --git a/app/components/icons/closed_lock_component.rb b/app/components/icons/closed_lock_component.rb new file mode 100644 index 000000000..bf4aa57d6 --- /dev/null +++ b/app/components/icons/closed_lock_component.rb @@ -0,0 +1,2 @@ +class Icons::ClosedLockComponent < ViewComponent::Base +end diff --git a/app/components/icons/groups_component.html.erb b/app/components/icons/groups_component.html.erb new file mode 100644 index 000000000..1b0ea3d9d --- /dev/null +++ b/app/components/icons/groups_component.html.erb @@ -0,0 +1,3 @@ + + + diff --git a/app/components/icons/groups_component.rb b/app/components/icons/groups_component.rb new file mode 100644 index 000000000..ffa816ea0 --- /dev/null +++ b/app/components/icons/groups_component.rb @@ -0,0 +1,2 @@ +class Icons::GroupsComponent < ViewComponent::Base +end diff --git a/app/components/icons/rules_component.html.erb b/app/components/icons/rules_component.html.erb index 7baee57a4..976dab4ff 100644 --- a/app/components/icons/rules_component.html.erb +++ b/app/components/icons/rules_component.html.erb @@ -1 +1,3 @@ -
Add Icons::Rules template here
+ + + diff --git a/app/components/icons/tags_component.html.erb b/app/components/icons/tags_component.html.erb index 32e6edb6f..ba4c1b833 100644 --- a/app/components/icons/tags_component.html.erb +++ b/app/components/icons/tags_component.html.erb @@ -1 +1,3 @@ -
Add Icons::Tags template here
+ + + diff --git a/app/components/icons/users_component.html.erb b/app/components/icons/users_component.html.erb new file mode 100644 index 000000000..c4ff2650a --- /dev/null +++ b/app/components/icons/users_component.html.erb @@ -0,0 +1,3 @@ + + + diff --git a/app/components/icons/users_component.rb b/app/components/icons/users_component.rb new file mode 100644 index 000000000..0b2eeb15d --- /dev/null +++ b/app/components/icons/users_component.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Icons::UsersComponent < ViewComponent::Base +end diff --git a/app/components/layout/message_thread_sidebar_component.html.erb b/app/components/layout/message_thread_sidebar_component.html.erb index aa00943d8..ecc841b3a 100644 --- a/app/components/layout/message_thread_sidebar_component.html.erb +++ b/app/components/layout/message_thread_sidebar_component.html.erb @@ -1,8 +1,3 @@ -
- - - -
<% @thread_messages.each do |message| %> <%= link_to message, class:"py-5 px-2", style:"width: calc(100% + 1rem); margin-left: -0.5rem; #{'background: #EFF6FF;' if @selected_message == message}" do %> diff --git a/app/components/layout/sidebar_divider_component.html.erb b/app/components/layout/sidebar_divider_component.html.erb new file mode 100644 index 000000000..14058a01e --- /dev/null +++ b/app/components/layout/sidebar_divider_component.html.erb @@ -0,0 +1,5 @@ +
+ + + +
diff --git a/app/components/layout/sidebar_divider_component.rb b/app/components/layout/sidebar_divider_component.rb new file mode 100644 index 000000000..e2e3cb5fd --- /dev/null +++ b/app/components/layout/sidebar_divider_component.rb @@ -0,0 +1,2 @@ +class Layout::SidebarDividerComponent < ViewComponent::Base +end diff --git a/app/components/message_component.html.erb b/app/components/message_component.html.erb index 5201d4282..0db409fd6 100644 --- a/app/components/message_component.html.erb +++ b/app/components/message_component.html.erb @@ -1,5 +1,5 @@
- <%= render MessageThreadHeaderComponent.new(@message.thread) %> + <%= render MessageThreadHeaderComponent.new(@message.thread, @available_tags) %>
<% if @notice %>
<% @message.tags.each do |tag| %> -
-

<%= tag.name %>

- <%= button_to messages_tag_path(MessagesTag.find_by(message_id: @message.id, tag_id: tag.id)), method: :delete, form: { data: { turbo_confirm: "Naozaj odstrániť štítok #{tag.name} zo správy?" } } do %> - - - - <% end %> -
+ <% if tag.visible %> +
+

<%= tag.name %>

+ <%= button_to messages_tag_path(MessagesTag.find_by(message_id: @message.id, tag_id: tag.id)), method: :delete, form: { data: { turbo_confirm: "Naozaj odstrániť štítok #{tag.name} zo správy?" } } do %> + + + + <% end %> +
+ <% end %> <% end %> - <%= render Common::TagSelectorComponent.new(@message) %> + <%= render Common::TagSelectorComponent.new(@message, @available_tags) %>
@@ -78,7 +80,6 @@
<%= render MessageAttachmentComponent.with_collection(@message.objects) %>
- <% if @message.can_be_authorized? %> <%= form_with(url: authorize_delivery_notification_message_path(@message), method: :post, local: true, style:'width: 100%;') do |form| %>
diff --git a/app/components/message_component.rb b/app/components/message_component.rb index e13834d88..ac35364c2 100644 --- a/app/components/message_component.rb +++ b/app/components/message_component.rb @@ -1,8 +1,9 @@ class MessageComponent < ViewComponent::Base renders_many :attachments - def initialize(message:, notice:) + def initialize(message:, notice:, available_tags:) @message = message @notice = notice + @available_tags = available_tags end end diff --git a/app/components/message_thread_header_component.html.erb b/app/components/message_thread_header_component.html.erb index 7bcfc526e..9b81614a2 100644 --- a/app/components/message_thread_header_component.html.erb +++ b/app/components/message_thread_header_component.html.erb @@ -14,7 +14,7 @@
<% end %> <% end %> - <%= render Common::TagSelectorComponent.new(@message_thread) %> + <%= render Common::TagSelectorComponent.new(@message_thread, @available_tags) %>
diff --git a/app/components/message_thread_header_component.rb b/app/components/message_thread_header_component.rb index c1bb566f6..e5190d872 100644 --- a/app/components/message_thread_header_component.rb +++ b/app/components/message_thread_header_component.rb @@ -1,5 +1,6 @@ class MessageThreadHeaderComponent < ViewComponent::Base - def initialize(message_thread) + def initialize(message_thread, available_tags) @message_thread = message_thread + @available_tags = available_tags end end diff --git a/app/components/settings/rules/actions_form_component.html.erb b/app/components/settings/rules/actions_form_component.html.erb index e0eaee9e6..0432d6331 100644 --- a/app/components/settings/rules/actions_form_component.html.erb +++ b/app/components/settings/rules/actions_form_component.html.erb @@ -9,9 +9,7 @@

Úprava pravidla

Krok 3 z 3 – Akcie pravidla

- <%= link_to settings_automation_rules_path, data: { turbo_frame: "_top" } do %> - <%= render Common::CloseButtonComponent.new %> - <% end %> + <%= render Common::CloseButtonComponent.new(link_to: settings_automation_rules_path) %>
<%= render Icons::InfoComponent.new %> @@ -40,7 +38,7 @@ <% end %>
<%= rule_form.button "Späť", formaction: conditions_step_settings_automation_rule_path, class:"flex justify-center items-center flex-grow relative overflow-hidden gap-2.5 px-3.5 py-2.5 rounded-md border border-gray-300 text-base font-medium text-left text-gray-900 bg-white" %> - <%= rule_form.button "Uložiť zmeny", class:"flex justify-center items-center flex-grow relative overflow-hidden gap-2.5 px-3.5 py-2.5 rounded-md text-base font-medium text-left text-white bg-blue-600" %> + <%= rule_form.button "Uložiť zmeny", class:"flex justify-center items-center flex-grow relative overflow-hidden gap-2.5 px-3.5 py-2.5 rounded-md text-base font-medium text-left text-white bg-blue-600", data: { turbo_frame: "_top" } %>
<% end %>
diff --git a/app/components/settings/rules/automation_rules_list_component.html.erb b/app/components/settings/rules/automation_rules_list_component.html.erb index 1614d2658..5111c5644 100644 --- a/app/components/settings/rules/automation_rules_list_component.html.erb +++ b/app/components/settings/rules/automation_rules_list_component.html.erb @@ -15,5 +15,19 @@ +
+
+
+ <%= render Icons::InfoComponent.new %> +
+
+
Pridať štítky
+
V prípade zadania jasných pravidiel je možné automaticky k novým správam prideliť existujúce štítky
+
+ <%= link_to admin_tenant_tags_path(Current.tenant), class:"px-3.5 py-2.5 bg-white rounded-md border border-gray-300 justify-center items-center gap-2.5 flex" do %> +

Nastaviť štítky

+ <% end %> +
+
diff --git a/app/components/settings/rules/automation_rules_table_row_component.html.erb b/app/components/settings/rules/automation_rules_table_row_component.html.erb index 51283149d..290a7a511 100644 --- a/app/components/settings/rules/automation_rules_table_row_component.html.erb +++ b/app/components/settings/rules/automation_rules_table_row_component.html.erb @@ -22,7 +22,7 @@

- <%= link_to edit_settings_automation_rule_path(@automation_rule), data: { turbo_frame: :modal } do %> + <%= link_to edit_settings_automation_rule_path(@automation_rule) do %> <%= render Common::EditButtonComponent.new %> <% end %> <%= button_to settings_automation_rule_path(@automation_rule), method: :delete do %> diff --git a/app/components/settings/rules/conditions_form_component.html.erb b/app/components/settings/rules/conditions_form_component.html.erb index 930ebc26b..5310c4b32 100644 --- a/app/components/settings/rules/conditions_form_component.html.erb +++ b/app/components/settings/rules/conditions_form_component.html.erb @@ -9,9 +9,7 @@

Úprava pravidla

Krok 2 z 3 – Podmienky pravidla

- <%= link_to settings_automation_rules_path, data: { turbo_frame: "_top" } do %> - <%= render Common::CloseButtonComponent.new %> - <% end %> + <%= render Common::CloseButtonComponent.new(link_to: settings_automation_rules_path) %>
<%= render Icons::InfoComponent.new %> diff --git a/app/components/settings/rules/rule_form_component.html.erb b/app/components/settings/rules/rule_form_component.html.erb index fb9700d00..0b8c2d5f7 100644 --- a/app/components/settings/rules/rule_form_component.html.erb +++ b/app/components/settings/rules/rule_form_component.html.erb @@ -9,9 +9,7 @@

Úprava pravidla

Krok 1 z 3 – Hlavička pravidla

- <%= link_to settings_automation_rules_path, data: { turbo_frame: "_top" } do %> - <%= render Common::CloseButtonComponent.new %> - <% end %> + <%= render Common::CloseButtonComponent.new(link_to: settings_automation_rules_path) %>
<%= render Icons::InfoComponent.new %> diff --git a/app/controllers/admin/boxes_controller.rb b/app/controllers/admin/boxes_controller.rb index abee6b7b5..f4e127a72 100644 --- a/app/controllers/admin/boxes_controller.rb +++ b/app/controllers/admin/boxes_controller.rb @@ -23,9 +23,8 @@ def edit def create @box = Current.tenant.boxes.new(box_params) authorize([:admin, @box]) - if @box.save - redirect_to admin_tenant_url(Current.tenant), notice: "Box was successfully created." + redirect_to admin_tenant_boxes_url(Current.tenant), notice: "Box was successfully created." else render :new, status: :unprocessable_entity end @@ -34,7 +33,7 @@ def create def update authorize([:admin, @box]) if @box.update(box_params) - redirect_to admin_tenant_url(Current.tenant), notice: "Box was successfully updated." + redirect_to admin_tenant_boxes_url(Current.tenant), notice: "Box was successfully updated." else render :edit, status: :unprocessable_entity end @@ -43,7 +42,7 @@ def update def destroy authorize([:admin, @box]) @box.destroy - redirect_to admin_tenant_url(Current.tenant), notice: "Box was successfully destroyed." + redirect_to admin_tenant_boxes_url(Current.tenant), notice: "Box was successfully destroyed." end private @@ -53,6 +52,6 @@ def set_box end def box_params - params.require(:box).permit(:name, :uri) + params.require(:box).permit(:name, :uri, :short_name, :color) end end diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index 7172db990..11578d6d2 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -1,5 +1,5 @@ class Admin::GroupsController < ApplicationController - before_action :set_group, only: %i[show edit update destroy edit_members search_non_members] + before_action :set_group, only: %i[show edit update destroy edit_members show_members edit_permissions search_non_members search_non_tags] def index authorize([:admin, Group]) @@ -25,13 +25,21 @@ def edit_members authorize([:admin, @group]) end + def show_members + authorize([:admin, @group]) + end + + def edit_permissions + authorize([:admin, @group]) + end + def create @group = Current.tenant.groups.new(group_params) @group.group_type = 'CUSTOM' authorize([:admin, @group]) if @group.save - redirect_to edit_members_admin_tenant_group_url(Current.tenant, @group, step: :new), notice: 'Group was successfully created.' + redirect_to edit_members_admin_tenant_group_url(Current.tenant, @group, step: :new), notice: 'Group was successfully created' else render :new, status: :unprocessable_entity end @@ -40,8 +48,7 @@ def create def update authorize([:admin, @group]) if @group.update(group_params) - flash[:notice] = 'Group was successfully updated' - render turbo_stream: turbo_stream.action(:redirect, admin_tenant_groups_url) + redirect_to admin_tenant_groups_url(Current.tenant), notice: 'Group was successfully updated' else render :edit, status: :unprocessable_entity end @@ -50,8 +57,7 @@ def update def destroy authorize([:admin, @group]) @group.destroy - flash[:notice] = 'Group was successfully updated' - render turbo_stream: turbo_stream.action(:redirect, admin_tenant_groups_url) + redirect_to admin_tenant_groups_url(Current.tenant), notice: 'Group was successfully destroyed' end def search_non_members @@ -61,6 +67,13 @@ def search_non_members @users = non_members_search_clause end + def search_non_tags + authorize([:admin, @group]) + return if params[:name_search].blank? + + @tags = non_tags_search_clause + end + private def non_members_search_clause @@ -71,6 +84,14 @@ def non_members_search_clause .order(:name) end + def non_tags_search_clause + policy_scope([:admin, Tag]) + .where(tenant: Current.tenant.id) + .where.not(id: Tag.joins(:tag_groups).where(tag_groups: { group_id: @group.id })) + .where('unaccent(name) ILIKE unaccent(?)', "%#{params[:name_search]}%") + .order(:name) + end + def set_group @group = policy_scope([:admin, Group]).find(params[:id]) end diff --git a/app/controllers/admin/tag_groups_controller.rb b/app/controllers/admin/tag_groups_controller.rb index a8e4572b6..8e8e53749 100644 --- a/app/controllers/admin/tag_groups_controller.rb +++ b/app/controllers/admin/tag_groups_controller.rb @@ -1,20 +1,24 @@ class Admin::TagGroupsController < ApplicationController - before_action :set_tag_group, only: %i[ destroy ] - # TODO - rediscuss the whole concept of SITE_ADMIN vs TENANT admin responsibilities and functionality + before_action :set_tag_group, only: %i[destroy] + # TODO: rediscuss the whole concept of SITE_ADMIN vs TENANT admin responsibilities and functionality + + # TODO: Toto je trochu nestastne, ze to nastavuje skupiny. Komponent, co listuje vsetky TagGroups ale naozaj listuje skupiny, a k nim potom tagy. Keby som to daval pod skupiny, tak asi pod samostatnu akciu, aby som odlisil na aky komponent idem (kedze je to iny, ako pre administraciu skupin) + def index + authorize([:admin, TagGroup]) + @groups = policy_scope([:admin, Group]) + end def create @tag_group = TagGroup.new(tag_group_params) authorize([:admin, @tag_group]) - @tag_group.save! - - redirect_back fallback_location:"/", notice: "Tag permission was successfully assigned." + redirect_to edit_permissions_admin_tenant_group_url(Current.tenant, @tag_group.group), notice: "Tag permission was successfully assigned" end def destroy authorize([:admin, @tag_group]) @tag_group.destroy - redirect_back fallback_location:"/", notice: "Tag permission was successfully destroyed." + redirect_to edit_permissions_admin_tenant_group_url(Current.tenant, @tag_group.group), notice: "Tag permission was successfully destroyed" end private diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb index fd977d643..cbc4ac43c 100644 --- a/app/controllers/admin/tags_controller.rb +++ b/app/controllers/admin/tags_controller.rb @@ -1,8 +1,8 @@ class Admin::TagsController < ApplicationController - before_action :set_tag, only: %i[show edit update destroy] + before_action :set_tag, only: %i[show edit update destroy visibility_toggle] def index - authorize Tag + authorize [:admin, Tag] @tags = policy_scope([:admin, Tag]) end @@ -22,10 +22,11 @@ def edit def create @tag = Current.tenant.tags.new(tag_params) + @tag.user_id = Current.user.id authorize([:admin, @tag]) if @tag.save - redirect_to admin_tenant_url(Current.tenant), notice: "Tag was successfully created." + redirect_to admin_tenant_tags_path(Current.tenant), notice: 'Tag was successfully created' else render :new, status: :unprocessable_entity end @@ -34,7 +35,7 @@ def create def update authorize([:admin, @tag]) if @tag.update(tag_params) - redirect_to admin_tenant_url(Current.tenant), notice: "Tag was successfully updated." + redirect_to admin_tenant_tags_path(Current.tenant), notice: 'Tag was successfully updated' else render :edit, status: :unprocessable_entity end @@ -43,7 +44,7 @@ def update def destroy authorize([:admin, @tag]) @tag.destroy - redirect_to admin_tenant_url(Current.tenant), notice: "Tag was successfully destroyed." + redirect_to admin_tenant_tags_path(Current.tenant), notice: 'Tag was successfully created' end private @@ -55,4 +56,8 @@ def set_tag def tag_params params.require(:tag).permit(:name, :visible, :user_id, :tenant_id) end + + def tag_params_visibility + params.permit(:visible) + end end diff --git a/app/controllers/admin/tenants_controller.rb b/app/controllers/admin/tenants_controller.rb index b8a16fb3c..8cc883821 100644 --- a/app/controllers/admin/tenants_controller.rb +++ b/app/controllers/admin/tenants_controller.rb @@ -25,28 +25,20 @@ def edit def create @tenant = Tenant.new(tenant_params) authorize([:admin, @tenant]) - respond_to do |format| - if @tenant.save - format.html { redirect_to admin_tenant_url(@tenant), notice: 'Tenant was successfully created.' } - format.json { render :show, status: :created, location: @tenant } - else - format.html { render :new, status: :unprocessable_entity } - format.json { render json: @tenant.errors, status: :unprocessable_entity } - end + if @tenant.save + redirect_to admin_tenants_url, notice: 'Tenant was successfully created' + else + render :new, status: :unprocessable_entity end end # PATCH/PUT /tenants/1 or /tenants/1.json def update authorize([:admin, @tenant]) - respond_to do |format| - if @tenant.update(tenant_params) - format.html { redirect_to admin_tenant_url(@tenant), notice: 'Tenant was successfully updated.' } - format.json { render :show, status: :ok, location: @tenant } - else - format.html { render :edit, status: :unprocessable_entity } - format.json { render json: @tenant.errors, status: :unprocessable_entity } - end + if @tenant.update(tenant_params) + redirect_to admin_tenants_url, notice: 'Tenant was successfully updated' + else + render :edit, status: :unprocessable_entity end end @@ -54,11 +46,8 @@ def update def destroy authorize([:admin, @tenant]) @tenant.destroy - session[:tenant_id] = nil - respond_to do |format| - format.html { redirect_to admin_tenants_url, notice: 'Tenant was successfully destroyed.' } - format.json { head :no_content } - end + session[:tenant_id] = nil if Current.tenant == @tenant + redirect_to admin_tenants_url, notice: 'Tenant was successfully destroyed' end private @@ -72,4 +61,4 @@ def set_tenant def tenant_params params.require(:tenant).permit(:name) end -end \ No newline at end of file +end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 058d0ab57..feba69499 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,16 +1,9 @@ class Admin::UsersController < ApplicationController - before_action :set_user, only: %i[show edit update destroy] + before_action :set_user, only: %i[edit update destroy] def index authorize([:admin, User]) - @users = policy_scope([:admin, User]) - end - - def show - @user = policy_scope([:admin, User]).find(params[:id]) - authorize([:admin, @user]) - @other_groups = other_groups - @other_tags = other_tags + @users = policy_scope([:admin, User]).where(tenant_id: Current.tenant.id) end def new @@ -26,38 +19,26 @@ def create @user = Current.tenant.users.new(user_params) authorize([:admin, @user]) - respond_to do |format| - if @user.save - format.html { redirect_to admin_tenant_url(Current.tenant), notice: 'User was successfully created.' } - format.json { render :show, status: :created, location: @user } - else - format.html { render :new, status: :unprocessable_entity } - format.json { render json: @user.errors, status: :unprocessable_entity } - end + if @user.save + redirect_to admin_tenant_users_url(Current.tenant), notice: 'User was successfully created' + else + render :new, status: :unprocessable_entity end end def update authorize([:admin, @user]) - respond_to do |format| - if @user.update(user_params) - format.html { redirect_to admin_tenant_url(Current.tenant), notice: 'User was successfully updated.' } - format.json { render :show, status: :ok, location: @user } - else - format.html { render :edit, status: :unprocessable_entity } - format.json { render json: @user.errors, status: :unprocessable_entity } - end + if @user.update(user_params) + redirect_to admin_tenant_users_url(Current.tenant), notice: 'User was successfully updated' + else + render :edit, status: :unprocessable_entity end end def destroy authorize([:admin, @user]) @user.destroy - - respond_to do |format| - format.html { redirect_to admin_tenant_url(Current.tenant), notice: 'User was successfully destroyed.' } - format.json { head :no_content } - end + redirect_to admin_tenant_users_url(Current.tenant), notice: 'User was successfully destroyed' end private @@ -69,18 +50,4 @@ def set_user def user_params params.require(:user).permit(:name, :email, :user_type) end - - def other_groups - @other_groups = - Group - .where(tenant_id: params[:tenant_id]) - .where.not(group_type: 'USER') - .where.not(id: Group.includes(:users).where(users: { id: @user.id })) - end - def other_tags - @other_tags = - Tag - .where(tenant_id: params[:tenant_id]) - .where.not(id: Tag.includes(:users).where(users: { id: @user.id })) - end end diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index b61a46cf0..6aa6a1d87 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -6,8 +6,6 @@ def show @message.update(read: true) @message_thread = @message.thread - - @notice = notice end def authorize_delivery_notification @@ -16,7 +14,7 @@ def authorize_delivery_notification notice = Message.authorize_delivery_notification(@message) ? "Správa bola zaradená na prevzatie." : "Správu nie je možné prevziať." redirect_to message_path(@message), notice: notice end - + private def set_message diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index be3861f91..bf17d36f1 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -3,6 +3,7 @@ class SessionsController < ApplicationController skip_after_action :verify_authorized skip_after_action :verify_policy_scoped skip_before_action :set_menu_context + layout 'login' def login end @@ -18,6 +19,6 @@ def destroy end def failure - render html: "Authorization failed (#{request.params['message']})", status: :forbidden + render html: "Authorization failed (#{request.params["message"]})", status: :forbidden end end diff --git a/app/controllers/settings/automation_rules_controller.rb b/app/controllers/settings/automation_rules_controller.rb index 3614cfe27..b9eb8d461 100644 --- a/app/controllers/settings/automation_rules_controller.rb +++ b/app/controllers/settings/automation_rules_controller.rb @@ -22,8 +22,7 @@ def create @automation_rule.user = Current.user authorize @automation_rule, policy_class: Settings::AutomationRulePolicy if @automation_rule.save - flash[:notice] = 'Thing was successfully created' - render turbo_stream: turbo_stream.action(:redirect, settings_automation_rules_path) + redirect_to settings_automation_rules_path, notice: 'Rule was successfully created' else render :new, status: :unprocessable_entity end @@ -32,8 +31,7 @@ def create def update authorize @automation_rule, policy_class: Settings::AutomationRulePolicy if @automation_rule.update(automation_rule_params) - flash[:notice] = 'Thing was successfully updated' - render turbo_stream: turbo_stream.action(:redirect, settings_automation_rules_path) + redirect_to settings_automation_rules_path, notice: 'Rule was successfully created' else # TODO: Vieme nejako zachranit? render :new, status: :unprocessable_entity @@ -54,7 +52,6 @@ def actions_step authorize @automation_rule, policy_class: Settings::AutomationRulePolicy end - def conditions_step authorize @automation_rule, policy_class: Settings::AutomationRulePolicy end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index d353ce046..2634c1208 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,13 +1,28 @@ class TagsController < ApplicationController - before_action :set_tag + before_action :set_tag, only: %i[show] before_action :set_visible_tags def show - authorize @tag + authorize [:admin, @tag] + end + + def get_available + authorize [Tag] + set_object + @tenant = Current.tenant + @tags = + @tenant.tags.where.not(id: @object.tags.ids).where(visible: true) + .where(id: TagGroup.select(:tag_id).joins(:group, :tag, group: :users).where(group: { tenant_id: @tenant.id }, tag: { tenant_id: @tenant.id }, users: { id: Current.user.id })) + respond_to { |format| format.html } end private + def set_object + @object = policy_scope(Message).find(params[:object_id]) if params[:object_class] == 'Message' + @object = policy_scope(MessageThread).find(params[:object_id]) if params[:object_class] == 'MessageThread' + end + def set_visible_tags @visible_tags = policy_scope(Tag).where(visible: true) end diff --git a/app/javascript/controllers/debounce_controller.js b/app/javascript/controllers/debounce_controller.js new file mode 100644 index 000000000..f10f6d786 --- /dev/null +++ b/app/javascript/controllers/debounce_controller.js @@ -0,0 +1,14 @@ +import { Controller } from "@hotwired/stimulus"; + +export default class extends Controller { + static targets = ["form"]; + + connect() {} + + debounce() { + clearTimeout(this.timeout); + this.timeout = setTimeout(() => { + this.formTarget.requestSubmit(); + }, 300); + } +} diff --git a/app/javascript/controllers/hello_controller.js b/app/javascript/controllers/hello_controller.js deleted file mode 100644 index 5975c0789..000000000 --- a/app/javascript/controllers/hello_controller.js +++ /dev/null @@ -1,7 +0,0 @@ -import { Controller } from "@hotwired/stimulus" - -export default class extends Controller { - connect() { - this.element.textContent = "Hello World!" - } -} diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js index d0685d3b7..1b47ccee3 100644 --- a/app/javascript/controllers/index.js +++ b/app/javascript/controllers/index.js @@ -4,5 +4,5 @@ import { application } from "./application" -import HelloController from "./hello_controller" -application.register("hello", HelloController) +import DebounceController from "./debounce_controller" +application.register("debounce", DebounceController) diff --git a/app/jobs/drafts/parse_import_job.rb b/app/jobs/drafts/parse_import_job.rb index 40680da35..7576a8ff5 100644 --- a/app/jobs/drafts/parse_import_job.rb +++ b/app/jobs/drafts/parse_import_job.rb @@ -77,11 +77,7 @@ def load_import_csv(import, csv_path) last_message_delivered_at: Time.now ) - message_thread.tags << Tag.find_or_create_by!( - name: "Drafts", - tenant: import.box.tenant, - visible: true - ) + message_thread.tags << Tag.find_by!(name: "Drafts", tenant: import.box.tenant) MessageDraft.create!( uuid: uuid, diff --git a/app/lib/sidebar_menu.rb b/app/lib/sidebar_menu.rb index 72b1180de..866896645 100644 --- a/app/lib/sidebar_menu.rb +++ b/app/lib/sidebar_menu.rb @@ -13,8 +13,8 @@ def get_menu private def initial_structure(controller, action) - return default_message_thread_menu if %w[messages message_drafts].include?(controller) - return admin_main_menu if Current.user.admin? || Current.user.site_admin? + return default_message_thread_menu if controller.in? %w[messages message_drafts] + return admin_main_menu if (controller.in? %w[groups users tags tag_groups automation_rules boxes tenants]) && (Current.user.admin? || Current.user.site_admin?) default_main_menu end @@ -23,25 +23,30 @@ def default_main_menu [ TW::SidebarMenuItemComponent.new(name: 'Prehľad', url: root_path, icon: Icons::DashboardComponent.new), TW::SidebarMenuItemComponent.new(name: 'Správy', url: message_threads_path, icon: Icons::SchrankaComponent.new), - Layout::TagListComponent.new(tags: @parameters[:tags]) + Layout::TagListComponent.new(tags: @parameters[:tags]), + TW::SidebarMenuItemComponent.new(name: 'Nastavenia', url: admin_tenant_users_path(Current.tenant), icon: Icons::SettingsComponent.new) ] end def admin_main_menu [ - TW::SidebarMenuItemComponent.new(name: 'Prehľad', url: root_path, icon: Icons::DashboardComponent.new), - TW::SidebarMenuItemComponent.new(name: 'Správy', url: message_threads_path, icon: Icons::SchrankaComponent.new), - Layout::TagListComponent.new(tags: @parameters[:tags]), - TW::SidebarMenuDividerComponent.new(name: 'Nastavenia'), - TW::SidebarMenuItemComponent.new(name: 'Nastavenie pravidiel', url: settings_automation_rules_path, icon: Icons::SettingsComponent.new), - TW::SidebarMenuDividerComponent.new(name: 'Administrácia'), - TW::SidebarMenuItemComponent.new(name: 'Schránky', url: boxes_path, icon: Icons::BoxesComponent.new), - TW::SidebarMenuItemComponent.new(name: 'Administrácia', url: admin_tenants_path, icon: Icons::AdminComponent.new), - TW::SidebarMenuItemComponent.new(name: 'Good Job Dashboard', url: good_job_path, icon: Icons::GoodJobComponent.new) - ] + Layout::BackToBoxComponent.new(), + Layout::SidebarDividerComponent.new(), + TW::SidebarMenuDividerComponent.new(name: 'Produkt'), + Current.user.site_admin? ? TW::SidebarMenuItemComponent.new(name: 'Tenanti', url: admin_tenants_path, icon: Icons::GroupsComponent.new) : nil, + TW::SidebarMenuItemComponent.new(name: 'Používatelia', url: admin_tenant_users_path(Current.tenant), icon: Icons::UsersComponent.new), + TW::SidebarMenuItemComponent.new(name: 'Pravidlá', url: settings_automation_rules_path, icon: Icons::RulesComponent.new), + TW::SidebarMenuItemComponent.new(name: 'Prístup', url: admin_tenant_tag_groups_path(Current.tenant), icon: Icons::ClosedLockComponent.new), + TW::SidebarMenuItemComponent.new(name: 'Schránky', url: admin_tenant_boxes_path(Current.tenant), icon: Icons::BoxesComponent.new), + TW::SidebarMenuItemComponent.new(name: 'Skupiny', url: admin_tenant_groups_path(Current.tenant), icon: Icons::GroupsComponent.new), + TW::SidebarMenuItemComponent.new(name: 'Štítky', url: admin_tenant_tags_path(Current.tenant), icon: Icons::TagsComponent.new), + Layout::SidebarDividerComponent.new(), + TW::SidebarMenuDividerComponent.new(name: 'Admin'), + TW::SidebarMenuItemComponent.new(name: 'Good Job Dashboard', url: good_job_path, icon: Icons::GoodJobComponent.new), + ].compact end def default_message_thread_menu - [Layout::BackToBoxComponent.new, Layout::MessageThreadSidebarComponent.new(message: @parameters[:message])] if @parameters && @parameters[:message] + [Layout::BackToBoxComponent.new, Layout::SidebarDividerComponent.new, Layout::MessageThreadSidebarComponent.new(message: @parameters[:message])] if @parameters && @parameters[:message] end end diff --git a/app/models/box.rb b/app/models/box.rb index f693f287f..2da8df232 100644 --- a/app/models/box.rb +++ b/app/models/box.rb @@ -18,5 +18,32 @@ class Box < ApplicationRecord has_many :message_drafts_imports, dependent: :destroy before_destroy ->(box) { EventBus.publish(:box_destroyed, box.id) } -end + before_create { self.color = Box.colors.keys[name.hash % Box.colors.size] if color.blank? } + + enum :color, + { + slate: 'slate', + gray: 'gray', + zinc: 'zinc', + neutral: 'neutral', + stone: 'stone', + red: 'red', + orange: 'orange', + amber: 'amber', + yellow: 'yellow', + lime: 'lime', + green: 'green', + emerald: 'emerald', + teal: 'teal', + cyan: 'cyan', + sky: 'sky', + blue: 'blue', + indigo: 'indigo', + violet: 'violet', + purple: 'purple', + fuchsia: 'fuchsia', + pink: 'pink', + rose: 'rose' + } +end diff --git a/app/models/govbox/message.rb b/app/models/govbox/message.rb index 37c17b055..266a63fac 100644 --- a/app/models/govbox/message.rb +++ b/app/models/govbox/message.rb @@ -112,6 +112,7 @@ def self.create_message_tag(message, govbox_message) tag = Tag.find_or_create_by!( name: "slovensko.sk:#{govbox_message.folder.full_name}", tenant: govbox_message.box.tenant, + external: true, visible: !govbox_message.folder.system? ) diff --git a/app/models/tenant.rb b/app/models/tenant.rb index 31e06a8de..5cf6df7c5 100644 --- a/app/models/tenant.rb +++ b/app/models/tenant.rb @@ -17,14 +17,15 @@ class Tenant < ApplicationRecord has_many :automation_rules, class_name: 'Automation::Rule', dependent: :destroy has_many :folders, through: :boxes has_many :tags, dependent: :destroy - after_create :create_default_groups + after_create :create_default_objects validates_presence_of :name private - def create_default_groups + def create_default_objects groups.create!(name: 'all', group_type: 'ALL') groups.create!(name: 'admins', group_type: 'ADMIN') + tags.create!(name: 'Drafts', external: false, visible: true) end end diff --git a/app/policies/admin/group_policy.rb b/app/policies/admin/group_policy.rb index 73b73b047..b4b4ec855 100644 --- a/app/policies/admin/group_policy.rb +++ b/app/policies/admin/group_policy.rb @@ -46,6 +46,14 @@ def edit_members? update? end + def show_members? + update? + end + + def edit_permissions? + update? + end + def destroy? @user.site_admin? || @user.admin? end @@ -54,4 +62,8 @@ def search_non_members? @user.site_admin? || @user.admin? end + def search_non_tags? + @user.site_admin? || @user.admin? + end + end diff --git a/app/policies/admin/tag_group_policy.rb b/app/policies/admin/tag_group_policy.rb index 215b8a12c..b17405123 100644 --- a/app/policies/admin/tag_group_policy.rb +++ b/app/policies/admin/tag_group_policy.rb @@ -18,7 +18,7 @@ def resolve end end - def index + def index? @user.site_admin? || @user.admin? end diff --git a/app/policies/admin/tag_policy.rb b/app/policies/admin/tag_policy.rb index 40ff018c0..fa70bced6 100644 --- a/app/policies/admin/tag_policy.rb +++ b/app/policies/admin/tag_policy.rb @@ -14,7 +14,7 @@ def resolve end end - def index + def index? @user.site_admin? || @user.admin? end diff --git a/app/policies/admin/user_policy.rb b/app/policies/admin/user_policy.rb index a3ad63887..645c9467a 100644 --- a/app/policies/admin/user_policy.rb +++ b/app/policies/admin/user_policy.rb @@ -17,7 +17,7 @@ def resolve end end - def index + def index? @user.site_admin? || @user.admin? end diff --git a/app/policies/tag_policy.rb b/app/policies/tag_policy.rb index fad809012..55d3078e2 100644 --- a/app/policies/tag_policy.rb +++ b/app/policies/tag_policy.rb @@ -27,4 +27,8 @@ def resolve def show? true end + + def get_available? + true + end end diff --git a/app/views/admin/boxes/edit.html.erb b/app/views/admin/boxes/edit.html.erb index c967a4a99..8cff92d70 100644 --- a/app/views/admin/boxes/edit.html.erb +++ b/app/views/admin/boxes/edit.html.erb @@ -1,6 +1 @@ -
-

Editing box

- <%= render "form", box: @box %> - <%= link_to "Show this box", admin_tenant_box_path(Current.tenant, @box), class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> - <%= link_to "Back to tenant", admin_tenant_path(Current.tenant), class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
+<%= render Admin::Boxes::BoxFormComponent.new(box: @box, action: :edit) %> diff --git a/app/views/admin/boxes/index.html.erb b/app/views/admin/boxes/index.html.erb index 754c94b89..3dac44f9c 100644 --- a/app/views/admin/boxes/index.html.erb +++ b/app/views/admin/boxes/index.html.erb @@ -1,13 +1 @@ -
- <% if notice.present? %> -

<%= notice %>

- <% end %> -
-

Boxes

- <%= link_to 'New box', new_admin_box_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %> -
-
- <%= render @boxes %> -
-
+<%= render Admin::Boxes::BoxesListComponent.new(@boxes) %> diff --git a/app/views/admin/boxes/new.html.erb b/app/views/admin/boxes/new.html.erb index e00de502d..5285c2fcc 100644 --- a/app/views/admin/boxes/new.html.erb +++ b/app/views/admin/boxes/new.html.erb @@ -1,5 +1 @@ -
-

New box

- <%= render "form", box: @box %> - <%= link_to 'Back to tenant', admin_tenant_path(Current.tenant), class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
+<%= render Admin::Boxes::BoxFormComponent.new(box: @box, action: :new) %> diff --git a/app/views/admin/group_memberships/create.html.erb b/app/views/admin/group_memberships/create.html.erb new file mode 100644 index 000000000..cfeca4bc7 --- /dev/null +++ b/app/views/admin/group_memberships/create.html.erb @@ -0,0 +1 @@ +<%= render Admin::Groups::GroupFormComponent.new(group: @group, readonly: false)%> diff --git a/app/views/admin/group_memberships/create.turbo_stream.erb b/app/views/admin/group_memberships/create.turbo_stream.erb deleted file mode 100644 index d55113fc6..000000000 --- a/app/views/admin/group_memberships/create.turbo_stream.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%# TODO: Toto sa mi nepodarilo vyriesit standartnym redirectom, len takymto hackom. Nahodou nejake napady? Problem je, ze create sa vola z ineho turbo framu, z ktoreho neviem inak uniknut %> -<%= turbo_stream.update 'modal' do %> - <%= render Admin::Groups::GroupFormComponent.new(group: @group, step: :new)%> -<% end %> diff --git a/app/views/admin/groups/edit_members.html.erb b/app/views/admin/groups/edit_members.html.erb index f532aa6ee..9eb8077f8 100644 --- a/app/views/admin/groups/edit_members.html.erb +++ b/app/views/admin/groups/edit_members.html.erb @@ -1,2 +1 @@ -<%= render Admin::Groups::GroupFormComponent.new(group: @group, step: :new) if params[:step] && params[:step] == 'new' %> -<%= render Admin::Groups::GroupFormComponent.new(group: @group, step: :edit) if !params[:step] || params[:step] != 'edit' %> +<%= render Admin::Groups::GroupFormComponent.new(group: @group, readonly: false) %> diff --git a/app/views/admin/groups/edit_permissions.html.erb b/app/views/admin/groups/edit_permissions.html.erb new file mode 100644 index 000000000..bf0cbe7ae --- /dev/null +++ b/app/views/admin/groups/edit_permissions.html.erb @@ -0,0 +1 @@ +<%= render Admin::Permissions::GroupFormComponent.new(group: @group) %> diff --git a/app/views/admin/groups/search_non_tags.turbo_stream.erb b/app/views/admin/groups/search_non_tags.turbo_stream.erb new file mode 100644 index 000000000..4d135ed1f --- /dev/null +++ b/app/views/admin/groups/search_non_tags.turbo_stream.erb @@ -0,0 +1,5 @@ +<%= turbo_stream.update 'tag-search-results' do %> + <% if !params[:name_search].empty? %> + <%= render Admin::Permissions::PermissionsAddPopupComponent.new(tags: @tags, group: @group) %> + <% end %> +<% end %> diff --git a/app/views/admin/groups/show_members.html.erb b/app/views/admin/groups/show_members.html.erb new file mode 100644 index 000000000..1cf123a8a --- /dev/null +++ b/app/views/admin/groups/show_members.html.erb @@ -0,0 +1 @@ +<%= render Admin::Groups::GroupFormComponent.new(group: @group, readonly: true) %> diff --git a/app/views/admin/tag_groups/index.html.erb b/app/views/admin/tag_groups/index.html.erb new file mode 100644 index 000000000..54a19255e --- /dev/null +++ b/app/views/admin/tag_groups/index.html.erb @@ -0,0 +1 @@ +<%= render Admin::Permissions::GroupsListComponent.new(@groups) %> diff --git a/app/views/admin/tags/edit.html.erb b/app/views/admin/tags/edit.html.erb index 2e88ede92..18d320002 100644 --- a/app/views/admin/tags/edit.html.erb +++ b/app/views/admin/tags/edit.html.erb @@ -1,6 +1 @@ -
-

Editing tag

- <%= render "form", tag: @tag %> - <%= link_to "Show this tag", admin_tenant_tag_path(Current.tenant, @tag), class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> - <%= link_to "Back to tenant", admin_tenant_path(Current.tenant), class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
+<%= render Admin::Tags::TagFormComponent.new(tag: @tag, action: :edit) %> diff --git a/app/views/admin/tags/index.html.erb b/app/views/admin/tags/index.html.erb index 1933ed2d5..3f6708b2f 100644 --- a/app/views/admin/tags/index.html.erb +++ b/app/views/admin/tags/index.html.erb @@ -1,13 +1 @@ -
- <% if notice.present? %> -

<%= notice %>

- <% end %> -
-

Tags

- <%= link_to 'New tag', new_admin_tag_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %> -
-
- <%= render @tags %> -
-
+<%= render Admin::Tags::TagsListComponent.new(@tags) %> diff --git a/app/views/admin/tags/new.html.erb b/app/views/admin/tags/new.html.erb index d428803d8..eda4f5ee3 100644 --- a/app/views/admin/tags/new.html.erb +++ b/app/views/admin/tags/new.html.erb @@ -1,5 +1 @@ -
-

New tag

- <%= render "form", tag: @tag %> - <%= link_to 'Back to tenant', admin_tenant_path(Current.tenant), class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
+<%= render Admin::Tags::TagFormComponent.new(tag: @tag, action: :new) %> diff --git a/app/views/admin/tags/visibility_toggle.html.erb b/app/views/admin/tags/visibility_toggle.html.erb new file mode 100644 index 000000000..bce935c2b --- /dev/null +++ b/app/views/admin/tags/visibility_toggle.html.erb @@ -0,0 +1 @@ +<%= render Admin::Tags::VisibilityToggleComponent.new(@tag) %> diff --git a/app/views/admin/tenants/edit.html.erb b/app/views/admin/tenants/edit.html.erb index 520cef89d..2d31254c0 100644 --- a/app/views/admin/tenants/edit.html.erb +++ b/app/views/admin/tenants/edit.html.erb @@ -1,6 +1 @@ -
-

Editing tenant

- <%= render "form", tenant: @tenant %> - <%= link_to "Show this tenant", [:admin, @tenant], class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> - <%= link_to "Back to tenants", admin_tenants_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
+<%= render Admin::Tenants::TenantFormComponent.new(tenant: @tenant, action: :edit) %> diff --git a/app/views/admin/tenants/index.html.erb b/app/views/admin/tenants/index.html.erb index 4005ba346..432a180e3 100644 --- a/app/views/admin/tenants/index.html.erb +++ b/app/views/admin/tenants/index.html.erb @@ -1,12 +1 @@ -
- <% if notice.present? %> -

<%= notice %>

- <% end %> -
-

Tenants

- <%= link_to 'New tenant', new_admin_tenant_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %> -
-
- <%= render @tenants %> -
-
+<%= render Admin::Tenants::TenantsListComponent.new(@tenants) %> diff --git a/app/views/admin/tenants/new.html.erb b/app/views/admin/tenants/new.html.erb index 70cf94ee3..e4989ae8f 100644 --- a/app/views/admin/tenants/new.html.erb +++ b/app/views/admin/tenants/new.html.erb @@ -1,5 +1 @@ -
-

New tenant

- <%= render "form", tenant: @tenant %> - <%= link_to 'Back to tenants', admin_tenants_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
+<%= render Admin::Tenants::TenantFormComponent.new(tenant: @tenant, action: :new) %> diff --git a/app/views/admin/users/_form.html.erb b/app/views/admin/users/_form.html.erb deleted file mode 100644 index c5d4004c1..000000000 --- a/app/views/admin/users/_form.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -<%= form_with(model: [:admin, Current.tenant, user], class: "contents") do |form| %> - <% if user.errors.any? %> -
-

<%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:

- -
- <% end %> -
- <%= form.label :name %> - <%= form.text_field :name, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %> -
-
- <%= form.label :email %> - <%= form.text_field :email, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %> -
-
- <%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %> -
-<% end %> diff --git a/app/views/admin/users/_user.html.erb b/app/views/admin/users/_user.html.erb deleted file mode 100644 index d765135a7..000000000 --- a/app/views/admin/users/_user.html.erb +++ /dev/null @@ -1,8 +0,0 @@ - - <%= link_to user.name, admin_tenant_user_url(Current.tenant, @user) %> - - <%= user.email%> - - <%= link_to 'Edit this user', edit_admin_tenant_user_url(Current.tenant, @user), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %> - - diff --git a/app/views/admin/users/edit.html.erb b/app/views/admin/users/edit.html.erb index 1ac5982af..0b419cf11 100644 --- a/app/views/admin/users/edit.html.erb +++ b/app/views/admin/users/edit.html.erb @@ -1,5 +1 @@ -
-

Editing user

- <%= render "form", user: @user %> - <%= link_to "Back to users", :back, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
+<%= render Admin::Users::UserFormComponent.new(user: @user, action: :edit) %> diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb index dfc2a671c..b454a0349 100644 --- a/app/views/admin/users/index.html.erb +++ b/app/views/admin/users/index.html.erb @@ -1,14 +1 @@ -
- <% if notice.present? %> -

<%= notice %>

- <% end %> - -
-

Users

- <%= link_to 'New user', new_user_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %> -
- -
- <%= render @users %> -
-
+<%= render Admin::Users::UsersListComponent.new(@users) %> diff --git a/app/views/admin/users/new.html.erb b/app/views/admin/users/new.html.erb index cb63ee156..65170352e 100644 --- a/app/views/admin/users/new.html.erb +++ b/app/views/admin/users/new.html.erb @@ -1,5 +1 @@ -
-

New user

- <%= render "form", user: @user %> - <%= link_to 'Back to users', :back , class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
+<%= render Admin::Users::UserFormComponent.new(user: @user, action: :new) %> diff --git a/app/views/admin/users/show.html.erb b/app/views/admin/users/show.html.erb deleted file mode 100644 index f8bfcea7b..000000000 --- a/app/views/admin/users/show.html.erb +++ /dev/null @@ -1,188 +0,0 @@ -
-
-
-
    -
  • -
    -

    User

    -
    -
    -
    - <% if notice.present? %> -

    <%= notice %>

    - <% end %> - <%= render @user %> - <%= link_to 'Edit this user', edit_admin_tenant_user_url(Current.tenant, @user), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
    - <%= button_to 'Destroy this user', admin_tenant_user_path(@user), method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %> -
    - <%= link_to 'Back to tenant', admin_tenant_path(Current.tenant), class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %> -
    -
    -
  • - -
  • -
    -
    -

    Groups Membership

    -
    -
    -
    -
    -
    -
    - - - - - - - - - - <%= render Admin::GroupMembershipTableRowComponent.with_collection(@user.group_memberships) %> - -
    - - Name - - - - - - Type - - - - - Edit -
    -
    -
    -
    -
    -
    -
    -
  • -
  • -
    - -
    -

    Other Groups

    -
    -
    -
    -
    -
    -
    - - - - - - - - - - <%= render Admin::GroupTableRowComponent.with_collection(@other_groups, user: @user, group_action: 'add') %> - -
    - - Name - - - - - - Type - - - - - Edit -
    -
    -
    -
    -
    -
    -
    -
  • -
  • -
    - -
    -

    Tags Assigned (obsolete)

    -
    -
    -
    -
    -
    -
    - - - - - - - - - - <%= render Admin::TagUserTableRowComponent.with_collection(@user.tag_users) %> - -
    - - Name - - - - - - Type - - - - - Edit -
    -
    -
    -
    -
    -
    -
    -
  • -
-
-
-
diff --git a/app/views/boxes/show.html.erb b/app/views/boxes/show.html.erb index 522361940..f05ac20a5 100644 --- a/app/views/boxes/show.html.erb +++ b/app/views/boxes/show.html.erb @@ -1,5 +1,4 @@

Schránka <%= @box.name %>

- <%= form_tag box_sync_path(@box), method: :post do %> <%= submit_tag 'Stiahnúť nové správy' %> <% end %> diff --git a/app/views/layouts/login.html.erb b/app/views/layouts/login.html.erb new file mode 100644 index 000000000..08c27b419 --- /dev/null +++ b/app/views/layouts/login.html.erb @@ -0,0 +1,15 @@ + + + + GovboxPro + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + <%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %> + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %> + + + <%= yield %> + + diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb index a04952616..851ce633d 100644 --- a/app/views/messages/show.html.erb +++ b/app/views/messages/show.html.erb @@ -1,5 +1,5 @@ <%= render TW::FlashComponent.new(flash: flash) %> -<%= render MessageComponent.new(message: @message, notice: @notice) do |component| %> +<%= render MessageComponent.new(message: @message, notice: @notice, available_tags: @available_tags) do |component| %> <% @message.objects.each do |message_object| %> <% component.with_attachment do %> <% render MessageAttachmentComponent.new(message_attachment: message_object) %> diff --git a/app/views/sessions/login.html.erb b/app/views/sessions/login.html.erb index 46cbf8b15..b79f13bc3 100644 --- a/app/views/sessions/login.html.erb +++ b/app/views/sessions/login.html.erb @@ -1,4 +1,19 @@ - -<% unless Current.user %> -

<%= button_to "Sign in with Google", "/auth/google_oauth2", method: :post, data: { turbo: false }, class: "rounded-md bg-indigo-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" %>

-<% end %> +
+
+ <%= image_tag("SD_icon.png", alt: "logo", class:"mx-auto h-10 w-auto") %> +

Prihláste sa do svojho účtu

+
+
+
+
+
+ <%= button_to "Sign in with Google", "/auth/google_oauth2", method: :post, data: { turbo: false }, class: "flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-semibold leading-6 text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" %> +
+
+
+

+ Nemáte účet? + Kontaktujte nás +

+
+
diff --git a/app/views/tags/get_available.html.erb b/app/views/tags/get_available.html.erb new file mode 100644 index 000000000..ba0800546 --- /dev/null +++ b/app/views/tags/get_available.html.erb @@ -0,0 +1 @@ +<%= render Common::TagSelectorPopupComponent.new(@object, @tags) %> diff --git a/config/routes.rb b/config/routes.rb index b017e7a50..1695867d3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,4 @@ Rails.application.routes.draw do - - namespace :settings do resources :automation_rules resource :automation_rule do @@ -25,18 +23,22 @@ resources :tenants do resources :groups do get :edit_members, on: :member + get :show_members, on: :member + get :edit_permissions, on: :member post :search_non_members, on: :member - resources :group_memberships, param: :index + post :search_non_tags, on: :member + resources :group_memberships do + end end resources :users resources :boxes resources :tags + resources :tag_groups end + end - resources :group_memberships - resources :tag_users - - resources :tag_groups, only: [:create, :destroy] + resources :tags do + get :get_available, on: :collection end resources :boxes, path: 'schranky', only: [:index, :show] do diff --git a/db/migrate/20230912140348_add_short_name_to_boxes.rb b/db/migrate/20230912140348_add_short_name_to_boxes.rb new file mode 100644 index 000000000..018371d16 --- /dev/null +++ b/db/migrate/20230912140348_add_short_name_to_boxes.rb @@ -0,0 +1,6 @@ +class AddShortNameToBoxes < ActiveRecord::Migration[7.0] + def change + add_column :boxes, :short_name, :string + add_index :boxes, %i[tenant_id short_name], unique: true + end +end diff --git a/db/migrate/20230912140629_add_color_to_boxes.rb b/db/migrate/20230912140629_add_color_to_boxes.rb new file mode 100644 index 000000000..5a45a887b --- /dev/null +++ b/db/migrate/20230912140629_add_color_to_boxes.rb @@ -0,0 +1,12 @@ +class AddColorToBoxes < ActiveRecord::Migration[7.0] + def change + create_enum :color, %w[slate gray zinc neutral stone red orange amber yellow lime green emerald teal cyan sky blue indigo violet purple fuchsia pink rose] + change_table :boxes do |t| + t.enum :color, enum_type: 'color' + end + Box.all.each do |box| + box.color = Box.colors.keys[@box.name.hash % Box.colors.size] + box.short_name = box.name[0] + end + end +end diff --git a/db/migrate/20230914151243_add_external_to_tags.rb b/db/migrate/20230914151243_add_external_to_tags.rb new file mode 100644 index 000000000..4c6edfc71 --- /dev/null +++ b/db/migrate/20230914151243_add_external_to_tags.rb @@ -0,0 +1,9 @@ +class AddExternalToTags < ActiveRecord::Migration[7.0] + def change + add_column :tags, :external, :boolean, default: false + Tag.all.each do |tag| + tag.external = (tag.name.match? '^slovensko.sk') + tag.save + end + end +end diff --git a/db/migrate/20230922090015_add_draft_tag_to_tenants.rb b/db/migrate/20230922090015_add_draft_tag_to_tenants.rb new file mode 100644 index 000000000..37c6bfdff --- /dev/null +++ b/db/migrate/20230922090015_add_draft_tag_to_tenants.rb @@ -0,0 +1,8 @@ +class AddDraftTagToTenants < ActiveRecord::Migration[7.0] + def change + Tenant.all.each do |tenant| + tenant.tags.find_or_create_by!(name: 'Drafts', external: false, visible: true) + tenant.save! + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 6b8ead85d..872e55442 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_09_20_093653) do +ActiveRecord::Schema[7.0].define(version: 2023_09_22_090015) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -18,6 +18,7 @@ # Custom types defined in this database. # Note that some types may not work with other database engines. Be careful if changing database. + create_enum "color", ["slate", "gray", "zinc", "neutral", "stone", "red", "orange", "amber", "yellow", "lime", "green", "emerald", "teal", "cyan", "sky", "blue", "indigo", "violet", "purple", "fuchsia", "pink", "rose"] create_enum "group_type", ["ALL", "USER", "CUSTOM", "ADMIN"] create_table "active_storage_attachments", force: :cascade do |t| @@ -85,6 +86,9 @@ t.datetime "updated_at", null: false t.bigint "tenant_id", null: false t.boolean "syncable", default: true, null: false + t.string "short_name" + t.enum "color", enum_type: "color" + t.index ["tenant_id", "short_name"], name: "index_boxes_on_tenant_id_and_short_name", unique: true t.index ["tenant_id"], name: "index_boxes_on_tenant_id" end @@ -358,6 +362,7 @@ t.datetime "updated_at", null: false t.boolean "visible", default: true, null: false t.bigint "user_id" + t.boolean "external", default: false t.index "tenant_id, lower((name)::text)", name: "index_tags_on_tenant_id_and_lowercase_name", unique: true t.index ["tenant_id"], name: "index_tags_on_tenant_id" t.index ["user_id"], name: "index_tags_on_user_id" diff --git a/db/seeds.rb b/db/seeds.rb index 929ca5d11..29af7ad86 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -8,8 +8,8 @@ tenant.users.find_or_create_by!(email: email, name: "Site ADMIN User #{i}") end -box = tenant.boxes.find_or_create_by!(name: "Dev box", uri: "ico://sk/83300252") -Govbox::ApiConnection.find_or_create_by!(sub: "SPL_Irvin_83300252_KK_24022023", box_id: box.id, api_token_private_key: File.read(Rails.root + "security/govbox_api_fix.pem")) +box = tenant.boxes.find_or_create_by!(name: "Dev box", uri: "ico://sk/83300252", short_name: 'DEV') +Govbox::ApiConnection.find_or_create_by!(sub: "SPL_Irvin_83300252_KK_24022023", box: box, api_token_private_key: File.read(Rails.root + "security/govbox_api_fix.pem")) tenant.tags.find_or_create_by!(name: 'NASES', user_id: tenant.users.first.id) diff --git a/test/fixtures/boxes.yml b/test/fixtures/boxes.yml index 3e16aab1c..fdd42f777 100644 --- a/test/fixtures/boxes.yml +++ b/test/fixtures/boxes.yml @@ -4,9 +4,10 @@ one: name: MyString uri: MyString tenant: solver + short_name: MY1 two: name: MyString uri: MyString tenant: solver - + short_name: MY2 diff --git a/test/fixtures/tags.yml b/test/fixtures/tags.yml index 043e1779f..482de69c7 100644 --- a/test/fixtures/tags.yml +++ b/test/fixtures/tags.yml @@ -2,10 +2,12 @@ one: name: MyString + external: false visible: true tenant: solver two: name: MyString2 + external: false visible: false tenant: solver diff --git a/test/models/govbox/message_test.rb b/test/models/govbox/message_test.rb index 3ff20fd16..16de9f86d 100644 --- a/test/models/govbox/message_test.rb +++ b/test/models/govbox/message_test.rb @@ -24,6 +24,7 @@ class Govbox::MessageTest < ActiveSupport::TestCase assert_equal message.tags.count, 1 assert_equal message.tags.first.name, "slovensko.sk:#{govbox_message.folder.name}" assert_equal message.tags.first.visible, false + assert_equal message.tags.first.external, true assert_equal message.thread.tags.count, 1 assert_equal message.tags.first, message.thread.tags.first end @@ -41,7 +42,7 @@ class Govbox::MessageTest < ActiveSupport::TestCase test "should not create new tag if already exists" do govbox_message = govbox_messages(:one) - tag = Tag.create!(name: "slovensko.sk:#{govbox_message.folder.name}", tenant: govbox_message.folder.box.tenant, visible: false) + tag = Tag.create!(name: "slovensko.sk:#{govbox_message.folder.name}", tenant: govbox_message.folder.box.tenant, visible: false, external: true) Govbox::Message.create_message_with_thread!(govbox_message) @@ -57,7 +58,7 @@ class Govbox::MessageTest < ActiveSupport::TestCase govbox_message1 = govbox_messages(:one) govbox_message2 = govbox_messages(:three) - tag = Tag.create!(name: "slovensko.sk:#{govbox_message1.folder.name}", tenant: govbox_message1.folder.box.tenant, visible: false) + tag = Tag.create!(name: "slovensko.sk:#{govbox_message1.folder.name}", tenant: govbox_message1.folder.box.tenant, visible: false, external: true) Govbox::Message.create_message_with_thread!(govbox_message1) message1 = Message.last