From 91305445165755be7ac6fa53f3289d97a14d840f Mon Sep 17 00:00:00 2001 From: did Date: Thu, 22 Dec 2011 14:28:12 -0800 Subject: [PATCH] refactoring the creation of custom contents --- Gemfile | 4 +- .../locomotive/models/content.js.coffee | 11 ++ .../views/content_types/_form_view.js.coffee | 2 - .../locomotive/views/contents/_form.js.coffee | 21 +++ .../locomotive/views/contents/edit.js.coffee | 6 + .../locomotive/views/contents/new.js.coffee | 8 ++ .../locomotive/contents_controller.rb | 56 +++----- app/helpers/locomotive/base_helper.rb | 14 +- app/models/locomotive/content_instance.rb | 130 +++++++++--------- .../locomotive/content_presenter.rb | 15 ++ .../locomotive/content_types/_form.html.haml | 11 ++ app/views/locomotive/contents/_form.html.haml | 10 +- app/views/locomotive/contents/edit.html.haml | 9 +- app/views/locomotive/contents/new.html.haml | 7 +- .../custom_fields/_category_tmpl.html.haml | 17 --- .../custom_fields/_edit_field.html.haml | 20 --- .../locomotive/custom_fields/_index.html.haml | 52 ------- .../custom_fields/edit_category.html.haml | 17 --- config/locales/admin_ui.en.yml | 18 +-- 19 files changed, 183 insertions(+), 245 deletions(-) create mode 100644 app/assets/javascripts/locomotive/models/content.js.coffee create mode 100644 app/assets/javascripts/locomotive/views/contents/_form.js.coffee create mode 100644 app/assets/javascripts/locomotive/views/contents/edit.js.coffee create mode 100644 app/assets/javascripts/locomotive/views/contents/new.js.coffee create mode 100644 app/presenters/locomotive/content_presenter.rb delete mode 100644 app/views/locomotive/custom_fields/_category_tmpl.html.haml delete mode 100644 app/views/locomotive/custom_fields/_edit_field.html.haml delete mode 100644 app/views/locomotive/custom_fields/_index.html.haml delete mode 100644 app/views/locomotive/custom_fields/edit_category.html.haml diff --git a/Gemfile b/Gemfile index 3fbe0bb7..b8662442 100644 --- a/Gemfile +++ b/Gemfile @@ -13,8 +13,8 @@ gem 'bson_ext', '~> 1.4.0' gem 'mongoid', '~> 2.3.3' gem 'locomotive_mongoid_acts_as_tree', :git => 'git@github.com:locomotivecms/mongoid_acts_as_tree.git' # gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git' -# gem 'custom_fields', :path => '../gems/custom_fields' # DEV -gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => 'experimental' +gem 'custom_fields', :path => '../gems/custom_fields' # DEV +# gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => 'experimental' gem 'kaminari' gem 'haml', '~> 3.1.3' diff --git a/app/assets/javascripts/locomotive/models/content.js.coffee b/app/assets/javascripts/locomotive/models/content.js.coffee new file mode 100644 index 00000000..be02ca6a --- /dev/null +++ b/app/assets/javascripts/locomotive/models/content.js.coffee @@ -0,0 +1,11 @@ +class Locomotive.Models.Content extends Backbone.Model + + paramRoot: 'content' + + urlRoot: "#{Locomotive.mount_on}/content_type/:slug/contents" + +class Locomotive.Models.ContentsCollection extends Backbone.Collection + + model: Locomotive.Models.Content + + url: "#{Locomotive.mount_on}/content_type/:slug/contents" \ No newline at end of file diff --git a/app/assets/javascripts/locomotive/views/content_types/_form_view.js.coffee b/app/assets/javascripts/locomotive/views/content_types/_form_view.js.coffee index 8ddacba9..74bc2e5c 100644 --- a/app/assets/javascripts/locomotive/views/content_types/_form_view.js.coffee +++ b/app/assets/javascripts/locomotive/views/content_types/_form_view.js.coffee @@ -12,8 +12,6 @@ class Locomotive.Views.ContentTypes.FormView extends Locomotive.Views.Shared.For initialize: -> @model = new Locomotive.Models.ContentType(@options.content_type) - window.foo = @model - Backbone.ModelBinding.bind @ render: -> diff --git a/app/assets/javascripts/locomotive/views/contents/_form.js.coffee b/app/assets/javascripts/locomotive/views/contents/_form.js.coffee new file mode 100644 index 00000000..21e7ca2f --- /dev/null +++ b/app/assets/javascripts/locomotive/views/contents/_form.js.coffee @@ -0,0 +1,21 @@ +#= require ../shared/form_view + +Locomotive.Views.Contents ||= {} + +class Locomotive.Views.Contents.FormView extends Locomotive.Views.Shared.FormView + + el: '#content' + + events: + 'submit': 'save' + + initialize: -> + @model = new Locomotive.Models.Content(@options.content) + + Backbone.ModelBinding.bind @ + + render: -> + super() + + return @ + diff --git a/app/assets/javascripts/locomotive/views/contents/edit.js.coffee b/app/assets/javascripts/locomotive/views/contents/edit.js.coffee new file mode 100644 index 00000000..a98fc43f --- /dev/null +++ b/app/assets/javascripts/locomotive/views/contents/edit.js.coffee @@ -0,0 +1,6 @@ +Locomotive.Views.Contents ||= {} + +class Locomotive.Views.Contents.EditView extends Locomotive.Views.Contents.FormView + + save: (event) -> + @save_in_ajax event \ No newline at end of file diff --git a/app/assets/javascripts/locomotive/views/contents/new.js.coffee b/app/assets/javascripts/locomotive/views/contents/new.js.coffee new file mode 100644 index 00000000..738d50ad --- /dev/null +++ b/app/assets/javascripts/locomotive/views/contents/new.js.coffee @@ -0,0 +1,8 @@ +Locomotive.Views.Contents ||= {} + +class Locomotive.Views.Contents.NewView extends Locomotive.Views.Contents.FormView + + save: (event) -> + @save_in_ajax event, + on_success: (response, xhr) -> + window.location.href = xhr.getResponseHeader('location') diff --git a/app/controllers/locomotive/contents_controller.rb b/app/controllers/locomotive/contents_controller.rb index c220cf3e..8c121aeb 100644 --- a/app/controllers/locomotive/contents_controller.rb +++ b/app/controllers/locomotive/contents_controller.rb @@ -11,36 +11,44 @@ module Locomotive before_filter :authorize_content - helper_method :breadcrumb_root, :breadcrumb_url, :back_url - def index - @contents = @content_type.list_or_group_contents + @contents = @content_type.contents + respond_with @contents end def new - new! { @content.attributes = params[:content] } + @content = @content_type.contents.build + respond_with @content end def create - create! { after_create_or_update_url } + @content = @content_type.contents.create(params[:content]) + respond_with @content, :location => edit_content_url(@content_type.slug, @content._id) end def edit - edit! { @content.attributes = params[:content] } + @content = @content_type.contents.find(params[:id]) + respond_with @content end def update - update! { after_create_or_update_url } + @content = @content_type.contents.find(params[:id]) + @content.update_attributes(params[:content]) + respond_with @content, :location => edit_content_url(@content_type.slug, @content._id) end def sort - @content_type.sort_contents!(params[:children]) - - respond_with(@content_type, :location => contents_url(@content_type.slug)) + # TODO + # @content_type.sort_contents!(params[:children]) + # @page = current_site.pages.find(params[:id]) + # @page.sort_children!(params[:children]) + respond_with @content_type end def destroy - destroy! { contents_url(@content_type.slug) } + @content = @content_type.contents.find(params[:id]) + @content.destroy + respond_with @content, :location => pages_url end protected @@ -49,35 +57,9 @@ module Locomotive @content_type ||= current_site.content_types.where(:slug => params[:slug]).first end - def begin_of_association_chain - set_content_type - end - - def after_create_or_update_url - if params[:breadcrumb_alias].blank? - edit_content_url(@content_type.slug, @content.id) - else - self.breadcrumb_url - end - end - def authorize_content authorize! params[:action].to_sym, ContentInstance end - def breadcrumb_root - return nil if params[:breadcrumb_alias].blank? - - @breadcrumb_root ||= resource.send(params[:breadcrumb_alias].to_sym) - end - - def breadcrumb_url - edit_content_url(self.breadcrumb_root._parent.slug, self.breadcrumb_root) - end - - def back_url - self.breadcrumb_root ? self.breadcrumb_url : contents_url(@content_type.slug) - end - end end diff --git a/app/helpers/locomotive/base_helper.rb b/app/helpers/locomotive/base_helper.rb index c4a3e0e8..d3deec9d 100644 --- a/app/helpers/locomotive/base_helper.rb +++ b/app/helpers/locomotive/base_helper.rb @@ -36,13 +36,13 @@ module Locomotive::BaseHelper end end - def collection_to_js(collection, options = {}) - js = collection.collect { |object| object.to_json } - - options_to_js = ActiveSupport::JSON.encode(options).gsub(/^\{/, '').gsub(/\}$/, '') - - "new Object({ \"collection\": [#{js.join(', ')}], #{options_to_js} })" - end + # def collection_to_js(collection, options = {}) # FIXME: DEPRECATED + # js = collection.collect { |object| object.to_json } + # + # options_to_js = ActiveSupport::JSON.encode(options).gsub(/^\{/, '').gsub(/\}$/, '') + # + # "new Object({ \"collection\": [#{js.join(', ')}], #{options_to_js} })" + # end def flash_message if not flash.empty? diff --git a/app/models/locomotive/content_instance.rb b/app/models/locomotive/content_instance.rb index 6de020b0..d6231e14 100644 --- a/app/models/locomotive/content_instance.rb +++ b/app/models/locomotive/content_instance.rb @@ -8,25 +8,24 @@ module Locomotive include Extensions::Shared::Seo ## fields (dynamic fields) ## - field :_highlighted_field + # field :_highlighted_field field :_slug field :_position_in_list, :type => Integer, :default => 0 field :_visible, :type => Boolean, :default => true ## validations ## - validate :require_highlighted_field + # validate :require_highlighted_field validates :_slug, :presence => true, :uniqueness => { :scope => :content_type_id } ## associations ## belongs_to :site belongs_to :content_type, :class_name => 'Locomotive::ContentType', :inverse_of => :contents - # embedded_in :content_type, :class_name => 'Locomotive::ContentType', :inverse_of => :contents ## callbacks ## before_validation :set_slug - before_save :set_visibility + # before_save :set_visibility before_create :add_to_list_bottom - after_create :send_notifications + # after_create :send_notifications ## named scopes ## scope :visible, :where => { :_visible => true } @@ -34,21 +33,15 @@ module Locomotive ## methods ## - # delegate :site, :to => :content_type - alias :visible? :_visible? alias :_permalink :_slug alias :_permalink= :_slug= - # def site_id # needed by the uploader of custom fields - # self.content_type.site_id + # def highlighted_field_value + # self.send(self.content_type.highlighted_field_name) # end - - def highlighted_field_value - self.send(self.content_type.highlighted_field_name) - end - - alias :_label :highlighted_field_value + # + # alias :_label :highlighted_field_value def visible? self._visible || self._visible.nil? @@ -78,72 +71,81 @@ module Locomotive Locomotive::Liquid::Drops::Content.new(self) end + def to_presenter + Locomotive::ContentPresenter.new(self) + end + + def as_json(options = {}) + self.to_presenter.as_json + end + protected # Sets the slug of the instance by using the value of the highlighted field # (if available). If a sibling content instance has the same permalink then a # unique one will be generated def set_slug - self._slug = highlighted_field_value.dup if _slug.blank? && highlighted_field_value.present? - - if _slug.present? - self._slug.permalink! - self._slug = next_unique_slug if slug_already_taken? - end + # self._slug = highlighted_field_value.dup if _slug.blank? && highlighted_field_value.present? + # + # if _slug.present? + # self._slug.permalink! + # self._slug = next_unique_slug if slug_already_taken? + # end end # Return the next available unique slug as a string def next_unique_slug - slug = _slug.gsub(/-\d*$/, '') - last_slug = _parent.contents.where(:_id.ne => _id, :_slug => /^#{slug}-?\d*?$/i).order_by(:_slug).last._slug - next_number = last_slug.scan(/-(\d)$/).flatten.first.to_i + 1 - - [slug, next_number].join('-') + # slug = _slug.gsub(/-\d*$/, '') + # last_slug = _parent.contents.where(:_id.ne => _id, :_slug => /^#{slug}-?\d*?$/i).order_by(:_slug).last._slug + # next_number = last_slug.scan(/-(\d)$/).flatten.first.to_i + 1 + # + # [slug, next_number].join('-') end - def slug_already_taken? - _parent.contents.where(:_id.ne => _id, :_slug => _slug).any? - end + # def slug_already_taken? + # _parent.contents.where(:_id.ne => _id, :_slug => _slug).any? + # end - def set_visibility - %w(visible active).map(&:to_sym).each do |_alias| - if self.methods.include?(_alias) - self._visible = self.send(_alias) - return - end - end - # field = self.content_type.contents_custom_fields.detect { |f| %w{visible active}.include?(f._alias) } - # self._visible = self.send(field._name) rescue true - end + # def set_visibility + # %w(visible active).map(&:to_sym).each do |_alias| + # if self.methods.include?(_alias) + # self._visible = self.send(_alias) + # return + # end + # end + # # field = self.content_type.contents_custom_fields.detect { |f| %w{visible active}.include?(f._alias) } + # # self._visible = self.send(field._name) rescue true + # end def add_to_list_bottom - self._position_in_list = self.content_type.contents.size + # TODO + # self._position_in_list = self.content_type.contents.size end - def require_highlighted_field - _alias = self.highlighted_field_alias - if self.send(_alias).blank? - self.errors.add(_alias, :blank) - end - end - - def highlighted_field_alias - self.content_type.highlighted_field._alias.to_sym - end - - def send_notifications - return unless self.content_type.api_enabled? && !self.content_type.api_accounts.blank? - - accounts = self.content_type.site.accounts.to_a - - self.content_type.api_accounts.each do |account_id| - next if account_id.blank? - - account = accounts.detect { |a| a.id.to_s == account_id.to_s } - - Locomotive::Notifications.new_content_instance(account, self).deliver - end - end + # def require_highlighted_field + # _alias = self.highlighted_field_alias + # if self.send(_alias).blank? + # self.errors.add(_alias, :blank) + # end + # end + # + # def highlighted_field_alias + # self.content_type.highlighted_field._alias.to_sym + # end + # + # def send_notifications + # return unless self.content_type.api_enabled? && !self.content_type.api_accounts.blank? + # + # accounts = self.content_type.site.accounts.to_a + # + # self.content_type.api_accounts.each do |account_id| + # next if account_id.blank? + # + # account = accounts.detect { |a| a.id.to_s == account_id.to_s } + # + # Locomotive::Notifications.new_content_instance(account, self).deliver + # end + # end end end diff --git a/app/presenters/locomotive/content_presenter.rb b/app/presenters/locomotive/content_presenter.rb new file mode 100644 index 00000000..76c6f412 --- /dev/null +++ b/app/presenters/locomotive/content_presenter.rb @@ -0,0 +1,15 @@ +module Locomotive + class ContentPresenter < BasePresenter + + # delegate :name, :description, :slug, :order_by, :order_direction, :highlighted_field_name, :group_by_field_name, :api_accounts, :to => :source + + # def contents_custom_fields + # self.source.ordered_contents_custom_fields.collect(&:as_json) + # end + # + # def included_methods + # super + %w(name description slug order_by order_direction highlighted_field_name group_by_field_name api_accounts contents_custom_fields) + # end + + end +end \ No newline at end of file diff --git a/app/views/locomotive/content_types/_form.html.haml b/app/views/locomotive/content_types/_form.html.haml index ac40ab36..feac5510 100644 --- a/app/views/locomotive/content_types/_form.html.haml +++ b/app/views/locomotive/content_types/_form.html.haml @@ -6,22 +6,33 @@ { content_type: #{@content_type.persisted? ? @content_type.to_json : 'null'} } = f.inputs :name => :information do + = f.input :name, :wrapper_html => { :class => 'highlighted' } + = f.input :slug + = f.input :description = f.inputs :name => :custom_fields, :class => "inputs foldable" do + = f.input :contents_custom_fields, :as => :'Locomotive::Empty', :label => false, :wrapper_html => { :id => 'custom_fields_input' } - if @content_type.persisted? = f.inputs :name => :presentation, :class => "inputs foldable #{'folded' if inputs_folded?(@content_type)}" do + = f.input :highlighted_field_id, :as => :select, :collection => options_for_highlighted_field(@content_type), :include_blank => false + = f.input :group_by_field_id, :as => :select, :collection => options_for_group_by_field(@content_type) + = f.input :raw_item_template, :as => :'Locomotive::SmallCode' = f.inputs :name => :options, :class => "inputs foldable #{'folded' if inputs_folded?(@content_type)}" do + = f.input :order_by, :as => :select, :collection => options_for_order_by(@content_type), :include_blank => false + = f.input :order_direction, :as => :select, :collection => options_for_order_direction, :include_blank => false, :wrapper_html => { :style => "#{'display: none' if @content_type.order_manually?}" } + = f.input :public_form_enabled, :as => :'Locomotive::Toggle' + = f.input :public_form_accounts, :as => :select, :collection => options_for_account, :include_blank => false, :multiple => true, :wrapper_html => { :class => 'multiple', :style => (@content_type.public_form_enabled? ? '' : 'display: none') } diff --git a/app/views/locomotive/contents/_form.html.haml b/app/views/locomotive/contents/_form.html.haml index 6e713ac1..4fa13b8c 100644 --- a/app/views/locomotive/contents/_form.html.haml +++ b/app/views/locomotive/contents/_form.html.haml @@ -1,10 +1,10 @@ -- content_for :head do - = include_javascripts :edit_custom_fields, :contents - = include_stylesheets :fancybox +- content_for :backbone_view_data do + :plain + { content: #{@content.persisted? ? @content.to_json : 'null'} } -= render 'locomotive/custom_fields/custom_form', :form => f, :title => :attributes, :parent => @content_type +/ = render 'locomotive/custom_fields/custom_form', :form => f, :title => :attributes, :parent => @content_type -= f.foldable_inputs :name => :advanced_options do += f.inputs :name => :advanced_options, :class => "inputs foldable #{'folded' if inputs_folded?(@content)}" do = f.input :_slug = f.input :seo_title diff --git a/app/views/locomotive/contents/edit.html.haml b/app/views/locomotive/contents/edit.html.haml index 0116830a..03040748 100644 --- a/app/views/locomotive/contents/edit.html.haml +++ b/app/views/locomotive/contents/edit.html.haml @@ -1,7 +1,4 @@ -/ - if breadcrumb_root -/ - title t('.title.breadcrumb', :root => link_to(breadcrumb_root._label, breadcrumb_url), :type => @content_type.name.capitalize) -/ - else -- title t('.title.default', :type => @content_type.name.capitalize) +- title t('.title', :type => @content_type.name.capitalize) - content_for :submenu do = render 'locomotive/shared/menu/contents' @@ -17,8 +14,8 @@ %p= @content_type.description -= semantic_form_for @content, :as => :content, :url => content_url(@content_type.slug, @content), :html => { :multipart => true, :class => 'save-with-shortcut' } do |form| += semantic_form_for @content, :as => :content, :url => content_url(@content_type.slug, @content), :html => { :multipart => true } do |form| = render 'form', :f => form - = render 'locomotive/shared/form_actions', :back_url => back_url, :button_label => :update \ No newline at end of file + = render 'locomotive/shared/form_actions', :back_url => contents_url(@content_type.slug), :button_label => :update \ No newline at end of file diff --git a/app/views/locomotive/contents/new.html.haml b/app/views/locomotive/contents/new.html.haml index f321d610..8417d426 100644 --- a/app/views/locomotive/contents/new.html.haml +++ b/app/views/locomotive/contents/new.html.haml @@ -1,7 +1,4 @@ -- if breadcrumb_root - - title t('.title.breadcrumb', :root => link_to(breadcrumb_root._label, breadcrumb_url), :type => @content_type.name.capitalize) -- else - - title t('.title.default', :type => @content_type.name.capitalize) +- title t('.title', :type => @content_type.name.capitalize) - content_for :submenu do = render 'locomotive/shared/menu/contents' @@ -19,4 +16,4 @@ = render 'form', :f => form - = render 'locomotive/shared/form_actions', :back_url => back_url, :button_label => :create \ No newline at end of file + = render 'locomotive/shared/form_actions', :back_url => contents_url(@content_type.slug), :button_label => :create \ No newline at end of file diff --git a/app/views/locomotive/custom_fields/_category_tmpl.html.haml b/app/views/locomotive/custom_fields/_category_tmpl.html.haml deleted file mode 100644 index f3bbd5a9..00000000 --- a/app/views/locomotive/custom_fields/_category_tmpl.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -%script{ :id => 'category-tmpl', :type => 'text/x-mustache-template', :'data-base-input-name' => "custom_field[category_items_attributes]" } - %li{ :class => "item {{behaviour_flag}} {{new_record_flag}} {{errors_flag}} {{required_flag}}" } - %span.handle - = image_tag 'admin/form/icons/drag.png' - - {{#if_existing_record}} - %input{ :name => '{{base_name}}[id]', :value => '{{{id}}}', :type => 'hidden', :'data-field' => 'id' } - %input{ :name => '{{base_name}}[_destroy]', :value => '0', :type => 'hidden', :'data-field' => '_destroy' } - {{/if_existing_record}} - - %input{ :name => '{{base_name}}[position]', :value => '{{{position}}}', :type => 'hidden', :'data-field' => 'position' } - %input{ :name => '{{base_name}}[name]', :value => '{{{name}}}', :type => 'text', :'data-field' => 'name' } - - %span.actions - = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove', :confirm => t('locomotive.messages.confirm') - %button{ :class => 'button light add', :type => 'button' } - %span!= t('locomotive.buttons.new_item') \ No newline at end of file diff --git a/app/views/locomotive/custom_fields/_edit_field.html.haml b/app/views/locomotive/custom_fields/_edit_field.html.haml deleted file mode 100644 index 58a6884a..00000000 --- a/app/views/locomotive/custom_fields/_edit_field.html.haml +++ /dev/null @@ -1,20 +0,0 @@ -.fancybox-wrapper - #edit-custom-field - %h2!= t('.title') - - = form_tag '#', :class => 'formtastic' do - = fields_for CustomFields::Field.new, :builder => Formtastic::SemanticFormHelper.builder do |g| - = g.inputs :name => :attributes do - = g.input :_alias - = g.input :hint - = g.input :text_formatting, :as => 'select', :collection => options_for_text_formatting, :include_blank => false, :wrapper_html => { :style => 'display: none' } - = g.input :target, :as => 'select', :collection => options_for_association_target, :include_blank => false, :wrapper_html => { :style => 'display: none' } - = g.input :reverse_lookup, :as => 'select', :collection => [], :include_blank => true, :wrapper_html => { :style => 'display: none' } - - .popup-actions - %p - %button.button.light{ :type => 'submit' } - %span= t('locomotive.shared.form_actions.update') - - %script{ :type => 'text/javascript', :name => 'reverse_lookups' } - != collection_to_js(options_for_reverse_lookups(content_type)) \ No newline at end of file diff --git a/app/views/locomotive/custom_fields/_index.html.haml b/app/views/locomotive/custom_fields/_index.html.haml deleted file mode 100644 index 055de105..00000000 --- a/app/views/locomotive/custom_fields/_index.html.haml +++ /dev/null @@ -1,52 +0,0 @@ -- collection_name = "#{collection_name.singularize}_custom_fields" -- custom_fields = form.object.send(collection_name.to_sym) -- ordered_custom_fields = form.object.send(:"ordered_#{collection_name}") -- field_klass = "#{form.object.class.name}#{collection_name.classify}".gsub(/CustomField$/, 'Field').constantize - -= form.foldable_inputs :name => defined?(form_name) ? form_name : :custom_fields, :class => 'editable-list fields' do - - %script{ :type => 'text/x-mustache-template', :name => 'template', :'data-base-input-name' => "#{form.object.class.name.underscore}[#{collection_name}_attributes]" } - %li{ :class => "item {{behaviour_flag}} {{new_record_flag}} {{errors_flag}} {{required_flag}}" } - %span.handle - = image_tag 'admin/form/icons/drag.png' - - {{#if_existing_record}} - %input{ :name => '{{base_name}}[id]', :value => '{{{id}}}', :type => 'hidden', :'data-field' => 'id' } - %input{ :name => '{{base_name}}[_destroy]', :value => '0', :type => 'hidden', :'data-field' => '_destroy' } - {{/if_existing_record}} - - %input{ :name => '{{base_name}}[position]', :value => '{{{position}}}', :type => 'hidden', :'data-field' => 'position' } - - %input{ :name => '{{base_name}}[_alias]', :value => '{{{_alias}}}', :type => 'hidden', :'data-field' => '_alias' } - - %input{ :name => '{{base_name}}[hint]', :value => '{{{hint}}}', :type => 'hidden', :'data-field' => 'hint' } - - %input{ :name => '{{base_name}}[text_formatting]', :value => '{{{text_formatting}}}', :type => 'hidden', :'data-field' => 'text_formatting' } - - %input{ :name => '{{base_name}}[target]', :value => '{{{target}}}', :type => 'hidden', :'data-field' => 'target' } - - %input{ :name => '{{base_name}}[reverse_lookup]', :value => '{{{reverse_lookup}}}', :type => 'hidden', :'data-field' => 'reverse_lookup' } - - %input{ :name => '{{base_name}}[label]', :value => '{{{label}}}', :type => 'text', :'data-field' => 'label' } - - — - - %em.editable {{kind_name}} - - = select_tag '{{base_name}}[kind]', options_for_select(options_for_field_kind), :'data-field' => 'kind' - -   - - %input{ :name => '{{base_name}}[required]', :value => '0', :type => 'hidden', :'data-field' => 'hidden_required' } - %input{ :name => '{{base_name}}[required]', :'{{required_checked}}' => '{{required_checked}}', :value => '1', :type => 'checkbox', :'data-field' => 'required', :id => '{{base_dom_id}}_required' } - - %label{ :for => "{{{base_dom_id}}}_required" }= t('.is_required') - - %span.actions - = link_to image_tag('admin/form/pen.png'), '#edit-custom-field', :class => 'edit first' - = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove', :confirm => t('locomotive.messages.confirm') - %button{ :class => 'button light add', :type => 'button' } - %span!= t('locomotive.buttons.new_item') - - %script{ :type => 'text/javascript', :name => 'data' } - != collection_to_js(ordered_custom_fields, :template => field_klass.new(:label => t('.default_label'), :_alias => '', :kind => 'string').to_hash) diff --git a/app/views/locomotive/custom_fields/edit_category.html.haml b/app/views/locomotive/custom_fields/edit_category.html.haml deleted file mode 100644 index dbf5a3d4..00000000 --- a/app/views/locomotive/custom_fields/edit_category.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -#edit-custom-field-category - .inner - %h2!= t('.title') - - %p!= t('.help') - - = semantic_form_for @field, :as => :custom_field, :url => custom_field_url(@parent.class.model_name.underscore, @parent.slug, @field) do |f| - - = f.foldable_inputs :name => t('.collection_label'), :class => 'editable-list off' - - %script{ :type => 'text/javascript', :name => 'data' } - != "var categories = #{collection_to_js(@field.ordered_category_items, :template => CustomFields::Types::Category::Item.new)};" - - .popup-actions - %p - %button.button.light{ :type => 'submit' } - %span= t('locomotive.shared.form_actions.update') \ No newline at end of file diff --git a/config/locales/admin_ui.en.yml b/config/locales/admin_ui.en.yml index 1942f870..24b5dd9e 100644 --- a/config/locales/admin_ui.en.yml +++ b/config/locales/admin_ui.en.yml @@ -248,24 +248,20 @@ en: title: 'Listing "%{type}"' edit: edit model destroy: remove model - download: download items - new: new item + download: download entries + new: new entry category_noname: "No name" - lastest_items: "Lastest items" + lastest_entries: "Lastest entries" updated_at: "Updated at" list: - no_items: "There are no items for now. Just click here to create the first one." + no_entries: "There are no entries for now. Just click here to create the first one." new: - title: - default: '%{type} — new item' - breadcrumb: '%{root} » %{type} — new item' + title: '%{type} — new entry' edit: - title: - default: '%{type} — editing item' - breadcrumb: '%{root} » %{type} — editing item' + title: '%{type} — editing entry' form: has_many: - new_item: New item + new_entry: New entry image_picker: link: Insert an image into the code