Skip to content

Commit

Permalink
[User fields] rename to service
Browse files Browse the repository at this point in the history
  • Loading branch information
aivils committed Jul 2, 2018
1 parent 7fcd779 commit c21b654
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
18 changes: 9 additions & 9 deletions app/controllers/admin/person_custom_fields_controller.rb
@@ -1,14 +1,14 @@
class Admin::PersonCustomFieldsController < Admin::AdminBaseController
before_action :ensure_feature_flag_enabled
before_action :set_selected_left_navi_link
before_action :set_presenter
before_action :set_service

def new
@presenter.new_custom_field
@service.new_custom_field
end

def create
success = @presenter.create
success = @service.create
if success
redirect_to admin_person_custom_fields_path
else
Expand All @@ -18,21 +18,21 @@ def create
end

def edit
@presenter.find_custom_field
@service.find_custom_field
end

def update
@presenter.update
@service.update
redirect_to admin_person_custom_fields_path
end

def destroy
@presenter.destroy
@service.destroy
redirect_to admin_person_custom_fields_path
end

def order
@presenter.order
@service.order
render body: nil, status: 200
end

Expand All @@ -42,8 +42,8 @@ def set_selected_left_navi_link
@selected_left_navi_link = "user_fields"
end

def set_presenter
@presenter = Admin::PersonCustomFieldsPresenter.new(
def set_service
@service = Admin::PersonCustomFieldsService.new(
community: @current_community,
params: params)
end
Expand Down
@@ -1,4 +1,4 @@
class Admin::PersonCustomFieldsPresenter
class Admin::PersonCustomFieldsService
attr_reader :community, :params, :min_option_count, :custom_field

def initialize(community:, params:)
Expand Down
20 changes: 10 additions & 10 deletions app/views/admin/person_custom_fields/_form.haml
@@ -1,19 +1,19 @@
- content_for :javascript do
ST.CustomFields.initForm({
locale: '#{I18n.locale}',
option_count: #{presenter.custom_field.options.size},
min_count: #{presenter.min_option_count}
option_count: #{service.custom_field.options.size},
min_count: #{service.min_option_count}
});

- custom_field = presenter.custom_field
- path = presenter.edit? ? admin_person_custom_field_path(custom_field) : admin_person_custom_fields_path(:field_type => custom_field.type)
- custom_field = service.custom_field
- path = service.edit? ? admin_person_custom_field_path(custom_field) : admin_person_custom_fields_path(:field_type => custom_field.type)
= form_for custom_field, as: :custom_field, url: path, html: {id: 'custom_field_form'} do |form|
= render 'admin/person_custom_fields/form/field_name', form: form, presenter: presenter
= render 'admin/person_custom_fields/form/field_required', form: form, presenter: presenter
= render 'admin/person_custom_fields/form/field_name', form: form, service: service
= render 'admin/person_custom_fields/form/field_required', form: form, service: service
- custom_field.with(:numeric) do
= render 'admin/person_custom_fields/form/field_min_max', form: form, presenter: presenter
= render 'admin/person_custom_fields/form/field_min_max', form: form, service: service
- custom_field.with(:dropdown) do
= render 'admin/person_custom_fields/form/field_options', form: form, presenter: presenter
= render 'admin/person_custom_fields/form/field_options', form: form, service: service
- custom_field.with(:checkbox) do
= render 'admin/person_custom_fields/form/field_options', form: form, presenter: presenter
= render 'admin/person_custom_fields/form/buttons', form: form, presenter: presenter
= render 'admin/person_custom_fields/form/field_options', form: form, service: service
= render 'admin/person_custom_fields/form/buttons', form: form, service: service
4 changes: 2 additions & 2 deletions app/views/admin/person_custom_fields/edit.haml
Expand Up @@ -2,10 +2,10 @@
%h1
= t("layouts.admin.admin")
= "-"
= t(".edit_user_field", :field_name => @presenter.custom_field.name(I18n.locale))
= t(".edit_user_field", :field_name => @service.custom_field.name(I18n.locale))

= render "admin/left_hand_navigation", links: admin_links_for(@current_community)

.left-navi-section
= render 'form', presenter: @presenter
= render 'form', service: @service

4 changes: 2 additions & 2 deletions app/views/admin/person_custom_fields/form/_field_min_max.haml
@@ -1,5 +1,5 @@
- min = form.object.display_min || presenter.number_min
- max = form.object.display_max || presenter.number_max
- min = form.object.display_min || service.number_min
- max = form.object.display_max || service.number_max
.row
.col-3
= form.label :min, t("admin.person_custom_fields.index.minimum_value")
Expand Down
Expand Up @@ -4,7 +4,7 @@
.col-12
#options.custom-field-options
%script{type: "text/template", class: "template", id: "new-option-tmpl"}
= render 'admin/person_custom_fields/form/new_option', option: presenter.new_option,
= render 'admin/person_custom_fields/form/new_option', option: service.new_option,
option_id: "${id}", sort_priority: "${sortPriority}"
- custom_field.options.sort.each_with_index do |option, index|
= render 'admin/person_custom_fields/form/new_option', option: option,
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/person_custom_fields/index.haml
Expand Up @@ -26,8 +26,8 @@

= render 'fixed_fields'

- if @presenter.show_custom_fields?
= render partial: 'custom_field', collection: @presenter.custom_fields, as: :custom_field
- if @service.show_custom_fields?
= render partial: 'custom_field', collection: @service.custom_fields, as: :custom_field

#custom-field-ajax-status
.ajax-notification.ajax-notice.custom-field-ajax-status-message#custom-field-ajax-saving
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/person_custom_fields/new.haml
Expand Up @@ -8,4 +8,4 @@

.left-navi-section
#new-person-field-form.new-field-form
= render 'form', presenter: @presenter
= render 'form', service: @service

0 comments on commit c21b654

Please sign in to comment.