Skip to content

Commit

Permalink
新規作成画面に項目追加、編集画面に画像表示、旧テキストボックス削除
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Oct 17, 2023
1 parent 8e79047 commit d4bd906
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/controllers/admin/custom_emojis_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def set_custom_emoji
end

def resource_params
params.require(:custom_emoji).permit(:shortcode, :image, :visible_in_picker)
params.require(:custom_emoji).permit(:shortcode, :image, :visible_in_picker, :aliases_raw, :license)
end

def update_params
Expand Down Expand Up @@ -101,7 +101,7 @@ def action_from_button
end

def form_custom_emoji_batch_params
params.require(:form_custom_emoji_batch).permit(:action, :category_id, :category_name, :aliases_raw, custom_emoji_ids: [])
params.require(:form_custom_emoji_batch).permit(:action, :category_id, :category_name, custom_emoji_ids: [])
end
end
end
5 changes: 2 additions & 3 deletions app/models/form/custom_emoji_batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Form::CustomEmojiBatch
include AccountableConcern

attr_accessor :custom_emoji_ids, :action, :current_account,
:category_id, :category_name, :aliases_raw, :visible_in_picker
:category_id, :category_name, :visible_in_picker

def save
case action
Expand Down Expand Up @@ -43,8 +43,7 @@ def update!
end

custom_emojis.each do |custom_emoji|
new_aliases_raw = (aliases_raw.presence || custom_emoji.aliases_raw)
custom_emoji.update(category_id: category&.id, aliases_raw: new_aliases_raw)
custom_emoji.update(category_id: category&.id)
log_action :update, custom_emoji
end
end
Expand Down
3 changes: 3 additions & 0 deletions app/views/admin/custom_emojis/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
- CustomEmojiFilter::KEYS.each do |key|
= hidden_field_tag key, params[key] if params[key].present?

.fields-group
= custom_emoji_tag(@custom_emoji)

%h4= t('admin.custom_emojis.shortcode')

.fields-group
Expand Down
6 changes: 0 additions & 6 deletions app/views/admin/custom_emojis/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@
.label_input
= f.text_field :category_name, class: 'string optional', placeholder: t('admin.custom_emojis.create_new_category'), 'aria-label': t('admin.custom_emojis.create_new_category')

.fields-row
.fields-group.fields-row__column
.input.string.optional
.label_input
= f.text_field :aliases_raw, class: 'string optional', placeholder: 'Alias names', 'aria-label': 'Alias names'

.batch-table__body
- if @custom_emojis.empty?
= nothing_here 'nothing-here--under-tabs'
Expand Down
10 changes: 10 additions & 0 deletions app/views/admin/custom_emojis/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@

.fields-group
= f.input :shortcode, wrapper: :with_label, label: t('admin.custom_emojis.shortcode'), hint: t('admin.custom_emojis.shortcode_hint')

.fields-group
= f.input :image, wrapper: :with_label, input_html: { accept: CustomEmoji::IMAGE_MIME_TYPES.join(' ') }, hint: t('admin.custom_emojis.image_hint', size: number_to_human_size(CustomEmoji::LIMIT))

.fields-group
= f.input :visible_in_picker, as: :boolean, wrapper: :with_label, label: t('admin.custom_emojis.visible_in_picker')

.fields-group
= f.input :aliases_raw, wrapper: :with_label, kmyblue: true, label: t('admin.custom_emojis.aliases'), hint: t('admin.custom_emojis.aliases_hint')

.fields-group
= f.input :license, wrapper: :with_label, kmyblue: true, label: t('admin.custom_emojis.license'), hint: t('admin.custom_emojis.license_hint')

.actions
= f.button :button, t('admin.custom_emojis.upload'), type: :submit

0 comments on commit d4bd906

Please sign in to comment.