diff --git a/app/controllers/entries_controller.rb b/app/controllers/entries_controller.rb index 1f6c7d5..cfe5f6d 100644 --- a/app/controllers/entries_controller.rb +++ b/app/controllers/entries_controller.rb @@ -78,7 +78,7 @@ class EntriesController < ApplicationController end def entry_params - params.require(:entry).permit(:category) + params.require(:entry).permit(:category, :fi, :en, :sv, :no, :ru, :de, :notes) end def validate_language_code(code) diff --git a/app/views/admin/requests/edit.html.erb b/app/views/admin/requests/edit.html.erb index e3d193c..d820b4f 100644 --- a/app/views/admin/requests/edit.html.erb +++ b/app/views/admin/requests/edit.html.erb @@ -18,50 +18,7 @@ <% end %>
-
- <%= f.label :category, "Category", class: "block text-sm font-semibold text-gray-700 mb-2" %> - <%= f.select :category, Entry.categories.keys.map { |cat| [cat.humanize, cat] }, {}, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> -
- -
-

Translations

-
-
- <%= f.label :fi, "🇫🇮 Finnish", class: "block text-sm font-medium text-gray-700 mb-2" %> - <%= f.text_field :fi, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> -
- -
- <%= f.label :en, "🇬🇧 English", class: "block text-sm font-medium text-gray-700 mb-2" %> - <%= f.text_field :en, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> -
- -
- <%= f.label :sv, "🇸🇪 Swedish", class: "block text-sm font-medium text-gray-700 mb-2" %> - <%= f.text_field :sv, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> -
- -
- <%= f.label :no, "🇳🇴 Norwegian", class: "block text-sm font-medium text-gray-700 mb-2" %> - <%= f.text_field :no, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> -
- -
- <%= f.label :ru, "🇷🇺 Russian", class: "block text-sm font-medium text-gray-700 mb-2" %> - <%= f.text_field :ru, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> -
- -
- <%= f.label :de, "🇩🇪 German", class: "block text-sm font-medium text-gray-700 mb-2" %> - <%= f.text_field :de, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> -
-
-
- -
- <%= f.label :notes, "Additional Notes", class: "block text-sm font-semibold text-gray-700 mb-2" %> - <%= f.text_area :notes, rows: 4, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition", placeholder: "Any additional context or information about this entry..." %> -
+ <%= render 'entries/form_fields', f: f %>

Requester (Read-only)

