From 38fb7de203e68926b1257bbf924aa036aa2e9a05 Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Tue, 1 Oct 2024 15:44:32 +0400 Subject: [PATCH 01/17] WIP: added state machine for Answers, added admin answers page and etc... --- .../admin/comments/application_controller.rb | 4 ++ .../resumes_answers_comments_controller.rb | 29 ++++++++++++++ .../comments/resumes_answers_controller.rb | 40 +++++++++++++++++++ .../comments/resumes_comments_controller.rb | 11 +++++ app/models/resume/answer.rb | 36 ++++++++++++----- .../layouts/web/admin/application.html.slim | 3 ++ .../resumes_answers/_search_form.html.slim | 8 ++++ .../comments/resumes_answers/edit.html.slim | 3 ++ .../comments/resumes_answers/index.html.slim | 40 +++++++++++++++++++ .../comments/resumes_comments/index.html.slim | 14 +++++++ config/routes.rb | 15 +++++++ .../20240930104633_add_state_to_answer.rb | 5 +++ db/schema.rb | 3 +- test/factories/resume_answers.rb | 17 ++++---- test/fixtures/resume/answers.yml | 17 ++++---- test/models/resume/answer_test.rb | 17 ++++---- 16 files changed, 228 insertions(+), 34 deletions(-) create mode 100644 app/controllers/web/admin/comments/application_controller.rb create mode 100644 app/controllers/web/admin/comments/resumes_answers_comments_controller.rb create mode 100644 app/controllers/web/admin/comments/resumes_answers_controller.rb create mode 100644 app/controllers/web/admin/comments/resumes_comments_controller.rb create mode 100644 app/views/web/admin/comments/resumes_answers/_search_form.html.slim create mode 100644 app/views/web/admin/comments/resumes_answers/edit.html.slim create mode 100644 app/views/web/admin/comments/resumes_answers/index.html.slim create mode 100644 app/views/web/admin/comments/resumes_comments/index.html.slim create mode 100644 db/migrate/20240930104633_add_state_to_answer.rb diff --git a/app/controllers/web/admin/comments/application_controller.rb b/app/controllers/web/admin/comments/application_controller.rb new file mode 100644 index 000000000..9b1dd17b5 --- /dev/null +++ b/app/controllers/web/admin/comments/application_controller.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class Web::Admin::Comments::ApplicationController < Web::Admin::ApplicationController +end diff --git a/app/controllers/web/admin/comments/resumes_answers_comments_controller.rb b/app/controllers/web/admin/comments/resumes_answers_comments_controller.rb new file mode 100644 index 000000000..c50cc494e --- /dev/null +++ b/app/controllers/web/admin/comments/resumes_answers_comments_controller.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class Web::Admin::Comments::ResumesAnswersCommentsController < Web::Admin::Comments::ApplicationController + before_action :set_answers_comment, only: %i[edit update archive restore] + + def edit; end + + def update + if @comment.update(comment_params) + redirect_to admin_resumes_answers_path + else + render :edit + end + end + + def archive; end + + def restore; end + + private + + def set_answers_comment + @comment = Resume::Answer::Comment.find(params[:id]) + end + + def comment_params + params.require(:resume_answer_comment).permit(:content) + end +end diff --git a/app/controllers/web/admin/comments/resumes_answers_controller.rb b/app/controllers/web/admin/comments/resumes_answers_controller.rb new file mode 100644 index 000000000..a27a2d10e --- /dev/null +++ b/app/controllers/web/admin/comments/resumes_answers_controller.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +class Web::Admin::Comments::ResumesAnswersController < Web::Admin::Comments::ApplicationController + before_action :set_answer, only: %i[edit update archive restore] + + def index + @search = Resume::Answer.web.includes(comments: :user).ransack(params[:q]) + @resumes_answers = @search.result(sort: 'created_at desc').page(params[:page]) + end + + def edit; end + + def update + if @answer.update(answer_params) + redirect_to admin_resumes_answers_path + else + render :edit + end + end + + def archive + @answer.archive! if @answer.may_archive? + redirect_to admin_resumes_answers_path, notice: t('.success') + end + + def restore + @answer.restore! if @answer.may_restore? + redirect_to admin_resumes_answers_path, notice: t('.success') + end + + private + + def set_answer + @answer = Resume::Answer.find(params[:id]) + end + + def answer_params + params.require(:resume_answer) + end +end diff --git a/app/controllers/web/admin/comments/resumes_comments_controller.rb b/app/controllers/web/admin/comments/resumes_comments_controller.rb new file mode 100644 index 000000000..7b8701d3e --- /dev/null +++ b/app/controllers/web/admin/comments/resumes_comments_controller.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class Web::Admin::Comments::ResumesCommentsController < Web::Admin::Comments::ApplicationController + def index + @resume_comments = Resume::Comment.includes(:user, :resume) + @resume_answers = Resume::Answer.includes(:user, :resume, comments: :user).ransack(params[:q]) + + @search = Resume::Comment.ransack(params[:q]) + @resumes_comments = @search.result(sort: 'created_at desc').includes(:resume).page(params[:page]) + end +end diff --git a/app/models/resume/answer.rb b/app/models/resume/answer.rb index b69ab12fc..62021ed13 100644 --- a/app/models/resume/answer.rb +++ b/app/models/resume/answer.rb @@ -4,14 +4,15 @@ # # Table name: resume_answers # -# id :integer not null, primary key -# applying_state :string -# content :text -# likes_count :integer -# created_at :datetime not null -# updated_at :datetime not null -# resume_id :integer not null -# user_id :integer not null +# id :integer not null, primary key +# applying_state :string +# content :text +# likes_count :integer +# publishing_state :string default("published") +# created_at :datetime not null +# updated_at :datetime not null +# resume_id :integer not null +# user_id :integer not null # # Indexes # @@ -46,6 +47,19 @@ class Resume::Answer < ApplicationRecord end end + aasm :publishing, column: :publishing_state do + state :published, initial: true + state :archived + + event :archive do + transitions from: :published, to: :archived + end + + event :restore do + transitions from: :archived, to: :published + end + end + def to_s content end @@ -59,6 +73,10 @@ def tota_ai_author? end def self.ransackable_attributes(_auth_object = nil) - %w[user_id] + %w[id user_id publishing_state created_at] + end + + def self.ransackable_associations(_auth_object = nil) + %w[comments likes notifications resume user] end end diff --git a/app/views/layouts/web/admin/application.html.slim b/app/views/layouts/web/admin/application.html.slim index 12d1ea82c..3d7587b9a 100644 --- a/app/views/layouts/web/admin/application.html.slim +++ b/app/views/layouts/web/admin/application.html.slim @@ -15,6 +15,9 @@ html.h-100 lang="#{I18n.locale}" = sidebar_menu_item t('.admins'), 'bi-person-fill-gear', admin_root_path = sidebar_menu_item t('.all_users'), 'bi-people', admin_users_path = sidebar_menu_item t('.all_resumes'), 'bi-card-text', admin_resumes_path + = sidebar_menu_divider t('.comments') + = sidebar_menu_item t('.resume_comments'), 'bi-chat-dots', admin_resumes_comments_path + = sidebar_menu_item t('.resume_answers'), 'bi-chat-dots', admin_resumes_answers_path = sidebar_menu_divider t('.vacancies') = sidebar_menu_item t('.on_moderate'), 'bi-briefcase', on_moderate_admin_vacancies_path = sidebar_menu_item t('.all_vacancies'), 'bi-briefcase-fill', admin_vacancies_path diff --git a/app/views/web/admin/comments/resumes_answers/_search_form.html.slim b/app/views/web/admin/comments/resumes_answers/_search_form.html.slim new file mode 100644 index 000000000..ba1175b25 --- /dev/null +++ b/app/views/web/admin/comments/resumes_answers/_search_form.html.slim @@ -0,0 +1,8 @@ +.p-3.mb-3.bg-light + = search_form_for q, default_filter_form_options(url: url_for) do |f| + = f.input :resume_name_cont, placeholder: han('resume', :name), label: false + = f.input :user_email_cont, placeholder: han('user', :email), label: false + = f.input :publishing_state_eq, as: :select, collection: states_for_select(Resume::Answer, :publishing), label: false + .col.d-flex.align-self-end + = f.button :submit, class: 'btn-primary me-2 flex-grow-1' + = link_to t('reset'), url_for, class: 'btn btn-outline-primary' diff --git a/app/views/web/admin/comments/resumes_answers/edit.html.slim b/app/views/web/admin/comments/resumes_answers/edit.html.slim new file mode 100644 index 000000000..73654e555 --- /dev/null +++ b/app/views/web/admin/comments/resumes_answers/edit.html.slim @@ -0,0 +1,3 @@ += simple_form_for @answer, url: admin_resumes_answer_path(@answer) do |f| + = f.input :content, label: false, input_html: { rows: 12 } + = f.button :submit, class: 'btn btn-success' diff --git a/app/views/web/admin/comments/resumes_answers/index.html.slim b/app/views/web/admin/comments/resumes_answers/index.html.slim new file mode 100644 index 000000000..89f3455e1 --- /dev/null +++ b/app/views/web/admin/comments/resumes_answers/index.html.slim @@ -0,0 +1,40 @@ += render 'search_form', q: @search + +table.table + thead + tr + th = sort_link(@search, 'id') + th = sort_link(@search, 'resume_name') + th = sort_link(@search, 'user_email') + th = sort_link(@search, 'content') + th = sort_link(@search, 'publishing_state') + th = sort_link(@search, 'created_at') + th = t('actions') + tbody + - @resumes_answers.each do |answer| + tr + td = link_to answer.id, resume_path(answer.resume, anchor: "answer-#{answer.id}") + td = link_to answer.resume.name, resume_path(answer.resume) + td = link_to answer.user.email, user_path(answer.user) + td = answer.content + td = answer.publishing_state + td = l(answer.created_at, format: :short) + td + .btn-group[role='group' aria-label="#{t('action_buttons')}"] + = link_to edit_admin_resumes_answer_path(answer), class: 'btn btn-outline-primary btn-sm', title: t('.edit') do + span.bi.bi-gear-fill + - if answer.may_restore? + = link_to restore_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-success btn-sm', data: { confirm: t('.confirm_restore') }, title: t('.restore') do + span.bi.bi-arrow-counterclockwise + - elsif answer.may_archive? + = link_to archive_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive') }, title: t('.archive') do + span.bi.bi-trash3 + - answer.comments.each do |comment| + tr + td = comment.id + td = '-' + td = comment.user.email + td = comment.content + td = '-' + td = comment.created_at + td = '-' diff --git a/app/views/web/admin/comments/resumes_comments/index.html.slim b/app/views/web/admin/comments/resumes_comments/index.html.slim new file mode 100644 index 000000000..6d5768868 --- /dev/null +++ b/app/views/web/admin/comments/resumes_comments/index.html.slim @@ -0,0 +1,14 @@ +table.table + thead + tr + th = 'id' + th = 'resume' + th = 'user' + th = 'content' + tbody + - @resumes_comments.each do |comment| + tr + td = comment.id + td = link_to comment.resume.name, resume_path(comment.resume) + td = comment.user.email + td = comment.content diff --git a/config/routes.rb b/config/routes.rb index b67fd374d..ff7bf10fb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -99,6 +99,21 @@ get :lost end end + scope module: :comments do + resources :resumes_comments do + member do + patch :archive + patch :restore + end + end + resources :resumes_answers do + member do + patch :archive + patch :restore + end + end + end + resources :resumes, only: %i[index edit update] do member do patch :archive diff --git a/db/migrate/20240930104633_add_state_to_answer.rb b/db/migrate/20240930104633_add_state_to_answer.rb new file mode 100644 index 000000000..8e76f5402 --- /dev/null +++ b/db/migrate/20240930104633_add_state_to_answer.rb @@ -0,0 +1,5 @@ +class AddStateToAnswer < ActiveRecord::Migration[7.1] + def change + add_column :resume_answers, :publishing_state, :string, default: 'published' + end +end diff --git a/db/schema.rb b/db/schema.rb index 870a13ef0..5cf246658 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.1].define(version: 2024_07_07_200834) do +ActiveRecord::Schema[7.1].define(version: 2024_09_30_104633) do create_table "career_items", force: :cascade do |t| t.integer "order" t.integer "career_id", null: false @@ -165,6 +165,7 @@ t.datetime "updated_at", null: false t.integer "likes_count" t.string "applying_state" + t.string "publishing_state", default: "published" t.index ["resume_id"], name: "index_resume_answers_on_resume_id" t.index ["user_id", "resume_id"], name: "index_resume_answers_on_user_id_and_resume_id", unique: true t.index ["user_id"], name: "index_resume_answers_on_user_id" diff --git a/test/factories/resume_answers.rb b/test/factories/resume_answers.rb index 4b1e732a4..7185463b5 100644 --- a/test/factories/resume_answers.rb +++ b/test/factories/resume_answers.rb @@ -4,14 +4,15 @@ # # Table name: resume_answers # -# id :integer not null, primary key -# applying_state :string -# content :text -# likes_count :integer -# created_at :datetime not null -# updated_at :datetime not null -# resume_id :integer not null -# user_id :integer not null +# id :integer not null, primary key +# applying_state :string +# content :text +# likes_count :integer +# publishing_state :string default("published") +# created_at :datetime not null +# updated_at :datetime not null +# resume_id :integer not null +# user_id :integer not null # # Indexes # diff --git a/test/fixtures/resume/answers.yml b/test/fixtures/resume/answers.yml index e19b70894..7d6ceabee 100644 --- a/test/fixtures/resume/answers.yml +++ b/test/fixtures/resume/answers.yml @@ -2,14 +2,15 @@ # # Table name: resume_answers # -# id :integer not null, primary key -# applying_state :string -# content :text -# likes_count :integer -# created_at :datetime not null -# updated_at :datetime not null -# resume_id :integer not null -# user_id :integer not null +# id :integer not null, primary key +# applying_state :string +# content :text +# likes_count :integer +# publishing_state :string default("published") +# created_at :datetime not null +# updated_at :datetime not null +# resume_id :integer not null +# user_id :integer not null # # Indexes # diff --git a/test/models/resume/answer_test.rb b/test/models/resume/answer_test.rb index 5674e2169..ad09b0afd 100644 --- a/test/models/resume/answer_test.rb +++ b/test/models/resume/answer_test.rb @@ -4,14 +4,15 @@ # # Table name: resume_answers # -# id :integer not null, primary key -# applying_state :string -# content :text -# likes_count :integer -# created_at :datetime not null -# updated_at :datetime not null -# resume_id :integer not null -# user_id :integer not null +# id :integer not null, primary key +# applying_state :string +# content :text +# likes_count :integer +# publishing_state :string default("published") +# created_at :datetime not null +# updated_at :datetime not null +# resume_id :integer not null +# user_id :integer not null # # Indexes # From d25b06aada11918157f5cfa3ddc64a23152c153b Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Wed, 2 Oct 2024 15:17:07 +0400 Subject: [PATCH 02/17] WIP: updated i18n --- .../comments/resumes_answers_controller.rb | 21 ++++++++++++++----- .../comments/resumes_answers/edit.html.slim | 4 ++-- config/locales/admin/en.flash.yml | 11 ++++++++++ config/locales/admin/en.yml | 5 +++++ config/locales/admin/ru.flash.yml | 11 ++++++++++ config/locales/admin/ru.layouts.yml | 3 +++ config/locales/admin/ru.yml | 18 +++++++++------- config/locales/en.activerecord.yml | 2 ++ config/locales/ru.activerecord.yml | 3 +++ 9 files changed, 64 insertions(+), 14 deletions(-) diff --git a/app/controllers/web/admin/comments/resumes_answers_controller.rb b/app/controllers/web/admin/comments/resumes_answers_controller.rb index a27a2d10e..3f5962c8a 100644 --- a/app/controllers/web/admin/comments/resumes_answers_controller.rb +++ b/app/controllers/web/admin/comments/resumes_answers_controller.rb @@ -12,20 +12,31 @@ def edit; end def update if @answer.update(answer_params) + f(:success) redirect_to admin_resumes_answers_path else - render :edit + f(:error) + render :edit, status: :unprocessable_entity end end def archive - @answer.archive! if @answer.may_archive? - redirect_to admin_resumes_answers_path, notice: t('.success') + return unless @answer.may_archive? + + if @answer.archive! + f(:success) + else + f(:error) + end + + redirect_to admin_resumes_answers_path end def restore @answer.restore! if @answer.may_restore? - redirect_to admin_resumes_answers_path, notice: t('.success') + + f(:success) + redirect_to admin_resumes_answers_path end private @@ -35,6 +46,6 @@ def set_answer end def answer_params - params.require(:resume_answer) + params.require(:resume_answer).permit(:content) end end diff --git a/app/views/web/admin/comments/resumes_answers/edit.html.slim b/app/views/web/admin/comments/resumes_answers/edit.html.slim index 73654e555..4e9349c79 100644 --- a/app/views/web/admin/comments/resumes_answers/edit.html.slim +++ b/app/views/web/admin/comments/resumes_answers/edit.html.slim @@ -1,3 +1,3 @@ = simple_form_for @answer, url: admin_resumes_answer_path(@answer) do |f| - = f.input :content, label: false, input_html: { rows: 12 } - = f.button :submit, class: 'btn btn-success' + = f.input :content, input_html: { rows: 12 } + .mt-2 = f.button :submit, class: 'btn btn-success' diff --git a/config/locales/admin/en.flash.yml b/config/locales/admin/en.flash.yml index 6fc435adc..bdc028427 100644 --- a/config/locales/admin/en.flash.yml +++ b/config/locales/admin/en.flash.yml @@ -40,6 +40,17 @@ en: update: success: Resume updated successfully error: "Failed to update job vacancy. Please correct errors in the form: %{messages}" + comments: + resumes_answers: + archive: + success: Answer on resume successfully archived + error: Failed to archive answer + restore: + success: Answer on resume successfully restored + error: Failed to restore answer + update: + success: Answer on resume successfully updated + error: Failed to update answer vacancies: cancel: success: Vacancy canceled successfull diff --git a/config/locales/admin/en.yml b/config/locales/admin/en.yml index a770ec0d1..1a564a900 100644 --- a/config/locales/admin/en.yml +++ b/config/locales/admin/en.yml @@ -69,6 +69,11 @@ en: restore: Restore archive: Archive last_satep_finished_at: Last activity date + comments: + resumes_answers: + index: + confirm_archive: Are you sure you want to archive answer? + confirm_restore: Are you sure you want to restore answer? resumes: index: edit: Edit CV diff --git a/config/locales/admin/ru.flash.yml b/config/locales/admin/ru.flash.yml index 6b2fc6f8b..b1b2fa955 100644 --- a/config/locales/admin/ru.flash.yml +++ b/config/locales/admin/ru.flash.yml @@ -40,6 +40,17 @@ ru: update: success: Резюме успешно обновленно error: Не удалось обновить резюме... Проверьте данные в форме и попробуйте еще раз. + comments: + resumes_answers: + archive: + success: Ответ на резюме успешно архивирован + error: Не удалось архивировать ответ на резюме + restore: + success: Ответ на резюме успешно восстановлен + error: Не удалось восстановить ответ на резюме + update: + success: Ответ на резюме успешно обновлен + error: Не удалось обновить ответ на резюме vacancies: archive: success: Вакансия успешно архивирована diff --git a/config/locales/admin/ru.layouts.yml b/config/locales/admin/ru.layouts.yml index a3df1bac9..0489ce6b5 100644 --- a/config/locales/admin/ru.layouts.yml +++ b/config/locales/admin/ru.layouts.yml @@ -7,6 +7,9 @@ ru: admins: Администраторы all_users: Пользователи all_resumes: Резюме + comments: Комментарии + resume_comments: Комментарии к резюме + resume_answers: Ответы на резюме vacancies: Вакансии on_moderate: На модерации all_vacancies: Все вакансии diff --git a/config/locales/admin/ru.yml b/config/locales/admin/ru.yml index a7409ed09..6aa1de176 100644 --- a/config/locales/admin/ru.yml +++ b/config/locales/admin/ru.yml @@ -29,7 +29,7 @@ ru: users_lost_career: Студенты которые давно не учились show: user_id_html: 'ID: %{id}' - email: 'email: %{email}' + email: "email: %{email}" last_activity_at: Последняя активность progress: Прогресс current_step: Текущий шаг @@ -65,6 +65,11 @@ ru: archive: Архивировать restore: Восстановить last_satep_finished_at: Дата последней активности + comments: + resumes_answers: + index: + confirm_archive: Вы уверенны что хотите архивировать ответ? + confirm_restore: Вы уверенны что хотите восстановить ответ? resumes: index: edit: Редактировать резюме @@ -83,8 +88,8 @@ ru: new: Новая вакансия search_form: creator: имя/фамилия/почта - created_at_from: 'Дата создания с:' - created_at_to: 'по:' + created_at_from: "Дата создания с:" + created_at_to: "по:" new: new_vacancy: Новая вакансия edit: @@ -122,7 +127,7 @@ ru: show: edit: Редактировать users_career: Студенты проходящие карьерный трек - career_track: 'Карьерный трек: %{name}' + career_track: "Карьерный трек: %{name}" steps: Шаги карьерного трека new: cancel: Отменить @@ -151,8 +156,8 @@ ru: no_date: Не завершен steps: edit: - step: 'Шаг: %{name}' - attached_careers: 'Связанные карьерные треки:' + step: "Шаг: %{name}" + attached_careers: "Связанные карьерные треки:" form: notification: Если требуется студенту отправить уведомление cancel: Отменить @@ -200,4 +205,3 @@ ru: edit: Редактировать show: step: Шаг карьерного трека - diff --git a/config/locales/en.activerecord.yml b/config/locales/en.activerecord.yml index 76263c53f..1cd7afbab 100644 --- a/config/locales/en.activerecord.yml +++ b/config/locales/en.activerecord.yml @@ -29,6 +29,8 @@ en: content: Answer applying_state/pending: Awaiting confirmation applying_state/applied: Changes applied + publishing_state/published: Published + publishing_state/archived: Archived resume/job: content: Description resume/comment: diff --git a/config/locales/ru.activerecord.yml b/config/locales/ru.activerecord.yml index b31c2c29e..4d186da0d 100644 --- a/config/locales/ru.activerecord.yml +++ b/config/locales/ru.activerecord.yml @@ -139,8 +139,11 @@ ru: about_myself: О себе resume/answer: content: Ответ + publishing_state: Опубликован? applying_state/pending: Ожидает подтверждения applying_state/applied: Изменения внесены + publishing_state/published: Опубликован + publishing_state/archived: В архиве resume/job: content: Описание resume/work: From f87130c78e7e65cac2f4347b468dd49115e166df Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Wed, 2 Oct 2024 15:36:26 +0400 Subject: [PATCH 03/17] WIP: Updated search form, added search for content and date of create --- app/models/resume/answer.rb | 2 +- .../web/admin/comments/resumes_answers/_search_form.html.slim | 3 +++ config/locales/admin/en.yml | 3 +++ config/locales/admin/ru.yml | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/resume/answer.rb b/app/models/resume/answer.rb index 62021ed13..49bf1a1ab 100644 --- a/app/models/resume/answer.rb +++ b/app/models/resume/answer.rb @@ -73,7 +73,7 @@ def tota_ai_author? end def self.ransackable_attributes(_auth_object = nil) - %w[id user_id publishing_state created_at] + %w[id content user_id publishing_state created_at] end def self.ransackable_associations(_auth_object = nil) diff --git a/app/views/web/admin/comments/resumes_answers/_search_form.html.slim b/app/views/web/admin/comments/resumes_answers/_search_form.html.slim index ba1175b25..073fb406b 100644 --- a/app/views/web/admin/comments/resumes_answers/_search_form.html.slim +++ b/app/views/web/admin/comments/resumes_answers/_search_form.html.slim @@ -2,7 +2,10 @@ = search_form_for q, default_filter_form_options(url: url_for) do |f| = f.input :resume_name_cont, placeholder: han('resume', :name), label: false = f.input :user_email_cont, placeholder: han('user', :email), label: false + = f.input :content_cont, placeholder: han('Resume::Answer', :content), label: false = f.input :publishing_state_eq, as: :select, collection: states_for_select(Resume::Answer, :publishing), label: false + = f.input :created_at_gteq, as: :date, html5: true, label: t('.created_at_from') + = f.input :created_at_lteq, as: :date, html5: true, label: t('.created_at_to') .col.d-flex.align-self-end = f.button :submit, class: 'btn-primary me-2 flex-grow-1' = link_to t('reset'), url_for, class: 'btn btn-outline-primary' diff --git a/config/locales/admin/en.yml b/config/locales/admin/en.yml index 1a564a900..c0d143268 100644 --- a/config/locales/admin/en.yml +++ b/config/locales/admin/en.yml @@ -74,6 +74,9 @@ en: index: confirm_archive: Are you sure you want to archive answer? confirm_restore: Are you sure you want to restore answer? + search_form: + created_at_from: 'Creation date from:' + created_at_to: 'By:' resumes: index: edit: Edit CV diff --git a/config/locales/admin/ru.yml b/config/locales/admin/ru.yml index 6aa1de176..b08f9c13a 100644 --- a/config/locales/admin/ru.yml +++ b/config/locales/admin/ru.yml @@ -70,6 +70,9 @@ ru: index: confirm_archive: Вы уверенны что хотите архивировать ответ? confirm_restore: Вы уверенны что хотите восстановить ответ? + search_form: + created_at_from: "Дата создания с:" + created_at_to: "по:" resumes: index: edit: Редактировать резюме From 0dd51e89c285386ceae662b02fb85da7f0101b50 Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Wed, 2 Oct 2024 20:36:39 +0400 Subject: [PATCH 04/17] WIP: Updated view --- .../comments/resumes_answers_controller.rb | 11 ++++------- .../comments/resumes_answers/index.html.slim | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/controllers/web/admin/comments/resumes_answers_controller.rb b/app/controllers/web/admin/comments/resumes_answers_controller.rb index 3f5962c8a..3bff215fe 100644 --- a/app/controllers/web/admin/comments/resumes_answers_controller.rb +++ b/app/controllers/web/admin/comments/resumes_answers_controller.rb @@ -23,18 +23,15 @@ def update def archive return unless @answer.may_archive? - if @answer.archive! - f(:success) - else - f(:error) - end - + @answer.archive! + f(:success) redirect_to admin_resumes_answers_path end def restore - @answer.restore! if @answer.may_restore? + return unless @answer.may_restore? + @answer.restore! f(:success) redirect_to admin_resumes_answers_path end diff --git a/app/views/web/admin/comments/resumes_answers/index.html.slim b/app/views/web/admin/comments/resumes_answers/index.html.slim index 89f3455e1..0a042a798 100644 --- a/app/views/web/admin/comments/resumes_answers/index.html.slim +++ b/app/views/web/admin/comments/resumes_answers/index.html.slim @@ -4,6 +4,7 @@ table.table thead tr th = sort_link(@search, 'id') + th = sort_link(@search, 'comment_id') th = sort_link(@search, 'resume_name') th = sort_link(@search, 'user_email') th = sort_link(@search, 'content') @@ -12,8 +13,9 @@ table.table th = t('actions') tbody - @resumes_answers.each do |answer| - tr + tr.table-light td = link_to answer.id, resume_path(answer.resume, anchor: "answer-#{answer.id}") + td = answer.comments.count td = link_to answer.resume.name, resume_path(answer.resume) td = link_to answer.user.email, user_path(answer.user) td = answer.content @@ -31,10 +33,13 @@ table.table span.bi.bi-trash3 - answer.comments.each do |comment| tr - td = comment.id - td = '-' - td = comment.user.email + td + td = link_to comment.id, resume_path(answer.resume, anchor: "answer_comment-#{comment.id}") + td + td = link_to comment.user.email, user_path(comment.user.email) td = comment.content - td = '-' - td = comment.created_at - td = '-' + td + td = l(answer.created_at, format: :short) + td + += paginate @resumes_answers From d0983d0fc047949cbc2445075d318d4963f8a5dc Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Wed, 2 Oct 2024 20:36:39 +0400 Subject: [PATCH 05/17] WIP: Updated view --- app/models/resume/answer/comment.rb | 8 + .../comments/resumes_answers/index.html.slim | 189 ++++++++++++++---- 2 files changed, 156 insertions(+), 41 deletions(-) diff --git a/app/models/resume/answer/comment.rb b/app/models/resume/answer/comment.rb index 82fd5ae84..685ead608 100644 --- a/app/models/resume/answer/comment.rb +++ b/app/models/resume/answer/comment.rb @@ -45,4 +45,12 @@ def to_s def author?(user) user_id == user.id end + + def self.ransackable_associations(_auth_object = nil) + %w[answer answer_user notifications resume user] + end + + def self.ransackable_attributes(_auth_object = nil) + %w[answer_id answer_user_id content created_at id id_value resume_id updated_at user_id] + end end diff --git a/app/views/web/admin/comments/resumes_answers/index.html.slim b/app/views/web/admin/comments/resumes_answers/index.html.slim index 0a042a798..edf798fce 100644 --- a/app/views/web/admin/comments/resumes_answers/index.html.slim +++ b/app/views/web/admin/comments/resumes_answers/index.html.slim @@ -1,45 +1,152 @@ = render 'search_form', q: @search -table.table - thead - tr - th = sort_link(@search, 'id') - th = sort_link(@search, 'comment_id') - th = sort_link(@search, 'resume_name') - th = sort_link(@search, 'user_email') - th = sort_link(@search, 'content') - th = sort_link(@search, 'publishing_state') - th = sort_link(@search, 'created_at') - th = t('actions') - tbody - - @resumes_answers.each do |answer| - tr.table-light - td = link_to answer.id, resume_path(answer.resume, anchor: "answer-#{answer.id}") - td = answer.comments.count - td = link_to answer.resume.name, resume_path(answer.resume) - td = link_to answer.user.email, user_path(answer.user) - td = answer.content - td = answer.publishing_state - td = l(answer.created_at, format: :short) - td - .btn-group[role='group' aria-label="#{t('action_buttons')}"] - = link_to edit_admin_resumes_answer_path(answer), class: 'btn btn-outline-primary btn-sm', title: t('.edit') do - span.bi.bi-gear-fill - - if answer.may_restore? - = link_to restore_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-success btn-sm', data: { confirm: t('.confirm_restore') }, title: t('.restore') do - span.bi.bi-arrow-counterclockwise - - elsif answer.may_archive? - = link_to archive_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive') }, title: t('.archive') do - span.bi.bi-trash3 - - answer.comments.each do |comment| - tr - td - td = link_to comment.id, resume_path(answer.resume, anchor: "answer_comment-#{comment.id}") - td - td = link_to comment.user.email, user_path(comment.user.email) - td = comment.content - td - td = l(answer.created_at, format: :short) - td +- @resumes_answers.each do |answer| + .card.mb-2 + .card-body + .row + .col-3 + .row + .col-4 + strong ID: + .col-8 + = link_to answer.id, resume_path(answer.resume, anchor: "answer-#{answer.id}") + .row + .col-4 + strong Resume: + .col-8 + = link_to answer.resume.name, resume_path(answer.resume) + .row + .col-4 + strong Comments: + .col-8 + = answer.comments.count + .row + .col-4 + strong User: + .col-8 + = link_to answer.user.email, user_path(answer.user) + .col-7 + .row + == markdown2html answer.content, details: true + .col-2 + .row + .btn-group[role='group' aria-label="#{t('action_buttons')}"] + = link_to edit_admin_resumes_answer_path(answer), class: 'btn btn-outline-primary btn-sm', title: t('.edit') do + span.bi.bi-gear-fill + - if answer.may_restore? + = link_to restore_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-success btn-sm', data: { confirm: t('.confirm_restore') }, title: t('.restore') do + span.bi.bi-arrow-counterclockwise + - elsif answer.may_archive? + = link_to archive_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive') }, title: t('.archive') do + span.bi.bi-trash3 + +/ table.table +/ thead +/ tr +/ th = 'info' +/ th = 'content' +/ th = t('actions') +/ tbody +/ - @resumes_answers.each do |answer| +/ tr +/ td +/ .row +/ .row +/ .col +/ strong ID: +/ .col +/ = link_to answer.id, resume_path(answer.resume, anchor: "answer-#{answer.id}") +/ .row +/ .col +/ strong Resume: +/ .col +/ = link_to answer.resume.name, resume_path(answer.resume) +/ .row +/ .col +/ strong Comments: +/ .col +/ = answer.comments.count +/ .row +/ .col +/ strong User: +/ .col +/ = link_to answer.user.email, user_path(answer.user) +/ .row +/ .col +/ strong Created: +/ .col +/ = l(answer.created_at, format: :long) +/ .row +/ .col +/ strong Published: +/ .col +/ = answer.publishing_state +/ .row +/ .col colspan="2" +/ - if answer.comments.any? +/ button.w-100 class="btn btn-outline-primary btn-sm" type="button" data-bs-toggle="collapse" data-bs-target="#comments-#{answer.id}" aria-expanded="false" aria-controls="comments-#{answer.id}" +/ span.bi.bi-chat-dots-fill +/ span = t('show_comments', count: answer.comments.count) +/ td == markdown2html answer.content, details: true +/ td +/ .btn-group[role='group' aria-label="#{t('action_buttons')}"] +/ = link_to edit_admin_resumes_answer_path(answer), class: 'btn btn-outline-primary btn-sm', title: t('.edit') do +/ span.bi.bi-gear-fill +/ - if answer.may_restore? +/ = link_to restore_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-success btn-sm', data: { confirm: t('.confirm_restore') }, title: t('.restore') do +/ span.bi.bi-arrow-counterclockwise +/ - elsif answer.may_archive? +/ = link_to archive_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive') }, title: t('.archive') do +/ span.bi.bi-trash3 +/ tr.collapse(id="comments-#{answer.id}") +/ td.colspan-3 +/ - if answer.comments.any? +/ ul +/ - answer.comments.each do |comment| +/ li = "#{comment.user.email}: #{comment.content}" +/ - else +/ p No comments available + +/ table.table +/ thead +/ tr +/ th = sort_link(@search, 'id') +/ th = sort_link(@search, 'comment_id') +/ th = sort_link(@search, 'resume_name') +/ th = sort_link(@search, 'user_email') +/ th = sort_link(@search, 'content') +/ th = sort_link(@search, 'publishing_state') +/ th = sort_link(@search, 'created_at') +/ th = t('actions') +/ tbody +/ - @resumes_answers.each do |answer| +/ tr.table-light +/ td = link_to answer.id, resume_path(answer.resume, anchor: "answer-#{answer.id}") +/ td = answer.comments.count +/ td = link_to answer.resume.name, resume_path(answer.resume) +/ td = link_to answer.user.email, user_path(answer.user) +/ td = answer.content +/ td = answer.publishing_state +/ td = l(answer.created_at, format: :short) +/ td +/ .btn-group[role='group' aria-label="#{t('action_buttons')}"] +/ = link_to edit_admin_resumes_answer_path(answer), class: 'btn btn-outline-primary btn-sm', title: t('.edit') do +/ span.bi.bi-gear-fill +/ - if answer.may_restore? +/ = link_to restore_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-success btn-sm', data: { confirm: t('.confirm_restore') }, title: t('.restore') do +/ span.bi.bi-arrow-counterclockwise +/ - elsif answer.may_archive? +/ = link_to archive_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive') }, title: t('.archive') do +/ span.bi.bi-trash3 +/ - answer.comments.each do |comment| +/ tr +/ td +/ td = link_to comment.id, resume_path(answer.resume, anchor: "answer_comment-#{comment.id}") +/ td +/ td = link_to comment.user.email, user_path(comment.user.email) +/ td = comment.content +/ td +/ td = l(answer.created_at, format: :short) +/ td = paginate @resumes_answers From 42bb9d92d2620fc1f39aeb7e660825f4601cff3d Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Wed, 2 Oct 2024 20:36:39 +0400 Subject: [PATCH 06/17] WIP: Updated view --- .../comments/resumes_answers/index.html.slim | 65 ++++++++++++------- config/locales/admin/en.yml | 1 + config/locales/admin/ru.yml | 1 + 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/app/views/web/admin/comments/resumes_answers/index.html.slim b/app/views/web/admin/comments/resumes_answers/index.html.slim index edf798fce..95151da13 100644 --- a/app/views/web/admin/comments/resumes_answers/index.html.slim +++ b/app/views/web/admin/comments/resumes_answers/index.html.slim @@ -2,34 +2,14 @@ - @resumes_answers.each do |answer| .card.mb-2 - .card-body + .card-header.bg-white .row .col-3 - .row - .col-4 - strong ID: - .col-8 - = link_to answer.id, resume_path(answer.resume, anchor: "answer-#{answer.id}") - .row - .col-4 - strong Resume: - .col-8 - = link_to answer.resume.name, resume_path(answer.resume) - .row - .col-4 - strong Comments: - .col-8 - = answer.comments.count - .row - .col-4 - strong User: - .col-8 - = link_to answer.user.email, user_path(answer.user) + .fw-bold = link_to "##{answer.id}", resume_path(answer.resume, anchor: "answer-#{answer.id}") .col-7 - .row - == markdown2html answer.content, details: true + = link_to t('.answer_for', resume: answer.resume.name), resume_path(answer.resume) .col-2 - .row + .d-flex.align-items-end.flex-column .btn-group[role='group' aria-label="#{t('action_buttons')}"] = link_to edit_admin_resumes_answer_path(answer), class: 'btn btn-outline-primary btn-sm', title: t('.edit') do span.bi.bi-gear-fill @@ -39,6 +19,43 @@ - elsif answer.may_archive? = link_to archive_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive') }, title: t('.archive') do span.bi.bi-trash3 + .card-body + .row + .col-3 + .row#info + .mb-2 + strong.me-1 User: + = link_to "#{answer.user.first_name} #{answer.user.last_name}", user_path(answer.user) + .mb-2 + strong.me-1 = "#{Resume::Answer.human_attribute_name(:email)}:" + = link_to answer.user.email, user_path(answer.user) + .mb-2 + strong.me-1 = "#{Resume::Answer.human_attribute_name(:created_at)}:" + = l(answer.created_at, format: :short) + .mb-2 + strong.me-1 = "#{Resume::Answer.human_attribute_name(:likes_count)}:" + = answer.likes_count + .mb-2 + strong.me-1 = "#{Resume::Answer.human_attribute_name(:applying_state)}:" + = answer.applying_state + .mb-2 + strong.me-1 = "#{Resume::Answer.human_attribute_name(:publishing_state)}:" + = answer.publishing_state + .d-flex.align-items-start.flex-column#show-comment + - if answer.comments.any? + button class="btn btn-outline-primary btn-sm mt-auto" type="button" data-bs-toggle="collapse" data-bs-target="#comments-#{answer.id}" aria-expanded="false" aria-controls="comments-#{answer.id}" + span.bi.bi-chat-dots-fill + span = t('show_comments', count: answer.comments.count) + .col + .row + == markdown2html answer.content, details: true + - if answer.comments.any? + .row + .col-3 + .col-9 + / - answer.comments.each do |comment| + / .card.collapse(id="comments-#{answer.id}") + / .card-body / table.table / thead diff --git a/config/locales/admin/en.yml b/config/locales/admin/en.yml index c0d143268..6fec2b79d 100644 --- a/config/locales/admin/en.yml +++ b/config/locales/admin/en.yml @@ -74,6 +74,7 @@ en: index: confirm_archive: Are you sure you want to archive answer? confirm_restore: Are you sure you want to restore answer? + answer_for: "Answer for %{resume}" search_form: created_at_from: 'Creation date from:' created_at_to: 'By:' diff --git a/config/locales/admin/ru.yml b/config/locales/admin/ru.yml index b08f9c13a..f55dd03f8 100644 --- a/config/locales/admin/ru.yml +++ b/config/locales/admin/ru.yml @@ -70,6 +70,7 @@ ru: index: confirm_archive: Вы уверенны что хотите архивировать ответ? confirm_restore: Вы уверенны что хотите восстановить ответ? + answer_for: "Ответ к %{resume}" search_form: created_at_from: "Дата создания с:" created_at_to: "по:" From 68fd201b7141095ef64c5bad09acc4f53ba4e2de Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Fri, 11 Oct 2024 15:40:38 +0400 Subject: [PATCH 07/17] WIP: lint --- .../resumes_answers_comments_controller.rb | 4 +- .../comments/resumes_answers_controller.rb | 5 + .../resumes_answers/_answer_card.html.slim | 48 +++++ .../resumes_answers/_answer_comment.html.slim | 41 +++++ .../comments/resumes_answers/_menu.html.slim | 3 + .../resumes_answers/archived.html.slim | 10 ++ .../comments/resumes_answers/index.html.slim | 169 +----------------- .../resumes_answers_comments/edit.html.slim | 3 + app/views/web/shared/_answer.html.slim | 113 +++++++----- config/locales/admin/en.yml | 11 +- config/locales/admin/ru.yml | 13 +- config/locales/en.activerecord.yml | 3 + config/locales/en.views.yml | 5 +- config/locales/ru.activerecord.yml | 3 + config/locales/ru.views.yml | 3 +- config/routes.rb | 9 + 16 files changed, 229 insertions(+), 214 deletions(-) create mode 100644 app/views/web/admin/comments/resumes_answers/_answer_card.html.slim create mode 100644 app/views/web/admin/comments/resumes_answers/_answer_comment.html.slim create mode 100644 app/views/web/admin/comments/resumes_answers/_menu.html.slim create mode 100644 app/views/web/admin/comments/resumes_answers/archived.html.slim create mode 100644 app/views/web/admin/comments/resumes_answers_comments/edit.html.slim diff --git a/app/controllers/web/admin/comments/resumes_answers_comments_controller.rb b/app/controllers/web/admin/comments/resumes_answers_comments_controller.rb index c50cc494e..3cd16534d 100644 --- a/app/controllers/web/admin/comments/resumes_answers_comments_controller.rb +++ b/app/controllers/web/admin/comments/resumes_answers_comments_controller.rb @@ -7,9 +7,11 @@ def edit; end def update if @comment.update(comment_params) + f(:success) redirect_to admin_resumes_answers_path else - render :edit + f(:error) + render :edit, status: :unprocessable_entity end end diff --git a/app/controllers/web/admin/comments/resumes_answers_controller.rb b/app/controllers/web/admin/comments/resumes_answers_controller.rb index 3bff215fe..63f5b0fca 100644 --- a/app/controllers/web/admin/comments/resumes_answers_controller.rb +++ b/app/controllers/web/admin/comments/resumes_answers_controller.rb @@ -36,6 +36,11 @@ def restore redirect_to admin_resumes_answers_path end + def archived + @search = Resume::Answer.web.includes(comments: :user).where(publishing_state: 'archived').ransack(params[:q]) + @resumes_answers = @search.result(sort: 'created_at desc').page(params[:page]) + end + private def set_answer diff --git a/app/views/web/admin/comments/resumes_answers/_answer_card.html.slim b/app/views/web/admin/comments/resumes_answers/_answer_card.html.slim new file mode 100644 index 000000000..4fb396838 --- /dev/null +++ b/app/views/web/admin/comments/resumes_answers/_answer_card.html.slim @@ -0,0 +1,48 @@ +.card.mb-2 + .card-header.bg-white + .row + .col-3 + .fw-bold = link_to "##{answer.id}", resume_path(answer.resume, anchor: "answer-#{answer.id}") + .col-7 + = link_to t('.answer_for', resume: answer.resume.name), resume_path(answer.resume) + .col-2 + .d-flex.align-items-end.flex-column + .btn-group[role='group' aria-label="#{t('action_buttons')}"] + = link_to edit_admin_resumes_answer_path(answer), class: 'btn btn-outline-primary btn-sm', title: t('.edit') do + span.bi.bi-gear-fill + - if answer.may_restore? + = link_to restore_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-success btn-sm', data: { confirm: t('.confirm_restore') }, title: t('.restore') do + span.bi.bi-arrow-counterclockwise + - elsif answer.may_archive? + = link_to archive_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive') }, title: t('.archive') do + span.bi.bi-trash3 + .card-body + .row + .col-3 + .row#info + .mb-2 + strong.me-1 User: + = link_to "#{answer.user.first_name} #{answer.user.last_name}", user_path(answer.user) + .mb-2 + strong.me-1 = "#{Resume::Answer.human_attribute_name(:email)}:" + = link_to answer.user.email, user_path(answer.user) + .mb-2 + strong.me-1 = "#{Resume::Answer.human_attribute_name(:created_at)}:" + = l(answer.created_at, format: :short) + .mb-2 + strong.me-1 = "#{Resume::Answer.human_attribute_name(:likes_count)}:" + = answer.likes_count + .mb-2 + strong.me-1 = "#{Resume::Answer.human_attribute_name(:applying_state)}:" + = answer.applying_state + .mb-2 + strong.me-1 = "#{Resume::Answer.human_attribute_name(:publishing_state)}:" + = answer.publishing_state + .d-flex.align-items-start.flex-column#show-comment + - if answer.comments.any? + button class="btn btn-outline-primary btn-sm mt-auto" type="button" data-bs-toggle="collapse" data-bs-target="#comments-#{answer.id}" aria-expanded="false" aria-controls="comments-#{answer.id}" + span.me-1.bi.bi-chat-dots-fill + span = t('.show_comments', count: answer.comments.count) + .col + .row + == markdown2html answer.content, details: true diff --git a/app/views/web/admin/comments/resumes_answers/_answer_comment.html.slim b/app/views/web/admin/comments/resumes_answers/_answer_comment.html.slim new file mode 100644 index 000000000..21e8aa99d --- /dev/null +++ b/app/views/web/admin/comments/resumes_answers/_answer_comment.html.slim @@ -0,0 +1,41 @@ +.row + .col-3 + .col-9 + - answer.comments.each do |comment| + .card.mb-2.collapse(id="comments-#{answer.id}") + .card-header + .row + .col-4 + .fw-bold = link_to "##{comment.id}", resume_path(answer.resume, anchor: "answer_comment-#{comment.id}") + .col-6 + = link_to t('.answer_comment_for', resume: answer.id), resume_path(answer.resume) + .col-2 + .d-flex.align-items-end.flex-column + .btn-group[role='group' aria-label="#{t('action_buttons')}"] + = link_to edit_admin_resumes_answers_comment_path(comment), class: 'btn btn-outline-primary btn-sm', title: t('.edit') do + span.bi.bi-gear-fill + - if answer.may_restore? + = link_to restore_admin_resumes_answers_comment_path(comment, page: params[:page]), method: :patch, class: 'btn btn-outline-success btn-sm', data: { confirm: t('.confirm_restore') }, title: t('.restore') do + span.bi.bi-arrow-counterclockwise + - elsif answer.may_archive? + = link_to archive_admin_resumes_answers_comment_path(comment, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive') }, title: t('.archive') do + span.bi.bi-trash3 + .card-body + .row + .col-4 + .row#info + .mb-2 + strong.me-1 = "#{Resume::Answer::Comment.human_attribute_name(:user)}:" + = link_to "#{comment.user.first_name} #{comment.user.last_name}", user_path(comment.user) + .mb-2 + strong.me-1 = "#{Resume::Answer::Comment.human_attribute_name(:email)}:" + = link_to comment.user.email, user_path(comment.user) + .mb-2 + strong.me-1 = "#{Resume::Answer::Comment.human_attribute_name(:created_at)}:" + = l(comment.created_at, format: :short) + / .mb-2 + / strong.me-1 = "#{Resume::Answer.human_attribute_name(:publishing_state)}:" + / = comment.publishing_state + .col + .row + == markdown2html comment.content, details: true diff --git a/app/views/web/admin/comments/resumes_answers/_menu.html.slim b/app/views/web/admin/comments/resumes_answers/_menu.html.slim new file mode 100644 index 000000000..01657bfde --- /dev/null +++ b/app/views/web/admin/comments/resumes_answers/_menu.html.slim @@ -0,0 +1,3 @@ +ul.nav.nav-tabs.mb-4 + = menu_item t('.all'), admin_resumes_answers_path + = menu_item t('.archived'), archived_admin_resumes_answers_path diff --git a/app/views/web/admin/comments/resumes_answers/archived.html.slim b/app/views/web/admin/comments/resumes_answers/archived.html.slim new file mode 100644 index 000000000..0869d73b5 --- /dev/null +++ b/app/views/web/admin/comments/resumes_answers/archived.html.slim @@ -0,0 +1,10 @@ += render 'search_form', q: @search + += render 'menu' + +- @resumes_answers.each do |answer| + = render 'answer_card', answer: + - if answer.comments.any? + = render 'answer_comment', answer: + += paginate @resumes_answers diff --git a/app/views/web/admin/comments/resumes_answers/index.html.slim b/app/views/web/admin/comments/resumes_answers/index.html.slim index 95151da13..0869d73b5 100644 --- a/app/views/web/admin/comments/resumes_answers/index.html.slim +++ b/app/views/web/admin/comments/resumes_answers/index.html.slim @@ -1,169 +1,10 @@ = render 'search_form', q: @search -- @resumes_answers.each do |answer| - .card.mb-2 - .card-header.bg-white - .row - .col-3 - .fw-bold = link_to "##{answer.id}", resume_path(answer.resume, anchor: "answer-#{answer.id}") - .col-7 - = link_to t('.answer_for', resume: answer.resume.name), resume_path(answer.resume) - .col-2 - .d-flex.align-items-end.flex-column - .btn-group[role='group' aria-label="#{t('action_buttons')}"] - = link_to edit_admin_resumes_answer_path(answer), class: 'btn btn-outline-primary btn-sm', title: t('.edit') do - span.bi.bi-gear-fill - - if answer.may_restore? - = link_to restore_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-success btn-sm', data: { confirm: t('.confirm_restore') }, title: t('.restore') do - span.bi.bi-arrow-counterclockwise - - elsif answer.may_archive? - = link_to archive_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive') }, title: t('.archive') do - span.bi.bi-trash3 - .card-body - .row - .col-3 - .row#info - .mb-2 - strong.me-1 User: - = link_to "#{answer.user.first_name} #{answer.user.last_name}", user_path(answer.user) - .mb-2 - strong.me-1 = "#{Resume::Answer.human_attribute_name(:email)}:" - = link_to answer.user.email, user_path(answer.user) - .mb-2 - strong.me-1 = "#{Resume::Answer.human_attribute_name(:created_at)}:" - = l(answer.created_at, format: :short) - .mb-2 - strong.me-1 = "#{Resume::Answer.human_attribute_name(:likes_count)}:" - = answer.likes_count - .mb-2 - strong.me-1 = "#{Resume::Answer.human_attribute_name(:applying_state)}:" - = answer.applying_state - .mb-2 - strong.me-1 = "#{Resume::Answer.human_attribute_name(:publishing_state)}:" - = answer.publishing_state - .d-flex.align-items-start.flex-column#show-comment - - if answer.comments.any? - button class="btn btn-outline-primary btn-sm mt-auto" type="button" data-bs-toggle="collapse" data-bs-target="#comments-#{answer.id}" aria-expanded="false" aria-controls="comments-#{answer.id}" - span.bi.bi-chat-dots-fill - span = t('show_comments', count: answer.comments.count) - .col - .row - == markdown2html answer.content, details: true - - if answer.comments.any? - .row - .col-3 - .col-9 - / - answer.comments.each do |comment| - / .card.collapse(id="comments-#{answer.id}") - / .card-body - -/ table.table -/ thead -/ tr -/ th = 'info' -/ th = 'content' -/ th = t('actions') -/ tbody -/ - @resumes_answers.each do |answer| -/ tr -/ td -/ .row -/ .row -/ .col -/ strong ID: -/ .col -/ = link_to answer.id, resume_path(answer.resume, anchor: "answer-#{answer.id}") -/ .row -/ .col -/ strong Resume: -/ .col -/ = link_to answer.resume.name, resume_path(answer.resume) -/ .row -/ .col -/ strong Comments: -/ .col -/ = answer.comments.count -/ .row -/ .col -/ strong User: -/ .col -/ = link_to answer.user.email, user_path(answer.user) -/ .row -/ .col -/ strong Created: -/ .col -/ = l(answer.created_at, format: :long) -/ .row -/ .col -/ strong Published: -/ .col -/ = answer.publishing_state -/ .row -/ .col colspan="2" -/ - if answer.comments.any? -/ button.w-100 class="btn btn-outline-primary btn-sm" type="button" data-bs-toggle="collapse" data-bs-target="#comments-#{answer.id}" aria-expanded="false" aria-controls="comments-#{answer.id}" -/ span.bi.bi-chat-dots-fill -/ span = t('show_comments', count: answer.comments.count) -/ td == markdown2html answer.content, details: true -/ td -/ .btn-group[role='group' aria-label="#{t('action_buttons')}"] -/ = link_to edit_admin_resumes_answer_path(answer), class: 'btn btn-outline-primary btn-sm', title: t('.edit') do -/ span.bi.bi-gear-fill -/ - if answer.may_restore? -/ = link_to restore_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-success btn-sm', data: { confirm: t('.confirm_restore') }, title: t('.restore') do -/ span.bi.bi-arrow-counterclockwise -/ - elsif answer.may_archive? -/ = link_to archive_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive') }, title: t('.archive') do -/ span.bi.bi-trash3 -/ tr.collapse(id="comments-#{answer.id}") -/ td.colspan-3 -/ - if answer.comments.any? -/ ul -/ - answer.comments.each do |comment| -/ li = "#{comment.user.email}: #{comment.content}" -/ - else -/ p No comments available += render 'menu' -/ table.table -/ thead -/ tr -/ th = sort_link(@search, 'id') -/ th = sort_link(@search, 'comment_id') -/ th = sort_link(@search, 'resume_name') -/ th = sort_link(@search, 'user_email') -/ th = sort_link(@search, 'content') -/ th = sort_link(@search, 'publishing_state') -/ th = sort_link(@search, 'created_at') -/ th = t('actions') -/ tbody -/ - @resumes_answers.each do |answer| -/ tr.table-light -/ td = link_to answer.id, resume_path(answer.resume, anchor: "answer-#{answer.id}") -/ td = answer.comments.count -/ td = link_to answer.resume.name, resume_path(answer.resume) -/ td = link_to answer.user.email, user_path(answer.user) -/ td = answer.content -/ td = answer.publishing_state -/ td = l(answer.created_at, format: :short) -/ td -/ .btn-group[role='group' aria-label="#{t('action_buttons')}"] -/ = link_to edit_admin_resumes_answer_path(answer), class: 'btn btn-outline-primary btn-sm', title: t('.edit') do -/ span.bi.bi-gear-fill -/ - if answer.may_restore? -/ = link_to restore_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-success btn-sm', data: { confirm: t('.confirm_restore') }, title: t('.restore') do -/ span.bi.bi-arrow-counterclockwise -/ - elsif answer.may_archive? -/ = link_to archive_admin_resumes_answer_path(answer, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive') }, title: t('.archive') do -/ span.bi.bi-trash3 -/ - answer.comments.each do |comment| -/ tr -/ td -/ td = link_to comment.id, resume_path(answer.resume, anchor: "answer_comment-#{comment.id}") -/ td -/ td = link_to comment.user.email, user_path(comment.user.email) -/ td = comment.content -/ td -/ td = l(answer.created_at, format: :short) -/ td +- @resumes_answers.each do |answer| + = render 'answer_card', answer: + - if answer.comments.any? + = render 'answer_comment', answer: = paginate @resumes_answers diff --git a/app/views/web/admin/comments/resumes_answers_comments/edit.html.slim b/app/views/web/admin/comments/resumes_answers_comments/edit.html.slim new file mode 100644 index 000000000..8bb48945e --- /dev/null +++ b/app/views/web/admin/comments/resumes_answers_comments/edit.html.slim @@ -0,0 +1,3 @@ += simple_form_for @comment, url: admin_resumes_answers_comment_path(@comment) do |f| + = f.input :content, input_html: { rows: 12 } + .mt-2 = f.button :submit, class: 'btn btn-success' diff --git a/app/views/web/shared/_answer.html.slim b/app/views/web/shared/_answer.html.slim index cb6d5d006..8522d8eb7 100644 --- a/app/views/web/shared/_answer.html.slim +++ b/app/views/web/shared/_answer.html.slim @@ -28,47 +28,72 @@ span.text-info = answer.aasm(:applying).human_state .card-body.d-flex - .me-3.h4 - - let current_user_likes_by_answer_id.fetch(answer.id, nil) do |like| - .text-center.text-muted.mb-2.mt-1.fw-light - = answer.likes.count - - if like - = link_to answer_like_path(answer, like), method: 'delete', class: 'text-decoration-none' do - span.bi.bi-hand-thumbs-up.text-secondary - - else - = link_to answer_likes_path(answer), method: 'post', class: 'text-decoration-none' do - span.bi.bi-hand-thumbs-up.text-secondary - .w-100 - .hexlet-cv-content.mb-3 - - if answer.user.email == ENV.fetch('EMAIL_SPECIAL_USER') - == markdown2html(answer.content, details: true) - - else - == markdown2html answer.content - - if answer.comments.web.any? - - answer.comments.web.each do |comment| - hr.mb-4 - .d-flex(id="answer_comment-#{comment.id}") - .me-auto - span.me-2.hexlet-cv-content.hexlet-cv-inline-paragraph - == markdown2html comment.content - span.small - - if comment.user - span.me-1 - = link_to comment.user, user_path(comment.user) - = link_to l(comment.created_at, format: :long_schema), url_for(anchor: "answer_comment-#{comment.id}"), class: 'text-muted' - - if comment.user == current_user - .d-flex - .me-2 - = link_to edit_answer_comment_path(answer, comment) - span.bi.bi-pen-fill.text-secondary - div - = link_to answer_comment_path(answer, comment), method: :delete, data: { confirm: t('confirm') } do - span.bi.bi-x-lg.text-secondary - hr.mb-4 - a.d-block.text-muted(href="#new_answer_comment-#{answer.id}" data-bs-toggle='collapse') - = t('.add_a_comment') - .collapse(id="new_answer_comment-#{answer.id}") - - if user_signed_in? - = render 'web/shared/comment_form', comment: answer.comments.build, url: answer_comments_path(answer) - - else - = render 'comment_requires' + - if answer.publishing_state == 'archived' + .w-100 + .hexlet-cv-content.mb-3 + .text-muted.text-center = t('.archived_comment', deleted_at: l(answer.updated_at, format: :long)) + - if answer.comments.web.any? + - answer.comments.web.each do |comment| + hr.mb-4 + .d-flex(id="answer_comment-#{comment.id}") + .me-auto + span.me-2.hexlet-cv-content.hexlet-cv-inline-paragraph + == markdown2html comment.content + span.small + - if comment.user + span.me-1 + = link_to comment.user, user_path(comment.user) + = link_to l(comment.created_at, format: :long_schema), url_for(anchor: "answer_comment-#{comment.id}"), class: 'text-muted' + - if comment.user == current_user + .d-flex + .me-2 + = link_to edit_answer_comment_path(answer, comment) + span.bi.bi-pen-fill.text-secondary + div + = link_to answer_comment_path(answer, comment), method: :delete, data: { confirm: t('confirm') } do + span.bi.bi-x-lg.text-secondary + - else + .me-3.h4 + - let current_user_likes_by_answer_id.fetch(answer.id, nil) do |like| + .text-center.text-muted.mb-2.mt-1.fw-light + = answer.likes.count + - if like + = link_to answer_like_path(answer, like), method: 'delete', class: 'text-decoration-none' do + span.bi.bi-hand-thumbs-up.text-secondary + - else + = link_to answer_likes_path(answer), method: 'post', class: 'text-decoration-none' do + span.bi.bi-hand-thumbs-up.text-secondary + .w-100 + .hexlet-cv-content.mb-3 + - if answer.user.email == ENV.fetch('EMAIL_SPECIAL_USER') + == markdown2html(answer.content, details: true) + - else + == markdown2html answer.content + - if answer.comments.web.any? + - answer.comments.web.each do |comment| + hr.mb-4 + .d-flex(id="answer_comment-#{comment.id}") + .me-auto + span.me-2.hexlet-cv-content.hexlet-cv-inline-paragraph + == markdown2html comment.content + span.small + - if comment.user + span.me-1 + = link_to comment.user, user_path(comment.user) + = link_to l(comment.created_at, format: :long_schema), url_for(anchor: "answer_comment-#{comment.id}"), class: 'text-muted' + - if comment.user == current_user + .d-flex + .me-2 + = link_to edit_answer_comment_path(answer, comment) + span.bi.bi-pen-fill.text-secondary + div + = link_to answer_comment_path(answer, comment), method: :delete, data: { confirm: t('confirm') } do + span.bi.bi-x-lg.text-secondary + hr.mb-4 + a.d-block.text-muted(href="#new_answer_comment-#{answer.id}" data-bs-toggle='collapse') + = t('.add_a_comment') + .collapse(id="new_answer_comment-#{answer.id}") + - if user_signed_in? + = render 'web/shared/comment_form', comment: answer.comments.build, url: answer_comments_path(answer) + - else + = render 'comment_requires' diff --git a/config/locales/admin/en.yml b/config/locales/admin/en.yml index 6fec2b79d..dc7168736 100644 --- a/config/locales/admin/en.yml +++ b/config/locales/admin/en.yml @@ -71,10 +71,19 @@ en: last_satep_finished_at: Last activity date comments: resumes_answers: - index: + answer_card: confirm_archive: Are you sure you want to archive answer? confirm_restore: Are you sure you want to restore answer? answer_for: "Answer for %{resume}" + edit: Edit answer + archive: Archive answer + restore: Restore answer + show_comments: + one: Show %{count} comment + other: Show %{count} comments + menu: + all: All + archived: Archived search_form: created_at_from: 'Creation date from:' created_at_to: 'By:' diff --git a/config/locales/admin/ru.yml b/config/locales/admin/ru.yml index f55dd03f8..031c325b4 100644 --- a/config/locales/admin/ru.yml +++ b/config/locales/admin/ru.yml @@ -67,10 +67,21 @@ ru: last_satep_finished_at: Дата последней активности comments: resumes_answers: - index: + answer_card: confirm_archive: Вы уверенны что хотите архивировать ответ? confirm_restore: Вы уверенны что хотите восстановить ответ? answer_for: "Ответ к %{resume}" + edit: Редактировать ответ + archive: Архивировать ответ + restore: Восстановить ответ + show_comments: + one: Показать %{count} комментарий + few: Показать %{count} комментария + many: Показать %{count} комментариев + other: Показать %{count} комментариев + menu: + all: Все + archived: Архивированные search_form: created_at_from: "Дата создания с:" created_at_to: "по:" diff --git a/config/locales/en.activerecord.yml b/config/locales/en.activerecord.yml index 1cd7afbab..1368c72fb 100644 --- a/config/locales/en.activerecord.yml +++ b/config/locales/en.activerecord.yml @@ -27,6 +27,9 @@ en: attributes: resume/answer: content: Answer + likes_count: Likes count + applying_state: Applied? + publishing_state: Published? applying_state/pending: Awaiting confirmation applying_state/applied: Changes applied publishing_state/published: Published diff --git a/config/locales/en.views.yml b/config/locales/en.views.yml index 59db2e1ab..2ce37568c 100644 --- a/config/locales/en.views.yml +++ b/config/locales/en.views.yml @@ -70,7 +70,7 @@ en: contacts: Contacts main: Main add: Add - additionally: Additionally + additionally: Additionally work_fields: remove_work: Delete work experience education_fields: @@ -79,6 +79,7 @@ en: add_a_comment: Add a comment apply: Apply title_apply: Apply recommendations + archived_comment: The comment was deleted %{deleted_at} and is no longer available. empty_list: empty: Empty links_guides: @@ -332,7 +333,7 @@ en: Cover letter %{letter} - +
Improved resume %{edit_text} diff --git a/config/locales/ru.activerecord.yml b/config/locales/ru.activerecord.yml index 4d186da0d..261ab979f 100644 --- a/config/locales/ru.activerecord.yml +++ b/config/locales/ru.activerecord.yml @@ -138,8 +138,11 @@ ru: projects_description: Описание проектов about_myself: О себе resume/answer: + user: Пользователь + likes_count: Количество лайков content: Ответ publishing_state: Опубликован? + applying_state: Подтвержден? applying_state/pending: Ожидает подтверждения applying_state/applied: Изменения внесены publishing_state/published: Опубликован diff --git a/config/locales/ru.views.yml b/config/locales/ru.views.yml index f76b47ad0..a2a226017 100644 --- a/config/locales/ru.views.yml +++ b/config/locales/ru.views.yml @@ -157,6 +157,7 @@ ru: answer: apply: Принять add_a_comment: Добавить комментарий/ссылку на вакансию + archived_comment: Комментарий был удален %{deleted_at} администратором и более недоступен. resume_filter: directions: Выберите направление name: Название резюме @@ -322,7 +323,7 @@ ru: tab_active: Активные tab_finished: Пройденные vacancies: - form: + form: archive: В архив cancel: Отмена new: diff --git a/config/routes.rb b/config/routes.rb index ff7bf10fb..1af84ab41 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -111,6 +111,15 @@ patch :archive patch :restore end + collection do + get :archived + end + end + resources :resumes_answers_comments do + member do + patch :archive + patch :restore + end end end From 8cc8a39fb7fe1e56305d0abcb74f2006740efb12 Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Mon, 14 Oct 2024 11:02:30 +0400 Subject: [PATCH 08/17] Added localize method for aasm state --- app/helpers/model_helper.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/helpers/model_helper.rb b/app/helpers/model_helper.rb index 63480ee52..696ed7373 100644 --- a/app/helpers/model_helper.rb +++ b/app/helpers/model_helper.rb @@ -4,4 +4,11 @@ module ModelHelper def states_for_select(model, state_machine = :state) model.aasm(state_machine).states.map { |s| [s.human_name, s.name] } end + + def state_for_render(model, state_machine = :state, state_name = :default) + model.aasm(state_machine) + .states + .find { |s| s.name == state_name.to_sym } + .try(:human_name) + end end From 0acd944991a3526c9d1da4b2a5f270425845b7ad Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Mon, 14 Oct 2024 11:04:08 +0400 Subject: [PATCH 09/17] WIP: updated views --- app/models/resume/answer.rb | 2 +- .../comments/resumes_answers/_answer_card.html.slim | 10 +++++----- .../comments/resumes_answers/_search_form.html.slim | 12 ++++++++---- app/views/web/shared/_answer.html.slim | 3 ++- config/locales/admin/en.yml | 9 ++++++--- config/locales/admin/ru.yml | 9 ++++++--- config/locales/en.activerecord.yml | 2 ++ config/locales/en.views.yml | 3 ++- config/locales/ru.activerecord.yml | 2 ++ config/locales/ru.views.yml | 3 ++- 10 files changed, 36 insertions(+), 19 deletions(-) diff --git a/app/models/resume/answer.rb b/app/models/resume/answer.rb index 49bf1a1ab..0ae535c23 100644 --- a/app/models/resume/answer.rb +++ b/app/models/resume/answer.rb @@ -73,7 +73,7 @@ def tota_ai_author? end def self.ransackable_attributes(_auth_object = nil) - %w[id content user_id publishing_state created_at] + %w[id content user_id publishing_state applying_state created_at] end def self.ransackable_associations(_auth_object = nil) diff --git a/app/views/web/admin/comments/resumes_answers/_answer_card.html.slim b/app/views/web/admin/comments/resumes_answers/_answer_card.html.slim index 4fb396838..5809ba372 100644 --- a/app/views/web/admin/comments/resumes_answers/_answer_card.html.slim +++ b/app/views/web/admin/comments/resumes_answers/_answer_card.html.slim @@ -21,7 +21,7 @@ .col-3 .row#info .mb-2 - strong.me-1 User: + strong.me-1 = "#{Resume::Answer.human_attribute_name(:user)}:" = link_to "#{answer.user.first_name} #{answer.user.last_name}", user_path(answer.user) .mb-2 strong.me-1 = "#{Resume::Answer.human_attribute_name(:email)}:" @@ -30,14 +30,14 @@ strong.me-1 = "#{Resume::Answer.human_attribute_name(:created_at)}:" = l(answer.created_at, format: :short) .mb-2 - strong.me-1 = "#{Resume::Answer.human_attribute_name(:likes_count)}:" - = answer.likes_count + strong.me-1 = "#{Resume::Answer.human_attribute_name(:updated_at)}:" + = l(answer.updated_at, format: :short) .mb-2 strong.me-1 = "#{Resume::Answer.human_attribute_name(:applying_state)}:" - = answer.applying_state + = state_for_render(Resume::Answer, :applying, answer.applying_state) .mb-2 strong.me-1 = "#{Resume::Answer.human_attribute_name(:publishing_state)}:" - = answer.publishing_state + = state_for_render(Resume::Answer, :publishing, answer.publishing_state) .d-flex.align-items-start.flex-column#show-comment - if answer.comments.any? button class="btn btn-outline-primary btn-sm mt-auto" type="button" data-bs-toggle="collapse" data-bs-target="#comments-#{answer.id}" aria-expanded="false" aria-controls="comments-#{answer.id}" diff --git a/app/views/web/admin/comments/resumes_answers/_search_form.html.slim b/app/views/web/admin/comments/resumes_answers/_search_form.html.slim index 073fb406b..649964cc5 100644 --- a/app/views/web/admin/comments/resumes_answers/_search_form.html.slim +++ b/app/views/web/admin/comments/resumes_answers/_search_form.html.slim @@ -3,9 +3,13 @@ = f.input :resume_name_cont, placeholder: han('resume', :name), label: false = f.input :user_email_cont, placeholder: han('user', :email), label: false = f.input :content_cont, placeholder: han('Resume::Answer', :content), label: false - = f.input :publishing_state_eq, as: :select, collection: states_for_select(Resume::Answer, :publishing), label: false - = f.input :created_at_gteq, as: :date, html5: true, label: t('.created_at_from') - = f.input :created_at_lteq, as: :date, html5: true, label: t('.created_at_to') + = f.input :applying_state_eq, as: :select, collection: states_for_select(Resume::Answer, :applying), label: false, include_blank: t('applying_state_select', scope: 'web.admin.comments.search_form') + = f.input :publishing_state_eq, as: :select, collection: states_for_select(Resume::Answer, :publishing), label: false, include_blank: t('publishing_state_select', scope: 'web.admin.comments.search_form') + = f.input :created_at_gteq, as: :date, html5: true, + label: t('created_at_from', scope: 'web.admin.comments.search_form') + = f.input :created_at_lteq, as: :date, html5: true, + label: t('created_at_to', scope: 'web.admin.comments.search_form') .col.d-flex.align-self-end - = f.button :submit, class: 'btn-primary me-2 flex-grow-1' + = f.button :submit, t('search_button', scope: 'web.admin.comments.search_form'), + class: 'btn-primary me-2 flex-grow-1' = link_to t('reset'), url_for, class: 'btn btn-outline-primary' diff --git a/app/views/web/shared/_answer.html.slim b/app/views/web/shared/_answer.html.slim index 8522d8eb7..ff9323c2a 100644 --- a/app/views/web/shared/_answer.html.slim +++ b/app/views/web/shared/_answer.html.slim @@ -31,7 +31,8 @@ - if answer.publishing_state == 'archived' .w-100 .hexlet-cv-content.mb-3 - .text-muted.text-center = t('.archived_comment', deleted_at: l(answer.updated_at, format: :long)) + h3.muted.text-center = t('.archived_comment_header') + .text-muted.text-center = t('.archived_comment_body', deleted_at: l(answer.updated_at, format: :long)) - if answer.comments.web.any? - answer.comments.web.each do |comment| hr.mb-4 diff --git a/config/locales/admin/en.yml b/config/locales/admin/en.yml index dc7168736..24d5058d3 100644 --- a/config/locales/admin/en.yml +++ b/config/locales/admin/en.yml @@ -84,9 +84,12 @@ en: menu: all: All archived: Archived - search_form: - created_at_from: 'Creation date from:' - created_at_to: 'By:' + search_form: + created_at_from: 'Creation date from:' + created_at_to: 'By:' + search_button: Search + publishing_state_select: Publishing state + applying_state_select: Applied state resumes: index: edit: Edit CV diff --git a/config/locales/admin/ru.yml b/config/locales/admin/ru.yml index 031c325b4..b013ff490 100644 --- a/config/locales/admin/ru.yml +++ b/config/locales/admin/ru.yml @@ -82,9 +82,12 @@ ru: menu: all: Все archived: Архивированные - search_form: - created_at_from: "Дата создания с:" - created_at_to: "по:" + search_form: + created_at_from: "Дата создания с:" + created_at_to: "по:" + search_button: Поиск + publishing_state_select: Опубликован? + applying_state_select: Подтврежден? resumes: index: edit: Редактировать резюме diff --git a/config/locales/en.activerecord.yml b/config/locales/en.activerecord.yml index 1368c72fb..e9eaf5a7e 100644 --- a/config/locales/en.activerecord.yml +++ b/config/locales/en.activerecord.yml @@ -34,6 +34,8 @@ en: applying_state/applied: Changes applied publishing_state/published: Published publishing_state/archived: Archived + created_at: Creation date + updated_at: Update date resume/job: content: Description resume/comment: diff --git a/config/locales/en.views.yml b/config/locales/en.views.yml index 2ce37568c..818e98d54 100644 --- a/config/locales/en.views.yml +++ b/config/locales/en.views.yml @@ -79,7 +79,8 @@ en: add_a_comment: Add a comment apply: Apply title_apply: Apply recommendations - archived_comment: The comment was deleted %{deleted_at} and is no longer available. + archived_comment_header: Comment is unavailable + archived_comment_body: The comment was deleted %{deleted_at} and is no longer available. empty_list: empty: Empty links_guides: diff --git a/config/locales/ru.activerecord.yml b/config/locales/ru.activerecord.yml index 261ab979f..9ad2ad15d 100644 --- a/config/locales/ru.activerecord.yml +++ b/config/locales/ru.activerecord.yml @@ -147,6 +147,8 @@ ru: applying_state/applied: Изменения внесены publishing_state/published: Опубликован publishing_state/archived: В архиве + created_at: Дата создания + updated_at: Дата обновления resume/job: content: Описание resume/work: diff --git a/config/locales/ru.views.yml b/config/locales/ru.views.yml index a2a226017..19b6ff5bc 100644 --- a/config/locales/ru.views.yml +++ b/config/locales/ru.views.yml @@ -157,7 +157,8 @@ ru: answer: apply: Принять add_a_comment: Добавить комментарий/ссылку на вакансию - archived_comment: Комментарий был удален %{deleted_at} администратором и более недоступен. + archived_comment_header: Комментарий недоступен + archived_comment_body: Комментарий был удален %{deleted_at} администратором и более недоступен. resume_filter: directions: Выберите направление name: Название резюме From 8e50d9cc650953d79abc54c84099075c0f5e0a0d Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Mon, 14 Oct 2024 13:35:56 +0400 Subject: [PATCH 10/17] Added admin tools for answers_comments --- .../comments/resumes_comments_controller.rb | 49 +++++++++++++++++-- app/models/resume/comment.rb | 35 ++++++++++--- .../comments/resumes_answers/_menu.html.slim | 4 +- .../resumes_answers/_search_form.html.slim | 1 - .../resumes_comments/_comment_card.html.slim | 37 ++++++++++++++ .../comments/resumes_comments/_menu.html.slim | 3 ++ .../resumes_comments/_search_form.html.slim | 13 +++++ .../resumes_comments/archived.html.slim | 8 +++ .../comments/resumes_comments/edit.html.slim | 3 ++ .../comments/resumes_comments/index.html.slim | 22 +++------ config/locales/admin/en.flash.yml | 10 ++++ config/locales/admin/en.yml | 11 +++++ config/locales/admin/ru.flash.yml | 10 ++++ config/locales/admin/ru.yml | 11 +++++ config/routes.rb | 3 ++ ...448_add_state_columnt_to_resume_comment.rb | 5 ++ db/schema.rb | 3 +- test/factories/resume_comments.rb | 13 ++--- test/fixtures/resume/comments.yml | 13 ++--- 19 files changed, 214 insertions(+), 40 deletions(-) create mode 100644 app/views/web/admin/comments/resumes_comments/_comment_card.html.slim create mode 100644 app/views/web/admin/comments/resumes_comments/_menu.html.slim create mode 100644 app/views/web/admin/comments/resumes_comments/_search_form.html.slim create mode 100644 app/views/web/admin/comments/resumes_comments/archived.html.slim create mode 100644 app/views/web/admin/comments/resumes_comments/edit.html.slim create mode 100644 db/migrate/20241014084448_add_state_columnt_to_resume_comment.rb diff --git a/app/controllers/web/admin/comments/resumes_comments_controller.rb b/app/controllers/web/admin/comments/resumes_comments_controller.rb index 7b8701d3e..1f77a8585 100644 --- a/app/controllers/web/admin/comments/resumes_comments_controller.rb +++ b/app/controllers/web/admin/comments/resumes_comments_controller.rb @@ -1,11 +1,52 @@ # frozen_string_literal: true class Web::Admin::Comments::ResumesCommentsController < Web::Admin::Comments::ApplicationController + before_action :set_comment, only: %i[edit update archive restore] def index - @resume_comments = Resume::Comment.includes(:user, :resume) - @resume_answers = Resume::Answer.includes(:user, :resume, comments: :user).ransack(params[:q]) + @search = Resume::Comment.web.includes(:user).ransack(params[:q]) + @resumes_comments = @search.result(sort: 'created_at desc').page(params[:page]) + end + + def archive + return unless @comment.may_archive? + + @comment.archive! + f(:success) + redirect_to admin_resumes_comments_path + end + + def restore + return unless @comment.may_restore? + + @comment.restore! + f(:success) + redirect_to admin_resumes_comments_path + end + + def archived + @search = Resume::Comment.web.includes(:user).where(publishing_state: 'archived').ransack(params[:q]) + @resumes_comments = @search.result(sort: 'created_at desc').page(params[:page]) + end + + def edit; end + + def update + if @comment.update(comment_params) + f(:success) + redirect_to admin_resumes_comments_path + else + f(:error) + render :edit, status: :unprocessable_entity + end + end + + private + + def set_comment + @comment = Resume::Comment.find(params[:id]) + end - @search = Resume::Comment.ransack(params[:q]) - @resumes_comments = @search.result(sort: 'created_at desc').includes(:resume).page(params[:page]) + def comment_params + params.require(:resume_comment).permit(:content) end end diff --git a/app/models/resume/comment.rb b/app/models/resume/comment.rb index 5dd1aed13..ea197d655 100644 --- a/app/models/resume/comment.rb +++ b/app/models/resume/comment.rb @@ -4,12 +4,13 @@ # # Table name: resume_comments # -# id :integer not null, primary key -# content :string -# created_at :datetime not null -# updated_at :datetime not null -# resume_id :integer -# user_id :integer +# id :integer not null, primary key +# content :string +# publishing_state :string default("published") +# created_at :datetime not null +# updated_at :datetime not null +# resume_id :integer +# user_id :integer # # Indexes # @@ -17,6 +18,7 @@ # index_resume_comments_on_user_id (user_id) # class Resume::Comment < ApplicationRecord + include AASM include Resume::CommentRepository validates :content, presence: true, length: { minimum: 10, maximum: 400 } @@ -24,6 +26,19 @@ class Resume::Comment < ApplicationRecord belongs_to :user has_many :notifications, as: :resource, dependent: :destroy + aasm :publishing, column: :publishing_state do + state :published, initial: true + state :archived + + event :archive do + transitions from: :published, to: :archived + end + + event :restore do + transitions from: :archived, to: :published + end + end + def to_s content end @@ -31,4 +46,12 @@ def to_s def author?(user) user_id == user.id end + + def self.ransackable_attributes(_auth_object = nil) + %w[content created_at id id_value resume_id updated_at user_id] + end + + def self.ransackable_associations(_auth_object = nil) + %w[notifications resume user] + end end diff --git a/app/views/web/admin/comments/resumes_answers/_menu.html.slim b/app/views/web/admin/comments/resumes_answers/_menu.html.slim index 01657bfde..17ec4cf8e 100644 --- a/app/views/web/admin/comments/resumes_answers/_menu.html.slim +++ b/app/views/web/admin/comments/resumes_answers/_menu.html.slim @@ -1,3 +1,3 @@ ul.nav.nav-tabs.mb-4 - = menu_item t('.all'), admin_resumes_answers_path - = menu_item t('.archived'), archived_admin_resumes_answers_path + = menu_item t('all', scope: 'web.admin.comments.menu'), admin_resumes_answers_path + = menu_item t('archived', scope: 'web.admin.comments.menu'), archived_admin_resumes_answers_path diff --git a/app/views/web/admin/comments/resumes_answers/_search_form.html.slim b/app/views/web/admin/comments/resumes_answers/_search_form.html.slim index 649964cc5..cbd33cefe 100644 --- a/app/views/web/admin/comments/resumes_answers/_search_form.html.slim +++ b/app/views/web/admin/comments/resumes_answers/_search_form.html.slim @@ -4,7 +4,6 @@ = f.input :user_email_cont, placeholder: han('user', :email), label: false = f.input :content_cont, placeholder: han('Resume::Answer', :content), label: false = f.input :applying_state_eq, as: :select, collection: states_for_select(Resume::Answer, :applying), label: false, include_blank: t('applying_state_select', scope: 'web.admin.comments.search_form') - = f.input :publishing_state_eq, as: :select, collection: states_for_select(Resume::Answer, :publishing), label: false, include_blank: t('publishing_state_select', scope: 'web.admin.comments.search_form') = f.input :created_at_gteq, as: :date, html5: true, label: t('created_at_from', scope: 'web.admin.comments.search_form') = f.input :created_at_lteq, as: :date, html5: true, diff --git a/app/views/web/admin/comments/resumes_comments/_comment_card.html.slim b/app/views/web/admin/comments/resumes_comments/_comment_card.html.slim new file mode 100644 index 000000000..35b4b3234 --- /dev/null +++ b/app/views/web/admin/comments/resumes_comments/_comment_card.html.slim @@ -0,0 +1,37 @@ +.card.mb-2 + .card-header.bg-white + .row + .col-3 + .fw-bold = link_to "##{comment.id}", resume_path(comment.resume, anchor: "comment-#{comment.id}") + .col-7 + = link_to t('.comment_for', resume: comment.resume.name), resume_path(comment.resume) + .col-2 + .d-flex.align-items-end.flex-column + .btn-group[role='group' aria-label="#{t('action_buttons')}"] + = link_to edit_admin_resumes_comment_path(comment), class: 'btn btn-outline-primary btn-sm', title: t('.edit') do + span.bi.bi-gear-fill + - if comment.may_restore? + = link_to restore_admin_resumes_comment_path(comment, page: params[:page]), method: :patch, class: 'btn btn-outline-success btn-sm', data: { confirm: t('.confirm_restore') }, title: t('.restore') do + span.bi.bi-arrow-counterclockwise + - elsif comment.may_archive? + = link_to archive_admin_resumes_comment_path(comment, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive') }, title: t('.archive') do + span.bi.bi-trash3 + .card-body + .row + .col-3 + .row#info + .mb-2 + strong.me-1 = "#{Resume::Comment.human_attribute_name(:user)}:" + = link_to "#{comment.user.first_name} #{comment.user.last_name}", user_path(comment.user) + .mb-2 + strong.me-1 = "#{Resume::Comment.human_attribute_name(:email)}:" + = link_to comment.user.email, user_path(comment.user) + .mb-2 + strong.me-1 = "#{Resume::Comment.human_attribute_name(:created_at)}:" + = l(comment.created_at, format: :short) + .mb-2 + strong.me-1 = "#{Resume::Comment.human_attribute_name(:updated_at)}:" + = l(comment.updated_at, format: :short) + .col + .row + == markdown2html comment.content, details: true diff --git a/app/views/web/admin/comments/resumes_comments/_menu.html.slim b/app/views/web/admin/comments/resumes_comments/_menu.html.slim new file mode 100644 index 000000000..39a28d781 --- /dev/null +++ b/app/views/web/admin/comments/resumes_comments/_menu.html.slim @@ -0,0 +1,3 @@ +ul.nav.nav-tabs.mb-4 + = menu_item t('all', scope: 'web.admin.comments.menu'), admin_resumes_comments_path + = menu_item t('archived', scope: 'web.admin.comments.menu'), archived_admin_resumes_comments_path diff --git a/app/views/web/admin/comments/resumes_comments/_search_form.html.slim b/app/views/web/admin/comments/resumes_comments/_search_form.html.slim new file mode 100644 index 000000000..7560cc7d1 --- /dev/null +++ b/app/views/web/admin/comments/resumes_comments/_search_form.html.slim @@ -0,0 +1,13 @@ +.p-3.mb-3.bg-light + = search_form_for q, default_filter_form_options(url: url_for) do |f| + = f.input :resume_name_cont, placeholder: han('resume', :name), label: false + = f.input :user_email_cont, placeholder: han('user', :email), label: false + = f.input :content_cont, placeholder: han('Resume::Comment', :content), label: false + = f.input :created_at_gteq, as: :date, html5: true, + label: t('created_at_from', scope: 'web.admin.comments.search_form') + = f.input :created_at_lteq, as: :date, html5: true, + label: t('created_at_to', scope: 'web.admin.comments.search_form') + .col.d-flex.align-self-end + = f.button :submit, t('search_button', scope: 'web.admin.comments.search_form'), + class: 'btn-primary me-2 flex-grow-1' + = link_to t('reset'), url_for, class: 'btn btn-outline-primary' diff --git a/app/views/web/admin/comments/resumes_comments/archived.html.slim b/app/views/web/admin/comments/resumes_comments/archived.html.slim new file mode 100644 index 000000000..c9c576f57 --- /dev/null +++ b/app/views/web/admin/comments/resumes_comments/archived.html.slim @@ -0,0 +1,8 @@ += render 'search_form', q: @search + += render 'menu' + +- @resumes_comments.each do |comment| + = render 'comment_card', comment: + += paginate @resumes_comments diff --git a/app/views/web/admin/comments/resumes_comments/edit.html.slim b/app/views/web/admin/comments/resumes_comments/edit.html.slim new file mode 100644 index 000000000..7ef44ec67 --- /dev/null +++ b/app/views/web/admin/comments/resumes_comments/edit.html.slim @@ -0,0 +1,3 @@ += simple_form_for @comment, url: admin_resumes_comment_path(@comment) do |f| + = f.input :content, input_html: { rows: 12 } + .mt-2 = f.button :submit, class: 'btn btn-success' diff --git a/app/views/web/admin/comments/resumes_comments/index.html.slim b/app/views/web/admin/comments/resumes_comments/index.html.slim index 6d5768868..c9c576f57 100644 --- a/app/views/web/admin/comments/resumes_comments/index.html.slim +++ b/app/views/web/admin/comments/resumes_comments/index.html.slim @@ -1,14 +1,8 @@ -table.table - thead - tr - th = 'id' - th = 'resume' - th = 'user' - th = 'content' - tbody - - @resumes_comments.each do |comment| - tr - td = comment.id - td = link_to comment.resume.name, resume_path(comment.resume) - td = comment.user.email - td = comment.content += render 'search_form', q: @search + += render 'menu' + +- @resumes_comments.each do |comment| + = render 'comment_card', comment: + += paginate @resumes_comments diff --git a/config/locales/admin/en.flash.yml b/config/locales/admin/en.flash.yml index bdc028427..693977392 100644 --- a/config/locales/admin/en.flash.yml +++ b/config/locales/admin/en.flash.yml @@ -51,6 +51,16 @@ en: update: success: Answer on resume successfully updated error: Failed to update answer + resumes_comments: + archive: + success: Comment for resume successfully archived + error: Failed to archive comment + restore: + success: Comment for resume successfully restored + error: Failed to restore comment + update: + success: Comment for resume successfully updated + error: Failed to update comment vacancies: cancel: success: Vacancy canceled successfull diff --git a/config/locales/admin/en.yml b/config/locales/admin/en.yml index 24d5058d3..8e5626227 100644 --- a/config/locales/admin/en.yml +++ b/config/locales/admin/en.yml @@ -70,6 +70,14 @@ en: archive: Archive last_satep_finished_at: Last activity date comments: + resumes_comments: + comment_card: + confirm_archive: Are you sure you want to archive comment? + confirm_restore: Are you sure you want to restore comment? + comment_for: "Comment for %{resume}" + edit: Edit comment + archive: Archive comment + restore: Restore comment resumes_answers: answer_card: confirm_archive: Are you sure you want to archive answer? @@ -90,6 +98,9 @@ en: search_button: Search publishing_state_select: Publishing state applying_state_select: Applied state + menu: + all: All + archived: Archived resumes: index: edit: Edit CV diff --git a/config/locales/admin/ru.flash.yml b/config/locales/admin/ru.flash.yml index b1b2fa955..6655cb5f6 100644 --- a/config/locales/admin/ru.flash.yml +++ b/config/locales/admin/ru.flash.yml @@ -51,6 +51,16 @@ ru: update: success: Ответ на резюме успешно обновлен error: Не удалось обновить ответ на резюме + resumes_comments: + archive: + success: Комментарий к резюме успешно архивирован + error: Не удалось архивировать комментарий к резюме + restore: + success: Комментарий к резюме успешно восстановлен + error: Не удалось восстановить комментарий к резюме + update: + success: Комментарий к резюме успешно обновлен + error: Не удалось обновить комментарий к резюме vacancies: archive: success: Вакансия успешно архивирована diff --git a/config/locales/admin/ru.yml b/config/locales/admin/ru.yml index b013ff490..652d0f1ec 100644 --- a/config/locales/admin/ru.yml +++ b/config/locales/admin/ru.yml @@ -66,6 +66,14 @@ ru: restore: Восстановить last_satep_finished_at: Дата последней активности comments: + resumes_comments: + comment_card: + confirm_archive: Вы уверенны что хотите архивировать комментарий? + confirm_restore: Вы уверенны что хотите восстановить комментарий? + comment_for: "Комментарий к %{resume}" + edit: Редактировать комментарий + archive: Архивировать комментарий + restore: Восстановить комментарий resumes_answers: answer_card: confirm_archive: Вы уверенны что хотите архивировать ответ? @@ -88,6 +96,9 @@ ru: search_button: Поиск publishing_state_select: Опубликован? applying_state_select: Подтврежден? + menu: + all: Все + archived: Архивированные resumes: index: edit: Редактировать резюме diff --git a/config/routes.rb b/config/routes.rb index 1af84ab41..fe9a62fa4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -105,6 +105,9 @@ patch :archive patch :restore end + collection do + get :archived + end end resources :resumes_answers do member do diff --git a/db/migrate/20241014084448_add_state_columnt_to_resume_comment.rb b/db/migrate/20241014084448_add_state_columnt_to_resume_comment.rb new file mode 100644 index 000000000..a6a7b88cc --- /dev/null +++ b/db/migrate/20241014084448_add_state_columnt_to_resume_comment.rb @@ -0,0 +1,5 @@ +class AddStateColumntToResumeComment < ActiveRecord::Migration[7.1] + def change + add_column :resume_comments, :publishing_state, :string, default: 'published' + end +end diff --git a/db/schema.rb b/db/schema.rb index 5cf246658..fb1894c6a 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.1].define(version: 2024_09_30_104633) do +ActiveRecord::Schema[7.1].define(version: 2024_10_14_084448) do create_table "career_items", force: :cascade do |t| t.integer "order" t.integer "career_id", null: false @@ -177,6 +177,7 @@ t.string "content" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "publishing_state", default: "published" t.index ["resume_id"], name: "index_resume_comments_on_resume_id" t.index ["user_id"], name: "index_resume_comments_on_user_id" end diff --git a/test/factories/resume_comments.rb b/test/factories/resume_comments.rb index 337dbf164..dd8eb4c6b 100644 --- a/test/factories/resume_comments.rb +++ b/test/factories/resume_comments.rb @@ -4,12 +4,13 @@ # # Table name: resume_comments # -# id :integer not null, primary key -# content :string -# created_at :datetime not null -# updated_at :datetime not null -# resume_id :integer -# user_id :integer +# id :integer not null, primary key +# content :string +# publishing_state :string default("published") +# created_at :datetime not null +# updated_at :datetime not null +# resume_id :integer +# user_id :integer # # Indexes # diff --git a/test/fixtures/resume/comments.yml b/test/fixtures/resume/comments.yml index fa709c408..0fa2b4e7e 100644 --- a/test/fixtures/resume/comments.yml +++ b/test/fixtures/resume/comments.yml @@ -2,12 +2,13 @@ # # Table name: resume_comments # -# id :integer not null, primary key -# content :string -# created_at :datetime not null -# updated_at :datetime not null -# resume_id :integer -# user_id :integer +# id :integer not null, primary key +# content :string +# publishing_state :string default("published") +# created_at :datetime not null +# updated_at :datetime not null +# resume_id :integer +# user_id :integer # # Indexes # From 1428fde3a43e55013fe80c8e41141d9c61a72434 Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Mon, 14 Oct 2024 15:33:44 +0400 Subject: [PATCH 11/17] Updated archived answer view --- app/views/web/shared/_answer.html.slim | 83 +++++++------------ .../web/shared/_archived_answer.html.slim | 35 ++++++++ .../web/shared/_archived_comment.html.slim | 0 config/locales/en.views.yml | 3 + config/locales/ru.views.yml | 3 + 5 files changed, 71 insertions(+), 53 deletions(-) create mode 100644 app/views/web/shared/_archived_answer.html.slim create mode 100644 app/views/web/shared/_archived_comment.html.slim diff --git a/app/views/web/shared/_answer.html.slim b/app/views/web/shared/_answer.html.slim index ff9323c2a..b81727e33 100644 --- a/app/views/web/shared/_answer.html.slim +++ b/app/views/web/shared/_answer.html.slim @@ -1,59 +1,36 @@ -.card.mb-5(id="answer-#{answer.id}") - .card-header.d-flex.py-3.bg-white - .me-auto.d-flex - span.fw-bold = link_to answer.user, user_path(answer.user) - span.mx-2.fw-light - = link_to distance_of_time_in_words_to_now(answer.created_at), url_for(anchor: "answer-#{answer.id}"), class: 'text-muted' +- if answer.publishing_state == 'archived' + = render 'web/shared/archived_answer', answer:, current_user_likes_by_answer_id: +- else + .card.mb-5(id="answer-#{answer.id}") + .card-header.d-flex.py-3.bg-white + .me-auto.d-flex + span.fw-bold = link_to answer.user, user_path(answer.user) + span.mx-2.fw-light + = link_to distance_of_time_in_words_to_now(answer.created_at), url_for(anchor: "answer-#{answer.id}"), class: 'text-muted' - - if current_user == answer.user - .d-flex.me-3 - .me-2 - = link_to edit_resume_answer_path(answer.resume, answer) do - span.bi.bi-pen-fill.text-secondary - div - = link_to resume_answer_path(answer.resume, answer), method: :delete, data: { confirm: t('confirm') } do - span.bi.bi-x-lg.text-secondary + - if current_user == answer.user + .d-flex.me-3 + .me-2 + = link_to edit_resume_answer_path(answer.resume, answer) do + span.bi.bi-pen-fill.text-secondary + div + = link_to resume_answer_path(answer.resume, answer), method: :delete, data: { confirm: t('confirm') } do + span.bi.bi-x-lg.text-secondary - div - - if answer.pending? && current_user == answer.resume.user - // FIXME: Data params does not work - = link_to t('.apply'), change_applying_state_resume_answer_path(answer.resume, answer), - data: { confirm: t('confirm'), params: { event: :apply }.to_param }, - method: :patch, - class: 'badge bg-success p-1', - title: t('.apply') - - elsif answer.applied? - span.text-success = answer.aasm(:applying).human_state - - elsif answer.pending? - span.text-info = answer.aasm(:applying).human_state + div + - if answer.pending? && current_user == answer.resume.user + // FIXME: Data params does not work + = link_to t('.apply'), change_applying_state_resume_answer_path(answer.resume, answer), + data: { confirm: t('confirm'), params: { event: :apply }.to_param }, + method: :patch, + class: 'badge bg-success p-1', + title: t('.apply') + - elsif answer.applied? + span.text-success = answer.aasm(:applying).human_state + - elsif answer.pending? + span.text-info = answer.aasm(:applying).human_state - .card-body.d-flex - - if answer.publishing_state == 'archived' - .w-100 - .hexlet-cv-content.mb-3 - h3.muted.text-center = t('.archived_comment_header') - .text-muted.text-center = t('.archived_comment_body', deleted_at: l(answer.updated_at, format: :long)) - - if answer.comments.web.any? - - answer.comments.web.each do |comment| - hr.mb-4 - .d-flex(id="answer_comment-#{comment.id}") - .me-auto - span.me-2.hexlet-cv-content.hexlet-cv-inline-paragraph - == markdown2html comment.content - span.small - - if comment.user - span.me-1 - = link_to comment.user, user_path(comment.user) - = link_to l(comment.created_at, format: :long_schema), url_for(anchor: "answer_comment-#{comment.id}"), class: 'text-muted' - - if comment.user == current_user - .d-flex - .me-2 - = link_to edit_answer_comment_path(answer, comment) - span.bi.bi-pen-fill.text-secondary - div - = link_to answer_comment_path(answer, comment), method: :delete, data: { confirm: t('confirm') } do - span.bi.bi-x-lg.text-secondary - - else + .card-body.d-flex .me-3.h4 - let current_user_likes_by_answer_id.fetch(answer.id, nil) do |like| .text-center.text-muted.mb-2.mt-1.fw-light diff --git a/app/views/web/shared/_archived_answer.html.slim b/app/views/web/shared/_archived_answer.html.slim new file mode 100644 index 000000000..c5dfb53ec --- /dev/null +++ b/app/views/web/shared/_archived_answer.html.slim @@ -0,0 +1,35 @@ +.card.mb-5(id="answer-#{answer.id}") + .card-header.d-flex.py-3.bg-white + .me-auto.d-flex + span.fw-bold.text-decoration-line-through = answer.user + span.mx-2.fw-light + .text-muted = distance_of_time_in_words_to_now(answer.created_at) + .card-body.d-flex + .w-100 + .hexlet-cv-content.mb-3 + h3.muted.text-center = t('web.shared.answer.archived_answer_header') + .text-muted.text-center = t('web.shared.answer.archived_answer_body', deleted_at: l(answer.updated_at, format: :long)) + - if answer.comments.web.any? + - answer.comments.web.each do |comment| + hr.mb-4 + .d-flex(id="answer_comment-#{comment.id}") + .me-auto + span.me-2.hexlet-cv-content.hexlet-cv-inline-paragraph + == markdown2html comment.content + span.small + - if comment.user + span.me-1 + = link_to comment.user, user_path(comment.user) + = link_to l(comment.created_at, format: :long_schema), url_for(anchor: "answer_comment-#{comment.id}"), class: 'text-muted' + - if comment.user == current_user + .d-flex + .me-2 + = link_to edit_answer_comment_path(answer, comment) + span.bi.bi-pen-fill.text-secondary + div + = link_to answer_comment_path(answer, comment), method: :delete, data: { confirm: t('confirm') } do + span.bi.bi-x-lg.text-secondary + hr.mb-4 + .text-muted + i.bi.bi-lock.me-1 + = t('web.shared.answer.closed_conversation') diff --git a/app/views/web/shared/_archived_comment.html.slim b/app/views/web/shared/_archived_comment.html.slim new file mode 100644 index 000000000..e69de29bb diff --git a/config/locales/en.views.yml b/config/locales/en.views.yml index 818e98d54..7b422e247 100644 --- a/config/locales/en.views.yml +++ b/config/locales/en.views.yml @@ -79,8 +79,11 @@ en: add_a_comment: Add a comment apply: Apply title_apply: Apply recommendations + archived_answer_header: Answer is unavailable + archived_answer_body: The answer was deleted %{deleted_at} and is no longer available. archived_comment_header: Comment is unavailable archived_comment_body: The comment was deleted %{deleted_at} and is no longer available. + closed_conversation: Further discussion is unavailable empty_list: empty: Empty links_guides: diff --git a/config/locales/ru.views.yml b/config/locales/ru.views.yml index 19b6ff5bc..203cd33ec 100644 --- a/config/locales/ru.views.yml +++ b/config/locales/ru.views.yml @@ -157,8 +157,11 @@ ru: answer: apply: Принять add_a_comment: Добавить комментарий/ссылку на вакансию + archived_answer_header: Ответ недоступен + archived_answer_body: Ответ был удален %{deleted_at} администратором и более недоступен. archived_comment_header: Комментарий недоступен archived_comment_body: Комментарий был удален %{deleted_at} администратором и более недоступен. + closed_conversation: Дальнейшее обсуждение недоступно resume_filter: directions: Выберите направление name: Название резюме From 8fd2838c0f411ef8edf321c46560ec12afaf5a65 Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Mon, 14 Oct 2024 15:33:44 +0400 Subject: [PATCH 12/17] Updated archived answer view --- app/views/web/resumes/show.html.slim | 22 ++++--------------- app/views/web/shared/_answer.html.slim | 22 ++++--------------- .../web/shared/_answer_comment.html.slim | 18 +++++++++++++++ .../web/shared/_archived_answer.html.slim | 22 ++++--------------- .../web/shared/_archived_comment.html.slim | 10 +++++++++ .../shared/_resume_answer_comment.html.slim | 18 +++++++++++++++ .../web/shared/_resume_comment.html.slim | 18 +++++++++++++++ 7 files changed, 76 insertions(+), 54 deletions(-) create mode 100644 app/views/web/shared/_answer_comment.html.slim create mode 100644 app/views/web/shared/_resume_answer_comment.html.slim create mode 100644 app/views/web/shared/_resume_comment.html.slim diff --git a/app/views/web/resumes/show.html.slim b/app/views/web/resumes/show.html.slim index 3aa7b01e1..3fc55024e 100644 --- a/app/views/web/resumes/show.html.slim +++ b/app/views/web/resumes/show.html.slim @@ -33,24 +33,10 @@ h3.text-center = @resume - @resume.comments.web.each_with_index do |comment, i| - if i != 0 hr.mb-4 - .d-flex(id="comment-#{comment.id}") - .me-auto - span.me-1.hexlet-cv-content.hexlet-cv-inline-paragraph - == markdown2html comment.content - span.small - - if comment.user - span.me-1 - = link_to comment.user, user_path(comment.user) - = link_to l(comment.created_at, format: :long_schema), url_for(anchor: "comment-#{comment.id}"), class: 'text-muted' - - if comment.user == current_user - .d-flex - .me-2 - = link_to edit_resume_comment_path(@resume, comment) - span.bi.bi-pen-fill.text-secondary - - div - = link_to resume_comment_path(@resume, comment), method: :delete, data: { confirm: t('confirm') } do - span.bi.bi-x-lg.text-secondary + - if comment.archived? + = render 'web/shared/archived_comment', comment: + - else + = render 'web/shared/resume_comment', comment: hr.my-2 a.d-block.text-muted(href="#new_resume_comment-#{@resume.id}" data-bs-toggle="collapse") = t('.add_a_comment') diff --git a/app/views/web/shared/_answer.html.slim b/app/views/web/shared/_answer.html.slim index b81727e33..7ca2bcd6b 100644 --- a/app/views/web/shared/_answer.html.slim +++ b/app/views/web/shared/_answer.html.slim @@ -49,24 +49,10 @@ == markdown2html answer.content - if answer.comments.web.any? - answer.comments.web.each do |comment| - hr.mb-4 - .d-flex(id="answer_comment-#{comment.id}") - .me-auto - span.me-2.hexlet-cv-content.hexlet-cv-inline-paragraph - == markdown2html comment.content - span.small - - if comment.user - span.me-1 - = link_to comment.user, user_path(comment.user) - = link_to l(comment.created_at, format: :long_schema), url_for(anchor: "answer_comment-#{comment.id}"), class: 'text-muted' - - if comment.user == current_user - .d-flex - .me-2 - = link_to edit_answer_comment_path(answer, comment) - span.bi.bi-pen-fill.text-secondary - div - = link_to answer_comment_path(answer, comment), method: :delete, data: { confirm: t('confirm') } do - span.bi.bi-x-lg.text-secondary + - if comment.archived? + = render 'web/shared/archived_comment', comment: + -else + = render 'web/shared/resume_answer_comment', comment:, answer: hr.mb-4 a.d-block.text-muted(href="#new_answer_comment-#{answer.id}" data-bs-toggle='collapse') = t('.add_a_comment') diff --git a/app/views/web/shared/_answer_comment.html.slim b/app/views/web/shared/_answer_comment.html.slim new file mode 100644 index 000000000..635681794 --- /dev/null +++ b/app/views/web/shared/_answer_comment.html.slim @@ -0,0 +1,18 @@ +hr.mb-4 +.d-flex(id="answer_comment-#{comment.id}") + .me-auto + span.me-2.hexlet-cv-content.hexlet-cv-inline-paragraph + == markdown2html comment.content + span.small + - if comment.user + span.me-1 + = link_to comment.user, user_path(comment.user) + = link_to l(comment.created_at, format: :long_schema), url_for(anchor: "answer_comment-#{comment.id}"), class: 'text-muted' + - if comment.user == current_user + .d-flex + .me-2 + = link_to edit_answer_comment_path(answer, comment) + span.bi.bi-pen-fill.text-secondary + div + = link_to answer_comment_path(answer, comment), method: :delete, data: { confirm: t('confirm') } do + span.bi.bi-x-lg.text-secondary diff --git a/app/views/web/shared/_archived_answer.html.slim b/app/views/web/shared/_archived_answer.html.slim index c5dfb53ec..f0cb30e30 100644 --- a/app/views/web/shared/_archived_answer.html.slim +++ b/app/views/web/shared/_archived_answer.html.slim @@ -11,24 +11,10 @@ .text-muted.text-center = t('web.shared.answer.archived_answer_body', deleted_at: l(answer.updated_at, format: :long)) - if answer.comments.web.any? - answer.comments.web.each do |comment| - hr.mb-4 - .d-flex(id="answer_comment-#{comment.id}") - .me-auto - span.me-2.hexlet-cv-content.hexlet-cv-inline-paragraph - == markdown2html comment.content - span.small - - if comment.user - span.me-1 - = link_to comment.user, user_path(comment.user) - = link_to l(comment.created_at, format: :long_schema), url_for(anchor: "answer_comment-#{comment.id}"), class: 'text-muted' - - if comment.user == current_user - .d-flex - .me-2 - = link_to edit_answer_comment_path(answer, comment) - span.bi.bi-pen-fill.text-secondary - div - = link_to answer_comment_path(answer, comment), method: :delete, data: { confirm: t('confirm') } do - span.bi.bi-x-lg.text-secondary + - if comment.archived? + = render 'web/shared/archived_comment', comment: + -else + = render 'web/shared/resume_answer_comment', comment:, answer: hr.mb-4 .text-muted i.bi.bi-lock.me-1 diff --git a/app/views/web/shared/_archived_comment.html.slim b/app/views/web/shared/_archived_comment.html.slim index e69de29bb..f6711a809 100644 --- a/app/views/web/shared/_archived_comment.html.slim +++ b/app/views/web/shared/_archived_comment.html.slim @@ -0,0 +1,10 @@ +.d-flex(id="comment-#{comment.id}") + .me-auto + span.me-1.hexlet-cv-content.hexlet-cv-inline-paragraph + .text-muted.text-center = t('web.shared.answer.archived_comment_header') + .text-muted.text-center = t('web.shared.answer.archived_comment_body', deleted_at: l(comment.updated_at, format: :long)) + span.small + - if comment.user + span.text-decoration-line-through.me-1 + = comment.user + span.text-muted = l(comment.created_at, format: :long_schema) diff --git a/app/views/web/shared/_resume_answer_comment.html.slim b/app/views/web/shared/_resume_answer_comment.html.slim new file mode 100644 index 000000000..635681794 --- /dev/null +++ b/app/views/web/shared/_resume_answer_comment.html.slim @@ -0,0 +1,18 @@ +hr.mb-4 +.d-flex(id="answer_comment-#{comment.id}") + .me-auto + span.me-2.hexlet-cv-content.hexlet-cv-inline-paragraph + == markdown2html comment.content + span.small + - if comment.user + span.me-1 + = link_to comment.user, user_path(comment.user) + = link_to l(comment.created_at, format: :long_schema), url_for(anchor: "answer_comment-#{comment.id}"), class: 'text-muted' + - if comment.user == current_user + .d-flex + .me-2 + = link_to edit_answer_comment_path(answer, comment) + span.bi.bi-pen-fill.text-secondary + div + = link_to answer_comment_path(answer, comment), method: :delete, data: { confirm: t('confirm') } do + span.bi.bi-x-lg.text-secondary diff --git a/app/views/web/shared/_resume_comment.html.slim b/app/views/web/shared/_resume_comment.html.slim new file mode 100644 index 000000000..213ea384a --- /dev/null +++ b/app/views/web/shared/_resume_comment.html.slim @@ -0,0 +1,18 @@ +.d-flex(id="comment-#{comment.id}") + .me-auto + span.me-1.hexlet-cv-content.hexlet-cv-inline-paragraph + == markdown2html comment.content + span.small + - if comment.user + span.me-1 + = link_to comment.user, user_path(comment.user) + = link_to l(comment.created_at, format: :long_schema), url_for(anchor: "comment-#{comment.id}"), class: 'text-muted' + - if comment.user == current_user + .d-flex + .me-2 + = link_to edit_resume_comment_path(@resume, comment) + span.bi.bi-pen-fill.text-secondary + + div + = link_to resume_comment_path(@resume, comment), method: :delete, data: { confirm: t('confirm') } do + span.bi.bi-x-lg.text-secondary From c22bb641b3046ee714ac5083dd992e343b758b2b Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Mon, 18 Nov 2024 14:12:53 +0400 Subject: [PATCH 13/17] Fixed error, added aasm state for Answer::Comment --- app/models/resume/answer/comment.rb | 31 ++++++++++++++----- ..._state_columnt_to_resume_answer_comment.rb | 5 +++ db/schema.rb | 3 +- test/factories/resume_answer_comments.rb | 17 +++++----- test/fixtures/resume/answer/comments.yml | 17 +++++----- test/models/resume/answer/comment_test.rb | 17 +++++----- 6 files changed, 57 insertions(+), 33 deletions(-) create mode 100644 db/migrate/20241118100206_add_state_columnt_to_resume_answer_comment.rb diff --git a/app/models/resume/answer/comment.rb b/app/models/resume/answer/comment.rb index 685ead608..a85040371 100644 --- a/app/models/resume/answer/comment.rb +++ b/app/models/resume/answer/comment.rb @@ -4,14 +4,15 @@ # # Table name: resume_answer_comments # -# id :integer not null, primary key -# content :string -# created_at :datetime not null -# updated_at :datetime not null -# answer_id :integer not null -# answer_user_id :integer not null -# resume_id :integer not null -# user_id :integer not null +# id :integer not null, primary key +# content :string +# publishing_state :string default("published") +# created_at :datetime not null +# updated_at :datetime not null +# answer_id :integer not null +# answer_user_id :integer not null +# resume_id :integer not null +# user_id :integer not null # # Indexes # @@ -28,6 +29,7 @@ # user_id (user_id => users.id) # class Resume::Answer::Comment < ApplicationRecord + include AASM validates :content, presence: true, length: { minimum: 10, maximum: 400 } belongs_to :resume @@ -38,6 +40,19 @@ class Resume::Answer::Comment < ApplicationRecord include Resume::Answer::CommentRepository + aasm :publishing, column: :publishing_state do + state :published, initial: true + state :archived + + event :archive do + transitions from: :published, to: :archived + end + + event :restore do + transitions from: :archived, to: :published + end + end + def to_s content end diff --git a/db/migrate/20241118100206_add_state_columnt_to_resume_answer_comment.rb b/db/migrate/20241118100206_add_state_columnt_to_resume_answer_comment.rb new file mode 100644 index 000000000..e49810cc2 --- /dev/null +++ b/db/migrate/20241118100206_add_state_columnt_to_resume_answer_comment.rb @@ -0,0 +1,5 @@ +class AddStateColumntToResumeAnswerComment < ActiveRecord::Migration[7.1] + def change + add_column :resume_answer_comments, :publishing_state, :string, default: 'published' + end +end diff --git a/db/schema.rb b/db/schema.rb index fb1894c6a..b25f8424e 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.1].define(version: 2024_10_14_084448) do +ActiveRecord::Schema[7.1].define(version: 2024_11_18_100206) do create_table "career_items", force: :cascade do |t| t.integer "order" t.integer "career_id", null: false @@ -139,6 +139,7 @@ t.string "content" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "publishing_state", default: "published" t.index ["answer_id"], name: "index_resume_answer_comments_on_answer_id" t.index ["answer_user_id"], name: "index_resume_answer_comments_on_answer_user_id" t.index ["resume_id"], name: "index_resume_answer_comments_on_resume_id" diff --git a/test/factories/resume_answer_comments.rb b/test/factories/resume_answer_comments.rb index b02f98c8a..ebe3255b7 100644 --- a/test/factories/resume_answer_comments.rb +++ b/test/factories/resume_answer_comments.rb @@ -4,14 +4,15 @@ # # Table name: resume_answer_comments # -# id :integer not null, primary key -# content :string -# created_at :datetime not null -# updated_at :datetime not null -# answer_id :integer not null -# answer_user_id :integer not null -# resume_id :integer not null -# user_id :integer not null +# id :integer not null, primary key +# content :string +# publishing_state :string default("published") +# created_at :datetime not null +# updated_at :datetime not null +# answer_id :integer not null +# answer_user_id :integer not null +# resume_id :integer not null +# user_id :integer not null # # Indexes # diff --git a/test/fixtures/resume/answer/comments.yml b/test/fixtures/resume/answer/comments.yml index 7bed65bbc..2e513379f 100644 --- a/test/fixtures/resume/answer/comments.yml +++ b/test/fixtures/resume/answer/comments.yml @@ -2,14 +2,15 @@ # # Table name: resume_answer_comments # -# id :integer not null, primary key -# content :string -# created_at :datetime not null -# updated_at :datetime not null -# answer_id :integer not null -# answer_user_id :integer not null -# resume_id :integer not null -# user_id :integer not null +# id :integer not null, primary key +# content :string +# publishing_state :string default("published") +# created_at :datetime not null +# updated_at :datetime not null +# answer_id :integer not null +# answer_user_id :integer not null +# resume_id :integer not null +# user_id :integer not null # # Indexes # diff --git a/test/models/resume/answer/comment_test.rb b/test/models/resume/answer/comment_test.rb index a8d297079..f7b8e7fac 100644 --- a/test/models/resume/answer/comment_test.rb +++ b/test/models/resume/answer/comment_test.rb @@ -4,14 +4,15 @@ # # Table name: resume_answer_comments # -# id :integer not null, primary key -# content :string -# created_at :datetime not null -# updated_at :datetime not null -# answer_id :integer not null -# answer_user_id :integer not null -# resume_id :integer not null -# user_id :integer not null +# id :integer not null, primary key +# content :string +# publishing_state :string default("published") +# created_at :datetime not null +# updated_at :datetime not null +# answer_id :integer not null +# answer_user_id :integer not null +# resume_id :integer not null +# user_id :integer not null # # Indexes # From 523be72d7941e7b1564095d1604312a8b510fbfa Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Mon, 18 Nov 2024 15:29:41 +0400 Subject: [PATCH 14/17] Fixed view for admin->resume->answer->comment --- .../resumes_answers_comments_controller.rb | 16 ++++++++++++++-- .../resumes_answers/_answer_comment.html.slim | 12 ++++++------ config/locales/admin/ru.yml | 7 +++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/controllers/web/admin/comments/resumes_answers_comments_controller.rb b/app/controllers/web/admin/comments/resumes_answers_comments_controller.rb index 3cd16534d..89a451469 100644 --- a/app/controllers/web/admin/comments/resumes_answers_comments_controller.rb +++ b/app/controllers/web/admin/comments/resumes_answers_comments_controller.rb @@ -15,9 +15,21 @@ def update end end - def archive; end + def archive + return unless @comment.may_archive? - def restore; end + @comment.archive! + f(:success) + redirect_to admin_resumes_answers_path + end + + def restore + return unless @comment.may_restore? + + @comment.restore! + f(:success) + redirect_to admin_resumes_answers_path + end private diff --git a/app/views/web/admin/comments/resumes_answers/_answer_comment.html.slim b/app/views/web/admin/comments/resumes_answers/_answer_comment.html.slim index 21e8aa99d..43b9d034d 100644 --- a/app/views/web/admin/comments/resumes_answers/_answer_comment.html.slim +++ b/app/views/web/admin/comments/resumes_answers/_answer_comment.html.slim @@ -8,17 +8,17 @@ .col-4 .fw-bold = link_to "##{comment.id}", resume_path(answer.resume, anchor: "answer_comment-#{comment.id}") .col-6 - = link_to t('.answer_comment_for', resume: answer.id), resume_path(answer.resume) + = link_to t('.answer_comment_for', resume: answer.id), resume_path(answer.resume, anchor: "answer-#{answer.id}") .col-2 .d-flex.align-items-end.flex-column .btn-group[role='group' aria-label="#{t('action_buttons')}"] - = link_to edit_admin_resumes_answers_comment_path(comment), class: 'btn btn-outline-primary btn-sm', title: t('.edit') do + = link_to edit_admin_resumes_answers_comment_path(comment), class: 'btn btn-outline-primary btn-sm', title: t('.edit', answer: answer.id) do span.bi.bi-gear-fill - - if answer.may_restore? - = link_to restore_admin_resumes_answers_comment_path(comment, page: params[:page]), method: :patch, class: 'btn btn-outline-success btn-sm', data: { confirm: t('.confirm_restore') }, title: t('.restore') do + - if comment.may_restore? + = link_to restore_admin_resumes_answers_comment_path(comment, page: params[:page]), method: :patch, class: 'btn btn-outline-success btn-sm', data: { confirm: t('.confirm_restore', answer: answer.id) }, title: t('.restore', answer: answer.id) do span.bi.bi-arrow-counterclockwise - - elsif answer.may_archive? - = link_to archive_admin_resumes_answers_comment_path(comment, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive') }, title: t('.archive') do + - elsif comment.may_archive? + = link_to archive_admin_resumes_answers_comment_path(comment, page: params[:page]), method: :patch, class: 'btn btn-outline-danger btn-sm', data: { confirm: t('.confirm_archive', answer: answer.id) }, title: t('.archive', answer: answer.id) do span.bi.bi-trash3 .card-body .row diff --git a/config/locales/admin/ru.yml b/config/locales/admin/ru.yml index 652d0f1ec..a44123613 100644 --- a/config/locales/admin/ru.yml +++ b/config/locales/admin/ru.yml @@ -87,6 +87,13 @@ ru: few: Показать %{count} комментария many: Показать %{count} комментариев other: Показать %{count} комментариев + answer_comment: + answer_comment_for: "Комментарий к ответу к #%{resume}" + edit: "Редактировать комментарий к ответу #%{answer}" + archive: "Архивировать комментарий к ответу #%{answer}" + restore: "Восстановить комментарий к ответу #%{answer}" + confirm_restore: "Вы уверенны что хотите восстановить комментарий к ответу #%{answer}?" + confirm_archive: "Вы уверенны что хотите архивировать комментарий к ответу #%{answer}?" menu: all: Все archived: Архивированные From ed794f93e886f78d335d0d2acd38bbc6d6cc027a Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Fri, 29 Nov 2024 20:15:33 +0400 Subject: [PATCH 15/17] Updated makefile for building on computers with m-series processors --- Gemfile.lock | 1 + Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index f2dec7fee..373e063ff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -570,6 +570,7 @@ GEM PLATFORMS arm64-darwin-22 arm64-darwin-23 + arm64-darwin-24 x86_64-darwin-21 x86_64-darwin-22 x86_64-linux diff --git a/Makefile b/Makefile index f79e96ea7..ba8e27e27 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ setup: setup-heroku-arm64: arch -x86_64 /bin/zsh -c 'curl https://cli-assets.heroku.com/install.sh | sh' -# setup-arm64: setup-heroku-arm64 setup-app +setup-arm64: setup-heroku-arm64 setup-app setup-app: cp -n .env.example .env || true From 9fe45c37837237629a358623baacca6722ee9879 Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Mon, 2 Dec 2024 13:30:07 +0400 Subject: [PATCH 16/17] Added missed l18n --- config/locales/admin/en.flash.yml | 22 ++++++++++++++++------ config/locales/admin/en.yml | 7 +++++++ config/locales/admin/ru.flash.yml | 26 +++++++++++++++++++------- config/locales/ru.activerecord.yml | 6 ++---- config/locales/ru.attributes.yml | 3 +++ 5 files changed, 47 insertions(+), 17 deletions(-) diff --git a/config/locales/admin/en.flash.yml b/config/locales/admin/en.flash.yml index 693977392..b3aeb9ad3 100644 --- a/config/locales/admin/en.flash.yml +++ b/config/locales/admin/en.flash.yml @@ -44,23 +44,33 @@ en: resumes_answers: archive: success: Answer on resume successfully archived - error: Failed to archive answer + error: "Failed to archive answer, errors occurred: %{errors}" restore: success: Answer on resume successfully restored - error: Failed to restore answer + error: "Failed to restore answer, errors occurred: %{errors}" update: success: Answer on resume successfully updated - error: Failed to update answer + error: "Failed to update answer, errors occurred: %{errors}" resumes_comments: archive: success: Comment for resume successfully archived - error: Failed to archive comment + error: "Failed to archive comment, errors occurred: %{errors}" restore: success: Comment for resume successfully restored - error: Failed to restore comment + error: "Failed to restore comment, errors occurred: %{errors}" update: success: Comment for resume successfully updated - error: Failed to update comment + error: "Failed to update comment, errors occurred: %{errors}" + resumes_answers_comments: + archive: + success: Comment for answer successfully archived + error: "Failed to archive comment for answer, errors occurred: %{errors}" + restore: + success: Comment for answer successfully restored + error: "Failed to restore answers comment, errors occurred: %{errors}" + update: + success: Comment for answer successfully updated + error: "Failed to update comment for answer, errors occurred: %{errors}" vacancies: cancel: success: Vacancy canceled successfull diff --git a/config/locales/admin/en.yml b/config/locales/admin/en.yml index 8e5626227..7a9f94301 100644 --- a/config/locales/admin/en.yml +++ b/config/locales/admin/en.yml @@ -89,6 +89,13 @@ en: show_comments: one: Show %{count} comment other: Show %{count} comments + answer_comment: + answer_comment_for: "Comment for answer #%{answer}" + edit: "Edit comment for answer #%{answer}" + archive: "Archive comment for answer #%{answer}" + restore: "Restore comment for answer #%{answer}" + confirm_restore: "Are you sure you want to restore comment for answer #%{answer}?" + confirm_archive: "Are you sure you want to archive comment for answer #%{answer}?" menu: all: All archived: Archived diff --git a/config/locales/admin/ru.flash.yml b/config/locales/admin/ru.flash.yml index 6655cb5f6..2d8e80c08 100644 --- a/config/locales/admin/ru.flash.yml +++ b/config/locales/admin/ru.flash.yml @@ -35,32 +35,44 @@ ru: resumes: archive: success: Резюме успешно архивировано + error: "Возникли ошибки: %{errors}" restore: success: Резюме успешно опубликовано + error: "Возникли ошибки: %{errors}" update: success: Резюме успешно обновленно - error: Не удалось обновить резюме... Проверьте данные в форме и попробуйте еще раз. + error: "Возникли ошибки: %{errors}" comments: resumes_answers: archive: success: Ответ на резюме успешно архивирован - error: Не удалось архивировать ответ на резюме + error: "Не удалось архивировать ответ на резюме, возникли ошибки: %{errors}" restore: success: Ответ на резюме успешно восстановлен - error: Не удалось восстановить ответ на резюме + error: "Не удалось восстановить ответ на резюме, возникли ошибки: %{errors}" update: success: Ответ на резюме успешно обновлен - error: Не удалось обновить ответ на резюме + error: "Не удалось обновить ответ на резюме, возникли ошибки: %{errors}" resumes_comments: archive: success: Комментарий к резюме успешно архивирован - error: Не удалось архивировать комментарий к резюме + error: "Не удалось архивировать комментарий к резюме, возникли ошибки: %{errors}" restore: success: Комментарий к резюме успешно восстановлен - error: Не удалось восстановить комментарий к резюме + error: "Не удалось восстановить комментарий к резюме, возникли ошибки: %{errors}" update: success: Комментарий к резюме успешно обновлен - error: Не удалось обновить комментарий к резюме + error: "Не удалось обновить комментарий к резюме, возникли ошибки: %{errors}" + resumes_answers_comments: + archive: + success: Комментарий к ответу успешно архивирован + error: "Не удалось архивировать комментарий к ответу, возникли ошибки: %{errors}" + restore: + success: Комментарий к ответу успешно восстановлен + error: "Не удалось восстановить комментарий к ответу, возникли ошибки: %{errors}" + update: + success: Комментарий к ответу успешно обновлен + error: "Не удалось обновить комментарий к ответу, возникли ошибки: %{errors}" vacancies: archive: success: Вакансия успешно архивирована diff --git a/config/locales/ru.activerecord.yml b/config/locales/ru.activerecord.yml index 9ad2ad15d..8c2a9f274 100644 --- a/config/locales/ru.activerecord.yml +++ b/config/locales/ru.activerecord.yml @@ -141,14 +141,12 @@ ru: user: Пользователь likes_count: Количество лайков content: Ответ - publishing_state: Опубликован? - applying_state: Подтвержден? + publishing_state: Ст. публикации + applying_state: Ст. подтверждения applying_state/pending: Ожидает подтверждения applying_state/applied: Изменения внесены publishing_state/published: Опубликован publishing_state/archived: В архиве - created_at: Дата создания - updated_at: Дата обновления resume/job: content: Описание resume/work: diff --git a/config/locales/ru.attributes.yml b/config/locales/ru.attributes.yml index 04e1b1a06..c9b2d8629 100644 --- a/config/locales/ru.attributes.yml +++ b/config/locales/ru.attributes.yml @@ -1,3 +1,6 @@ ru: attributes: created_at: Дата создания + updated_at: Дата обновления + user: Пользователь + publishing_state: Ст. публикации From 9131c74f05e58050c160f22502a56b3952d2f04c Mon Sep 17 00:00:00 2001 From: Alexander Veselov Date: Tue, 3 Dec 2024 20:53:48 +0400 Subject: [PATCH 17/17] Updated the comments style a bit (it's now anchored in the center) --- app/views/web/shared/_archived_comment.html.slim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/web/shared/_archived_comment.html.slim b/app/views/web/shared/_archived_comment.html.slim index f6711a809..b47cfaf8d 100644 --- a/app/views/web/shared/_archived_comment.html.slim +++ b/app/views/web/shared/_archived_comment.html.slim @@ -1,8 +1,9 @@ -.d-flex(id="comment-#{comment.id}") +hr.mb-4 +.(id="comment-#{comment.id}") .me-auto - span.me-1.hexlet-cv-content.hexlet-cv-inline-paragraph - .text-muted.text-center = t('web.shared.answer.archived_comment_header') - .text-muted.text-center = t('web.shared.answer.archived_comment_body', deleted_at: l(comment.updated_at, format: :long)) + span.me-1.hexlet-cv-content.hexlet-cv-inline-paragraph.text-center + .text-muted = t('web.shared.answer.archived_comment_header') + .text-muted = t('web.shared.answer.archived_comment_body', deleted_at: l(comment.updated_at, format: :long)) span.small - if comment.user span.text-decoration-line-through.me-1