]> cat aescling's git repositories - mastodon.git/commitdiff
Spike out index and new views for keyword mutes controller.
authorDavid Yip <yipdw@member.fsf.org>
Sun, 15 Oct 2017 09:51:42 +0000 (04:51 -0500)
committerDavid Yip <yipdw@member.fsf.org>
Sat, 21 Oct 2017 19:54:36 +0000 (14:54 -0500)
app/controllers/settings/keyword_mutes_controller.rb
app/views/settings/keyword_mutes/_keyword_mute.html.haml [new file with mode: 0644]
app/views/settings/keyword_mutes/index.html.haml
app/views/settings/keyword_mutes/new.html.haml [new file with mode: 0644]
config/locales/en.yml

index ffe94e33a432068843195f4c0c9b60e1ddaa2f7f..4b3e01b9cad94c0fd10034e2ea8dd0749e74d5c5 100644 (file)
@@ -4,4 +4,27 @@ class Settings::KeywordMutesController < ApplicationController
   layout 'admin'
 
   before_action :authenticate_user!
+  before_action :set_account
+
+  def index
+    @keyword_mutes = paginated_keyword_mutes_for_account
+  end
+
+  def new
+    @keyword_mute = keyword_mutes_for_account.build
+  end
+
+  private
+
+  def set_account
+    @account = current_user.account
+  end
+
+  def keyword_mutes_for_account
+    KeywordMute.where(account: @account)
+  end
+
+  def paginated_keyword_mutes_for_account
+    keyword_mutes_for_account.order(:keyword).page params[:page]
+  end
 end
diff --git a/app/views/settings/keyword_mutes/_keyword_mute.html.haml b/app/views/settings/keyword_mutes/_keyword_mute.html.haml
new file mode 100644 (file)
index 0000000..a2698ac
--- /dev/null
@@ -0,0 +1,7 @@
+%tr
+  %td
+    = keyword_mute.keyword
+  %td
+    = table_link_to 'edit', t('settings.keyword_mutes.edit'), edit_settings_keyword_mute_path(keyword_mute)
+  %td
+    = table_link_to 'times', t('settings.keyword_mutes.delete'), settings_keyword_mute_path(keyword_mute), method: :delete, data: { confirm: t('admin.accounts.are_you_sure') }
index 421fbeba29d67b6ba98855ebdd9f6791d4a7b11f..6b212895d2176a70eb4e3062caea02599cda9058 100644 (file)
@@ -1,2 +1,15 @@
 - content_for :page_title do
   = t('settings.keyword_mutes')
+
+.table-wrapper
+  %table.table
+    %thead
+      %tr
+        %th= t('settings.keyword_mutes.keyword')
+        %th
+        %th
+      %tbody
+        = render @keyword_mutes
+
+= paginate @keyword_mutes
+= link_to t('settings.keyword_mutes.add_keyword'), new_settings_keyword_mute_path, class: 'button'
diff --git a/app/views/settings/keyword_mutes/new.html.haml b/app/views/settings/keyword_mutes/new.html.haml
new file mode 100644 (file)
index 0000000..5e8268e
--- /dev/null
@@ -0,0 +1,19 @@
+- content_for :page_title do
+  = t('settings.keyword_mutes.add_keyword')
+
+= simple_form_for @keyword_mute, url: settings_keyword_mutes_path do |f|
+  = render 'shared/error_messages', object: @keyword_mute
+
+  %p.muted-hint
+    Keywords match word boundaries case-insensitively.  For example:
+    %ul
+      %li
+        <strong>alice</strong> matches <strong>alice</strong>, <strong>Alice</strong>, and <strong>Alice's</strong>
+      %li
+        <strong>bob</strong> matches <strong>bob</strong> and <strong>Bob</strong> but not <strong>bobcat</strong>
+
+  .fields-group
+    = f.input :keyword
+
+  .actions
+    = f.button :button, t('admin.keyword_mutes.add_keyword'), type: :submit
index 6b4e602bd8fbb59720d7bc2916b9df4693d30342..5b91f832058fcfa107a9091e6a63498359b20951 100644 (file)
@@ -215,6 +215,11 @@ en:
       contact_information:
         email: Business e-mail
         username: Contact username
+      keyword_mutes:
+        edit: Edit
+        delete: Delete
+        add_keyword: Add keyword
+        keyword: Keyword
       registrations:
         closed_message:
           desc_html: Displayed on frontpage when registrations are closed. You can use HTML tags
This page took 0.039699 seconds and 3 git commands to generate.