diff --git a/app/views/entries/_form_fields.html.erb b/app/views/entries/_form_fields.html.erb new file mode 100644 index 0000000..7073af4 --- /dev/null +++ b/app/views/entries/_form_fields.html.erb @@ -0,0 +1,57 @@ +<%# Local variables expected: + # - f: form builder object + # - show_category: boolean (default: true) - whether to show category field + # - show_notes: boolean (default: true) - whether to show notes field +%> + +<% show_category = local_assigns.fetch(:show_category, true) %> +<% show_notes = local_assigns.fetch(:show_notes, true) %> + +<% if show_category %> +
+ <%= f.label :category, "Category", class: "block text-sm font-semibold text-gray-700 mb-2" %> + <%= f.select :category, Entry.categories.keys.map { |cat| [cat.humanize, cat] }, { prompt: "Select a category" }, { required: true, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" } %> +
+<% end %> + +
+

Translations (at least one required)

+
+
+ <%= f.label :fi, "🇫🇮 Finnish", class: "block text-sm font-medium text-gray-700 mb-2" %> + <%= f.text_field :fi, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> +
+ +
+ <%= f.label :en, "🇬🇧 English", class: "block text-sm font-medium text-gray-700 mb-2" %> + <%= f.text_field :en, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> +
+ +
+ <%= f.label :sv, "🇸🇪 Swedish", class: "block text-sm font-medium text-gray-700 mb-2" %> + <%= f.text_field :sv, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> +
+ +
+ <%= f.label :no, "🇳🇴 Norwegian", class: "block text-sm font-medium text-gray-700 mb-2" %> + <%= f.text_field :no, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> +
+ +
+ <%= f.label :ru, "🇷🇺 Russian", class: "block text-sm font-medium text-gray-700 mb-2" %> + <%= f.text_field :ru, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> +
+ +
+ <%= f.label :de, "🇩🇪 German", class: "block text-sm font-medium text-gray-700 mb-2" %> + <%= f.text_field :de, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> +
+
+
+ +<% if show_notes %> +
+ <%= f.label :notes, "Additional Notes (optional)", class: "block text-sm font-semibold text-gray-700 mb-2" %> + <%= f.text_area :notes, rows: 4, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition", placeholder: "Any additional context or information about this entry..." %> +
+<% end %> diff --git a/app/views/entries/edit.html.erb b/app/views/entries/edit.html.erb index d8495df..6bb674a 100644 --- a/app/views/entries/edit.html.erb +++ b/app/views/entries/edit.html.erb @@ -1,70 +1,99 @@ <% content_for :title, "Edit Entry" %> - - -
-
- <%= link_to "← Back to entry", entry_path(@entry), class: "text-sm text-slate-500 hover:text-indigo-600" %> - <%= link_to "Back to search", entries_path, class: "text-sm text-slate-500 hover:text-indigo-600" %> -
- -
-
- Edit Category - <% if @entry.verified? %> -
- - Verified +
+
+
+
+ <%= link_to root_path, class: "flex items-center gap-2" do %> + Sanasto + Wiki + <% end %> +
+ <%= link_to "Browse", entries_path, class: "text-sm font-medium text-slate-600 hover:text-indigo-600 transition" %> + <%= link_to "Download XLSX", download_entries_path(format: :xlsx), class: "text-xs font-bold text-indigo-700 px-3 py-2 rounded-md border border-indigo-200 bg-indigo-50 hover:bg-indigo-100 transition" %>
- <% else %> - Unverified - <% end %> +
+
-
- <%= form_with model: @entry, class: "space-y-4" do |form| %> -
- <%= form.label :category, "Category", class: "block text-xs font-bold text-slate-500 uppercase tracking-widest mb-2" %> - <%= form.select :category, +
+
+
+
+
+

Edit Entry

+ <% if @entry.verified? %> +
+ + Verified +
+ <% else %> + Unverified + <% end %> +
+

Update the translations and details for this entry.

+
+ + <%= form_with model: @entry, class: "space-y-6" do |f| %> + <% if @entry.errors.any? %> +
+

Please fix the following errors:

+
    + <% @entry.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+
+ <%= f.label :category, "Category", class: "block text-sm font-semibold text-gray-700 mb-2" %> + <%= f.select :category, Entry.categories.keys.map { |key| [key.tr("_", " ").capitalize, key] }, {}, - class: "block w-full border-slate-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" %> -
-
- <%= form.submit "Save Category", class: "bg-indigo-600 text-white px-4 py-2 rounded-lg text-sm font-semibold hover:bg-indigo-700 transition" %> -
- <% end %> - -
- <% supported_languages.each do |language| %> - <% translation = entry_translation_for(@entry, language.code) %> - <% next if translation.blank? %> -
-
- <%= "#{language.name} (#{language.code.upcase})" %> + { class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" } %>
-

<%= translation %>

+
+ +
+

Translations (at least one required)

+
+ <% %w[fi en sv no ru de].each do |lang_code| %> +
+ <%= f.label lang_code.to_sym, + case lang_code + when 'fi' then '🇫🇮 Finnish' + when 'en' then '🇬🇧 English' + when 'sv' then '🇸🇪 Swedish' + when 'no' then '🇳🇴 Norwegian' + when 'ru' then '🇷🇺 Russian' + when 'de' then '🇩🇪 German' + end, + class: "block text-sm font-medium text-gray-700 mb-2" %> + <%= f.text_field lang_code.to_sym, + class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> +
+ <% end %> +
+
+ +
+ <%= f.label :notes, "Additional Notes (optional)", class: "block text-sm font-semibold text-gray-700 mb-2" %> + <%= f.text_area :notes, rows: 4, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition", placeholder: "Any additional context or information about this entry..." %> +
+ +
+ <%= f.submit "Save Changes", class: "flex-1 bg-indigo-600 hover:bg-indigo-700 text-white font-semibold py-3 px-6 rounded-lg transition shadow-md hover:shadow-lg" %> + <%= link_to "Cancel", entry_path(@entry), class: "flex-1 text-center bg-gray-100 hover:bg-gray-200 text-gray-800 font-semibold py-3 px-6 rounded-lg transition" %>
<% end %> -
- <% if @entry.notes.present? %> -
-

Context & Notes

-

<%= @entry.notes %>

+
+ <%= link_to "← Back to entry", entry_path(@entry), class: "text-indigo-600 hover:text-indigo-800 font-semibold" %> • + <%= link_to "Back to search", entries_path, class: "text-indigo-600 hover:text-indigo-800 font-semibold" %>
- <% end %> +
-
+
diff --git a/app/views/requests/new.html.erb b/app/views/requests/new.html.erb index c44a3e5..44791de 100644 --- a/app/views/requests/new.html.erb +++ b/app/views/requests/new.html.erb @@ -65,52 +65,9 @@ <%= f.email_field :email, required: true, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %>
<% end %> - -
- <%= f.label :category, "Category", class: "block text-sm font-semibold text-gray-700 mb-2" %> - <%= f.select :category, Entry.categories.keys.map { |cat| [cat.humanize, cat] }, { prompt: "Select a category" }, { required: true, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" } %> -
-
-

Translations (at least one required)

-
-
- <%= f.label :fi, "🇫🇮 Finnish", class: "block text-sm font-medium text-gray-700 mb-2" %> - <%= f.text_field :fi, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> -
- -
- <%= f.label :en, "🇬🇧 English", class: "block text-sm font-medium text-gray-700 mb-2" %> - <%= f.text_field :en, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> -
- -
- <%= f.label :sv, "🇸🇪 Swedish", class: "block text-sm font-medium text-gray-700 mb-2" %> - <%= f.text_field :sv, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> -
- -
- <%= f.label :no, "🇳🇴 Norwegian", class: "block text-sm font-medium text-gray-700 mb-2" %> - <%= f.text_field :no, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> -
- -
- <%= f.label :ru, "🇷🇺 Russian", class: "block text-sm font-medium text-gray-700 mb-2" %> - <%= f.text_field :ru, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> -
- -
- <%= f.label :de, "🇩🇪 German", class: "block text-sm font-medium text-gray-700 mb-2" %> - <%= f.text_field :de, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition" %> -
-
-
- -
- <%= f.label :notes, "Additional Notes (optional)", class: "block text-sm font-semibold text-gray-700 mb-2" %> - <%= f.text_area :notes, rows: 4, class: "w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition", placeholder: "Any additional context or information about this entry..." %> -
+ <%= render 'entries/form_fields', f: f %>
<%= f.submit "Submit Request", class: "flex-1 bg-indigo-600 hover:bg-indigo-700 text-white font-semibold py-3 px-6 rounded-lg transition shadow-md hover:shadow-lg" %> diff --git a/docs/TODO.md b/docs/TODO.md index 12a4edd..1dbe1f9 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -49,11 +49,11 @@ - [x] **Live search** (AJAX updates without page reload) ### Entry Management -- [ ] **Create entry form** with all language fields -- [ ] **Edit entry form** (contributors only) +- [x] **Create entry form** with all language fields +- [x] **Edit entry form** (contributors only) - [ ] **Delete entries** (admin only, with confirmation) - [ ] **Bulk actions** (select multiple, bulk edit/delete) -- [ ] **Entry validation** (at least one language required, category required) +- [x] **Entry validation** (at least one language required, category required) ### Suggested Meanings - [ ] **Submit alternative translation** form